* [PATCH] fs: move the posix_acl_fix_xattr_{to_from}_user out of xattr code
@ 2020-02-21 17:37 Christoph Hellwig
2020-03-03 13:42 ` Andreas Gruenbacher
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2020-02-21 17:37 UTC (permalink / raw)
To: agruenba, viro; +Cc: linux-fsdevel
There is no excuse to ever perform actions related to a specific handler
directly from the generic xattr code as we have handler that understand
the specific data in given attrs. As a nice sideeffect this removes
tons of pointless boilerplate code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/posix_acl.c | 62 ++-------------------------------
fs/xattr.c | 8 +----
include/linux/posix_acl_xattr.h | 12 -------
3 files changed, 3 insertions(+), 79 deletions(-)
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 249672bf54fe..09f1b7d186f0 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -663,64 +663,6 @@ int posix_acl_update_mode(struct inode *inode, umode_t *mode_p,
}
EXPORT_SYMBOL(posix_acl_update_mode);
-/*
- * Fix up the uids and gids in posix acl extended attributes in place.
- */
-static void posix_acl_fix_xattr_userns(
- struct user_namespace *to, struct user_namespace *from,
- void *value, size_t size)
-{
- struct posix_acl_xattr_header *header = value;
- struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
- int count;
- kuid_t uid;
- kgid_t gid;
-
- if (!value)
- return;
- if (size < sizeof(struct posix_acl_xattr_header))
- return;
- if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
- return;
-
- count = posix_acl_xattr_count(size);
- if (count < 0)
- return;
- if (count == 0)
- return;
-
- for (end = entry + count; entry != end; entry++) {
- switch(le16_to_cpu(entry->e_tag)) {
- case ACL_USER:
- uid = make_kuid(from, le32_to_cpu(entry->e_id));
- entry->e_id = cpu_to_le32(from_kuid(to, uid));
- break;
- case ACL_GROUP:
- gid = make_kgid(from, le32_to_cpu(entry->e_id));
- entry->e_id = cpu_to_le32(from_kgid(to, gid));
- break;
- default:
- break;
- }
- }
-}
-
-void posix_acl_fix_xattr_from_user(void *value, size_t size)
-{
- struct user_namespace *user_ns = current_user_ns();
- if (user_ns == &init_user_ns)
- return;
- posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size);
-}
-
-void posix_acl_fix_xattr_to_user(void *value, size_t size)
-{
- struct user_namespace *user_ns = current_user_ns();
- if (user_ns == &init_user_ns)
- return;
- posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size);
-}
-
/*
* Convert from extended attribute to in-memory representation.
*/
@@ -851,7 +793,7 @@ posix_acl_xattr_get(const struct xattr_handler *handler,
if (acl == NULL)
return -ENODATA;
- error = posix_acl_to_xattr(&init_user_ns, acl, value, size);
+ error = posix_acl_to_xattr(current_user_ns(), acl, value, size);
posix_acl_release(acl);
return error;
@@ -889,7 +831,7 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
int ret;
if (value) {
- acl = posix_acl_from_xattr(&init_user_ns, value, size);
+ acl = posix_acl_from_xattr(current_user_ns(), value, size);
if (IS_ERR(acl))
return PTR_ERR(acl);
}
diff --git a/fs/xattr.c b/fs/xattr.c
index 90dd78f0eb27..c31e9a9ea172 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -437,10 +437,7 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
error = -EFAULT;
goto out;
}
- if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
- (strcmp(kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0))
- posix_acl_fix_xattr_from_user(kvalue, size);
- else if (strcmp(kname, XATTR_NAME_CAPS) == 0) {
+ if (strcmp(kname, XATTR_NAME_CAPS) == 0) {
error = cap_convert_nscap(d, &kvalue, size);
if (error < 0)
goto out;
@@ -537,9 +534,6 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
error = vfs_getxattr(d, kname, kvalue, size);
if (error > 0) {
- if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
- (strcmp(kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0))
- posix_acl_fix_xattr_to_user(kvalue, error);
if (size && copy_to_user(value, kvalue, error))
error = -EFAULT;
} else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h
index 2387709991b5..8f5e70a1bd05 100644
--- a/include/linux/posix_acl_xattr.h
+++ b/include/linux/posix_acl_xattr.h
@@ -32,18 +32,6 @@ posix_acl_xattr_count(size_t size)
return size / sizeof(struct posix_acl_xattr_entry);
}
-#ifdef CONFIG_FS_POSIX_ACL
-void posix_acl_fix_xattr_from_user(void *value, size_t size);
-void posix_acl_fix_xattr_to_user(void *value, size_t size);
-#else
-static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
-{
-}
-static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
-{
-}
-#endif
-
struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
const void *value, size_t size);
int posix_acl_to_xattr(struct user_namespace *user_ns,
--
2.24.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] fs: move the posix_acl_fix_xattr_{to_from}_user out of xattr code
2020-02-21 17:37 [PATCH] fs: move the posix_acl_fix_xattr_{to_from}_user out of xattr code Christoph Hellwig
@ 2020-03-03 13:42 ` Andreas Gruenbacher
2020-03-17 14:57 ` Christoph Hellwig
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Gruenbacher @ 2020-03-03 13:42 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: Christoph Hellwig, Alexander Viro, linux-fsdevel
Miklos,
On Fri, Feb 21, 2020 at 7:01 PM Christoph Hellwig <hch@lst.de> wrote:
> There is no excuse to ever perform actions related to a specific handler
> directly from the generic xattr code as we have handler that understand
> the specific data in given attrs. As a nice sideeffect this removes
> tons of pointless boilerplate code.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
can you please review this change from an overlayfs point of view?
Thanks,
Andreas
> ---
> fs/posix_acl.c | 62 ++-------------------------------
> fs/xattr.c | 8 +----
> include/linux/posix_acl_xattr.h | 12 -------
> 3 files changed, 3 insertions(+), 79 deletions(-)
>
> diff --git a/fs/posix_acl.c b/fs/posix_acl.c
> index 249672bf54fe..09f1b7d186f0 100644
> --- a/fs/posix_acl.c
> +++ b/fs/posix_acl.c
> @@ -663,64 +663,6 @@ int posix_acl_update_mode(struct inode *inode, umode_t *mode_p,
> }
> EXPORT_SYMBOL(posix_acl_update_mode);
>
> -/*
> - * Fix up the uids and gids in posix acl extended attributes in place.
> - */
> -static void posix_acl_fix_xattr_userns(
> - struct user_namespace *to, struct user_namespace *from,
> - void *value, size_t size)
> -{
> - struct posix_acl_xattr_header *header = value;
> - struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
> - int count;
> - kuid_t uid;
> - kgid_t gid;
> -
> - if (!value)
> - return;
> - if (size < sizeof(struct posix_acl_xattr_header))
> - return;
> - if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
> - return;
> -
> - count = posix_acl_xattr_count(size);
> - if (count < 0)
> - return;
> - if (count == 0)
> - return;
> -
> - for (end = entry + count; entry != end; entry++) {
> - switch(le16_to_cpu(entry->e_tag)) {
> - case ACL_USER:
> - uid = make_kuid(from, le32_to_cpu(entry->e_id));
> - entry->e_id = cpu_to_le32(from_kuid(to, uid));
> - break;
> - case ACL_GROUP:
> - gid = make_kgid(from, le32_to_cpu(entry->e_id));
> - entry->e_id = cpu_to_le32(from_kgid(to, gid));
> - break;
> - default:
> - break;
> - }
> - }
> -}
> -
> -void posix_acl_fix_xattr_from_user(void *value, size_t size)
> -{
> - struct user_namespace *user_ns = current_user_ns();
> - if (user_ns == &init_user_ns)
> - return;
> - posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size);
> -}
> -
> -void posix_acl_fix_xattr_to_user(void *value, size_t size)
> -{
> - struct user_namespace *user_ns = current_user_ns();
> - if (user_ns == &init_user_ns)
> - return;
> - posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size);
> -}
> -
> /*
> * Convert from extended attribute to in-memory representation.
> */
> @@ -851,7 +793,7 @@ posix_acl_xattr_get(const struct xattr_handler *handler,
> if (acl == NULL)
> return -ENODATA;
>
> - error = posix_acl_to_xattr(&init_user_ns, acl, value, size);
> + error = posix_acl_to_xattr(current_user_ns(), acl, value, size);
> posix_acl_release(acl);
>
> return error;
> @@ -889,7 +831,7 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
> int ret;
>
> if (value) {
> - acl = posix_acl_from_xattr(&init_user_ns, value, size);
> + acl = posix_acl_from_xattr(current_user_ns(), value, size);
> if (IS_ERR(acl))
> return PTR_ERR(acl);
> }
> diff --git a/fs/xattr.c b/fs/xattr.c
> index 90dd78f0eb27..c31e9a9ea172 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -437,10 +437,7 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
> error = -EFAULT;
> goto out;
> }
> - if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
> - (strcmp(kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0))
> - posix_acl_fix_xattr_from_user(kvalue, size);
> - else if (strcmp(kname, XATTR_NAME_CAPS) == 0) {
> + if (strcmp(kname, XATTR_NAME_CAPS) == 0) {
> error = cap_convert_nscap(d, &kvalue, size);
> if (error < 0)
> goto out;
> @@ -537,9 +534,6 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
>
> error = vfs_getxattr(d, kname, kvalue, size);
> if (error > 0) {
> - if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
> - (strcmp(kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0))
> - posix_acl_fix_xattr_to_user(kvalue, error);
> if (size && copy_to_user(value, kvalue, error))
> error = -EFAULT;
> } else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
> diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h
> index 2387709991b5..8f5e70a1bd05 100644
> --- a/include/linux/posix_acl_xattr.h
> +++ b/include/linux/posix_acl_xattr.h
> @@ -32,18 +32,6 @@ posix_acl_xattr_count(size_t size)
> return size / sizeof(struct posix_acl_xattr_entry);
> }
>
> -#ifdef CONFIG_FS_POSIX_ACL
> -void posix_acl_fix_xattr_from_user(void *value, size_t size);
> -void posix_acl_fix_xattr_to_user(void *value, size_t size);
> -#else
> -static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
> -{
> -}
> -static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
> -{
> -}
> -#endif
> -
> struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
> const void *value, size_t size);
> int posix_acl_to_xattr(struct user_namespace *user_ns,
> --
> 2.24.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fs: move the posix_acl_fix_xattr_{to_from}_user out of xattr code
2020-03-03 13:42 ` Andreas Gruenbacher
@ 2020-03-17 14:57 ` Christoph Hellwig
2020-03-19 13:40 ` Miklos Szeredi
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2020-03-17 14:57 UTC (permalink / raw)
To: Andreas Gruenbacher
Cc: Miklos Szeredi, Christoph Hellwig, Alexander Viro, linux-fsdevel
On Tue, Mar 03, 2020 at 02:42:50PM +0100, Andreas Gruenbacher wrote:
> Miklos,
>
> On Fri, Feb 21, 2020 at 7:01 PM Christoph Hellwig <hch@lst.de> wrote:
> > There is no excuse to ever perform actions related to a specific handler
> > directly from the generic xattr code as we have handler that understand
> > the specific data in given attrs. As a nice sideeffect this removes
> > tons of pointless boilerplate code.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> can you please review this change from an overlayfs point of view?
ping?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fs: move the posix_acl_fix_xattr_{to_from}_user out of xattr code
2020-03-17 14:57 ` Christoph Hellwig
@ 2020-03-19 13:40 ` Miklos Szeredi
0 siblings, 0 replies; 6+ messages in thread
From: Miklos Szeredi @ 2020-03-19 13:40 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Andreas Gruenbacher, Alexander Viro, linux-fsdevel
On Tue, Mar 17, 2020 at 3:57 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Tue, Mar 03, 2020 at 02:42:50PM +0100, Andreas Gruenbacher wrote:
> > Miklos,
> >
> > On Fri, Feb 21, 2020 at 7:01 PM Christoph Hellwig <hch@lst.de> wrote:
> > > There is no excuse to ever perform actions related to a specific handler
> > > directly from the generic xattr code as we have handler that understand
> > > the specific data in given attrs. As a nice sideeffect this removes
> > > tons of pointless boilerplate code.
> > >
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> >
> > can you please review this change from an overlayfs point of view?
>
> ping?
To me it looks like these need fixup:
fs/overlayfs/dir.c:
- err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
+ err = posix_acl_to_xattr(current_user_ns(), acl, buffer, size);
fs/overlayfs/super.c:
- acl = posix_acl_from_xattr(&init_user_ns, value, size);
+ acl = posix_acl_from_xattr(current_user_ns(), value, size);
Thanks,
Miklos
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fs: move the posix_acl_fix_xattr_{to_from}_user out of xattr code
2020-03-24 7:50 Christoph Hellwig
@ 2020-03-24 9:14 ` Miklos Szeredi
0 siblings, 0 replies; 6+ messages in thread
From: Miklos Szeredi @ 2020-03-24 9:14 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Al Viro, Andreas Gruenbacher, linux-fsdevel
On Tue, Mar 24, 2020 at 8:50 AM Christoph Hellwig <hch@lst.de> wrote:
>
> There is no excuse to ever perform actions related to a specific handler
> directly from the generic xattr code as we have handler that understand
> the specific data in given attrs. As a nice sideeffect this removes
> tons of pointless boilerplate code.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>
> Changes since v1:
> - fix up file systems that have their own ACL xattr handlers
>
> fs/9p/acl.c | 4 +--
> fs/overlayfs/dir.c | 2 +-
> fs/overlayfs/super.c | 2 +-
> fs/posix_acl.c | 62 ++-------------------------------
> fs/xattr.c | 8 +----
> include/linux/posix_acl_xattr.h | 12 -------
> 6 files changed, 7 insertions(+), 83 deletions(-)
>
> diff --git a/fs/9p/acl.c b/fs/9p/acl.c
> index 6261719f6f2a..f3455ba2a84d 100644
> --- a/fs/9p/acl.c
> +++ b/fs/9p/acl.c
> @@ -232,7 +232,7 @@ static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
> return PTR_ERR(acl);
> if (acl == NULL)
> return -ENODATA;
> - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
> + error = posix_acl_to_xattr(current_user_ns(), acl, buffer, size);
Okay, but the uncached cache is still broken. It needs the xattr to
be converted to acl (posix_acl_to_xattr(&init_user_ns, ...)) then back
to xattr here.
> posix_acl_release(acl);
>
> return error;
> @@ -262,7 +262,7 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
> return -EPERM;
> if (value) {
> /* update the cached acl value */
> - acl = posix_acl_from_xattr(&init_user_ns, value, size);
> + acl = posix_acl_from_xattr(current_user_ns(), value, size);
Same in this function.
Thanks,
Miklos
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] fs: move the posix_acl_fix_xattr_{to_from}_user out of xattr code
@ 2020-03-24 7:50 Christoph Hellwig
2020-03-24 9:14 ` Miklos Szeredi
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2020-03-24 7:50 UTC (permalink / raw)
To: viro, agruenba; +Cc: miklos, linux-fsdevel
There is no excuse to ever perform actions related to a specific handler
directly from the generic xattr code as we have handler that understand
the specific data in given attrs. As a nice sideeffect this removes
tons of pointless boilerplate code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
Changes since v1:
- fix up file systems that have their own ACL xattr handlers
fs/9p/acl.c | 4 +--
fs/overlayfs/dir.c | 2 +-
fs/overlayfs/super.c | 2 +-
fs/posix_acl.c | 62 ++-------------------------------
fs/xattr.c | 8 +----
include/linux/posix_acl_xattr.h | 12 -------
6 files changed, 7 insertions(+), 83 deletions(-)
diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index 6261719f6f2a..f3455ba2a84d 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -232,7 +232,7 @@ static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
return PTR_ERR(acl);
if (acl == NULL)
return -ENODATA;
- error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
+ error = posix_acl_to_xattr(current_user_ns(), acl, buffer, size);
posix_acl_release(acl);
return error;
@@ -262,7 +262,7 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
return -EPERM;
if (value) {
/* update the cached acl value */
- acl = posix_acl_from_xattr(&init_user_ns, value, size);
+ acl = posix_acl_from_xattr(current_user_ns(), value, size);
if (IS_ERR(acl))
return PTR_ERR(acl);
else if (acl) {
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 8e57d5372b8f..0b07e99475fd 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -416,7 +416,7 @@ static int ovl_set_upper_acl(struct dentry *upperdentry, const char *name,
if (!buffer)
return -ENOMEM;
- err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
+ err = posix_acl_to_xattr(current_user_ns(), acl, buffer, size);
if (err < 0)
goto out_free;
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 319fe0d355b0..4c62636f295b 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -874,7 +874,7 @@ ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
/* Check that everything is OK before copy-up */
if (value) {
- acl = posix_acl_from_xattr(&init_user_ns, value, size);
+ acl = posix_acl_from_xattr(current_user_ns(), value, size);
if (IS_ERR(acl))
return PTR_ERR(acl);
}
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 249672bf54fe..09f1b7d186f0 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -663,64 +663,6 @@ int posix_acl_update_mode(struct inode *inode, umode_t *mode_p,
}
EXPORT_SYMBOL(posix_acl_update_mode);
-/*
- * Fix up the uids and gids in posix acl extended attributes in place.
- */
-static void posix_acl_fix_xattr_userns(
- struct user_namespace *to, struct user_namespace *from,
- void *value, size_t size)
-{
- struct posix_acl_xattr_header *header = value;
- struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
- int count;
- kuid_t uid;
- kgid_t gid;
-
- if (!value)
- return;
- if (size < sizeof(struct posix_acl_xattr_header))
- return;
- if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
- return;
-
- count = posix_acl_xattr_count(size);
- if (count < 0)
- return;
- if (count == 0)
- return;
-
- for (end = entry + count; entry != end; entry++) {
- switch(le16_to_cpu(entry->e_tag)) {
- case ACL_USER:
- uid = make_kuid(from, le32_to_cpu(entry->e_id));
- entry->e_id = cpu_to_le32(from_kuid(to, uid));
- break;
- case ACL_GROUP:
- gid = make_kgid(from, le32_to_cpu(entry->e_id));
- entry->e_id = cpu_to_le32(from_kgid(to, gid));
- break;
- default:
- break;
- }
- }
-}
-
-void posix_acl_fix_xattr_from_user(void *value, size_t size)
-{
- struct user_namespace *user_ns = current_user_ns();
- if (user_ns == &init_user_ns)
- return;
- posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size);
-}
-
-void posix_acl_fix_xattr_to_user(void *value, size_t size)
-{
- struct user_namespace *user_ns = current_user_ns();
- if (user_ns == &init_user_ns)
- return;
- posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size);
-}
-
/*
* Convert from extended attribute to in-memory representation.
*/
@@ -851,7 +793,7 @@ posix_acl_xattr_get(const struct xattr_handler *handler,
if (acl == NULL)
return -ENODATA;
- error = posix_acl_to_xattr(&init_user_ns, acl, value, size);
+ error = posix_acl_to_xattr(current_user_ns(), acl, value, size);
posix_acl_release(acl);
return error;
@@ -889,7 +831,7 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
int ret;
if (value) {
- acl = posix_acl_from_xattr(&init_user_ns, value, size);
+ acl = posix_acl_from_xattr(current_user_ns(), value, size);
if (IS_ERR(acl))
return PTR_ERR(acl);
}
diff --git a/fs/xattr.c b/fs/xattr.c
index 90dd78f0eb27..c31e9a9ea172 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -437,10 +437,7 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
error = -EFAULT;
goto out;
}
- if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
- (strcmp(kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0))
- posix_acl_fix_xattr_from_user(kvalue, size);
- else if (strcmp(kname, XATTR_NAME_CAPS) == 0) {
+ if (strcmp(kname, XATTR_NAME_CAPS) == 0) {
error = cap_convert_nscap(d, &kvalue, size);
if (error < 0)
goto out;
@@ -537,9 +534,6 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
error = vfs_getxattr(d, kname, kvalue, size);
if (error > 0) {
- if ((strcmp(kname, XATTR_NAME_POSIX_ACL_ACCESS) == 0) ||
- (strcmp(kname, XATTR_NAME_POSIX_ACL_DEFAULT) == 0))
- posix_acl_fix_xattr_to_user(kvalue, error);
if (size && copy_to_user(value, kvalue, error))
error = -EFAULT;
} else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h
index 2387709991b5..8f5e70a1bd05 100644
--- a/include/linux/posix_acl_xattr.h
+++ b/include/linux/posix_acl_xattr.h
@@ -32,18 +32,6 @@ posix_acl_xattr_count(size_t size)
return size / sizeof(struct posix_acl_xattr_entry);
}
-#ifdef CONFIG_FS_POSIX_ACL
-void posix_acl_fix_xattr_from_user(void *value, size_t size);
-void posix_acl_fix_xattr_to_user(void *value, size_t size);
-#else
-static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
-{
-}
-static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
-{
-}
-#endif
-
struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
const void *value, size_t size);
int posix_acl_to_xattr(struct user_namespace *user_ns,
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-03-24 9:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 17:37 [PATCH] fs: move the posix_acl_fix_xattr_{to_from}_user out of xattr code Christoph Hellwig
2020-03-03 13:42 ` Andreas Gruenbacher
2020-03-17 14:57 ` Christoph Hellwig
2020-03-19 13:40 ` Miklos Szeredi
2020-03-24 7:50 Christoph Hellwig
2020-03-24 9:14 ` Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).