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 <shr@xxxxxx> > --- 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; }