lkml.org 
[lkml]   [2020]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] exec: remove comparision of variable i_size of type loff_t against SIZE_MAX
On Thu, Feb 27, 2020 at 03:31:33PM -0800, Scott Branden wrote:
> Remove comparision of (i_size > SIZE_MAX).
> i_size is of type loff_t and can not be great than SIZE_MAX (~(size_t)0).
>
> Signed-off-by: Scott Branden <scott.branden@broadcom.com>
> ---
> fs/exec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/exec.c b/fs/exec.c
> index db17be51b112..16c229752f74 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -919,7 +919,7 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size,
> ret = -EINVAL;
> goto out;
> }
> - if (i_size > SIZE_MAX || (max_size > 0 && i_size > max_size)) {
> + if (max_size > 0 && i_size > max_size) {
> ret = -EFBIG;
> goto out;
> }

Nope, loff_t is 64-bit while size_t can be 32-bit. And this check is
intentional, see https://git.kernel.org/torvalds/c/691115c3513ec83e

- Eric

\
 
 \ /
  Last update: 2020-02-28 00:41    [W:0.041 / U:1.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site