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:	Wed, 10 Apr 2013 16:32:53 -0700
From:	Dave Hansen <dave@...1.net>
To:	bp@...en8.de
Cc:	hpa@...ux.intel.com, linux-kernel@...r.kernel.org, x86@...nel.org,
	Dave Hansen <dave@...1.net>
Subject: [PATCH 3/5] avoid /dev/kmem oopses with DEBUG_VIRTUAL


DEBUG_VIRTUAL, ensures that when __pa() is only called on
addresses for which its results are correct.  For everything
else, we BUG_ON().

This changes the /dev/kmem ordering so that we check pfn_valid()
_before_ we call __pa().  This ensures we're not calling __pa()
with gibberish and avoids the BUG_ON() in those cases, instead
returning the error to userspace _before_ the __pa() call.



Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
---

 linux.git-davehans/drivers/char/mem.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff -puN drivers/char/mem.c~make-devmem-work-on-highmem3a drivers/char/mem.c
--- linux.git/drivers/char/mem.c~make-devmem-work-on-highmem3a	2013-04-10 16:23:45.361087291 -0700
+++ linux.git-davehans/drivers/char/mem.c	2013-04-10 16:23:45.365087295 -0700
@@ -347,9 +347,6 @@ static int mmap_kmem(struct file *file,
 	 */
 	if (kernel_vaddr >= high_memory)
 		return -EIO;
-	/* Turn a kernel-virtual address into a physical page frame */
-	pfn = __pa(kernel_vaddr) >> PAGE_SHIFT;
-
 	/*
 	 * RED-PEN: on some architectures there is more mapped memory than
 	 * available in mem_map which pfn_valid checks for. Perhaps should add a
@@ -360,6 +357,9 @@ static int mmap_kmem(struct file *file,
 	if (!pfn_valid(pfn))
 		return -EIO;
 
+	/* Turn a kernel-virtual address into a physical page frame */
+	pfn = __pa(kernel_vaddr) >> PAGE_SHIFT;
+
 	vma->vm_pgoff = pfn;
 	return mmap_mem(file, vma);
 }
_
--
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