Skip to contentSkip to conversation

mm/usercopy: Drop extra is_vmalloc_or_module check

PATCH In review Laura Abbott 3 participants 3 messages Apr 4, 2017 – Apr 5, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/usercopy: Drop extra is_vmalloc_or_module check

virt_addr_valid was previously insufficient to validate if virt_to_page could be called on an address on arm64. This has since been fixed up so there is no need for the extra check. Drop it.

---
I've given this some testing on my machine and haven't seen any problems (e.g. random crashes without the check) and the fix has been in for long enough now. I'm in no rush to have this merged so I'm okay if this sits in a tree somewhere to get more testing.

---
 mm/usercopy.c | 11 -----------
 1 file changed, 11 deletions(-)
mm/usercopy.c +0 -11
index d155e12563b1..4d23a0e0e232 100644
@@ -206,17 +206,6 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n,
 {
 	struct page *page;
 
-	/*
-	 * Some architectures (arm64) return true for virt_addr_valid() on
-	 * vmalloced addresses. Work around this by checking for vmalloc
-	 * first.
-	 *
-	 * We also need to check for module addresses explicitly since we
-	 * may copy static data from modules to userspace
-	 */
-	if (is_vmalloc_or_module_addr(ptr))
-		return NULL;
-
 	if (!virt_addr_valid(ptr))
 		return NULL;
 
Signature · 1 line
2.12.1
#1 lore raw
Quoted 10 lines · Laura Abbott

virt_addr_valid was previously insufficient to validate if virt_to_page could be called on an address on arm64. This has since been fixed up so there is no need for the extra check. Drop it.

---
I've given this some testing on my machine and haven't seen any problems (e.g. random crashes without the check) and the fix has been in for long enough now. I'm in no rush to have this merged so I'm okay if this sits in a tree somewhere to get more testing.

Awesome, thanks! I'll get it into my usercopy branch for -next.

-Kees

Quoted 29 lines
---
 mm/usercopy.c | 11 -----------
 1 file changed, 11 deletions(-)
mm/usercopy.c +0 -12
index d155e12563b1..4d23a0e0e232 100644
@@ -206,17 +206,6 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n,
 {
        struct page *page;
 
-       /*
-        * Some architectures (arm64) return true for virt_addr_valid() on
-        * vmalloced addresses. Work around this by checking for vmalloc
-        * first.
-        *
-        * We also need to check for module addresses explicitly since we
-        * may copy static data from modules to userspace
-        */
-       if (is_vmalloc_or_module_addr(ptr))
-               return NULL;
-
        if (!virt_addr_valid(ptr))
                return NULL;
 
--

2.12.1

Signature · 2 lines
Kees Cook
Pixel Security
Acked-by on v1 1/1
#2 lore raw
In reply to Laura Abbott
Quoted 10 lines · Laura Abbott

virt_addr_valid was previously insufficient to validate if virt_to_page could be called on an address on arm64. This has since been fixed up so there is no need for the extra check. Drop it.

---
I've given this some testing on my machine and haven't seen any problems (e.g. random crashes without the check) and the fix has been in for long enough now. I'm in no rush to have this merged so I'm okay if this sits in a tree somewhere to get more testing.

This looks good to me, given your fix for virt_add_valid() in mainline. FWIW:

Mark.

Quoted 29 lines
---
 mm/usercopy.c | 11 -----------
 1 file changed, 11 deletions(-)
mm/usercopy.c +0 -11
index d155e12563b1..4d23a0e0e232 100644
@@ -206,17 +206,6 @@ static inline const char *check_heap_object(const void *ptr, unsigned long n,
 {
 	struct page *page;
 
-	/*
-	 * Some architectures (arm64) return true for virt_addr_valid() on
-	 * vmalloced addresses. Work around this by checking for vmalloc
-	 * first.
-	 *
-	 * We also need to check for module addresses explicitly since we
-	 * may copy static data from modules to userspace
-	 */
-	if (is_vmalloc_or_module_addr(ptr))
-		return NULL;
-
 	if (!virt_addr_valid(ptr))
 		return NULL;
 
Signature · 1 line
2.12.1