From: Yang Li <yang.lee@linux.alibaba.com>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Yang Li <yang.lee@linux.alibaba.com>
Subject: [PATCH] xattr: switch to vmemdup_user()
Date: Tue, 2 Mar 2021 14:32:21 +0800 [thread overview]
Message-ID: <1614666741-16796-1-git-send-email-yang.lee@linux.alibaba.com> (raw)
Replace opencoded alloc and copy with vmemdup_user()
fixed the following coccicheck:
./fs/xattr.c:561:11-19: WARNING opportunity for vmemdup_user
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
fs/xattr.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/xattr.c b/fs/xattr.c
index b3444e0..b947ad2 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -558,11 +558,10 @@ int __vfs_setxattr_noperm(struct user_namespace *mnt_userns,
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);
+
+ if (IS_ERR(kvalue)) {
+ r = PTR_ERR(kvalue);
goto out;
}
if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
--
1.8.3.1
next reply other threads:[~2021-03-02 8:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 6:32 Yang Li [this message]
2021-03-04 12:17 ` [PATCH] xattr: switch to vmemdup_user() Matthew Wilcox
2021-09-29 21:20 ` kernel test robot
2021-09-29 21:20 ` kernel test robot
2021-09-29 22:38 ` kernel test robot
2021-09-29 22:38 ` 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=1614666741-16796-1-git-send-email-yang.lee@linux.alibaba.com \
--to=yang.lee@linux.alibaba.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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.