[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1639484357-76013-1-git-send-email-wangqing@vivo.com>
Date: Tue, 14 Dec 2021 04:19:17 -0800
From: Qing Wang <wangqing@...o.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Wang Qing <wangqing@...o.com>
Subject: [PATCH] fs: xattr: use vmemdup_user instead of kvmalloc and copy_from_user
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);
+ if (IS_ERR(kvalue)) {
+ error = PTR_ERR(kvalue);
goto out;
}
if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
--
2.7.4
Powered by blists - more mailing lists