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]
Date:   Tue, 14 Dec 2021 14:20:52 +0100
From:   Christian Brauner <christian.brauner@...ntu.com>
To:     Qing Wang <wangqing@...o.com>
Cc:     Alexander Viro <viro@...iv.linux.org.uk>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs: xattr: use vmemdup_user instead of kvmalloc and
 copy_from_user

On Tue, Dec 14, 2021 at 04:19:17AM -0800, Qing Wang wrote:
> From: Wang Qing <wangqing@...o.com>
> 
> fix memdup_user.cocci warning:
> fs/xattr.c:563:11-19: WARNING opportunity for vmemdup_user
> 
> Signed-off-by: Wang Qing <wangqing@...o.com>
> ---
>  fs/xattr.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/xattr.c b/fs/xattr.c
> index 5c8c517..71c301d
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -560,11 +560,9 @@ setxattr(struct user_namespace *mnt_userns, struct dentry *d,
>  	if (size) {
>  		if (size > XATTR_SIZE_MAX)
>  			return -E2BIG;
> -		kvalue = kvmalloc(size, GFP_KERNEL);
> -		if (!kvalue)
> -			return -ENOMEM;
> -		if (copy_from_user(kvalue, value, size)) {
> -			error = -EFAULT;
> +		kvalue = vmemdup_user(value, size);

This changes the allocation type from GFP_KERNEL to GFP_USER which is
probably not what we need at least it's not clear to me that it is.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ