Skip to content

Commit 7bcff5a

Browse files
committed
Merge tag 'v6.4/vfs.acl' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull acl updates from Christian Brauner: "After finishing the introduction of the new posix acl api last cycle the generic POSIX ACL xattr handlers are still around in the filesystems xattr handlers for two reasons: (1) Because a few filesystems rely on the ->list() method of the generic POSIX ACL xattr handlers in their ->listxattr() inode operation. (2) POSIX ACLs are only available if IOP_XATTR is raised. The IOP_XATTR flag is raised in inode_init_always() based on whether the sb->s_xattr pointer is non-NULL. IOW, the registered xattr handlers of the filesystem are used to raise IOP_XATTR. Removing the generic POSIX ACL xattr handlers from all filesystems would risk regressing filesystems that only implement POSIX ACL support and no other xattrs (nfs3 comes to mind). This contains the work to decouple POSIX ACLs from the IOP_XATTR flag as they don't depend on xattr handlers anymore. So it's now possible to remove the generic POSIX ACL xattr handlers from the sb->s_xattr list of all filesystems. This is a crucial step as the generic POSIX ACL xattr handlers aren't used for POSIX ACLs anymore and POSIX ACLs don't depend on the xattr infrastructure anymore. Adressing problem (1) will require more long-term work. It would be best to get rid of the ->list() method of xattr handlers completely at some point. For erofs, ext{2,4}, f2fs, jffs2, ocfs2, and reiserfs the nop POSIX ACL xattr handler is kept around so they can continue to use array-based xattr handler indexing. This update does simplify the ->listxattr() implementation of all these filesystems however" * tag 'v6.4/vfs.acl' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: acl: don't depend on IOP_XATTR ovl: check for ->listxattr() support reiserfs: rework priv inode handling fs: rename generic posix acl handlers reiserfs: rework ->listxattr() implementation fs: simplify ->listxattr() implementation fs: drop unused posix acl handlers xattr: remove unused argument xattr: add listxattr helper xattr: simplify listxattr helpers
2 parents ec40758 + e499214 commit 7bcff5a

34 files changed

Lines changed: 292 additions & 257 deletions

File tree

fs/9p/xattr.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,6 @@ static struct xattr_handler v9fs_xattr_security_handler = {
185185
const struct xattr_handler *v9fs_xattr_handlers[] = {
186186
&v9fs_xattr_user_handler,
187187
&v9fs_xattr_trusted_handler,
188-
#ifdef CONFIG_FS_POSIX_ACL
189-
&posix_acl_access_xattr_handler,
190-
&posix_acl_default_xattr_handler,
191-
#endif
192188
#ifdef CONFIG_9P_FS_SECURITY
193189
&v9fs_xattr_security_handler,
194190
#endif

fs/btrfs/xattr.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,6 @@ static const struct xattr_handler btrfs_btrfs_xattr_handler = {
444444

445445
const struct xattr_handler *btrfs_xattr_handlers[] = {
446446
&btrfs_security_xattr_handler,
447-
#ifdef CONFIG_BTRFS_FS_POSIX_ACL
448-
&posix_acl_access_xattr_handler,
449-
&posix_acl_default_xattr_handler,
450-
#endif
451447
&btrfs_trusted_xattr_handler,
452448
&btrfs_user_xattr_handler,
453449
&btrfs_btrfs_xattr_handler,

fs/ceph/xattr.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,10 +1411,6 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx)
14111411
* attributes are handled directly.
14121412
*/
14131413
const struct xattr_handler *ceph_xattr_handlers[] = {
1414-
#ifdef CONFIG_CEPH_FS_POSIX_ACL
1415-
&posix_acl_access_xattr_handler,
1416-
&posix_acl_default_xattr_handler,
1417-
#endif
14181414
&ceph_other_xattr_handler,
14191415
NULL,
14201416
};

fs/cifs/xattr.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,5 @@ const struct xattr_handler *cifs_xattr_handlers[] = {
487487
&smb3_ntsd_xattr_handler, /* alias for above since avoiding "cifs" */
488488
&cifs_cifs_ntsd_full_xattr_handler,
489489
&smb3_ntsd_full_xattr_handler, /* alias for above since avoiding "cifs" */
490-
#ifdef CONFIG_FS_POSIX_ACL
491-
&posix_acl_access_xattr_handler,
492-
&posix_acl_default_xattr_handler,
493-
#endif
494490
NULL
495491
};

fs/ecryptfs/inode.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,10 +1210,6 @@ static const struct xattr_handler ecryptfs_xattr_handler = {
12101210
};
12111211

12121212
const struct xattr_handler *ecryptfs_xattr_handlers[] = {
1213-
#ifdef CONFIG_FS_POSIX_ACL
1214-
&posix_acl_access_xattr_handler,
1215-
&posix_acl_default_xattr_handler,
1216-
#endif
12171213
&ecryptfs_xattr_handler,
12181214
NULL
12191215
};

fs/erofs/xattr.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,6 @@ const struct xattr_handler __maybe_unused erofs_xattr_security_handler = {
463463

464464
const struct xattr_handler *erofs_xattr_handlers[] = {
465465
&erofs_xattr_user_handler,
466-
#ifdef CONFIG_EROFS_FS_POSIX_ACL
467-
&posix_acl_access_xattr_handler,
468-
&posix_acl_default_xattr_handler,
469-
#endif
470466
&erofs_xattr_trusted_handler,
471467
#ifdef CONFIG_EROFS_FS_SECURITY
472468
&erofs_xattr_security_handler,
@@ -490,13 +486,9 @@ static int xattr_entrylist(struct xattr_iter *_it,
490486
unsigned int prefix_len;
491487
const char *prefix;
492488

493-
const struct xattr_handler *h =
494-
erofs_xattr_handler(entry->e_name_index);
495-
496-
if (!h || (h->list && !h->list(it->dentry)))
489+
prefix = erofs_xattr_prefix(entry->e_name_index, it->dentry);
490+
if (!prefix)
497491
return 1;
498-
499-
prefix = xattr_prefix(h);
500492
prefix_len = strlen(prefix);
501493

502494
if (!it->buffer) {

fs/erofs/xattr.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,30 @@ extern const struct xattr_handler erofs_xattr_user_handler;
4141
extern const struct xattr_handler erofs_xattr_trusted_handler;
4242
extern const struct xattr_handler erofs_xattr_security_handler;
4343

44-
static inline const struct xattr_handler *erofs_xattr_handler(unsigned int idx)
44+
static inline const char *erofs_xattr_prefix(unsigned int idx,
45+
struct dentry *dentry)
4546
{
47+
const struct xattr_handler *handler = NULL;
48+
4649
static const struct xattr_handler *xattr_handler_map[] = {
4750
[EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler,
4851
#ifdef CONFIG_EROFS_FS_POSIX_ACL
49-
[EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] =
50-
&posix_acl_access_xattr_handler,
51-
[EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] =
52-
&posix_acl_default_xattr_handler,
52+
[EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
53+
[EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &nop_posix_acl_default,
5354
#endif
5455
[EROFS_XATTR_INDEX_TRUSTED] = &erofs_xattr_trusted_handler,
5556
#ifdef CONFIG_EROFS_FS_SECURITY
5657
[EROFS_XATTR_INDEX_SECURITY] = &erofs_xattr_security_handler,
5758
#endif
5859
};
5960

60-
return idx && idx < ARRAY_SIZE(xattr_handler_map) ?
61-
xattr_handler_map[idx] : NULL;
61+
if (idx && idx < ARRAY_SIZE(xattr_handler_map))
62+
handler = xattr_handler_map[idx];
63+
64+
if (!xattr_handler_can_list(handler, dentry))
65+
return NULL;
66+
67+
return xattr_prefix(handler);
6268
}
6369

6470
extern const struct xattr_handler *erofs_xattr_handlers[];

fs/ext2/xattr.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ static void ext2_xattr_rehash(struct ext2_xattr_header *,
101101
static const struct xattr_handler *ext2_xattr_handler_map[] = {
102102
[EXT2_XATTR_INDEX_USER] = &ext2_xattr_user_handler,
103103
#ifdef CONFIG_EXT2_FS_POSIX_ACL
104-
[EXT2_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler,
105-
[EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
104+
[EXT2_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
105+
[EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &nop_posix_acl_default,
106106
#endif
107107
[EXT2_XATTR_INDEX_TRUSTED] = &ext2_xattr_trusted_handler,
108108
#ifdef CONFIG_EXT2_FS_SECURITY
@@ -113,10 +113,6 @@ static const struct xattr_handler *ext2_xattr_handler_map[] = {
113113
const struct xattr_handler *ext2_xattr_handlers[] = {
114114
&ext2_xattr_user_handler,
115115
&ext2_xattr_trusted_handler,
116-
#ifdef CONFIG_EXT2_FS_POSIX_ACL
117-
&posix_acl_access_xattr_handler,
118-
&posix_acl_default_xattr_handler,
119-
#endif
120116
#ifdef CONFIG_EXT2_FS_SECURITY
121117
&ext2_xattr_security_handler,
122118
#endif
@@ -125,14 +121,18 @@ const struct xattr_handler *ext2_xattr_handlers[] = {
125121

126122
#define EA_BLOCK_CACHE(inode) (EXT2_SB(inode->i_sb)->s_ea_block_cache)
127123

128-
static inline const struct xattr_handler *
129-
ext2_xattr_handler(int name_index)
124+
static inline const char *ext2_xattr_prefix(int name_index,
125+
struct dentry *dentry)
130126
{
131127
const struct xattr_handler *handler = NULL;
132128

133129
if (name_index > 0 && name_index < ARRAY_SIZE(ext2_xattr_handler_map))
134130
handler = ext2_xattr_handler_map[name_index];
135-
return handler;
131+
132+
if (!xattr_handler_can_list(handler, dentry))
133+
return NULL;
134+
135+
return xattr_prefix(handler);
136136
}
137137

138138
static bool
@@ -333,11 +333,10 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
333333
/* list the attribute names */
334334
for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry);
335335
entry = EXT2_XATTR_NEXT(entry)) {
336-
const struct xattr_handler *handler =
337-
ext2_xattr_handler(entry->e_name_index);
336+
const char *prefix;
338337

339-
if (handler && (!handler->list || handler->list(dentry))) {
340-
const char *prefix = handler->prefix ?: handler->name;
338+
prefix = ext2_xattr_prefix(entry->e_name_index, dentry);
339+
if (prefix) {
341340
size_t prefix_len = strlen(prefix);
342341
size_t size = prefix_len + entry->e_name_len + 1;
343342

fs/ext4/xattr.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ static void ext4_xattr_rehash(struct ext4_xattr_header *);
8888
static const struct xattr_handler * const ext4_xattr_handler_map[] = {
8989
[EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler,
9090
#ifdef CONFIG_EXT4_FS_POSIX_ACL
91-
[EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler,
92-
[EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
91+
[EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
92+
[EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &nop_posix_acl_default,
9393
#endif
9494
[EXT4_XATTR_INDEX_TRUSTED] = &ext4_xattr_trusted_handler,
9595
#ifdef CONFIG_EXT4_FS_SECURITY
@@ -101,10 +101,6 @@ static const struct xattr_handler * const ext4_xattr_handler_map[] = {
101101
const struct xattr_handler *ext4_xattr_handlers[] = {
102102
&ext4_xattr_user_handler,
103103
&ext4_xattr_trusted_handler,
104-
#ifdef CONFIG_EXT4_FS_POSIX_ACL
105-
&posix_acl_access_xattr_handler,
106-
&posix_acl_default_xattr_handler,
107-
#endif
108104
#ifdef CONFIG_EXT4_FS_SECURITY
109105
&ext4_xattr_security_handler,
110106
#endif
@@ -173,14 +169,18 @@ static void ext4_xattr_block_csum_set(struct inode *inode,
173169
bh->b_blocknr, BHDR(bh));
174170
}
175171

176-
static inline const struct xattr_handler *
177-
ext4_xattr_handler(int name_index)
172+
static inline const char *ext4_xattr_prefix(int name_index,
173+
struct dentry *dentry)
178174
{
179175
const struct xattr_handler *handler = NULL;
180176

181177
if (name_index > 0 && name_index < ARRAY_SIZE(ext4_xattr_handler_map))
182178
handler = ext4_xattr_handler_map[name_index];
183-
return handler;
179+
180+
if (!xattr_handler_can_list(handler, dentry))
181+
return NULL;
182+
183+
return xattr_prefix(handler);
184184
}
185185

186186
static int
@@ -740,11 +740,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
740740
size_t rest = buffer_size;
741741

742742
for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
743-
const struct xattr_handler *handler =
744-
ext4_xattr_handler(entry->e_name_index);
743+
const char *prefix;
745744

746-
if (handler && (!handler->list || handler->list(dentry))) {
747-
const char *prefix = handler->prefix ?: handler->name;
745+
prefix = ext4_xattr_prefix(entry->e_name_index, dentry);
746+
if (prefix) {
748747
size_t prefix_len = strlen(prefix);
749748
size_t size = prefix_len + entry->e_name_len + 1;
750749

fs/f2fs/xattr.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ const struct xattr_handler f2fs_xattr_security_handler = {
192192
static const struct xattr_handler *f2fs_xattr_handler_map[] = {
193193
[F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler,
194194
#ifdef CONFIG_F2FS_FS_POSIX_ACL
195-
[F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler,
196-
[F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
195+
[F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
196+
[F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &nop_posix_acl_default,
197197
#endif
198198
[F2FS_XATTR_INDEX_TRUSTED] = &f2fs_xattr_trusted_handler,
199199
#ifdef CONFIG_F2FS_FS_SECURITY
@@ -204,10 +204,6 @@ static const struct xattr_handler *f2fs_xattr_handler_map[] = {
204204

205205
const struct xattr_handler *f2fs_xattr_handlers[] = {
206206
&f2fs_xattr_user_handler,
207-
#ifdef CONFIG_F2FS_FS_POSIX_ACL
208-
&posix_acl_access_xattr_handler,
209-
&posix_acl_default_xattr_handler,
210-
#endif
211207
&f2fs_xattr_trusted_handler,
212208
#ifdef CONFIG_F2FS_FS_SECURITY
213209
&f2fs_xattr_security_handler,
@@ -216,13 +212,18 @@ const struct xattr_handler *f2fs_xattr_handlers[] = {
216212
NULL,
217213
};
218214

219-
static inline const struct xattr_handler *f2fs_xattr_handler(int index)
215+
static inline const char *f2fs_xattr_prefix(int index,
216+
struct dentry *dentry)
220217
{
221218
const struct xattr_handler *handler = NULL;
222219

223220
if (index > 0 && index < ARRAY_SIZE(f2fs_xattr_handler_map))
224221
handler = f2fs_xattr_handler_map[index];
225-
return handler;
222+
223+
if (!xattr_handler_can_list(handler, dentry))
224+
return NULL;
225+
226+
return xattr_prefix(handler);
226227
}
227228

228229
static struct f2fs_xattr_entry *__find_xattr(void *base_addr,
@@ -573,12 +574,12 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
573574
last_base_addr = (void *)base_addr + XATTR_SIZE(inode);
574575

575576
list_for_each_xattr(entry, base_addr) {
576-
const struct xattr_handler *handler =
577-
f2fs_xattr_handler(entry->e_name_index);
578577
const char *prefix;
579578
size_t prefix_len;
580579
size_t size;
581580

581+
prefix = f2fs_xattr_prefix(entry->e_name_index, dentry);
582+
582583
if ((void *)(entry) + sizeof(__u32) > last_base_addr ||
583584
(void *)XATTR_NEXT_ENTRY(entry) > last_base_addr) {
584585
f2fs_err(F2FS_I_SB(inode), "inode (%lu) has corrupted xattr",
@@ -590,10 +591,9 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
590591
goto cleanup;
591592
}
592593

593-
if (!handler || (handler->list && !handler->list(dentry)))
594+
if (!prefix)
594595
continue;
595596

596-
prefix = xattr_prefix(handler);
597597
prefix_len = strlen(prefix);
598598
size = prefix_len + entry->e_name_len + 1;
599599
if (buffer) {

0 commit comments

Comments
 (0)