Skip to content

Commit 6d13de1

Browse files
keestorvalds
authored andcommitted
uaccess: disallow > INT_MAX copy sizes
As we've done with VFS, string operations, etc, reject usercopy sizes larger than INT_MAX, which would be nice to have for catching bugs related to size calculation overflows[1]. This adds 10 bytes to x86_64 defconfig text and 1980 bytes to the data section: text data bss dec hex filename 19691167 5134320 1646664 26472151 193eed7 vmlinux.before 19691177 5136300 1646664 26474141 193f69d vmlinux.after [1] https://marc.info/?l=linux-s390&m=156631939010493&w=2 Link: http://lkml.kernel.org/r/201908251612.F9902D7A@keescook Signed-off-by: Kees Cook <[email protected]> Suggested-by: Dan Carpenter <[email protected]> Cc: Alexander Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5bf8bec commit 6d13de1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/thread_info.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ check_copy_size(const void *addr, size_t bytes, bool is_source)
147147
__bad_copy_to();
148148
return false;
149149
}
150+
if (WARN_ON_ONCE(bytes > INT_MAX))
151+
return false;
150152
check_object_size(addr, bytes, is_source);
151153
return true;
152154
}

0 commit comments

Comments
 (0)