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:54 -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 4/5] break up slow_virt_to_phys()


I need to use slow_virt_to_phys()'s functionality for addresses
which might not be valid.  So, I need a copy which can cleanly
return errors instead of doing a BUG_ON().

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

 linux.git-davehans/arch/x86/mm/pageattr.c |   40 +++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff -puN arch/x86/mm/pageattr.c~break-up-slow-virt_to_phys arch/x86/mm/pageattr.c
--- linux.git/arch/x86/mm/pageattr.c~break-up-slow-virt_to_phys	2013-04-10 16:23:45.571087500 -0700
+++ linux.git-davehans/arch/x86/mm/pageattr.c	2013-04-10 16:23:45.574087504 -0700
@@ -363,18 +363,7 @@ pte_t *lookup_address(unsigned long addr
 }
 EXPORT_SYMBOL_GPL(lookup_address);
 
-/*
- * This is necessary because __pa() does not work on some
- * kinds of memory, like vmalloc() or the alloc_remap()
- * areas on 32-bit NUMA systems.  The percpu areas can
- * end up in this kind of memory, for instance.
- *
- * This could be optimized, but it is only intended to be
- * used at inititalization time, and keeping it
- * unoptimized should increase the testing coverage for
- * the more obscure platforms.
- */
-phys_addr_t slow_virt_to_phys(void *__virt_addr)
+int kernel_lookup_vaddr(void *__virt_addr, phys_addr_t *result)
 {
 	unsigned long virt_addr = (unsigned long)__virt_addr;
 	phys_addr_t phys_addr;
@@ -385,12 +374,35 @@ phys_addr_t slow_virt_to_phys(void *__vi
 	pte_t *pte;
 
 	pte = lookup_address(virt_addr, &level);
-	BUG_ON(!pte);
+	if (!pte)
+		return -EFAULT;
 	psize = page_level_size(level);
 	pmask = page_level_mask(level);
 	offset = virt_addr & ~pmask;
 	phys_addr = pte_pfn(*pte) << PAGE_SHIFT;
-	return (phys_addr | offset);
+	*result = (phys_addr | offset);
+	return 0;
+}
+
+/*
+ * This is necessary because __pa() does not work on some
+ * kinds of memory, like vmalloc() or the alloc_remap()
+ * areas on 32-bit NUMA systems.  The percpu areas can
+ * end up in this kind of memory, for instance.
+ *
+ * This could be optimized, but it is only intended to be
+ * used at inititalization time, and keeping it
+ * unoptimized should increase the testing coverage for
+ * the more obscure platforms.
+ */
+phys_addr_t slow_virt_to_phys(void *virt_addr)
+{
+	phys_addr_t result;
+	int ret;
+
+	ret = kernel_lookup_vaddr(virt_addr, &result);
+	BUG_ON(ret);
+	return result;
 }
 EXPORT_SYMBOL_GPL(slow_virt_to_phys);
 
_
--
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