aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-04-10 18:50:48 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2016-04-10 19:31:09 -0400
commit79a628d14ec7ee9adfdc3ce04343d5ff7ec20c18 (patch)
tree96b0e5a6a97bed3bdd0669bbdf372f05db718404
parent5fdccfef483d088fcc533b282bf6953579d6d6f4 (diff)
reiserfs: switch to generic_{get,set,remove}xattr()
reiserfs_xattr_[sg]et() will fail with -EOPNOTSUPP for V1 inodes anyway, and all reiserfs instances of ->[sg]et() call it and so does ->set_acl(). Checks for name length in the instances had been bogus; they should've been "bugger off if it's _exactly_ the prefix" (as generic would do on its own) and not "bugger off if it's shorter than the prefix" - that can't happen. xattr_full_name() is needed to adjust for the fact that generic instances will skip the prefix in the name passed to ->[gs]et(); reiserfs homegrown analogues didn't. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/reiserfs/file.c6
-rw-r--r--fs/reiserfs/namei.c18
-rw-r--r--fs/reiserfs/xattr.c54
-rw-r--r--fs/reiserfs/xattr.h9
-rw-r--r--fs/reiserfs/xattr_security.c14
-rw-r--r--fs/reiserfs/xattr_trusted.c14
-rw-r--r--fs/reiserfs/xattr_user.c14
7 files changed, 31 insertions, 98 deletions
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 9424a4ba93a9..9ffaf7145644 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -260,10 +260,10 @@ const struct file_operations reiserfs_file_operations = {
260 260
261const struct inode_operations reiserfs_file_inode_operations = { 261const struct inode_operations reiserfs_file_inode_operations = {
262 .setattr = reiserfs_setattr, 262 .setattr = reiserfs_setattr,
263 .setxattr = reiserfs_setxattr, 263 .setxattr = generic_setxattr,
264 .getxattr = reiserfs_getxattr, 264 .getxattr = generic_getxattr,
265 .listxattr = reiserfs_listxattr, 265 .listxattr = reiserfs_listxattr,
266 .removexattr = reiserfs_removexattr, 266 .removexattr = generic_removexattr,
267 .permission = reiserfs_permission, 267 .permission = reiserfs_permission,
268 .get_acl = reiserfs_get_acl, 268 .get_acl = reiserfs_get_acl,
269 .set_acl = reiserfs_set_acl, 269 .set_acl = reiserfs_set_acl,
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 2a12d46d7fb4..8a36696d6df9 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -1650,10 +1650,10 @@ const struct inode_operations reiserfs_dir_inode_operations = {
1650 .mknod = reiserfs_mknod, 1650 .mknod = reiserfs_mknod,
1651 .rename = reiserfs_rename, 1651 .rename = reiserfs_rename,
1652 .setattr = reiserfs_setattr, 1652 .setattr = reiserfs_setattr,
1653 .setxattr = reiserfs_setxattr, 1653 .setxattr = generic_setxattr,
1654 .getxattr = reiserfs_getxattr, 1654 .getxattr = generic_getxattr,
1655 .listxattr = reiserfs_listxattr, 1655 .listxattr = reiserfs_listxattr,
1656 .removexattr = reiserfs_removexattr, 1656 .removexattr = generic_removexattr,
1657 .permission = reiserfs_permission, 1657 .permission = reiserfs_permission,
1658 .get_acl = reiserfs_get_acl, 1658 .get_acl = reiserfs_get_acl,
1659 .set_acl = reiserfs_set_acl, 1659 .set_acl = reiserfs_set_acl,
@@ -1667,10 +1667,10 @@ const struct inode_operations reiserfs_symlink_inode_operations = {
1667 .readlink = generic_readlink, 1667 .readlink = generic_readlink,
1668 .get_link = page_get_link, 1668 .get_link = page_get_link,
1669 .setattr = reiserfs_setattr, 1669 .setattr = reiserfs_setattr,
1670 .setxattr = reiserfs_setxattr, 1670 .setxattr = generic_setxattr,
1671 .getxattr = reiserfs_getxattr, 1671 .getxattr = generic_getxattr,
1672 .listxattr = reiserfs_listxattr, 1672 .listxattr = reiserfs_listxattr,
1673 .removexattr = reiserfs_removexattr, 1673 .removexattr = generic_removexattr,
1674 .permission = reiserfs_permission, 1674 .permission = reiserfs_permission,
1675}; 1675};
1676 1676
@@ -1679,10 +1679,10 @@ const struct inode_operations reiserfs_symlink_inode_operations = {
1679 */ 1679 */
1680const struct inode_operations reiserfs_special_inode_operations = { 1680const struct inode_operations reiserfs_special_inode_operations = {
1681 .setattr = reiserfs_setattr, 1681 .setattr = reiserfs_setattr,
1682 .setxattr = reiserfs_setxattr, 1682 .setxattr = generic_setxattr,
1683 .getxattr = reiserfs_getxattr, 1683 .getxattr = generic_getxattr,
1684 .listxattr = reiserfs_listxattr, 1684 .listxattr = reiserfs_listxattr,
1685 .removexattr = reiserfs_removexattr, 1685 .removexattr = generic_removexattr,
1686 .permission = reiserfs_permission, 1686 .permission = reiserfs_permission,
1687 .get_acl = reiserfs_get_acl, 1687 .get_acl = reiserfs_get_acl,
1688 .set_acl = reiserfs_set_acl, 1688 .set_acl = reiserfs_set_acl,
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 57e0b2310532..02137bbda0ec 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -764,60 +764,6 @@ find_xattr_handler_prefix(const struct xattr_handler **handlers,
764 return xah; 764 return xah;
765} 765}
766 766
767
768/*
769 * Inode operation getxattr()
770 */
771ssize_t
772reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
773 size_t size)
774{
775 const struct xattr_handler *handler;
776
777 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
778
779 if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
780 return -EOPNOTSUPP;
781
782 return handler->get(handler, dentry, name, buffer, size);
783}
784
785/*
786 * Inode operation setxattr()
787 *
788 * d_inode(dentry)->i_mutex down
789 */
790int
791reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
792 size_t size, int flags)
793{
794 const struct xattr_handler *handler;
795
796 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
797
798 if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
799 return -EOPNOTSUPP;
800
801 return handler->set(handler, dentry, name, value, size, flags);
802}
803
804/*
805 * Inode operation removexattr()
806 *
807 * d_inode(dentry)->i_mutex down
808 */
809int reiserfs_removexattr(struct dentry *dentry, const char *name)
810{
811 const struct xattr_handler *handler;
812
813 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
814
815 if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
816 return -EOPNOTSUPP;
817
818 return handler->set(handler, dentry, name, NULL, 0, XATTR_REPLACE);
819}
820
821struct listxattr_buf { 767struct listxattr_buf {
822 struct dir_context ctx; 768 struct dir_context ctx;
823 size_t size; 769 size_t size;
diff --git a/fs/reiserfs/xattr.h b/fs/reiserfs/xattr.h
index 15dde6262c00..613ff5aef94e 100644
--- a/fs/reiserfs/xattr.h
+++ b/fs/reiserfs/xattr.h
@@ -2,6 +2,7 @@
2#include <linux/init.h> 2#include <linux/init.h>
3#include <linux/list.h> 3#include <linux/list.h>
4#include <linux/rwsem.h> 4#include <linux/rwsem.h>
5#include <linux/xattr.h>
5 6
6struct inode; 7struct inode;
7struct dentry; 8struct dentry;
@@ -18,12 +19,7 @@ int reiserfs_permission(struct inode *inode, int mask);
18 19
19#ifdef CONFIG_REISERFS_FS_XATTR 20#ifdef CONFIG_REISERFS_FS_XATTR
20#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) 21#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
21ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
22 void *buffer, size_t size);
23int reiserfs_setxattr(struct dentry *dentry, const char *name,
24 const void *value, size_t size, int flags);
25ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size); 22ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
26int reiserfs_removexattr(struct dentry *dentry, const char *name);
27 23
28int reiserfs_xattr_get(struct inode *, const char *, void *, size_t); 24int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
29int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int); 25int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
@@ -92,10 +88,7 @@ static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
92 88
93#else 89#else
94 90
95#define reiserfs_getxattr NULL
96#define reiserfs_setxattr NULL
97#define reiserfs_listxattr NULL 91#define reiserfs_listxattr NULL
98#define reiserfs_removexattr NULL
99 92
100static inline void reiserfs_init_xattr_rwsem(struct inode *inode) 93static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
101{ 94{
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c
index ab0217d32039..ac7e104ada6b 100644
--- a/fs/reiserfs/xattr_security.c
+++ b/fs/reiserfs/xattr_security.c
@@ -12,26 +12,24 @@ static int
12security_get(const struct xattr_handler *handler, struct dentry *dentry, 12security_get(const struct xattr_handler *handler, struct dentry *dentry,
13 const char *name, void *buffer, size_t size) 13 const char *name, void *buffer, size_t size)
14{ 14{
15 if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
16 return -EINVAL;
17
18 if (IS_PRIVATE(d_inode(dentry))) 15 if (IS_PRIVATE(d_inode(dentry)))
19 return -EPERM; 16 return -EPERM;
20 17
21 return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); 18 return reiserfs_xattr_get(d_inode(dentry),
19 xattr_full_name(handler, name),
20 buffer, size);
22} 21}
23 22
24static int 23static int
25security_set(const struct xattr_handler *handler, struct dentry *dentry, 24security_set(const struct xattr_handler *handler, struct dentry *dentry,
26 const char *name, const void *buffer, size_t size, int flags) 25 const char *name, const void *buffer, size_t size, int flags)
27{ 26{
28 if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
29 return -EINVAL;
30
31 if (IS_PRIVATE(d_inode(dentry))) 27 if (IS_PRIVATE(d_inode(dentry)))
32 return -EPERM; 28 return -EPERM;
33 29
34 return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); 30 return reiserfs_xattr_set(d_inode(dentry),
31 xattr_full_name(handler, name),
32 buffer, size, flags);
35} 33}
36 34
37static bool security_list(struct dentry *dentry) 35static bool security_list(struct dentry *dentry)
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c
index 64b67aa643a9..cc248a581b60 100644
--- a/fs/reiserfs/xattr_trusted.c
+++ b/fs/reiserfs/xattr_trusted.c
@@ -11,26 +11,24 @@ static int
11trusted_get(const struct xattr_handler *handler, struct dentry *dentry, 11trusted_get(const struct xattr_handler *handler, struct dentry *dentry,
12 const char *name, void *buffer, size_t size) 12 const char *name, void *buffer, size_t size)
13{ 13{
14 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
15 return -EINVAL;
16
17 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) 14 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
18 return -EPERM; 15 return -EPERM;
19 16
20 return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); 17 return reiserfs_xattr_get(d_inode(dentry),
18 xattr_full_name(handler, name),
19 buffer, size);
21} 20}
22 21
23static int 22static int
24trusted_set(const struct xattr_handler *handler, struct dentry *dentry, 23trusted_set(const struct xattr_handler *handler, struct dentry *dentry,
25 const char *name, const void *buffer, size_t size, int flags) 24 const char *name, const void *buffer, size_t size, int flags)
26{ 25{
27 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
28 return -EINVAL;
29
30 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) 26 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
31 return -EPERM; 27 return -EPERM;
32 28
33 return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); 29 return reiserfs_xattr_set(d_inode(dentry),
30 xattr_full_name(handler, name),
31 buffer, size, flags);
34} 32}
35 33
36static bool trusted_list(struct dentry *dentry) 34static bool trusted_list(struct dentry *dentry)
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c
index 12e6306f562a..caad583086af 100644
--- a/fs/reiserfs/xattr_user.c
+++ b/fs/reiserfs/xattr_user.c
@@ -10,24 +10,22 @@ static int
10user_get(const struct xattr_handler *handler, struct dentry *dentry, 10user_get(const struct xattr_handler *handler, struct dentry *dentry,
11 const char *name, void *buffer, size_t size) 11 const char *name, void *buffer, size_t size)
12{ 12{
13
14 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
15 return -EINVAL;
16 if (!reiserfs_xattrs_user(dentry->d_sb)) 13 if (!reiserfs_xattrs_user(dentry->d_sb))
17 return -EOPNOTSUPP; 14 return -EOPNOTSUPP;
18 return reiserfs_xattr_get(d_inode(dentry), name, buffer, size); 15 return reiserfs_xattr_get(d_inode(dentry),
16 xattr_full_name(handler, name),
17 buffer, size);
19} 18}
20 19
21static int 20static int
22user_set(const struct xattr_handler *handler, struct dentry *dentry, 21user_set(const struct xattr_handler *handler, struct dentry *dentry,
23 const char *name, const void *buffer, size_t size, int flags) 22 const char *name, const void *buffer, size_t size, int flags)
24{ 23{
25 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
26 return -EINVAL;
27
28 if (!reiserfs_xattrs_user(dentry->d_sb)) 24 if (!reiserfs_xattrs_user(dentry->d_sb))
29 return -EOPNOTSUPP; 25 return -EOPNOTSUPP;
30 return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags); 26 return reiserfs_xattr_set(d_inode(dentry),
27 xattr_full_name(handler, name),
28 buffer, size, flags);
31} 29}
32 30
33static bool user_list(struct dentry *dentry) 31static bool user_list(struct dentry *dentry)