uaccess: Disallow > INT_MAX copy sizes
PATCH 1/1 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
--- include/linux/thread_info.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/thread_info.h +2 -0
@@ -147,6 +147,8 @@ check_copy_size(const void *addr, size_t bytes, bool is_source)__bad_copy_to ();return false; } +if (WARN_ON_ONCE (bytes >INT_MAX )) +return false;check_object_size (addr, bytes, is_source);return true; }
Signature · 5 lines
2.17.1 -- Kees Cook
Quoted 7 lines · Kees Cook
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_64defconfig text and 1980 bytes to the data section:
Quoted 8 lines
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
Suggested-by Dan Carpenter <[email protected]>Signed-off-by Kees Cook <[email protected]>
ping! Andrew, can you take this?
-Kees
Quoted 23 lines
--- include/linux/thread_info.h | 2 ++ 1 file changed, 2 insertions(+)include/linux/thread_info.h +2
-0@@ -147,6 +147,8 @@ check_copy_size(const void *addr, size_t bytes, bool is_source)__bad_copy_to ();return false; } +if (WARN_ON_ONCE (bytes >INT_MAX )) +return false;check_object_size (addr, bytes, is_source);return true; }Signature · 5 lines
2.17.1 -- Kees Cook
Signature · 1 line
Kees Cook
Quoted 12 lines · On Mon, 23 Sep 2019 16:08:54 -0700 Kees Cook <[email protected]> wrote:
Quoted 11 lines · Kees Cook
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_64defconfig 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
Quoted 6 lines
Quoted 4 lines
[1] https://marc.info/?l=linux-s390&m=156631939010493&w=2
Suggested-by Dan Carpenter <[email protected]>Signed-off-by Kees Cook <[email protected]>ping! Andrew, can you take this?
It's in my post 5.4-rc1 pile.