All of lore.kernel.org
 help / color / mirror / Atom feed
* [kernel-hardening] [RFC PATCH] lib: Harden csum_partial_copy_from_user
@ 2016-11-02 17:02 Vaishali Thakkar
  2016-11-02 20:44 ` Mark Rutland
  0 siblings, 1 reply; 9+ messages in thread
From: Vaishali Thakkar @ 2016-11-02 17:02 UTC (permalink / raw)
  To: kernel-hardening; +Cc: Vaishali Thakkar

The routine csum_partial_copy_from_user is same as csum_partial_copy
but it copies from user space for the checksumming. In other respects
it is identical, and can be used to copy an arbitrarily large buffer
from userspace into the kernel. Conceptually this exposes a similar
attack surface like copy_from_user. So, to validate the given address
we should call check_object_size here.

Note that in the absence of hardened usercopy this will have no impact.

Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
---
 lib/checksum.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/checksum.c b/lib/checksum.c
index d3ec93f..2e0fec8 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -33,6 +33,7 @@
  kills, so most of the assembly has to go. */
 
 #include <linux/export.h>
+#include <linux/thread_info.h>
 #include <net/checksum.h>
 
 #include <asm/byteorder.h>
@@ -158,6 +159,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst, int len,
 {
 	int missing;
 
+	check_object_size(dst, len, false);
 	missing = __copy_from_user(dst, src, len);
 	if (missing) {
 		memset(dst + len - missing, 0, missing);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-11-04 10:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-02 17:02 [kernel-hardening] [RFC PATCH] lib: Harden csum_partial_copy_from_user Vaishali Thakkar
2016-11-02 20:44 ` Mark Rutland
2016-11-02 21:59   ` Kees Cook
2016-11-03  2:14     ` Vaishali Thakkar
2016-11-03  4:23       ` Mark Rutland
2016-11-03  4:56         ` Vaishali Thakkar
2016-11-03 18:05           ` Mark Rutland
2016-11-04 10:03             ` Vaishali Thakkar
2016-11-03  5:03     ` Al Viro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.