Skip to content

Commit cac2f8b

Browse files
committed
fs: rename current get acl method
The current way of setting and getting posix acls through the generic xattr interface is error prone and type unsafe. The vfs needs to interpret and fixup posix acls before storing or reporting it to userspace. Various hacks exist to make this work. The code is hard to understand and difficult to maintain in it's current form. Instead of making this work by hacking posix acls through xattr handlers we are building a dedicated posix acl api around the get and set inode operations. This removes a lot of hackiness and makes the codepaths easier to maintain. A lot of background can be found in [1]. The current inode operation for getting posix acls takes an inode argument but various filesystems (e.g., 9p, cifs, overlayfs) need access to the dentry. In contrast to the ->set_acl() inode operation we cannot simply extend ->get_acl() to take a dentry argument. The ->get_acl() inode operation is called from: acl_permission_check() -> check_acl() -> get_acl() which is part of generic_permission() which in turn is part of inode_permission(). Both generic_permission() and inode_permission() are called in the ->permission() handler of various filesystems (e.g., overlayfs). So simply passing a dentry argument to ->get_acl() would amount to also having to pass a dentry argument to ->permission(). We should avoid this unnecessary change. So instead of extending the existing inode operation rename it from ->get_acl() to ->get_inode_acl() and add a ->get_acl() method later that passes a dentry argument and which filesystems that need access to the dentry can implement instead of ->get_inode_acl(). Filesystems like cifs which allow setting and getting posix acls but not using them for permission checking during lookup can simply not implement ->get_inode_acl(). This is intended to be a non-functional change. Link: https://lore.kernel.org/all/[email protected] [1] Suggested-by/Inspired-by: Christoph Hellwig <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Christian Brauner (Microsoft) <[email protected]>
1 parent 138060b commit cac2f8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+101
-100
lines changed

Documentation/filesystems/locking.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ prototypes::
7070
const char *(*get_link) (struct dentry *, struct inode *, struct delayed_call *);
7171
void (*truncate) (struct inode *);
7272
int (*permission) (struct inode *, int, unsigned int);
73-
struct posix_acl * (*get_acl)(struct inode *, int, bool);
73+
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
7474
int (*setattr) (struct dentry *, struct iattr *);
7575
int (*getattr) (const struct path *, struct kstat *, u32, unsigned int);
7676
ssize_t (*listxattr) (struct dentry *, char *, size_t);
@@ -88,9 +88,9 @@ prototypes::
8888
locking rules:
8989
all may block
9090

91-
============= =============================================
91+
============== =============================================
9292
ops i_rwsem(inode)
93-
============= =============================================
93+
============== =============================================
9494
lookup: shared
9595
create: exclusive
9696
link: exclusive (both)
@@ -104,7 +104,7 @@ readlink: no
104104
get_link: no
105105
setattr: exclusive
106106
permission: no (may not block if called in rcu-walk mode)
107-
get_acl: no
107+
get_inode_acl: no
108108
getattr: no
109109
listxattr: no
110110
fiemap: no
@@ -113,7 +113,7 @@ atomic_open: shared (exclusive if O_CREAT is set in open flags)
113113
tmpfile: no
114114
fileattr_get: no or exclusive
115115
fileattr_set: exclusive
116-
============= =============================================
116+
============== =============================================
117117

118118

119119
Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_rwsem

Documentation/filesystems/porting.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ ERR_PTR(...).
462462
argument; instead of passing IPERM_FLAG_RCU we add MAY_NOT_BLOCK into mask.
463463

464464
generic_permission() has also lost the check_acl argument; ACL checking
465-
has been taken to VFS and filesystems need to provide a non-NULL ->i_op->get_acl
466-
to read an ACL from disk.
465+
has been taken to VFS and filesystems need to provide a non-NULL
466+
->i_op->get_inode_acl to read an ACL from disk.
467467

468468
---
469469

Documentation/filesystems/vfs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ As of kernel 2.6.22, the following members are defined:
435435
const char *(*get_link) (struct dentry *, struct inode *,
436436
struct delayed_call *);
437437
int (*permission) (struct user_namespace *, struct inode *, int);
438-
struct posix_acl * (*get_acl)(struct inode *, int, bool);
438+
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
439439
int (*setattr) (struct user_namespace *, struct dentry *, struct iattr *);
440440
int (*getattr) (struct user_namespace *, const struct path *, struct kstat *, u32, unsigned int);
441441
ssize_t (*listxattr) (struct dentry *, char *, size_t);

fs/9p/vfs_inode_dotl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,14 +983,14 @@ const struct inode_operations v9fs_dir_inode_operations_dotl = {
983983
.getattr = v9fs_vfs_getattr_dotl,
984984
.setattr = v9fs_vfs_setattr_dotl,
985985
.listxattr = v9fs_listxattr,
986-
.get_acl = v9fs_iop_get_acl,
986+
.get_inode_acl = v9fs_iop_get_acl,
987987
};
988988

989989
const struct inode_operations v9fs_file_inode_operations_dotl = {
990990
.getattr = v9fs_vfs_getattr_dotl,
991991
.setattr = v9fs_vfs_setattr_dotl,
992992
.listxattr = v9fs_listxattr,
993-
.get_acl = v9fs_iop_get_acl,
993+
.get_inode_acl = v9fs_iop_get_acl,
994994
};
995995

996996
const struct inode_operations v9fs_symlink_inode_operations_dotl = {

fs/bad_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static const struct inode_operations bad_inode_ops =
177177
.setattr = bad_inode_setattr,
178178
.listxattr = bad_inode_listxattr,
179179
.get_link = bad_inode_get_link,
180-
.get_acl = bad_inode_get_acl,
180+
.get_inode_acl = bad_inode_get_acl,
181181
.fiemap = bad_inode_fiemap,
182182
.update_time = bad_inode_update_time,
183183
.atomic_open = bad_inode_atomic_open,

fs/btrfs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11288,7 +11288,7 @@ static const struct inode_operations btrfs_dir_inode_operations = {
1128811288
.mknod = btrfs_mknod,
1128911289
.listxattr = btrfs_listxattr,
1129011290
.permission = btrfs_permission,
11291-
.get_acl = btrfs_get_acl,
11291+
.get_inode_acl = btrfs_get_acl,
1129211292
.set_acl = btrfs_set_acl,
1129311293
.update_time = btrfs_update_time,
1129411294
.tmpfile = btrfs_tmpfile,
@@ -11341,7 +11341,7 @@ static const struct inode_operations btrfs_file_inode_operations = {
1134111341
.listxattr = btrfs_listxattr,
1134211342
.permission = btrfs_permission,
1134311343
.fiemap = btrfs_fiemap,
11344-
.get_acl = btrfs_get_acl,
11344+
.get_inode_acl = btrfs_get_acl,
1134511345
.set_acl = btrfs_set_acl,
1134611346
.update_time = btrfs_update_time,
1134711347
.fileattr_get = btrfs_fileattr_get,
@@ -11352,7 +11352,7 @@ static const struct inode_operations btrfs_special_inode_operations = {
1135211352
.setattr = btrfs_setattr,
1135311353
.permission = btrfs_permission,
1135411354
.listxattr = btrfs_listxattr,
11355-
.get_acl = btrfs_get_acl,
11355+
.get_inode_acl = btrfs_get_acl,
1135611356
.set_acl = btrfs_set_acl,
1135711357
.update_time = btrfs_update_time,
1135811358
};

fs/ceph/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ const struct inode_operations ceph_dir_iops = {
20332033
.getattr = ceph_getattr,
20342034
.setattr = ceph_setattr,
20352035
.listxattr = ceph_listxattr,
2036-
.get_acl = ceph_get_acl,
2036+
.get_inode_acl = ceph_get_acl,
20372037
.set_acl = ceph_set_acl,
20382038
.mknod = ceph_mknod,
20392039
.symlink = ceph_symlink,

fs/ceph/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const struct inode_operations ceph_file_iops = {
126126
.setattr = ceph_setattr,
127127
.getattr = ceph_getattr,
128128
.listxattr = ceph_listxattr,
129-
.get_acl = ceph_get_acl,
129+
.get_inode_acl = ceph_get_acl,
130130
.set_acl = ceph_set_acl,
131131
};
132132

fs/erofs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,20 +371,20 @@ int erofs_getattr(struct user_namespace *mnt_userns, const struct path *path,
371371
const struct inode_operations erofs_generic_iops = {
372372
.getattr = erofs_getattr,
373373
.listxattr = erofs_listxattr,
374-
.get_acl = erofs_get_acl,
374+
.get_inode_acl = erofs_get_acl,
375375
.fiemap = erofs_fiemap,
376376
};
377377

378378
const struct inode_operations erofs_symlink_iops = {
379379
.get_link = page_get_link,
380380
.getattr = erofs_getattr,
381381
.listxattr = erofs_listxattr,
382-
.get_acl = erofs_get_acl,
382+
.get_inode_acl = erofs_get_acl,
383383
};
384384

385385
const struct inode_operations erofs_fast_symlink_iops = {
386386
.get_link = simple_get_link,
387387
.getattr = erofs_getattr,
388388
.listxattr = erofs_listxattr,
389-
.get_acl = erofs_get_acl,
389+
.get_inode_acl = erofs_get_acl,
390390
};

fs/erofs/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,6 @@ const struct inode_operations erofs_dir_iops = {
228228
.lookup = erofs_lookup,
229229
.getattr = erofs_getattr,
230230
.listxattr = erofs_listxattr,
231-
.get_acl = erofs_get_acl,
231+
.get_inode_acl = erofs_get_acl,
232232
.fiemap = erofs_fiemap,
233233
};

0 commit comments

Comments
 (0)