Skip to content

Commit 1729f7c

Browse files
committed
erofs: mark inodes without acls in erofs_read_inode()
Similar to commit 91ef18b ("ext4: mark inodes without acls in __ext4_iget()"), the ACL state won't be read when the file owner performs a lookup, and the RCU fast path for lookups won't work because the ACL state remains unknown. If there are no extended attributes, or if the xattr filter indicates that no ACL xattr is present, call cache_no_acl() directly. Reviewed-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent d86d781 commit 1729f7c

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

fs/erofs/inode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ static int erofs_read_inode(struct inode *inode)
137137
err = -EFSCORRUPTED;
138138
goto err_out;
139139
}
140+
141+
if (IS_ENABLED(CONFIG_EROFS_FS_POSIX_ACL) &&
142+
erofs_inode_has_noacl(inode, ptr, ofs))
143+
cache_no_acl(inode);
144+
140145
switch (inode->i_mode & S_IFMT) {
141146
case S_IFDIR:
142147
vi->dot_omitted = (ifmt >> EROFS_I_DOT_OMITTED_BIT) & 1;

fs/erofs/xattr.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,26 @@ struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu)
587587
kfree(value);
588588
return acl;
589589
}
590+
591+
bool erofs_inode_has_noacl(struct inode *inode, void *kaddr, unsigned int ofs)
592+
{
593+
static const unsigned int bitmask =
594+
BIT(21) | /* system.posix_acl_default */
595+
BIT(30); /* system.posix_acl_access */
596+
struct erofs_sb_info *sbi = EROFS_I_SB(inode);
597+
const struct erofs_xattr_ibody_header *ih = kaddr + ofs;
598+
599+
if (EROFS_I(inode)->xattr_isize < sizeof(*ih))
600+
return true;
601+
602+
if (erofs_sb_has_xattr_filter(sbi) && !sbi->xattr_filter_reserved &&
603+
!check_add_overflow(ofs, sizeof(*ih), &ofs) &&
604+
ofs <= i_blocksize(inode)) {
605+
if ((le32_to_cpu(ih->h_name_filter) & bitmask) == bitmask)
606+
return true;
607+
}
608+
return false;
609+
}
590610
#endif
591611

592612
#ifdef CONFIG_EROFS_FS_PAGE_CACHE_SHARE

fs/erofs/xattr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu);
3232

3333
int erofs_xattr_fill_inode_fingerprint(struct erofs_inode_fingerprint *fp,
3434
struct inode *inode, const char *domain_id);
35-
35+
bool erofs_inode_has_noacl(struct inode *inode, void *kaddr, unsigned int ofs);
3636
#endif

0 commit comments

Comments
 (0)