Thread (26 messages) 26 messages, 4 authors, 2021-12-30

Re: [PATCH v10 2/5] fs: split off setxattr_copy and do_setxattr function from setxattr

From: Al Viro <viro@zeniv.linux.org.uk>
Date: 2021-12-30 01:15:14
Also in: linux-fsdevel

On Wed, Dec 29, 2021 at 12:29:59PM -0800, Stefan Roesch wrote:
+	if (ctx->size) {
+		if (ctx->size > XATTR_SIZE_MAX)
 			return -E2BIG;
-		kvalue = kvmalloc(size, GFP_KERNEL);
-		if (!kvalue)
+
+		ctx->kvalue = kvmalloc(ctx->size, GFP_KERNEL);
+		if (!ctx->kvalue)
 			return -ENOMEM;
-		if (copy_from_user(kvalue, value, size)) {
-			error = -EFAULT;
-			goto out;
+
+		if (copy_from_user(ctx->kvalue, ctx->value, ctx->size)) {
+			kvfree(ctx->kvalue);
+			return -EFAULT;
BTW, what's wrong with using vmemdup_user() here?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help