diff options
author | Fabian Frederick <fabf@skynet.be> | 2015-04-16 15:47:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:04:05 -0400 |
commit | 5e61473ea9f1ed6537ffaf6bf1cb60655f0d1b2c (patch) | |
tree | 4ee3f0645b0a060a78945e8ce214c75f31fffa22 | |
parent | a3cef4cd6886c755d2148739699751900b51a365 (diff) |
fs/hfsplus: move xattr_name allocation in hfsplus_setxattr()
security/trusted/user/osx setxattr did the same
xattr_name initialization. Move that operation in hfsplus_setxattr().
Tested with security/trusted/user getfattr/setfattr
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/hfsplus/xattr.c | 37 | ||||
-rw-r--r-- | fs/hfsplus/xattr.h | 8 | ||||
-rw-r--r-- | fs/hfsplus/xattr_security.c | 19 | ||||
-rw-r--r-- | fs/hfsplus/xattr_trusted.c | 18 | ||||
-rw-r--r-- | fs/hfsplus/xattr_user.c | 18 |
5 files changed, 35 insertions, 65 deletions
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c index 087f8da9e565..16f545dd929b 100644 --- a/fs/hfsplus/xattr.c +++ b/fs/hfsplus/xattr.c | |||
@@ -424,6 +424,28 @@ static int copy_name(char *buffer, const char *xattr_name, int name_len) | |||
424 | return len; | 424 | return len; |
425 | } | 425 | } |
426 | 426 | ||
427 | int hfsplus_setxattr(struct dentry *dentry, const char *name, | ||
428 | const void *value, size_t size, int flags, | ||
429 | const char *prefix, size_t prefixlen) | ||
430 | { | ||
431 | char *xattr_name; | ||
432 | int res; | ||
433 | |||
434 | if (!strcmp(name, "")) | ||
435 | return -EINVAL; | ||
436 | |||
437 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, | ||
438 | GFP_KERNEL); | ||
439 | if (!xattr_name) | ||
440 | return -ENOMEM; | ||
441 | strcpy(xattr_name, prefix); | ||
442 | strcpy(xattr_name + prefixlen, name); | ||
443 | res = __hfsplus_setxattr(dentry->d_inode, xattr_name, value, size, | ||
444 | flags); | ||
445 | kfree(xattr_name); | ||
446 | return res; | ||
447 | } | ||
448 | |||
427 | static ssize_t hfsplus_getxattr_finder_info(struct inode *inode, | 449 | static ssize_t hfsplus_getxattr_finder_info(struct inode *inode, |
428 | void *value, size_t size) | 450 | void *value, size_t size) |
429 | { | 451 | { |
@@ -847,9 +869,6 @@ static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name, | |||
847 | static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name, | 869 | static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name, |
848 | const void *buffer, size_t size, int flags, int type) | 870 | const void *buffer, size_t size, int flags, int type) |
849 | { | 871 | { |
850 | char *xattr_name; | ||
851 | int res; | ||
852 | |||
853 | if (!strcmp(name, "")) | 872 | if (!strcmp(name, "")) |
854 | return -EINVAL; | 873 | return -EINVAL; |
855 | 874 | ||
@@ -859,16 +878,10 @@ static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name, | |||
859 | */ | 878 | */ |
860 | if (is_known_namespace(name)) | 879 | if (is_known_namespace(name)) |
861 | return -EOPNOTSUPP; | 880 | return -EOPNOTSUPP; |
862 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN | ||
863 | + XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL); | ||
864 | if (!xattr_name) | ||
865 | return -ENOMEM; | ||
866 | strcpy(xattr_name, XATTR_MAC_OSX_PREFIX); | ||
867 | strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name); | ||
868 | 881 | ||
869 | res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | 882 | return hfsplus_setxattr(dentry, name, buffer, size, flags, |
870 | kfree(xattr_name); | 883 | XATTR_MAC_OSX_PREFIX, |
871 | return res; | 884 | XATTR_MAC_OSX_PREFIX_LEN); |
872 | } | 885 | } |
873 | 886 | ||
874 | static size_t hfsplus_osx_listxattr(struct dentry *dentry, char *list, | 887 | static size_t hfsplus_osx_listxattr(struct dentry *dentry, char *list, |
diff --git a/fs/hfsplus/xattr.h b/fs/hfsplus/xattr.h index 570d406a65e3..f9b0955b3d28 100644 --- a/fs/hfsplus/xattr.h +++ b/fs/hfsplus/xattr.h | |||
@@ -21,11 +21,9 @@ extern const struct xattr_handler *hfsplus_xattr_handlers[]; | |||
21 | int __hfsplus_setxattr(struct inode *inode, const char *name, | 21 | int __hfsplus_setxattr(struct inode *inode, const char *name, |
22 | const void *value, size_t size, int flags); | 22 | const void *value, size_t size, int flags); |
23 | 23 | ||
24 | static inline int hfsplus_setxattr(struct dentry *dentry, const char *name, | 24 | int hfsplus_setxattr(struct dentry *dentry, const char *name, |
25 | const void *value, size_t size, int flags) | 25 | const void *value, size_t size, int flags, |
26 | { | 26 | const char *prefix, size_t prefixlen); |
27 | return __hfsplus_setxattr(dentry->d_inode, name, value, size, flags); | ||
28 | } | ||
29 | 27 | ||
30 | ssize_t __hfsplus_getxattr(struct inode *inode, const char *name, | 28 | ssize_t __hfsplus_getxattr(struct inode *inode, const char *name, |
31 | void *value, size_t size); | 29 | void *value, size_t size); |
diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c index e67d52889448..aacff00a9ff9 100644 --- a/fs/hfsplus/xattr_security.c +++ b/fs/hfsplus/xattr_security.c | |||
@@ -24,22 +24,9 @@ static int hfsplus_security_getxattr(struct dentry *dentry, const char *name, | |||
24 | static int hfsplus_security_setxattr(struct dentry *dentry, const char *name, | 24 | static int hfsplus_security_setxattr(struct dentry *dentry, const char *name, |
25 | const void *buffer, size_t size, int flags, int type) | 25 | const void *buffer, size_t size, int flags, int type) |
26 | { | 26 | { |
27 | char *xattr_name; | 27 | return hfsplus_setxattr(dentry, name, buffer, size, flags, |
28 | int res; | 28 | XATTR_SECURITY_PREFIX, |
29 | 29 | XATTR_SECURITY_PREFIX_LEN); | |
30 | if (!strcmp(name, "")) | ||
31 | return -EINVAL; | ||
32 | |||
33 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, | ||
34 | GFP_KERNEL); | ||
35 | if (!xattr_name) | ||
36 | return -ENOMEM; | ||
37 | strcpy(xattr_name, XATTR_SECURITY_PREFIX); | ||
38 | strcpy(xattr_name + XATTR_SECURITY_PREFIX_LEN, name); | ||
39 | |||
40 | res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | ||
41 | kfree(xattr_name); | ||
42 | return res; | ||
43 | } | 30 | } |
44 | 31 | ||
45 | static size_t hfsplus_security_listxattr(struct dentry *dentry, char *list, | 32 | static size_t hfsplus_security_listxattr(struct dentry *dentry, char *list, |
diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c index 0b7d78f2d4e9..bcf65089b7f7 100644 --- a/fs/hfsplus/xattr_trusted.c +++ b/fs/hfsplus/xattr_trusted.c | |||
@@ -22,22 +22,8 @@ static int hfsplus_trusted_getxattr(struct dentry *dentry, const char *name, | |||
22 | static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name, | 22 | static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name, |
23 | const void *buffer, size_t size, int flags, int type) | 23 | const void *buffer, size_t size, int flags, int type) |
24 | { | 24 | { |
25 | char *xattr_name; | 25 | return hfsplus_setxattr(dentry, name, buffer, size, flags, |
26 | int res; | 26 | XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN); |
27 | |||
28 | if (!strcmp(name, "")) | ||
29 | return -EINVAL; | ||
30 | |||
31 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, | ||
32 | GFP_KERNEL); | ||
33 | if (!xattr_name) | ||
34 | return -ENOMEM; | ||
35 | strcpy(xattr_name, XATTR_TRUSTED_PREFIX); | ||
36 | strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name); | ||
37 | |||
38 | res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | ||
39 | kfree(xattr_name); | ||
40 | return res; | ||
41 | } | 27 | } |
42 | 28 | ||
43 | static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list, | 29 | static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list, |
diff --git a/fs/hfsplus/xattr_user.c b/fs/hfsplus/xattr_user.c index f8860df28842..5aa0e6dc4a1e 100644 --- a/fs/hfsplus/xattr_user.c +++ b/fs/hfsplus/xattr_user.c | |||
@@ -22,22 +22,8 @@ static int hfsplus_user_getxattr(struct dentry *dentry, const char *name, | |||
22 | static int hfsplus_user_setxattr(struct dentry *dentry, const char *name, | 22 | static int hfsplus_user_setxattr(struct dentry *dentry, const char *name, |
23 | const void *buffer, size_t size, int flags, int type) | 23 | const void *buffer, size_t size, int flags, int type) |
24 | { | 24 | { |
25 | char *xattr_name; | 25 | return hfsplus_setxattr(dentry, name, buffer, size, flags, |
26 | int res; | 26 | XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); |
27 | |||
28 | if (!strcmp(name, "")) | ||
29 | return -EINVAL; | ||
30 | |||
31 | xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1, | ||
32 | GFP_KERNEL); | ||
33 | if (!xattr_name) | ||
34 | return -ENOMEM; | ||
35 | strcpy(xattr_name, XATTR_USER_PREFIX); | ||
36 | strcpy(xattr_name + XATTR_USER_PREFIX_LEN, name); | ||
37 | |||
38 | res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | ||
39 | kfree(xattr_name); | ||
40 | return res; | ||
41 | } | 27 | } |
42 | 28 | ||
43 | static size_t hfsplus_user_listxattr(struct dentry *dentry, char *list, | 29 | static size_t hfsplus_user_listxattr(struct dentry *dentry, char *list, |