lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 18 Jul 2008 14:04:51 +0900
From:	Magnus Damm <magnus.damm@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	Magnus Damm <magnus.damm@...il.com>, hjk@...utronix.de,
	gregkh@...e.de, akpm@...ux-foundation.org
Subject: [PATCH 06/06] uio: Support multiple UIO_MEM_LOGICAL/VIRTUAL pages

From: Magnus Damm <damm@...l.co.jp>

This patch improves the UIO_MEM_LOGICAL and UIO_MEM_VIRTUAL page
fault code to support more than one page of data. Memory allocated
from the slab is however not supported, so a check for that is added
and the documentation gets a little update.

Signed-off-by: Magnus Damm <damm@...l.co.jp>
---

 Documentation/DocBook/uio-howto.tmpl |    2 +-
 drivers/uio/uio.c                    |   10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

--- 0001/Documentation/DocBook/uio-howto.tmpl
+++ work/Documentation/DocBook/uio-howto.tmpl	2008-07-18 12:45:22.000000000 +0900
@@ -376,7 +376,7 @@ Here's a description of the fields of <v
 <varname>int memtype</varname>: Required if the mapping is used. Set this to
 <varname>UIO_MEM_PHYS</varname> if you you have physical memory on your
 card to be mapped. Use <varname>UIO_MEM_LOGICAL</varname> for logical
-memory (e.g. allocated with <function>kmalloc()</function>). There's also
+memory (e.g. allocated with <function>alloc_pages()</function>). There's also
 <varname>UIO_MEM_VIRTUAL</varname> for virtual memory.
 </para></listitem>
 
--- 0006/drivers/uio/uio.c
+++ work/drivers/uio/uio.c	2008-07-18 12:49:38.000000000 +0900
@@ -455,12 +455,15 @@ static void uio_vma_close(struct vm_area
 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	struct uio_mem *imem = vma->vm_private_data;
+	unsigned long vaddr = imem->addr;
 	struct page *page;
 
+	vaddr += (vmf->pgoff - vma->vm_pgoff) << PAGE_SHIFT;
+
 	if (imem->memtype == UIO_MEM_LOGICAL)
-		page = virt_to_page(imem->addr);
+		page = virt_to_page(vaddr);
 	else
-		page = vmalloc_to_page((void *)imem->addr);
+		page = vmalloc_to_page((void *)vaddr);
 	get_page(page);
 	vmf->page = page;
 	return 0;
@@ -521,6 +524,9 @@ static int uio_mmap(struct file *filep, 
 		case UIO_MEM_PHYS:
 			return uio_mmap_physical(vma, imem);
 		case UIO_MEM_LOGICAL:
+			if (virt_to_page(imem->addr)->flags & (1 << PG_slab))
+				return -EINVAL; /* kmalloc() not supported */
+			/* fall-through */
 		case UIO_MEM_VIRTUAL:
 			return uio_mmap_logical(vma, imem);
 		default:
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ