Summary: This splits off vfs_getxattr call from the getxattr function. This will allow io_uring to call it from its io worker. Signed-off-by: Stefan Roesch <shr@xxxxxx> --- fs/internal.h | 6 ++++++ fs/xattr.c | 37 +++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index c5c82bfb5ecf..9805415b199c 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -208,6 +208,12 @@ struct xattr_ctx { int flags; }; +ssize_t do_getxattr(struct user_namespace *mnt_userns, + struct dentry *d, + const char *kname, + void __user *value, + size_t size); + void *setxattr_setup(struct user_namespace *mnt_userns, const char __user *name, struct xattr_ctx *data); diff --git a/fs/xattr.c b/fs/xattr.c index 13963b914ac5..9e1dba601a03 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -666,19 +666,12 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, /* * Extended attribute GET operations */ -static ssize_t -getxattr(struct user_namespace *mnt_userns, struct dentry *d, - const char __user *name, void __user *value, size_t size) +ssize_t +do_getxattr(struct user_namespace *mnt_userns, struct dentry *d, + const char *name, void __user *value, size_t size) { - ssize_t error; void *kvalue = NULL; - char kname[XATTR_NAME_MAX + 1]; - - error = strncpy_from_user(kname, name, sizeof(kname)); - if (error == 0 || error == sizeof(kname)) - error = -ERANGE; - if (error < 0) - return error; + size_t error; if (size) { if (size > XATTR_SIZE_MAX) @@ -688,10 +681,10 @@ getxattr(struct user_namespace *mnt_userns, struct dentry *d, return -ENOMEM; } - error = vfs_getxattr(mnt_userns, d, kname, kvalue, size); + error = vfs_getxattr(mnt_userns, d, name, kvalue, size); if (error > 0) { - if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) || - (strcmp(kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0)) + if ((strcmp(name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) || + (strcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0)) posix_acl_fix_xattr_to_user(mnt_userns, kvalue, error); if (size && copy_to_user(value, kvalue, error)) error = -EFAULT; @@ -706,6 +699,22 @@ getxattr(struct user_namespace *mnt_userns, struct dentry *d, return error; } +static ssize_t +getxattr(struct user_namespace *mnt_userns, struct dentry *d, + const char __user *name, void __user *value, size_t size) +{ + ssize_t error; + char kname[XATTR_NAME_MAX + 1]; + + error = strncpy_from_user(kname, name, sizeof(kname)); + if (error == 0 || error == sizeof(kname)) + error = -ERANGE; + if (error < 0) + return error; + + return do_getxattr(mnt_userns, d, kname, value, size); +} + static ssize_t path_getxattr(const char __user *pathname, const char __user *name, void __user *value, size_t size, unsigned int lookup_flags) -- 2.30.2