Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1359400
| From | Andreas Gruenbacher <agruenba@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v20 11/23] posix_acl: Improve xattr fixup code |
| Date | 2016-03-16 23:30 +0100 |
| Message-ID | <rds70-6Wr-5@gated-at.bofh.it> (permalink) |
| References | <rdrXj-6Sv-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Both XATTR_NAME_POSIX_ACL_ACCESS and XATTR_NAME_POSIX_ACL_DEFAULT have
the same XATTR_SYSTEM_PREFIX prefix; don't check for the same prefix
repeatedly.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/xattr.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/fs/xattr.c b/fs/xattr.c
index 4861322..c364696 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -295,6 +295,16 @@ out:
}
EXPORT_SYMBOL_GPL(vfs_removexattr);
+static void
+fix_xattr_from_user(const char *kname, void *kvalue, size_t size)
+{
+ if (strncmp(kname, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
+ return;
+ kname += XATTR_SYSTEM_PREFIX_LEN;
+ if (!strcmp(kname, XATTR_POSIX_ACL_ACCESS) ||
+ !strcmp(kname, XATTR_POSIX_ACL_DEFAULT))
+ posix_acl_fix_xattr_from_user(kvalue, size);
+}
/*
* Extended attribute SET operations
@@ -329,9 +339,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);
+ fix_xattr_from_user(kname, kvalue, size);
}
error = vfs_setxattr(d, kname, kvalue, size, flags);
@@ -396,6 +404,17 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
return error;
}
+static void
+fix_xattr_to_user(const char *kname, void *kvalue, size_t size)
+{
+ if (strncmp(kname, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
+ return;
+ kname += XATTR_SYSTEM_PREFIX_LEN;
+ if (!strcmp(kname, XATTR_POSIX_ACL_ACCESS) ||
+ !strcmp(kname, XATTR_POSIX_ACL_DEFAULT))
+ posix_acl_fix_xattr_to_user(kvalue, size);
+}
+
/*
* Extended attribute GET operations
*/
@@ -426,9 +445,7 @@ 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, size);
+ fix_xattr_to_user(kname, kvalue, size);
if (size && copy_to_user(value, kvalue, error))
error = -EFAULT;
} else if (error == -ERANGE && size >= XATTR_SIZE_MAX) {
--
2.5.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v20 00/23] Richacls (Core and Ext4) Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:20 +0100 [PATCH v20 03/23] vfs: Add MAY_DELETE_SELF and MAY_DELETE_CHILD permission flags Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:20 +0100 [PATCH v20 01/23] vfs: Add IS_ACL() and IS_RICHACL() tests Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:20 +0100 [PATCH v20 11/23] posix_acl: Improve xattr fixup code Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 13/23] vfs: Add get_richacl and set_richacl inode operations Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 05/23] vfs: Add permission flags for setting file attributes Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 09/23] richacl: Permission check algorithm Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 14/23] vfs: Cache richacl in struct inode Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 23/23] ext4: Add richacl feature flag Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 10/23] posix_acl: Unexport acl_by_type and make it static Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 04/23] vfs: Make the inode passed to inode_change_ok non-const Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 02/23] vfs: Add MAY_CREATE_FILE and MAY_CREATE_DIR permission flags Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 22/23] ext4: Add richacl support Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 08/23] richacl: Compute maximum file masks from an acl Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 16/23] richacl: Check if an acl is equivalent to a file mode Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 19/23] richacl: xattr mapping functions Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 06/23] richacl: In-memory representation and helper functions Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 21/23] vfs: Add richacl permission checking Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 07/23] richacl: Permission mapping functions Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 12/23] vfs: Cache base_acl objects in inodes Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 20/23] richacl: Add richacl xattr handler Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 18/23] richacl: Automatic Inheritance Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 15/23] richacl: Update the file masks in chmod() Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100 [PATCH v20 17/23] richacl: Create-time inheritance Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:30 +0100
csiph-web