Re: [PATCH 2/2] DSPBRIDGE: introduce VMA checking for cache operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Doyu Hiroshi (Nokia-D/Helsinki)" <hiroshi.doyu@xxxxxxxxx>
Subject: [PATCH 2/2] DSPBRIDGE: introduce VMA checking for cache operation
Date: Wed, 22 Jul 2009 10:22:50 +0200

> Check if the given area blongs to process virtul memory address space.
> 
> Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@xxxxxxxxx>
> ---
>  drivers/dsp/bridge/rmgr/proc.c |   32 ++++++++++++++++++++++++++++++++
>  1 files changed, 32 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c
> index 3a2879f..fe9dabf 100644
> --- a/drivers/dsp/bridge/rmgr/proc.c
> +++ b/drivers/dsp/bridge/rmgr/proc.c
> @@ -735,6 +735,30 @@ DSP_STATUS PROC_EnumNodes(DSP_HPROCESSOR hProcessor, OUT DSP_HNODE *aNodeTab,
>  	return status;
>  }
>  
> +/* Check if the given area blongs to process virtul memory address space */
> +static int memory_check_vma(unsigned long start, u32 len)
> +{
> +	int err = 0;
> +	unsigned long end;
> +	struct vm_area_struct *vma;
> +
> +	len = PAGE_ALIGN(len);
> +	end = start + len;
> +	if (end <= start)
> +		return -EINVAL;
> +
> +	down_read(&current->mm->mmap_sem);
> +
> +	vma = find_vma(current->mm, start);
> +	if (!vma || start < vma->vm_start) {

"end" should be checkd if it's lower than vm_end as below.

diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c
index fe9dabf..f567329 100644
--- a/drivers/dsp/bridge/rmgr/proc.c
+++ b/drivers/dsp/bridge/rmgr/proc.c
@@ -742,6 +742,7 @@ static int memory_check_vma(unsigned long start, u32 len)
        unsigned long end;
        struct vm_area_struct *vma;
 
+       start &= PAGE_MASK;
        len = PAGE_ALIGN(len);
        end = start + len;
        if (end <= start)
@@ -750,8 +751,9 @@ static int memory_check_vma(unsigned long start, u32 len)
        down_read(&current->mm->mmap_sem);
 
        vma = find_vma(current->mm, start);
-       if (!vma || start < vma->vm_start) {
-               pr_err("%s: no vma for %08lx %08lx\n", __func__, start, end);
+       if (!vma || start < vma->vm_start || end > vma->vm_end) {
+               pr_err("%s: no vma for %08lx-%08lx (%08lx-%08lx)\n", __func__,
+                      start, end, vma->vm_start, vma->vm_end);
                err = -EINVAL;
        }

The update one is attached.

Attachment: 0001-DSPBRIDGE-introduce-VMA-checking-for-cache-operatio.patch
Description: Binary data


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux