Skip to content

Commit b6151c4

Browse files
committed
Merge tag 'erofs-for-6.19-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
Pull erofs fix from Gao Xiang: - Don't increase s_stack_depth which caused regressions in some composefs mount setups (EROFS + ovl^2) Instead just allow one extra unaccounted fs stacking level for straightforward cases. * tag 'erofs-for-6.19-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs: erofs: don't bother with s_stack_depth increasing for now
2 parents cb2076b + 072a7c7 commit b6151c4

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

fs/erofs/super.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,14 +644,20 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
644644
* fs contexts (including its own) due to self-controlled RO
645645
* accesses/contexts and no side-effect changes that need to
646646
* context save & restore so it can reuse the current thread
647-
* context. However, it still needs to bump `s_stack_depth` to
648-
* avoid kernel stack overflow from nested filesystems.
647+
* context.
648+
* However, we still need to prevent kernel stack overflow due
649+
* to filesystem nesting: just ensure that s_stack_depth is 0
650+
* to disallow mounting EROFS on stacked filesystems.
651+
* Note: s_stack_depth is not incremented here for now, since
652+
* EROFS is the only fs supporting file-backed mounts for now.
653+
* It MUST change if another fs plans to support them, which
654+
* may also require adjusting FILESYSTEM_MAX_STACK_DEPTH.
649655
*/
650656
if (erofs_is_fileio_mode(sbi)) {
651-
sb->s_stack_depth =
652-
file_inode(sbi->dif0.file)->i_sb->s_stack_depth + 1;
653-
if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
654-
erofs_err(sb, "maximum fs stacking depth exceeded");
657+
inode = file_inode(sbi->dif0.file);
658+
if ((inode->i_sb->s_op == &erofs_sops && !sb->s_bdev) ||
659+
inode->i_sb->s_stack_depth) {
660+
erofs_err(sb, "file-backed mounts cannot be applied to stacked fses");
655661
return -ENOTBLK;
656662
}
657663
}

0 commit comments

Comments
 (0)