All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Brauner <christian.brauner@ubuntu.com>
To: Qing Wang <wangqing@vivo.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: xattr: use vmemdup_user instead of kvmalloc and copy_from_user
Date: Tue, 14 Dec 2021 14:20:52 +0100	[thread overview]
Message-ID: <20211214132052.loq4gp2wlj4s2nf7@wittgenstein> (raw)
In-Reply-To: <1639484357-76013-1-git-send-email-wangqing@vivo.com>

On Tue, Dec 14, 2021 at 04:19:17AM -0800, Qing Wang wrote:
> From: Wang Qing <wangqing@vivo.com>
> 
> fix memdup_user.cocci warning:
> fs/xattr.c:563:11-19: WARNING opportunity for vmemdup_user
> 
> Signed-off-by: Wang Qing <wangqing@vivo.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.

  reply	other threads:[~2021-12-14 13:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 12:19 [PATCH] fs: xattr: use vmemdup_user instead of kvmalloc and copy_from_user Qing Wang
2021-12-14 13:20 ` Christian Brauner [this message]
2021-12-16 12:23 ` [fs] 7db4f49247: WARNING:at_mm/slub.c:#kfree kernel test robot
2021-12-16 12:23   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211214132052.loq4gp2wlj4s2nf7@wittgenstein \
    --to=christian.brauner@ubuntu.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wangqing@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.