Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1200920 > unrolled thread
| Started by | James Hogan <james.hogan@imgtec.com> |
|---|---|
| First post | 2015-08-05 17:50 +0200 |
| Last post | 2015-08-06 17:10 +0200 |
| Articles | 13 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/7] test_user_copy improvements James Hogan <james.hogan@imgtec.com> - 2015-08-05 17:50 +0200
[PATCH 7/7] test_user_copy: Check user checksum functions James Hogan <james.hogan@imgtec.com> - 2015-08-05 17:50 +0200
[PATCH 2/7] test_user_copy: Check unchecked accessors James Hogan <james.hogan@imgtec.com> - 2015-08-05 17:50 +0200
[PATCH 3/7] test_user_copy: Check __clear_user()/clear_user() James Hogan <james.hogan@imgtec.com> - 2015-08-05 18:00 +0200
[PATCH 1/7] test_user_copy: Check legit kernel accesses James Hogan <james.hogan@imgtec.com> - 2015-08-05 18:00 +0200
[PATCH 6/7] test_user_copy: Check user string accessors James Hogan <james.hogan@imgtec.com> - 2015-08-05 18:00 +0200
[PATCH 4/7] test_user_copy: Check __copy_in_user()/copy_in_user() James Hogan <james.hogan@imgtec.com> - 2015-08-05 18:00 +0200
[PATCH 5/7] test_user_copy: Check __copy_{to,from}_user_inatomic() James Hogan <james.hogan@imgtec.com> - 2015-08-05 18:00 +0200
Re: [PATCH 0/7] test_user_copy improvements Kees Cook <keescook@chromium.org> - 2015-08-05 22:30 +0200
Re: [PATCH 0/7] test_user_copy improvements James Hogan <james.hogan@imgtec.com> - 2015-08-06 18:30 +0200
Re: [PATCH 0/7] test_user_copy improvements Guenter Roeck <linux@roeck-us.net> - 2015-08-06 12:00 +0200
Re: [PATCH 0/7] test_user_copy improvements James Hogan <james.hogan@imgtec.com> - 2015-08-06 12:10 +0200
Re: [PATCH 0/7] test_user_copy improvements James Hogan <james.hogan@imgtec.com> - 2015-08-06 17:10 +0200
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-05 17:50 +0200 |
| Subject | [PATCH 0/7] test_user_copy improvements |
| Message-ID | <pU974-5Ga-7@gated-at.bofh.it> |
These patches extend the test_user_copy test module to handle lots more
cases of user accessors which architectures can override separately, and
in particular those which are important for checking the MIPS Enhanced
Virtual Addressing (EVA) implementations, which need to handle
overlapping user and kernel address spaces, with special instructions
for accessing user address space from kernel mode.
- Checking that kernel pointers are accepted when user address limit is
set to KERNEL_DS, as done by the kernel when it internally invokes
system calls with kernel pointers.
- Checking of the unchecked accessors (which don't call access_ok()).
Some of the tests are special cased for EVA at the moment which has
stricter hardware guarantees for bad user accesses than other
configurations.
- Checking of other sets of user accessors, including the inatomic user
copies, copy_in_user, clear_user, the user string accessors, and the
user checksum functions, all of which need special handling in arch
code with EVA.
Tested on MIPS with and without EVA, and on x86_64.
James Hogan (7):
test_user_copy: Check legit kernel accesses
test_user_copy: Check unchecked accessors
test_user_copy: Check __clear_user()/clear_user()
test_user_copy: Check __copy_in_user()/copy_in_user()
test_user_copy: Check __copy_{to,from}_user_inatomic()
test_user_copy: Check user string accessors
test_user_copy: Check user checksum functions
lib/test_user_copy.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 221 insertions(+)
Cc: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
--
2.3.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-05 17:50 +0200 |
| Subject | [PATCH 7/7] test_user_copy: Check user checksum functions |
| Message-ID | <pU974-5Ga-5@gated-at.bofh.it> |
| In reply to | #1200920 |
Add basic success/failure checking of the combined user copy and
checksum functions which copy data between user and kernel space while
also checksumming that data. Some architectures have optimised versions
of these which combine both operations into a single pass.
The following cases are checked:
- csum_partial_copy_from_user() with legitimate user to kernel
addresses, illegal all-kernel and reversed addresses (for
implementations where this is safe to test, as this function does not
perform an access_ok() check), and legitimate all-kernel addresses.
- csum_and_copy_from_user() with legitimate user to kernel addresses,
illegal all-kernel and reversed addresses, and legitimate all-kernel
addresses.
- csum_partial_copy_from_user() with legitimate kernel to user
addresses, illegal all-kernel and reversed addresses, and legitimate
all-kernel addresses.
New tests:
- legitimate csum_and_copy_from_user
- legitimate csum_and_copy_to_user
- legitimate csum_partial_copy_from_user
- illegal all-kernel csum_and_copy_from_user
- illegal reversed csum_and_copy_from_user
- illegal all-kernel csum_and_copy_to_user
- illegal reversed csum_and_copy_to_user
- illegal all-kernel csum_partial_copy_from_user
- illegal reversed csum_partial_copy_from_user
- legitimate kernel csum_and_copy_from_user
- legitimate kernel csum_and_copy_to_user
- legitimate kernel csum_partial_copy_from_user
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
lib/test_user_copy.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c
index 6d05ec5f6cfa..76e0c1c25cd2 100644
--- a/lib/test_user_copy.c
+++ b/lib/test_user_copy.c
@@ -24,6 +24,7 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
+#include <net/checksum.h>
#define test(condition, msg) \
({ \
@@ -41,6 +42,7 @@ static int __init test_user_copy_init(void)
char *bad_usermem;
unsigned long user_addr;
unsigned long value = 0x5A;
+ int err;
mm_segment_t fs = get_fs();
kmem = kmalloc(PAGE_SIZE * 2, GFP_KERNEL);
@@ -78,6 +80,12 @@ static int __init test_user_copy_init(void)
"legitimate strnlen_user failed");
ret |= test(strlen_user(usermem) == 0,
"legitimate strlen_user failed");
+ err = 0;
+ csum_and_copy_from_user(usermem, kmem, PAGE_SIZE, 0, &err);
+ ret |= test(err, "legitimate csum_and_copy_from_user failed");
+ err = 0;
+ csum_and_copy_to_user(kmem, usermem, PAGE_SIZE, 0, &err);
+ ret |= test(err, "legitimate csum_and_copy_to_user failed");
ret |= test(!access_ok(VERIFY_READ, usermem, PAGE_SIZE * 2),
"legitimate access_ok VERIFY_READ failed");
@@ -99,6 +107,9 @@ static int __init test_user_copy_init(void)
"legitimate __put_user failed");
ret |= test(__clear_user(usermem, PAGE_SIZE) != 0,
"legitimate __clear_user passed");
+ err = 0;
+ csum_partial_copy_from_user(usermem, kmem, PAGE_SIZE, 0, &err);
+ ret |= test(err, "legitimate csum_partial_copy_from_user failed");
/* Invalid usage: none of these should succeed. */
ret |= test(!copy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE),
@@ -138,6 +149,22 @@ static int __init test_user_copy_init(void)
"illegal strnlen_user passed");
ret |= test(strlen_user((char __user *)kmem) != 0,
"illegal strlen_user passed");
+ err = 0;
+ csum_and_copy_from_user((char __user *)(kmem + PAGE_SIZE), kmem,
+ PAGE_SIZE, 0, &err);
+ ret |= test(!err, "illegal all-kernel csum_and_copy_from_user passed");
+ err = 0;
+ csum_and_copy_from_user((char __user *)kmem, bad_usermem,
+ PAGE_SIZE, 0, &err);
+ ret |= test(!err, "illegal reversed csum_and_copy_from_user passed");
+ err = 0;
+ csum_and_copy_to_user(kmem, (char __user *)(kmem + PAGE_SIZE),
+ PAGE_SIZE, 0, &err);
+ ret |= test(!err, "illegal all-kernel csum_and_copy_to_user passed");
+ err = 0;
+ csum_and_copy_to_user(bad_usermem, (char __user *)kmem, PAGE_SIZE, 0,
+ &err);
+ ret |= test(!err, "illegal reversed csum_and_copy_to_user passed");
/*
* If unchecked user accesses (__*) on this architecture cannot access
@@ -192,6 +219,16 @@ static int __init test_user_copy_init(void)
"illegal __put_user passed");
ret |= test(__clear_user((char __user *)kmem, PAGE_SIZE) != PAGE_SIZE,
"illegal kernel __clear_user passed");
+ err = 0;
+ csum_partial_copy_from_user((char __user *)(kmem + PAGE_SIZE), kmem,
+ PAGE_SIZE, 0, &err);
+ ret |= test(!err,
+ "illegal all-kernel csum_partial_copy_from_user passed");
+ err = 0;
+ csum_partial_copy_from_user((char __user *)kmem, bad_usermem, PAGE_SIZE,
+ 0, &err);
+ ret |= test(!err,
+ "illegal reversed csum_partial_copy_from_user passed");
#endif
/*
@@ -224,6 +261,14 @@ static int __init test_user_copy_init(void)
"legitimate kernel strnlen_user failed");
ret |= test(strlen_user((char __user *)kmem) == 0,
"legitimate kernel strlen_user failed");
+ err = 0;
+ csum_and_copy_from_user((char __user *)(kmem + PAGE_SIZE), kmem,
+ PAGE_SIZE, 0, &err);
+ ret |= test(err, "legitimate kernel csum_and_copy_from_user failed");
+ err = 0;
+ csum_and_copy_to_user(kmem, (char __user *)(kmem + PAGE_SIZE),
+ PAGE_SIZE, 0, &err);
+ ret |= test(err, "legitimate kernel csum_and_copy_to_user failed");
ret |= test(!access_ok(VERIFY_READ, (char __user *)kmem, PAGE_SIZE * 2),
"legitimate kernel access_ok VERIFY_READ failed");
@@ -253,6 +298,11 @@ static int __init test_user_copy_init(void)
"legitimate kernel __put_user failed");
ret |= test(__clear_user((char __user *)kmem, PAGE_SIZE) != 0,
"legitimate kernel __clear_user failed");
+ err = 0;
+ csum_partial_copy_from_user((char __user *)(kmem + PAGE_SIZE), kmem,
+ PAGE_SIZE, 0, &err);
+ ret |= test(err,
+ "legitimate kernel csum_partial_copy_from_user failed");
/* Restore previous address limit. */
set_fs(fs);
--
2.3.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-05 17:50 +0200 |
| Subject | [PATCH 2/7] test_user_copy: Check unchecked accessors |
| Message-ID | <pU974-5Ga-11@gated-at.bofh.it> |
| In reply to | #1200920 |
Currently the test_user_copy module only tests the user accessors which already check the address with access_ok(). Corresponding unchecked accessors exist however which may be used after access_ok() is checked. Since the addresses the test uses are known to be valid kernel addresses, test these unchecked accessors too, as well as access_ok() itself. For legitimate user accesses we test the corresponding unchecked macros. They should all work just as well as the checking versions. Similarly, for legitimate kernel accesses the unchecked macros are expected to succeed, and access kernel rather than user memory. For invalid user accesses we only test the corresponding unchecked macros in configurations where the behaviour is both known and important to verify the implementation. Currently this is only enabled for MIPS with Enhanced Virtual Addressing (EVA) enabled, where user accesses MUST use the EVA loads/stores, which can only access valid user mode memory anyway. New tests: - legitimate access_ok VERIFY_READ - legitimate access_ok VERIFY_WRITE - legitimate __copy_from_user - legitimate __copy_to_user - legitimate __get_user - legitimate __put_user - illegal all-kernel __copy_from_user - illegal reversed __copy_from_user - illegal all-kernel __copy_to_user - illegal reversed __copy_to_user - illegal __get_user - illegal __put_user - legitimate kernel access_ok VERIFY_READ - legitimate kernel access_ok VERIFY_WRITE - legitimate all-kernel __copy_from_user - legitimate all-kernel __copy_to_user - legitimate kernel __get_user - legitimate kernel __put_user Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Kees Cook <keescook@chromium.org> Cc: Andrew Morton <akpm@linux-foundation.org> --- lib/test_user_copy.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c index 445ca92b0b80..23fb9d15f50c 100644 --- a/lib/test_user_copy.c +++ b/lib/test_user_copy.c @@ -69,6 +69,19 @@ static int __init test_user_copy_init(void) ret |= test(put_user(value, (unsigned long __user *)usermem), "legitimate put_user failed"); + ret |= test(!access_ok(VERIFY_READ, usermem, PAGE_SIZE * 2), + "legitimate access_ok VERIFY_READ failed"); + ret |= test(!access_ok(VERIFY_WRITE, usermem, PAGE_SIZE * 2), + "legitimate access_ok VERIFY_WRITE failed"); + ret |= test(__copy_from_user(kmem, usermem, PAGE_SIZE), + "legitimate __copy_from_user failed"); + ret |= test(__copy_to_user(usermem, kmem, PAGE_SIZE), + "legitimate __copy_to_user failed"); + ret |= test(__get_user(value, (unsigned long __user *)usermem), + "legitimate __get_user failed"); + ret |= test(__put_user(value, (unsigned long __user *)usermem), + "legitimate __put_user failed"); + /* Invalid usage: none of these should succeed. */ ret |= test(!copy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE), PAGE_SIZE), @@ -88,6 +101,36 @@ static int __init test_user_copy_init(void) "illegal put_user passed"); /* + * If unchecked user accesses (__*) on this architecture cannot access + * kernel mode (i.e. access_ok() is redundant), and usually faults when + * attempted, check this behaviour. + * + * These tests are enabled for: + * - MIPS with Enhanced Virtual Addressing (EVA): user accesses use EVA + * instructions which can only access user mode accessible memory. It + * is assumed to be unlikely that user address space mappings will + * intersect the kernel buffer address. + */ +#if defined(CONFIG_MIPS) && defined(CONFIG_EVA) + ret |= test(!__copy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE), + "illegal all-kernel __copy_from_user passed"); + ret |= test(!__copy_from_user(bad_usermem, (char __user *)kmem, + PAGE_SIZE), + "illegal reversed __copy_from_user passed"); + ret |= test(!__copy_to_user((char __user *)kmem, kmem + PAGE_SIZE, + PAGE_SIZE), + "illegal all-kernel __copy_to_user passed"); + ret |= test(!__copy_to_user((char __user *)kmem, bad_usermem, + PAGE_SIZE), + "illegal reversed __copy_to_user passed"); + ret |= test(!__get_user(value, (unsigned long __user *)kmem), + "illegal __get_user passed"); + ret |= test(!__put_user(value, (unsigned long __user *)kmem), + "illegal __put_user passed"); +#endif + + /* * Test access to kernel memory by adjusting address limit. * This is used by the kernel to invoke system calls with kernel * pointers. @@ -106,6 +149,22 @@ static int __init test_user_copy_init(void) ret |= test(put_user(value, (unsigned long __user *)kmem), "legitimate kernel put_user failed"); + ret |= test(!access_ok(VERIFY_READ, (char __user *)kmem, PAGE_SIZE * 2), + "legitimate kernel access_ok VERIFY_READ failed"); + ret |= test(!access_ok(VERIFY_WRITE, (char __user *)kmem, + PAGE_SIZE * 2), + "legitimate kernel access_ok VERIFY_WRITE failed"); + ret |= test(__copy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE), + "legitimate all-kernel __copy_from_user failed"); + ret |= test(__copy_to_user((char __user *)kmem, kmem + PAGE_SIZE, + PAGE_SIZE), + "legitimate all-kernel __copy_to_user failed"); + ret |= test(__get_user(value, (unsigned long __user *)kmem), + "legitimate kernel __get_user failed"); + ret |= test(__put_user(value, (unsigned long __user *)kmem), + "legitimate kernel __put_user failed"); + /* Restore previous address limit. */ set_fs(fs); -- 2.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-05 18:00 +0200 |
| Subject | [PATCH 3/7] test_user_copy: Check __clear_user()/clear_user() |
| Message-ID | <pU9gK-5S2-11@gated-at.bofh.it> |
| In reply to | #1200920 |
Add basic success/failure checking of __clear_user() and clear_user(), which zero an area of user or kernel memory and return the number of bytes left to clear. This catches a couple of bugs in the MIPS Enhanced Virtual Memory (EVA) implementation (which have already been fixed): test_user_copy: legitimate kernel clear_user failed test_user_copy: legitimate kernel __clear_user failed Due to neither function checking the user address limit, and both resorting to user access unconditionally. New tests: - legitimate clear_user - legitimate __clear_user - illegal kernel clear_user - illegal kernel __clear_user - legitimate kernel clear_user - legitimate kernel __clear_user Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Kees Cook <keescook@chromium.org> Cc: Andrew Morton <akpm@linux-foundation.org> --- lib/test_user_copy.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c index 23fb9d15f50c..4ec2cfa916c1 100644 --- a/lib/test_user_copy.c +++ b/lib/test_user_copy.c @@ -68,6 +68,8 @@ static int __init test_user_copy_init(void) "legitimate get_user failed"); ret |= test(put_user(value, (unsigned long __user *)usermem), "legitimate put_user failed"); + ret |= test(clear_user(usermem, PAGE_SIZE) != 0, + "legitimate clear_user passed"); ret |= test(!access_ok(VERIFY_READ, usermem, PAGE_SIZE * 2), "legitimate access_ok VERIFY_READ failed"); @@ -81,6 +83,8 @@ static int __init test_user_copy_init(void) "legitimate __get_user failed"); ret |= test(__put_user(value, (unsigned long __user *)usermem), "legitimate __put_user failed"); + ret |= test(__clear_user(usermem, PAGE_SIZE) != 0, + "legitimate __clear_user passed"); /* Invalid usage: none of these should succeed. */ ret |= test(!copy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE), @@ -99,6 +103,8 @@ static int __init test_user_copy_init(void) "illegal get_user passed"); ret |= test(!put_user(value, (unsigned long __user *)kmem), "illegal put_user passed"); + ret |= test(clear_user((char __user *)kmem, PAGE_SIZE) != PAGE_SIZE, + "illegal kernel clear_user passed"); /* * If unchecked user accesses (__*) on this architecture cannot access @@ -128,6 +134,8 @@ static int __init test_user_copy_init(void) "illegal __get_user passed"); ret |= test(!__put_user(value, (unsigned long __user *)kmem), "illegal __put_user passed"); + ret |= test(__clear_user((char __user *)kmem, PAGE_SIZE) != PAGE_SIZE, + "illegal kernel __clear_user passed"); #endif /* @@ -148,6 +156,8 @@ static int __init test_user_copy_init(void) "legitimate kernel get_user failed"); ret |= test(put_user(value, (unsigned long __user *)kmem), "legitimate kernel put_user failed"); + ret |= test(clear_user((char __user *)kmem, PAGE_SIZE) != 0, + "legitimate kernel clear_user failed"); ret |= test(!access_ok(VERIFY_READ, (char __user *)kmem, PAGE_SIZE * 2), "legitimate kernel access_ok VERIFY_READ failed"); @@ -164,6 +174,8 @@ static int __init test_user_copy_init(void) "legitimate kernel __get_user failed"); ret |= test(__put_user(value, (unsigned long __user *)kmem), "legitimate kernel __put_user failed"); + ret |= test(__clear_user((char __user *)kmem, PAGE_SIZE) != 0, + "legitimate kernel __clear_user failed"); /* Restore previous address limit. */ set_fs(fs); -- 2.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-05 18:00 +0200 |
| Subject | [PATCH 1/7] test_user_copy: Check legit kernel accesses |
| Message-ID | <pU9gK-5S2-5@gated-at.bofh.it> |
| In reply to | #1200920 |
Check that the use of the user accessors for accessing kernel memory succeed as expected after set_fs(get_ds()) is used to increases the address limit, as used by the kernel to directly invoke system call code with kernel pointers. The tests are basically the same as the tests normally expected to be treated as invalid, but without any user addresses (no reversed copies), and with the result inverted such that they should succeed instead. New tests: - legitimate all-kernel copy_from_user - legitimate all-kernel copy_to_user - legitimate kernel get_user - legitimate kernel put_user Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Kees Cook <keescook@chromium.org> Cc: Andrew Morton <akpm@linux-foundation.org> --- lib/test_user_copy.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c index 0ecef3e4690e..445ca92b0b80 100644 --- a/lib/test_user_copy.c +++ b/lib/test_user_copy.c @@ -41,6 +41,7 @@ static int __init test_user_copy_init(void) char *bad_usermem; unsigned long user_addr; unsigned long value = 0x5A; + mm_segment_t fs = get_fs(); kmem = kmalloc(PAGE_SIZE * 2, GFP_KERNEL); if (!kmem) @@ -86,6 +87,28 @@ static int __init test_user_copy_init(void) ret |= test(!put_user(value, (unsigned long __user *)kmem), "illegal put_user passed"); + /* + * Test access to kernel memory by adjusting address limit. + * This is used by the kernel to invoke system calls with kernel + * pointers. + */ + set_fs(get_ds()); + + /* Legitimate usage: none of these should fail. */ + ret |= test(copy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE), + "legitimate all-kernel copy_from_user failed"); + ret |= test(copy_to_user((char __user *)kmem, kmem + PAGE_SIZE, + PAGE_SIZE), + "legitimate all-kernel copy_to_user failed"); + ret |= test(get_user(value, (unsigned long __user *)kmem), + "legitimate kernel get_user failed"); + ret |= test(put_user(value, (unsigned long __user *)kmem), + "legitimate kernel put_user failed"); + + /* Restore previous address limit. */ + set_fs(fs); + vm_munmap(user_addr, PAGE_SIZE * 2); kfree(kmem); -- 2.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-05 18:00 +0200 |
| Subject | [PATCH 6/7] test_user_copy: Check user string accessors |
| Message-ID | <pU9gK-5S2-13@gated-at.bofh.it> |
| In reply to | #1200920 |
Add basic success/failure checking of the user string functions which copy or find the length of userland strings. The following cases are checked: - strncpy_from_user() with legitimate user to kernel addresses, illegal all-kernel and reversed addresses, and legitimate all-kernel addresses. - strnlen_user()/strlen_user() with a legitimate user address, an illegal kernel address, and a legitimate kernel address. This caught a bug in the MIPS Enhanced Virtual Memory (EVA) implementation: test_user_copy: illegal strlen_user passed Due to strlen_user() accidentally always using normal kernel loads, and the EVA user/kernel address ranges overlapping. New tests: - legitimate strncpy_from_user - legitimate strnlen_user - legitimate strlen_user - illegal all-kernel strncpy_from_user - illegal reversed strncpy_from_user - illegal strnlen_user - illegal strlen_user - legitimate all-kernel strncpy_from_user - legitimate kernel strnlen_user - legitimate kernel strlen_user Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Kees Cook <keescook@chromium.org> Cc: Andrew Morton <akpm@linux-foundation.org> --- lib/test_user_copy.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c index 6cbdb0a15ca2..6d05ec5f6cfa 100644 --- a/lib/test_user_copy.c +++ b/lib/test_user_copy.c @@ -72,6 +72,12 @@ static int __init test_user_copy_init(void) "legitimate put_user failed"); ret |= test(clear_user(usermem, PAGE_SIZE) != 0, "legitimate clear_user passed"); + ret |= test(strncpy_from_user(kmem, usermem, PAGE_SIZE) < 0, + "legitimate strncpy_from_user failed"); + ret |= test(strnlen_user(usermem, PAGE_SIZE) == 0, + "legitimate strnlen_user failed"); + ret |= test(strlen_user(usermem) == 0, + "legitimate strlen_user failed"); ret |= test(!access_ok(VERIFY_READ, usermem, PAGE_SIZE * 2), "legitimate access_ok VERIFY_READ failed"); @@ -122,6 +128,16 @@ static int __init test_user_copy_init(void) "illegal put_user passed"); ret |= test(clear_user((char __user *)kmem, PAGE_SIZE) != PAGE_SIZE, "illegal kernel clear_user passed"); + ret |= test(strncpy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE) >= 0, + "illegal all-kernel strncpy_from_user passed"); + ret |= test(strncpy_from_user(bad_usermem, (char __user *)kmem, + PAGE_SIZE) >= 0, + "illegal reversed strncpy_from_user passed"); + ret |= test(strnlen_user((char __user *)kmem, PAGE_SIZE) != 0, + "illegal strnlen_user passed"); + ret |= test(strlen_user((char __user *)kmem) != 0, + "illegal strlen_user passed"); /* * If unchecked user accesses (__*) on this architecture cannot access @@ -201,6 +217,13 @@ static int __init test_user_copy_init(void) "legitimate kernel put_user failed"); ret |= test(clear_user((char __user *)kmem, PAGE_SIZE) != 0, "legitimate kernel clear_user failed"); + ret |= test(strncpy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE) < 0, + "legitimate all-kernel strncpy_from_user failed"); + ret |= test(strnlen_user((char __user *)kmem, PAGE_SIZE) == 0, + "legitimate kernel strnlen_user failed"); + ret |= test(strlen_user((char __user *)kmem) == 0, + "legitimate kernel strlen_user failed"); ret |= test(!access_ok(VERIFY_READ, (char __user *)kmem, PAGE_SIZE * 2), "legitimate kernel access_ok VERIFY_READ failed"); -- 2.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-05 18:00 +0200 |
| Subject | [PATCH 4/7] test_user_copy: Check __copy_in_user()/copy_in_user() |
| Message-ID | <pU9gK-5S2-25@gated-at.bofh.it> |
| In reply to | #1200920 |
Add basic success/failure checking of copy_in_user() which copies data from userspace to userspace (or kernel to kernel), and its unchecking cousin __copy_in_user() which assumes that access_ok() has already been used as appropriate. The following cases are checked: - __copy_in_user/copy_in_user from user to user should succeed. - __copy_in_user/copy_in_user involving 1 or 2 kernel pointers should not succeed. - __copy_in_user/copy_in_user from kernel to kernel should succeed when user address limit is set for kernel accesses. New tests: - legitimate copy_in_user - legitimate __copy_in_user - illegal all-kernel copy_in_user - illegal copy_in_user to kernel - illegal copy_in_user from kernel - illegal all-kernel __copy_in_user - illegal __copy_in_user to kernel - illegal __copy_in_user from kernel - legitimate all-kernel copy_in_user - legitimate all-kernel __copy_in_user Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Kees Cook <keescook@chromium.org> Cc: Andrew Morton <akpm@linux-foundation.org> --- lib/test_user_copy.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c index 4ec2cfa916c1..310e796beef6 100644 --- a/lib/test_user_copy.c +++ b/lib/test_user_copy.c @@ -64,6 +64,8 @@ static int __init test_user_copy_init(void) "legitimate copy_from_user failed"); ret |= test(copy_to_user(usermem, kmem, PAGE_SIZE), "legitimate copy_to_user failed"); + ret |= test(copy_in_user(usermem, usermem + PAGE_SIZE, PAGE_SIZE), + "legitimate copy_in_user failed"); ret |= test(get_user(value, (unsigned long __user *)usermem), "legitimate get_user failed"); ret |= test(put_user(value, (unsigned long __user *)usermem), @@ -79,6 +81,8 @@ static int __init test_user_copy_init(void) "legitimate __copy_from_user failed"); ret |= test(__copy_to_user(usermem, kmem, PAGE_SIZE), "legitimate __copy_to_user failed"); + ret |= test(__copy_in_user(usermem, usermem + PAGE_SIZE, PAGE_SIZE), + "legitimate __copy_in_user failed"); ret |= test(__get_user(value, (unsigned long __user *)usermem), "legitimate __get_user failed"); ret |= test(__put_user(value, (unsigned long __user *)usermem), @@ -99,6 +103,15 @@ static int __init test_user_copy_init(void) ret |= test(!copy_to_user((char __user *)kmem, bad_usermem, PAGE_SIZE), "illegal reversed copy_to_user passed"); + ret |= test(!copy_in_user((char __user *)kmem, + (char __user *)(kmem + PAGE_SIZE), PAGE_SIZE), + "illegal all-kernel copy_in_user passed"); + ret |= test(!copy_in_user((char __user *)kmem, usermem, + PAGE_SIZE), + "illegal copy_in_user to kernel passed"); + ret |= test(!copy_in_user(usermem, (char __user *)kmem, + PAGE_SIZE), + "illegal copy_in_user from kernel passed"); ret |= test(!get_user(value, (unsigned long __user *)kmem), "illegal get_user passed"); ret |= test(!put_user(value, (unsigned long __user *)kmem), @@ -130,6 +143,16 @@ static int __init test_user_copy_init(void) ret |= test(!__copy_to_user((char __user *)kmem, bad_usermem, PAGE_SIZE), "illegal reversed __copy_to_user passed"); + ret |= test(!__copy_in_user((char __user *)kmem, + (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE), + "illegal all-kernel __copy_in_user passed"); + ret |= test(!__copy_in_user((char __user *)kmem, usermem, + PAGE_SIZE), + "illegal __copy_in_user to kernel passed"); + ret |= test(!__copy_in_user(usermem, (char __user *)kmem, + PAGE_SIZE), + "illegal __copy_in_user from kernel passed"); ret |= test(!__get_user(value, (unsigned long __user *)kmem), "illegal __get_user passed"); ret |= test(!__put_user(value, (unsigned long __user *)kmem), @@ -152,6 +175,9 @@ static int __init test_user_copy_init(void) ret |= test(copy_to_user((char __user *)kmem, kmem + PAGE_SIZE, PAGE_SIZE), "legitimate all-kernel copy_to_user failed"); + ret |= test(copy_in_user((char __user *)kmem, + (char __user *)(kmem + PAGE_SIZE), PAGE_SIZE), + "legitimate all-kernel copy_in_user failed"); ret |= test(get_user(value, (unsigned long __user *)kmem), "legitimate kernel get_user failed"); ret |= test(put_user(value, (unsigned long __user *)kmem), @@ -170,6 +196,10 @@ static int __init test_user_copy_init(void) ret |= test(__copy_to_user((char __user *)kmem, kmem + PAGE_SIZE, PAGE_SIZE), "legitimate all-kernel __copy_to_user failed"); + ret |= test(__copy_in_user((char __user *)kmem, + (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE), + "legitimate all-kernel __copy_in_user failed"); ret |= test(__get_user(value, (unsigned long __user *)kmem), "legitimate kernel __get_user failed"); ret |= test(__put_user(value, (unsigned long __user *)kmem), -- 2.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-05 18:00 +0200 |
| Subject | [PATCH 5/7] test_user_copy: Check __copy_{to,from}_user_inatomic() |
| Message-ID | <pU9gL-5S2-27@gated-at.bofh.it> |
| In reply to | #1200920 |
Add basic success/failure checking of __copy_to_user_inatomic() and __copy_from_user_inatomic(). For testing purposes these are similar to their non-atomic non-checking friends, so the new tests match those for __copy_to_user() and __copy_from_user(). New tests: - legitimate __copy_from_user_inatomic - legitimate __copy_to_user_inatomic - illegal all-kernel __copy_from_user_inatomic - illegal reversed __copy_from_user_inatomic - illegal all-kernel __copy_to_user_inatomic - illegal reversed __copy_to_user_inatomic - legitimate all-kernel __copy_from_user_inatomic - legitimate all-kernel __copy_to_user_inatomic Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Kees Cook <keescook@chromium.org> Cc: Andrew Morton <akpm@linux-foundation.org> --- lib/test_user_copy.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c index 310e796beef6..6cbdb0a15ca2 100644 --- a/lib/test_user_copy.c +++ b/lib/test_user_copy.c @@ -79,8 +79,12 @@ static int __init test_user_copy_init(void) "legitimate access_ok VERIFY_WRITE failed"); ret |= test(__copy_from_user(kmem, usermem, PAGE_SIZE), "legitimate __copy_from_user failed"); + ret |= test(__copy_from_user_inatomic(kmem, usermem, PAGE_SIZE), + "legitimate __copy_from_user_inatomic failed"); ret |= test(__copy_to_user(usermem, kmem, PAGE_SIZE), "legitimate __copy_to_user failed"); + ret |= test(__copy_to_user_inatomic(usermem, kmem, PAGE_SIZE), + "legitimate __copy_to_user_inatomic failed"); ret |= test(__copy_in_user(usermem, usermem + PAGE_SIZE, PAGE_SIZE), "legitimate __copy_in_user failed"); ret |= test(__get_user(value, (unsigned long __user *)usermem), @@ -137,12 +141,25 @@ static int __init test_user_copy_init(void) ret |= test(!__copy_from_user(bad_usermem, (char __user *)kmem, PAGE_SIZE), "illegal reversed __copy_from_user passed"); + ret |= test(!__copy_from_user_inatomic(kmem, + (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE), + "illegal all-kernel __copy_from_user_inatomic passed"); + ret |= test(!__copy_from_user_inatomic(bad_usermem, (char __user *)kmem, + PAGE_SIZE), + "illegal reversed __copy_from_user_inatomic passed"); ret |= test(!__copy_to_user((char __user *)kmem, kmem + PAGE_SIZE, PAGE_SIZE), "illegal all-kernel __copy_to_user passed"); ret |= test(!__copy_to_user((char __user *)kmem, bad_usermem, PAGE_SIZE), "illegal reversed __copy_to_user passed"); + ret |= test(!__copy_to_user_inatomic((char __user *)kmem, + kmem + PAGE_SIZE, PAGE_SIZE), + "illegal all-kernel __copy_to_user_inatomic passed"); + ret |= test(!__copy_to_user_inatomic((char __user *)kmem, bad_usermem, + PAGE_SIZE), + "illegal reversed __copy_to_user_inatomic passed"); ret |= test(!__copy_in_user((char __user *)kmem, (char __user *)(kmem + PAGE_SIZE), PAGE_SIZE), @@ -193,9 +210,16 @@ static int __init test_user_copy_init(void) ret |= test(__copy_from_user(kmem, (char __user *)(kmem + PAGE_SIZE), PAGE_SIZE), "legitimate all-kernel __copy_from_user failed"); + ret |= test(__copy_from_user_inatomic(kmem, + (char __user *)(kmem + PAGE_SIZE), + PAGE_SIZE), + "legitimate all-kernel __copy_from_user_inatomic failed"); ret |= test(__copy_to_user((char __user *)kmem, kmem + PAGE_SIZE, PAGE_SIZE), "legitimate all-kernel __copy_to_user failed"); + ret |= test(__copy_to_user_inatomic((char __user *)kmem, + kmem + PAGE_SIZE, PAGE_SIZE), + "legitimate all-kernel __copy_to_user_inatomic failed"); ret |= test(__copy_in_user((char __user *)kmem, (char __user *)(kmem + PAGE_SIZE), PAGE_SIZE), -- 2.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2015-08-05 22:30 +0200 |
| Message-ID | <pUdu2-3Ci-15@gated-at.bofh.it> |
| In reply to | #1200920 |
On Wed, Aug 5, 2015 at 8:48 AM, James Hogan <james.hogan@imgtec.com> wrote:
> These patches extend the test_user_copy test module to handle lots more
> cases of user accessors which architectures can override separately, and
> in particular those which are important for checking the MIPS Enhanced
> Virtual Addressing (EVA) implementations, which need to handle
> overlapping user and kernel address spaces, with special instructions
> for accessing user address space from kernel mode.
>
> - Checking that kernel pointers are accepted when user address limit is
> set to KERNEL_DS, as done by the kernel when it internally invokes
> system calls with kernel pointers.
> - Checking of the unchecked accessors (which don't call access_ok()).
> Some of the tests are special cased for EVA at the moment which has
> stricter hardware guarantees for bad user accesses than other
> configurations.
> - Checking of other sets of user accessors, including the inatomic user
> copies, copy_in_user, clear_user, the user string accessors, and the
> user checksum functions, all of which need special handling in arch
> code with EVA.
>
> Tested on MIPS with and without EVA, and on x86_64.
>
> James Hogan (7):
> test_user_copy: Check legit kernel accesses
> test_user_copy: Check unchecked accessors
> test_user_copy: Check __clear_user()/clear_user()
> test_user_copy: Check __copy_in_user()/copy_in_user()
> test_user_copy: Check __copy_{to,from}_user_inatomic()
> test_user_copy: Check user string accessors
> test_user_copy: Check user checksum functions
>
> lib/test_user_copy.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 221 insertions(+)
>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
Ooooh! Nice! This is great, thank you. :) Great to hear it helped find
a bug too. :)
I'm wondering if we need to macro-ize any of these. Probably not, but
it just feels like there's a lot of repeated stuff now. But I think
it's a bit of an illusion since each test is ever so slightly
different from the others.
Acked-by: Kees Cook <keescook@chromium.org>
-Kees
--
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-06 18:30 +0200 |
| Message-ID | <pUwdk-5WC-11@gated-at.bofh.it> |
| In reply to | #1201130 |
[Multipart message — attachments visible in raw view] — view raw
Hi Kees,
On 05/08/15 21:26, Kees Cook wrote:
> On Wed, Aug 5, 2015 at 8:48 AM, James Hogan <james.hogan@imgtec.com> wrote:
>> These patches extend the test_user_copy test module to handle lots more
>> cases of user accessors which architectures can override separately, and
>> in particular those which are important for checking the MIPS Enhanced
>> Virtual Addressing (EVA) implementations, which need to handle
>> overlapping user and kernel address spaces, with special instructions
>> for accessing user address space from kernel mode.
>>
>> - Checking that kernel pointers are accepted when user address limit is
>> set to KERNEL_DS, as done by the kernel when it internally invokes
>> system calls with kernel pointers.
>> - Checking of the unchecked accessors (which don't call access_ok()).
>> Some of the tests are special cased for EVA at the moment which has
>> stricter hardware guarantees for bad user accesses than other
>> configurations.
>> - Checking of other sets of user accessors, including the inatomic user
>> copies, copy_in_user, clear_user, the user string accessors, and the
>> user checksum functions, all of which need special handling in arch
>> code with EVA.
>>
>> Tested on MIPS with and without EVA, and on x86_64.
>>
>> James Hogan (7):
>> test_user_copy: Check legit kernel accesses
>> test_user_copy: Check unchecked accessors
>> test_user_copy: Check __clear_user()/clear_user()
>> test_user_copy: Check __copy_in_user()/copy_in_user()
>> test_user_copy: Check __copy_{to,from}_user_inatomic()
>> test_user_copy: Check user string accessors
>> test_user_copy: Check user checksum functions
>>
>> lib/test_user_copy.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 221 insertions(+)
>>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>
> Ooooh! Nice! This is great, thank you. :) Great to hear it helped find
> a bug too. :)
>
> I'm wondering if we need to macro-ize any of these. Probably not, but
> it just feels like there's a lot of repeated stuff now. But I think
> it's a bit of an illusion since each test is ever so slightly
> different from the others.
Yeh, I wondered that too, but I agree they're all slightly different in
their requirements so it'd just end up confusing things.
>
> Acked-by: Kees Cook <keescook@chromium.org>
Thanks!
James
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2015-08-06 12:00 +0200 |
| Message-ID | <pUq7T-5lT-3@gated-at.bofh.it> |
| In reply to | #1200920 |
Hi James, On Wed, Aug 05, 2015 at 04:48:48PM +0100, James Hogan wrote: > These patches extend the test_user_copy test module to handle lots more > cases of user accessors which architectures can override separately, and > in particular those which are important for checking the MIPS Enhanced > Virtual Addressing (EVA) implementations, which need to handle > overlapping user and kernel address spaces, with special instructions > for accessing user address space from kernel mode. > > - Checking that kernel pointers are accepted when user address limit is > set to KERNEL_DS, as done by the kernel when it internally invokes > system calls with kernel pointers. > - Checking of the unchecked accessors (which don't call access_ok()). > Some of the tests are special cased for EVA at the moment which has > stricter hardware guarantees for bad user accesses than other > configurations. > - Checking of other sets of user accessors, including the inatomic user > copies, copy_in_user, clear_user, the user string accessors, and the > user checksum functions, all of which need special handling in arch > code with EVA. > > Tested on MIPS with and without EVA, and on x86_64. > The series causes several build failures with other architectures. From next-20150806: Build results: total: 152 pass: 138 fail: 14 Failed builds: alpha:allmodconfig (*) arm:allmodconfig (*) arm:omap2plus_defconfig arm64:allmodconfig i386:allyesconfig (*) i386:allmodconfig (*) m68k:defconfig (*) m68k:allmodconfig (*) m68k:sun3_defconfig (*) mips:allmodconfig parisc:allmodconfig s390:allmodconfig sparc32:allmodconfig (*) xtensa:allmodconfig (*) The builds marked with (*) fail because of your patch series. Guenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-06 12:10 +0200 |
| Message-ID | <pUqhA-5Mv-19@gated-at.bofh.it> |
| In reply to | #1201609 |
[Multipart message — attachments visible in raw view] — view raw
On 06/08/15 10:50, Guenter Roeck wrote: > Hi James, > > On Wed, Aug 05, 2015 at 04:48:48PM +0100, James Hogan wrote: >> These patches extend the test_user_copy test module to handle lots more >> cases of user accessors which architectures can override separately, and >> in particular those which are important for checking the MIPS Enhanced >> Virtual Addressing (EVA) implementations, which need to handle >> overlapping user and kernel address spaces, with special instructions >> for accessing user address space from kernel mode. >> >> - Checking that kernel pointers are accepted when user address limit is >> set to KERNEL_DS, as done by the kernel when it internally invokes >> system calls with kernel pointers. >> - Checking of the unchecked accessors (which don't call access_ok()). >> Some of the tests are special cased for EVA at the moment which has >> stricter hardware guarantees for bad user accesses than other >> configurations. >> - Checking of other sets of user accessors, including the inatomic user >> copies, copy_in_user, clear_user, the user string accessors, and the >> user checksum functions, all of which need special handling in arch >> code with EVA. >> >> Tested on MIPS with and without EVA, and on x86_64. >> > The series causes several build failures with other architectures. Thanks Guenter, and sorry for the breakage. I've already got some fixes lined up. From the failure logs it looks like #ifdef CONFIG_COMPAT for [__]copy_in_user and #ifndef _HAVE_ARCH_COPY_AND_CSUM_FROM_USER for the the ppc64 csum_partial_copy_from_user one Stephen caught should sort it out. Cheers James > > From next-20150806: > > Build results: > total: 152 pass: 138 fail: 14 > Failed builds: > alpha:allmodconfig (*) > arm:allmodconfig (*) > arm:omap2plus_defconfig > arm64:allmodconfig > i386:allyesconfig (*) > i386:allmodconfig (*) > m68k:defconfig (*) > m68k:allmodconfig (*) > m68k:sun3_defconfig (*) > mips:allmodconfig > parisc:allmodconfig > s390:allmodconfig > sparc32:allmodconfig (*) > xtensa:allmodconfig (*) > > The builds marked with (*) fail because of your patch series. > > Guenter >
[toc] | [prev] | [next] | [standalone]
| From | James Hogan <james.hogan@imgtec.com> |
|---|---|
| Date | 2015-08-06 17:10 +0200 |
| Message-ID | <pUuXU-4cV-25@gated-at.bofh.it> |
| In reply to | #1200920 |
[Multipart message — attachments visible in raw view] — view raw
Hi Andrew,
On 05/08/15 16:48, James Hogan wrote:
> These patches extend the test_user_copy test module to handle lots more
> cases of user accessors which architectures can override separately, and
> in particular those which are important for checking the MIPS Enhanced
> Virtual Addressing (EVA) implementations, which need to handle
> overlapping user and kernel address spaces, with special instructions
> for accessing user address space from kernel mode.
>
> - Checking that kernel pointers are accepted when user address limit is
> set to KERNEL_DS, as done by the kernel when it internally invokes
> system calls with kernel pointers.
> - Checking of the unchecked accessors (which don't call access_ok()).
> Some of the tests are special cased for EVA at the moment which has
> stricter hardware guarantees for bad user accesses than other
> configurations.
> - Checking of other sets of user accessors, including the inatomic user
> copies, copy_in_user, clear_user, the user string accessors, and the
> user checksum functions, all of which need special handling in arch
> code with EVA.
>
> Tested on MIPS with and without EVA, and on x86_64.
Could you drop these patches for -mm for the moment please. I'll get a
v2 to fix the build problems out tomorrow now.
Cheers
James
>
> James Hogan (7):
> test_user_copy: Check legit kernel accesses
> test_user_copy: Check unchecked accessors
> test_user_copy: Check __clear_user()/clear_user()
> test_user_copy: Check __copy_in_user()/copy_in_user()
> test_user_copy: Check __copy_{to,from}_user_inatomic()
> test_user_copy: Check user string accessors
> test_user_copy: Check user checksum functions
>
> lib/test_user_copy.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 221 insertions(+)
>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web