lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6cb8667a-1b0a-bb24-cf8d-880431acf815@huawei.com>
Date:   Mon, 19 Sep 2022 16:28:33 +0800
From:   Yicong Yang <yangyicong@...wei.com>
To:     Eliav Farber <farbere@...zon.com>
CC:     <andriy.shevchenko@...el.com>, <hhhawa@...zon.com>,
        <jonnyc@...zon.com>, <linux-fsdevel@...r.kernel.org>,
        <viro@...iv.linux.org.uk>, <akpm@...ux-foundation.org>,
        <yangyicong@...ilicon.com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] libfs: fix negative value support in simple_attr_write()

On 2022/9/18 21:50, Eliav Farber wrote:
> After commit 488dac0c9237 ("libfs: fix error cast of negative value in
> simple_attr_write()"), a user trying set a negative value will get a
> '-EINVAL' error, because simple_attr_write() was modified to use
> kstrtoull() which can handle only unsigned values, instead of
> simple_strtoll().
> 
> This breaks all the places using DEFINE_DEBUGFS_ATTRIBUTE() with format
> of a signed integer.
> 
> The u64 value which attr->set() receives is not an issue for negative
> numbers.
> The %lld and %llu in any case are for 64-bit value. Representing it as
> unsigned simplifies the generic code, but it doesn't mean we can't keep
> their signed value if we know that.
> 
> This change basically reverts the mentioned commit, but uses kstrtoll()
> instead of simple_strtoll() which is obsolete.
> 
> Fixes: 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()")

Thanks for fixing this.

Reviewed-by: Yicong Yang <yangyicong@...ilicon.com>

Sorry for my lack of knowledge for the -1 usage.

Thanks.

> Signed-off-by: Eliav Farber <farbere@...zon.com>
> ---
>  fs/libfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/libfs.c b/fs/libfs.c
> index 31b0ddf01c31..3bccd75815db 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -1016,7 +1016,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
>  		goto out;
>  
>  	attr->set_buf[size] = '\0';
> -	ret = kstrtoull(attr->set_buf, 0, &val);
> +	ret = kstrtoll(attr->set_buf, 0, &val);
>  	if (ret)
>  		goto out;
>  	ret = attr->set(attr->data, val);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ