aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErnesto A. Fernández <ernesto.mnd.fernandez@gmail.com>2018-08-22 00:59:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-22 13:52:50 -0400
commitf168d9fd634a4612d308d7dbe0a4d2a9b366c045 (patch)
treeae083873011b1d01e675070315ae7e0c6339378d
parentafd6c9e1f5287ad236adcf56db8c42fef65561fa (diff)
hfsplus: drop ACL support
The HFS+ Access Control Lists have not worked at all for the past five years, and nobody seems to have noticed. Besides, POSIX draft ACLs are not compatible with MacOS. Drop the feature entirely. Link: http://lkml.kernel.org/r/20180714190608.wtnmmtjqeyladkut@eaf Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com> Acked-by: Christoph Hellwig <hch@lst.de> Cc: Viacheslav Dubeyko <slava@dubeyko.com> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/hfsplus/Kconfig15
-rw-r--r--fs/hfsplus/Makefile2
-rw-r--r--fs/hfsplus/acl.h28
-rw-r--r--fs/hfsplus/dir.c9
-rw-r--r--fs/hfsplus/hfsplus_fs.h1
-rw-r--r--fs/hfsplus/inode.c11
-rw-r--r--fs/hfsplus/posix_acl.c144
-rw-r--r--fs/hfsplus/super.c4
-rw-r--r--fs/hfsplus/xattr.c6
-rw-r--r--fs/hfsplus/xattr.h3
-rw-r--r--fs/hfsplus/xattr_security.c13
11 files changed, 4 insertions, 232 deletions
diff --git a/fs/hfsplus/Kconfig b/fs/hfsplus/Kconfig
index 7cc8b4acf66a..a63371815aab 100644
--- a/fs/hfsplus/Kconfig
+++ b/fs/hfsplus/Kconfig
@@ -11,18 +11,3 @@ config HFSPLUS_FS
11 MacOS 8. It includes all Mac specific filesystem data such as 11 MacOS 8. It includes all Mac specific filesystem data such as
12 data forks and creator codes, but it also has several UNIX 12 data forks and creator codes, but it also has several UNIX
13 style features such as file ownership and permissions. 13 style features such as file ownership and permissions.
14
15config HFSPLUS_FS_POSIX_ACL
16 bool "HFS+ POSIX Access Control Lists"
17 depends on HFSPLUS_FS
18 select FS_POSIX_ACL
19 help
20 POSIX Access Control Lists (ACLs) support permissions for users and
21 groups beyond the owner/group/world scheme.
22
23 It needs to understand that POSIX ACLs are treated only under
24 Linux. POSIX ACLs doesn't mean something under Mac OS X.
25 Mac OS X beginning with version 10.4 ("Tiger") support NFSv4 ACLs,
26 which are part of the NFSv4 standard.
27
28 If you don't know what Access Control Lists are, say N
diff --git a/fs/hfsplus/Makefile b/fs/hfsplus/Makefile
index f6a56542f8d7..9ed20e64b983 100644
--- a/fs/hfsplus/Makefile
+++ b/fs/hfsplus/Makefile
@@ -8,5 +8,3 @@ obj-$(CONFIG_HFSPLUS_FS) += hfsplus.o
8hfsplus-objs := super.o options.o inode.o ioctl.o extents.o catalog.o dir.o btree.o \ 8hfsplus-objs := super.o options.o inode.o ioctl.o extents.o catalog.o dir.o btree.o \
9 bnode.o brec.o bfind.o tables.o unicode.o wrapper.o bitmap.o part_tbl.o \ 9 bnode.o brec.o bfind.o tables.o unicode.o wrapper.o bitmap.o part_tbl.o \
10 attributes.o xattr.o xattr_user.o xattr_security.o xattr_trusted.o 10 attributes.o xattr.o xattr_user.o xattr_security.o xattr_trusted.o
11
12hfsplus-$(CONFIG_HFSPLUS_FS_POSIX_ACL) += posix_acl.o
diff --git a/fs/hfsplus/acl.h b/fs/hfsplus/acl.h
deleted file mode 100644
index 488c2b75cf41..000000000000
--- a/fs/hfsplus/acl.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * linux/fs/hfsplus/acl.h
4 *
5 * Vyacheslav Dubeyko <slava@dubeyko.com>
6 *
7 * Handler for Posix Access Control Lists (ACLs) support.
8 */
9
10#include <linux/posix_acl_xattr.h>
11
12#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
13
14/* posix_acl.c */
15struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type);
16int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
17 int type);
18extern int hfsplus_init_posix_acl(struct inode *, struct inode *);
19
20#else /* CONFIG_HFSPLUS_FS_POSIX_ACL */
21#define hfsplus_get_posix_acl NULL
22#define hfsplus_set_posix_acl NULL
23
24static inline int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
25{
26 return 0;
27}
28#endif /* CONFIG_HFSPLUS_FS_POSIX_ACL */
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index b5254378f011..c5a70f83dbe7 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -18,7 +18,6 @@
18#include "hfsplus_fs.h" 18#include "hfsplus_fs.h"
19#include "hfsplus_raw.h" 19#include "hfsplus_raw.h"
20#include "xattr.h" 20#include "xattr.h"
21#include "acl.h"
22 21
23static inline void hfsplus_instantiate(struct dentry *dentry, 22static inline void hfsplus_instantiate(struct dentry *dentry,
24 struct inode *inode, u32 cnid) 23 struct inode *inode, u32 cnid)
@@ -455,7 +454,7 @@ static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
455 if (res) 454 if (res)
456 goto out_err; 455 goto out_err;
457 456
458 res = hfsplus_init_inode_security(inode, dir, &dentry->d_name); 457 res = hfsplus_init_security(inode, dir, &dentry->d_name);
459 if (res == -EOPNOTSUPP) 458 if (res == -EOPNOTSUPP)
460 res = 0; /* Operation is not supported. */ 459 res = 0; /* Operation is not supported. */
461 else if (res) { 460 else if (res) {
@@ -496,7 +495,7 @@ static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,
496 if (res) 495 if (res)
497 goto failed_mknod; 496 goto failed_mknod;
498 497
499 res = hfsplus_init_inode_security(inode, dir, &dentry->d_name); 498 res = hfsplus_init_security(inode, dir, &dentry->d_name);
500 if (res == -EOPNOTSUPP) 499 if (res == -EOPNOTSUPP)
501 res = 0; /* Operation is not supported. */ 500 res = 0; /* Operation is not supported. */
502 else if (res) { 501 else if (res) {
@@ -567,10 +566,6 @@ const struct inode_operations hfsplus_dir_inode_operations = {
567 .mknod = hfsplus_mknod, 566 .mknod = hfsplus_mknod,
568 .rename = hfsplus_rename, 567 .rename = hfsplus_rename,
569 .listxattr = hfsplus_listxattr, 568 .listxattr = hfsplus_listxattr,
570#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
571 .get_acl = hfsplus_get_posix_acl,
572 .set_acl = hfsplus_set_posix_acl,
573#endif
574}; 569};
575 570
576const struct file_operations hfsplus_dir_operations = { 571const struct file_operations hfsplus_dir_operations = {
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index d9255abafb81..8e039435958a 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -31,7 +31,6 @@
31#define DBG_EXTENT 0x00000020 31#define DBG_EXTENT 0x00000020
32#define DBG_BITMAP 0x00000040 32#define DBG_BITMAP 0x00000040
33#define DBG_ATTR_MOD 0x00000080 33#define DBG_ATTR_MOD 0x00000080
34#define DBG_ACL_MOD 0x00000100
35 34
36#if 0 35#if 0
37#define DBG_MASK (DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD) 36#define DBG_MASK (DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD)
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index c824f702feec..8e9427a42b81 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -21,7 +21,6 @@
21#include "hfsplus_fs.h" 21#include "hfsplus_fs.h"
22#include "hfsplus_raw.h" 22#include "hfsplus_raw.h"
23#include "xattr.h" 23#include "xattr.h"
24#include "acl.h"
25 24
26static int hfsplus_readpage(struct file *file, struct page *page) 25static int hfsplus_readpage(struct file *file, struct page *page)
27{ 26{
@@ -267,12 +266,6 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
267 setattr_copy(inode, attr); 266 setattr_copy(inode, attr);
268 mark_inode_dirty(inode); 267 mark_inode_dirty(inode);
269 268
270 if (attr->ia_valid & ATTR_MODE) {
271 error = posix_acl_chmod(inode, inode->i_mode);
272 if (unlikely(error))
273 return error;
274 }
275
276 return 0; 269 return 0;
277} 270}
278 271
@@ -336,10 +329,6 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
336static const struct inode_operations hfsplus_file_inode_operations = { 329static const struct inode_operations hfsplus_file_inode_operations = {
337 .setattr = hfsplus_setattr, 330 .setattr = hfsplus_setattr,
338 .listxattr = hfsplus_listxattr, 331 .listxattr = hfsplus_listxattr,
339#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
340 .get_acl = hfsplus_get_posix_acl,
341 .set_acl = hfsplus_set_posix_acl,
342#endif
343}; 332};
344 333
345static const struct file_operations hfsplus_file_operations = { 334static const struct file_operations hfsplus_file_operations = {
diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c
deleted file mode 100644
index 066114dcc3a2..000000000000
--- a/fs/hfsplus/posix_acl.c
+++ /dev/null
@@ -1,144 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/hfsplus/posix_acl.c
4 *
5 * Vyacheslav Dubeyko <slava@dubeyko.com>
6 *
7 * Handler for Posix Access Control Lists (ACLs) support.
8 */
9
10#include "hfsplus_fs.h"
11#include "xattr.h"
12#include "acl.h"
13
14struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type)
15{
16 struct posix_acl *acl;
17 char *xattr_name;
18 char *value = NULL;
19 ssize_t size;
20
21 hfs_dbg(ACL_MOD, "[%s]: ino %lu\n", __func__, inode->i_ino);
22
23 switch (type) {
24 case ACL_TYPE_ACCESS:
25 xattr_name = XATTR_NAME_POSIX_ACL_ACCESS;
26 break;
27 case ACL_TYPE_DEFAULT:
28 xattr_name = XATTR_NAME_POSIX_ACL_DEFAULT;
29 break;
30 default:
31 return ERR_PTR(-EINVAL);
32 }
33
34 size = __hfsplus_getxattr(inode, xattr_name, NULL, 0);
35
36 if (size > 0) {
37 value = (char *)hfsplus_alloc_attr_entry();
38 if (unlikely(!value))
39 return ERR_PTR(-ENOMEM);
40 size = __hfsplus_getxattr(inode, xattr_name, value, size);
41 }
42
43 if (size > 0)
44 acl = posix_acl_from_xattr(&init_user_ns, value, size);
45 else if (size == -ENODATA)
46 acl = NULL;
47 else
48 acl = ERR_PTR(size);
49
50 hfsplus_destroy_attr_entry((hfsplus_attr_entry *)value);
51
52 return acl;
53}
54
55static int __hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
56 int type)
57{
58 int err;
59 char *xattr_name;
60 size_t size = 0;
61 char *value = NULL;
62
63 hfs_dbg(ACL_MOD, "[%s]: ino %lu\n", __func__, inode->i_ino);
64
65 switch (type) {
66 case ACL_TYPE_ACCESS:
67 xattr_name = XATTR_NAME_POSIX_ACL_ACCESS;
68 break;
69
70 case ACL_TYPE_DEFAULT:
71 xattr_name = XATTR_NAME_POSIX_ACL_DEFAULT;
72 if (!S_ISDIR(inode->i_mode))
73 return acl ? -EACCES : 0;
74 break;
75
76 default:
77 return -EINVAL;
78 }
79
80 if (acl) {
81 size = posix_acl_xattr_size(acl->a_count);
82 if (unlikely(size > HFSPLUS_MAX_INLINE_DATA_SIZE))
83 return -ENOMEM;
84 value = (char *)hfsplus_alloc_attr_entry();
85 if (unlikely(!value))
86 return -ENOMEM;
87 err = posix_acl_to_xattr(&init_user_ns, acl, value, size);
88 if (unlikely(err < 0))
89 goto end_set_acl;
90 }
91
92 err = __hfsplus_setxattr(inode, xattr_name, value, size, 0);
93
94end_set_acl:
95 hfsplus_destroy_attr_entry((hfsplus_attr_entry *)value);
96
97 if (!err)
98 set_cached_acl(inode, type, acl);
99
100 return err;
101}
102
103int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, int type)
104{
105 int err;
106
107 if (type == ACL_TYPE_ACCESS && acl) {
108 err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
109 if (err)
110 return err;
111 }
112 return __hfsplus_set_posix_acl(inode, acl, type);
113}
114
115int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
116{
117 int err = 0;
118 struct posix_acl *default_acl, *acl;
119
120 hfs_dbg(ACL_MOD,
121 "[%s]: ino %lu, dir->ino %lu\n",
122 __func__, inode->i_ino, dir->i_ino);
123
124 if (S_ISLNK(inode->i_mode))
125 return 0;
126
127 err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
128 if (err)
129 return err;
130
131 if (default_acl) {
132 err = __hfsplus_set_posix_acl(inode, default_acl,
133 ACL_TYPE_DEFAULT);
134 posix_acl_release(default_acl);
135 }
136
137 if (acl) {
138 if (!err)
139 err = __hfsplus_set_posix_acl(inode, acl,
140 ACL_TYPE_ACCESS);
141 posix_acl_release(acl);
142 }
143 return err;
144}
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 80abba550bfa..eb4535eba95d 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -564,8 +564,8 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
564 goto out_put_hidden_dir; 564 goto out_put_hidden_dir;
565 } 565 }
566 566
567 err = hfsplus_init_inode_security(sbi->hidden_dir, 567 err = hfsplus_init_security(sbi->hidden_dir,
568 root, &str); 568 root, &str);
569 if (err == -EOPNOTSUPP) 569 if (err == -EOPNOTSUPP)
570 err = 0; /* Operation is not supported. */ 570 err = 0; /* Operation is not supported. */
571 else if (err) { 571 else if (err) {
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index e538b758c448..d5403b4004c9 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -8,10 +8,8 @@
8 */ 8 */
9 9
10#include "hfsplus_fs.h" 10#include "hfsplus_fs.h"
11#include <linux/posix_acl_xattr.h>
12#include <linux/nls.h> 11#include <linux/nls.h>
13#include "xattr.h" 12#include "xattr.h"
14#include "acl.h"
15 13
16static int hfsplus_removexattr(struct inode *inode, const char *name); 14static int hfsplus_removexattr(struct inode *inode, const char *name);
17 15
@@ -19,10 +17,6 @@ const struct xattr_handler *hfsplus_xattr_handlers[] = {
19 &hfsplus_xattr_osx_handler, 17 &hfsplus_xattr_osx_handler,
20 &hfsplus_xattr_user_handler, 18 &hfsplus_xattr_user_handler,
21 &hfsplus_xattr_trusted_handler, 19 &hfsplus_xattr_trusted_handler,
22#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
23 &posix_acl_access_xattr_handler,
24 &posix_acl_default_xattr_handler,
25#endif
26 &hfsplus_xattr_security_handler, 20 &hfsplus_xattr_security_handler,
27 NULL 21 NULL
28}; 22};
diff --git a/fs/hfsplus/xattr.h b/fs/hfsplus/xattr.h
index a4e611d69710..d14e362b3eba 100644
--- a/fs/hfsplus/xattr.h
+++ b/fs/hfsplus/xattr.h
@@ -38,7 +38,4 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size);
38int hfsplus_init_security(struct inode *inode, struct inode *dir, 38int hfsplus_init_security(struct inode *inode, struct inode *dir,
39 const struct qstr *qstr); 39 const struct qstr *qstr);
40 40
41int hfsplus_init_inode_security(struct inode *inode, struct inode *dir,
42 const struct qstr *qstr);
43
44#endif 41#endif
diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c
index f5550b006e88..cfbe6a3bfb1e 100644
--- a/fs/hfsplus/xattr_security.c
+++ b/fs/hfsplus/xattr_security.c
@@ -12,7 +12,6 @@
12 12
13#include "hfsplus_fs.h" 13#include "hfsplus_fs.h"
14#include "xattr.h" 14#include "xattr.h"
15#include "acl.h"
16 15
17static int hfsplus_security_getxattr(const struct xattr_handler *handler, 16static int hfsplus_security_getxattr(const struct xattr_handler *handler,
18 struct dentry *unused, struct inode *inode, 17 struct dentry *unused, struct inode *inode,
@@ -72,18 +71,6 @@ int hfsplus_init_security(struct inode *inode, struct inode *dir,
72 &hfsplus_initxattrs, NULL); 71 &hfsplus_initxattrs, NULL);
73} 72}
74 73
75int hfsplus_init_inode_security(struct inode *inode,
76 struct inode *dir,
77 const struct qstr *qstr)
78{
79 int err;
80
81 err = hfsplus_init_posix_acl(inode, dir);
82 if (!err)
83 err = hfsplus_init_security(inode, dir, qstr);
84 return err;
85}
86
87const struct xattr_handler hfsplus_xattr_security_handler = { 74const struct xattr_handler hfsplus_xattr_security_handler = {
88 .prefix = XATTR_SECURITY_PREFIX, 75 .prefix = XATTR_SECURITY_PREFIX,
89 .get = hfsplus_security_getxattr, 76 .get = hfsplus_security_getxattr,