From: Christian Brauner <[email protected]>
To: Stefan Roesch <[email protected]>
Cc: [email protected], [email protected],
[email protected], [email protected]
Subject: Re: [PATCH v6 2/5] fs: split off setxattr_setup function from setxattr
Date: Thu, 23 Dec 2021 11:24:40 +0100 [thread overview]
Message-ID: <20211223102440.4bd5t25tojkhpbuy@wittgenstein> (raw)
In-Reply-To: <[email protected]>
On Wed, Dec 22, 2021 at 01:01:24PM -0800, Stefan Roesch wrote:
> This splits of the setup part of the function
> setxattr in its own dedicated function called
> setxattr_setup.
>
> This makes it possible to call this function
> from io_uring in the pre-processing of an
> xattr request.
>
> Signed-off-by: Stefan Roesch <[email protected]>
> ---
I like the introduction of struct xattr_ctx.
But I would prefer if we called this setxattr_prepare() to mirror
setattr_prepare() and change the signature to:
int setxattr_setup(struct user_namespace *mnt_userns,
const char __user *name,
struct xattr_ctx *ctx,
void **xattr_val);
Since NULL is a success condition I think it makes more sense to have an
error returned and the value be a return argument. So sm like
(uncompiled and untested):
int setxattr_prepare(struct user_namespace *mnt_userns, const char __user *name,
struct xattr_ctx *ctx, void **xattr_val)
{
void *kvalue = NULL;
int error;
if (ctx->flags & ~(XATTR_CREATE | XATTR_REPLACE))
return -EINVAL;
error = strncpy_from_user(ctx->kname, name, ctx->kname_sz);
if (error == 0 || error == ctx->kname_sz)
return -ERANGE;
if (error < 0)
return error;
if (ctx->size) {
if (ctx->size > XATTR_SIZE_MAX)
return -E2BIG;
kvalue = kvmalloc(ctx->size, GFP_KERNEL);
if (!kvalue)
return -ENOMEM;
if (copy_from_user(kvalue, ctx->value, ctx->size)) {
kvfree(kvalue);
return -EFAULT;
}
if ((strcmp(ctx->kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
(strcmp(ctx->kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0))
posix_acl_fix_xattr_from_user(mnt_userns, kvalue, ctx->size);
}
*xattr_val = kvalue;
return 0;
}
next prev parent reply other threads:[~2021-12-23 10:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 21:01 [PATCH v6 0/5] io_uring: add xattr support Stefan Roesch
2021-12-22 21:01 ` [PATCH v6 1/5] fs: split off do_user_path_at_empty from user_path_at_empty() Stefan Roesch
2021-12-23 10:48 ` Christian Brauner
2021-12-22 21:01 ` [PATCH v6 2/5] fs: split off setxattr_setup function from setxattr Stefan Roesch
2021-12-23 10:24 ` Christian Brauner [this message]
2021-12-22 21:01 ` [PATCH v6 3/5] fs: split off do_getxattr from getxattr Stefan Roesch
2021-12-23 10:57 ` Christian Brauner
2021-12-22 21:01 ` [PATCH v6 4/5] io_uring: add fsetxattr and setxattr support Stefan Roesch
2021-12-23 14:52 ` Christian Brauner
2021-12-23 20:00 ` Stefan Roesch
2021-12-22 21:01 ` [PATCH v6 5/5] io_uring: add fgetxattr and getxattr support Stefan Roesch
2021-12-23 11:04 ` [PATCH v6 0/5] io_uring: add xattr support Christian Brauner
2021-12-23 14:39 ` Jens Axboe
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=20211223102440.4bd5t25tojkhpbuy@wittgenstein \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox