[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1386014416-4556-1-git-send-email-ivo.g.dimitrov.75@gmail.com>
Date: Mon, 2 Dec 2013 22:00:16 +0200
From: Ivaylo DImitrov <ivo.g.dimitrov.75@...il.com>
To: gregkh@...uxfoundation.org
Cc: nico@...lde.de, fabs@...sec.de, omar.ramirez@...itl.com,
pali.rohar@...il.com, pavel@....cz, linux-kernel@...r.kernel.org,
devel@...verdev.osuosl.org, tony@...mide.com,
felipe.contreras@...il.com, Ivaylo Dimitrov <freemangordon@....bg>
Subject: [PATCH] Staging: TIDSPBRIDGE: Use vm_iomap_memory for mmap-ing instead of remap_pfn_range
From: Ivaylo Dimitrov <freemangordon@....bg>
This fixes the following bug:
---- Bug Report ----
source file: drivers/staging/tidspbridge/rmgr/drv_interface.c
issue : mapping of physical memory without address range checks
259 static int bridge_mmap(struct file *filp, struct vm_area_struct *vma)
260 {
261 u32 status;
262
263 /* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */
264 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
265
266 dev_dbg(bridge, "%s: vm filp %p start %lx end %lx page_prot %ulx "
267 "flags %lx\n", __func__, filp,
268 vma->vm_start, vma->vm_end, vma->vm_page_prot,
269 vma->vm_flags);
270
271 status = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
272 vma->vm_end - vma->vm_start,
273 vma->vm_page_prot);
274 if (status != 0)
275 status = -EAGAIN;
276
277 return status;
278 }
The function provides an interface to remap physical memory to user space, but
does not provide any checks to ensure that the memory is within the region that
should be accessible.
Reported-by: Nico Golde <nico@...lde.de>
Reported-by: Fabian Yamaguchi <fabs@...sec.de>
Signed-off-by: Ivaylo Dimitrov <freemangordon@....bg>
Signed-off-by: Pavel Machek <pavel@....cz>
---
drivers/staging/tidspbridge/rmgr/drv_interface.c | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c
index 1aa4a3f..2d500ea 100644
--- a/drivers/staging/tidspbridge/rmgr/drv_interface.c
+++ b/drivers/staging/tidspbridge/rmgr/drv_interface.c
@@ -258,8 +258,9 @@ err:
/* This function maps kernel space memory to user space memory. */
static int bridge_mmap(struct file *filp, struct vm_area_struct *vma)
{
- u32 status;
-
+ struct omap_dsp_platform_data *pdata =
+ omap_dspbridge_dev->dev.platform_data;
+
/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
@@ -268,13 +269,9 @@ static int bridge_mmap(struct file *filp, struct vm_area_struct *vma)
vma->vm_start, vma->vm_end, vma->vm_page_prot,
vma->vm_flags);
- status = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
- vma->vm_end - vma->vm_start,
- vma->vm_page_prot);
- if (status != 0)
- status = -EAGAIN;
-
- return status;
+ return vm_iomap_memory(vma,
+ pdata->phys_mempool_base,
+ pdata->phys_mempool_size);
}
static const struct file_operations bridge_fops = {
--
1.5.6.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists