aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-02-01 13:43:45 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-02-01 13:43:45 -0500
commitefc518eb318c4d776933c23e7b82c2e5402b62de (patch)
treeee9100af7dd17039524c7833e0128de49eab5be1 /fs/hfsplus
parentfea8893da7c52906caa1a8dc3199f4b2ed3b8dbd (diff)
parentd22e6338db7f613dd4f6095c190682fcc519e4b7 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fixes from Al Viro: "Several obvious fixes" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: Fix mountpoint reference leakage in linkat hfsplus: use xattr handlers for removexattr Typo in compat_sys_lseek() declaration fs/super.c: sync ro remount after blocking writers vfs: unexport the getname() symbol
Diffstat (limited to 'fs/hfsplus')
-rw-r--r--fs/hfsplus/dir.c2
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hfsplus/xattr.c60
-rw-r--r--fs/hfsplus/xattr.h2
4 files changed, 19 insertions, 47 deletions
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 9ee62985e739..bdec66522de3 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -529,7 +529,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
529 .setxattr = generic_setxattr, 529 .setxattr = generic_setxattr,
530 .getxattr = generic_getxattr, 530 .getxattr = generic_getxattr,
531 .listxattr = hfsplus_listxattr, 531 .listxattr = hfsplus_listxattr,
532 .removexattr = hfsplus_removexattr, 532 .removexattr = generic_removexattr,
533#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL 533#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
534 .get_acl = hfsplus_get_posix_acl, 534 .get_acl = hfsplus_get_posix_acl,
535 .set_acl = hfsplus_set_posix_acl, 535 .set_acl = hfsplus_set_posix_acl,
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 4551cbd6bd43..fa929f325f87 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -331,7 +331,7 @@ static const struct inode_operations hfsplus_file_inode_operations = {
331 .setxattr = generic_setxattr, 331 .setxattr = generic_setxattr,
332 .getxattr = generic_getxattr, 332 .getxattr = generic_getxattr,
333 .listxattr = hfsplus_listxattr, 333 .listxattr = hfsplus_listxattr,
334 .removexattr = hfsplus_removexattr, 334 .removexattr = generic_removexattr,
335#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL 335#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
336 .get_acl = hfsplus_get_posix_acl, 336 .get_acl = hfsplus_get_posix_acl,
337 .set_acl = hfsplus_set_posix_acl, 337 .set_acl = hfsplus_set_posix_acl,
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index 0b4a5c9b93c4..4e27edc082a4 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -11,6 +11,8 @@
11#include "xattr.h" 11#include "xattr.h"
12#include "acl.h" 12#include "acl.h"
13 13
14static int hfsplus_removexattr(struct inode *inode, const char *name);
15
14const struct xattr_handler *hfsplus_xattr_handlers[] = { 16const struct xattr_handler *hfsplus_xattr_handlers[] = {
15 &hfsplus_xattr_osx_handler, 17 &hfsplus_xattr_osx_handler,
16 &hfsplus_xattr_user_handler, 18 &hfsplus_xattr_user_handler,
@@ -274,14 +276,8 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
274 HFSPLUS_IS_RSRC(inode)) 276 HFSPLUS_IS_RSRC(inode))
275 return -EOPNOTSUPP; 277 return -EOPNOTSUPP;
276 278
277 if (strncmp(name, XATTR_MAC_OSX_PREFIX, 279 if (value == NULL)
278 XATTR_MAC_OSX_PREFIX_LEN) == 0) 280 return hfsplus_removexattr(inode, name);
279 name += XATTR_MAC_OSX_PREFIX_LEN;
280
281 if (value == NULL) {
282 value = "";
283 size = 0;
284 }
285 281
286 err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd); 282 err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd);
287 if (err) { 283 if (err) {
@@ -399,16 +395,11 @@ end_setxattr:
399 return err; 395 return err;
400} 396}
401 397
402static inline int is_osx_xattr(const char *xattr_name)
403{
404 return !is_known_namespace(xattr_name);
405}
406
407static int name_len(const char *xattr_name, int xattr_name_len) 398static int name_len(const char *xattr_name, int xattr_name_len)
408{ 399{
409 int len = xattr_name_len + 1; 400 int len = xattr_name_len + 1;
410 401
411 if (is_osx_xattr(xattr_name)) 402 if (!is_known_namespace(xattr_name))
412 len += XATTR_MAC_OSX_PREFIX_LEN; 403 len += XATTR_MAC_OSX_PREFIX_LEN;
413 404
414 return len; 405 return len;
@@ -419,7 +410,7 @@ static int copy_name(char *buffer, const char *xattr_name, int name_len)
419 int len = name_len; 410 int len = name_len;
420 int offset = 0; 411 int offset = 0;
421 412
422 if (is_osx_xattr(xattr_name)) { 413 if (!is_known_namespace(xattr_name)) {
423 strncpy(buffer, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN); 414 strncpy(buffer, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN);
424 offset += XATTR_MAC_OSX_PREFIX_LEN; 415 offset += XATTR_MAC_OSX_PREFIX_LEN;
425 len += XATTR_MAC_OSX_PREFIX_LEN; 416 len += XATTR_MAC_OSX_PREFIX_LEN;
@@ -497,18 +488,6 @@ ssize_t __hfsplus_getxattr(struct inode *inode, const char *name,
497 HFSPLUS_IS_RSRC(inode)) 488 HFSPLUS_IS_RSRC(inode))
498 return -EOPNOTSUPP; 489 return -EOPNOTSUPP;
499 490
500 if (strncmp(name, XATTR_MAC_OSX_PREFIX,
501 XATTR_MAC_OSX_PREFIX_LEN) == 0) {
502 /* skip "osx." prefix */
503 name += XATTR_MAC_OSX_PREFIX_LEN;
504 /*
505 * Don't allow retrieving properly prefixed attributes
506 * by prepending them with "osx."
507 */
508 if (is_known_namespace(name))
509 return -EOPNOTSUPP;
510 }
511
512 if (!strcmp_xattr_finder_info(name)) 491 if (!strcmp_xattr_finder_info(name))
513 return hfsplus_getxattr_finder_info(inode, value, size); 492 return hfsplus_getxattr_finder_info(inode, value, size);
514 493
@@ -743,28 +722,18 @@ end_listxattr:
743 return res; 722 return res;
744} 723}
745 724
746int hfsplus_removexattr(struct dentry *dentry, const char *name) 725static int hfsplus_removexattr(struct inode *inode, const char *name)
747{ 726{
748 int err = 0; 727 int err = 0;
749 struct inode *inode = dentry->d_inode;
750 struct hfs_find_data cat_fd; 728 struct hfs_find_data cat_fd;
751 u16 flags; 729 u16 flags;
752 u16 cat_entry_type; 730 u16 cat_entry_type;
753 int is_xattr_acl_deleted = 0; 731 int is_xattr_acl_deleted = 0;
754 int is_all_xattrs_deleted = 0; 732 int is_all_xattrs_deleted = 0;
755 733
756 if ((!S_ISREG(inode->i_mode) &&
757 !S_ISDIR(inode->i_mode)) ||
758 HFSPLUS_IS_RSRC(inode))
759 return -EOPNOTSUPP;
760
761 if (!HFSPLUS_SB(inode->i_sb)->attr_tree) 734 if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
762 return -EOPNOTSUPP; 735 return -EOPNOTSUPP;
763 736
764 if (strncmp(name, XATTR_MAC_OSX_PREFIX,
765 XATTR_MAC_OSX_PREFIX_LEN) == 0)
766 name += XATTR_MAC_OSX_PREFIX_LEN;
767
768 if (!strcmp_xattr_finder_info(name)) 737 if (!strcmp_xattr_finder_info(name))
769 return -EOPNOTSUPP; 738 return -EOPNOTSUPP;
770 739
@@ -838,8 +807,12 @@ static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name,
838 if (len > HFSPLUS_ATTR_MAX_STRLEN) 807 if (len > HFSPLUS_ATTR_MAX_STRLEN)
839 return -EOPNOTSUPP; 808 return -EOPNOTSUPP;
840 809
841 strcpy(xattr_name, XATTR_MAC_OSX_PREFIX); 810 /*
842 strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name); 811 * Don't allow retrieving properly prefixed attributes
812 * by prepending them with "osx."
813 */
814 if (is_known_namespace(name))
815 return -EOPNOTSUPP;
843 816
844 return hfsplus_getxattr(dentry, xattr_name, buffer, size); 817 return hfsplus_getxattr(dentry, xattr_name, buffer, size);
845} 818}
@@ -857,12 +830,13 @@ static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name,
857 if (len > HFSPLUS_ATTR_MAX_STRLEN) 830 if (len > HFSPLUS_ATTR_MAX_STRLEN)
858 return -EOPNOTSUPP; 831 return -EOPNOTSUPP;
859 832
833 /*
834 * Don't allow setting properly prefixed attributes
835 * by prepending them with "osx."
836 */
860 if (is_known_namespace(name)) 837 if (is_known_namespace(name))
861 return -EOPNOTSUPP; 838 return -EOPNOTSUPP;
862 839
863 strcpy(xattr_name, XATTR_MAC_OSX_PREFIX);
864 strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name);
865
866 return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); 840 return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags);
867} 841}
868 842
diff --git a/fs/hfsplus/xattr.h b/fs/hfsplus/xattr.h
index 9e214490c313..288530cf80b5 100644
--- a/fs/hfsplus/xattr.h
+++ b/fs/hfsplus/xattr.h
@@ -40,8 +40,6 @@ static inline ssize_t hfsplus_getxattr(struct dentry *dentry,
40 40
41ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size); 41ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size);
42 42
43int hfsplus_removexattr(struct dentry *dentry, const char *name);
44
45int hfsplus_init_security(struct inode *inode, struct inode *dir, 43int hfsplus_init_security(struct inode *inode, struct inode *dir,
46 const struct qstr *qstr); 44 const struct qstr *qstr);
47 45