linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] uaccess: Disallow > INT_MAX copy sizes
@ 2019-08-25 23:18 Kees Cook
  2019-09-23 23:08 ` Kees Cook
  0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2019-08-25 23:18 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Alexander Viro, Dan Carpenter, linux-kernel

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

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 include/linux/thread_info.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 659a4400517b..e93e249a4e9b 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -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;
 }
-- 
2.17.1


-- 
Kees Cook

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

* Re: [PATCH] uaccess: Disallow > INT_MAX copy sizes
  2019-08-25 23:18 [PATCH] uaccess: Disallow > INT_MAX copy sizes Kees Cook
@ 2019-09-23 23:08 ` Kees Cook
  2019-09-24 23:29   ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2019-09-23 23:08 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Alexander Viro, Dan Carpenter, linux-kernel

On Sun, Aug 25, 2019 at 04:18:56PM -0700, Kees Cook wrote:
> 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
> 
> Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>

ping! Andrew, can you take this?

-Kees

> ---
>  include/linux/thread_info.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
> index 659a4400517b..e93e249a4e9b 100644
> --- a/include/linux/thread_info.h
> +++ b/include/linux/thread_info.h
> @@ -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;
>  }
> -- 
> 2.17.1
> 
> 
> -- 
> Kees Cook

-- 
Kees Cook

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

* Re: [PATCH] uaccess: Disallow > INT_MAX copy sizes
  2019-09-23 23:08 ` Kees Cook
@ 2019-09-24 23:29   ` Andrew Morton
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2019-09-24 23:29 UTC (permalink / raw)
  To: Kees Cook; +Cc: Alexander Viro, Dan Carpenter, linux-kernel

On Mon, 23 Sep 2019 16:08:54 -0700 Kees Cook <keescook@chromium.org> wrote:

> On Sun, Aug 25, 2019 at 04:18:56PM -0700, Kees Cook wrote:
> > 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
> > 
> > Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> 
> ping! Andrew, can you take this?

It's in my post 5.4-rc1 pile.

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

end of thread, other threads:[~2019-09-24 23:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-25 23:18 [PATCH] uaccess: Disallow > INT_MAX copy sizes Kees Cook
2019-09-23 23:08 ` Kees Cook
2019-09-24 23:29   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).