Commit b6151c4e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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
parents cb2076b0 072a7c7c
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -644,14 +644,20 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
		 * fs contexts (including its own) due to self-controlled RO
		 * accesses/contexts and no side-effect changes that need to
		 * context save & restore so it can reuse the current thread
		 * context.  However, it still needs to bump `s_stack_depth` to
		 * avoid kernel stack overflow from nested filesystems.
		 * context.
		 * However, we still need to prevent kernel stack overflow due
		 * to filesystem nesting: just ensure that s_stack_depth is 0
		 * to disallow mounting EROFS on stacked filesystems.
		 * Note: s_stack_depth is not incremented here for now, since
		 * EROFS is the only fs supporting file-backed mounts for now.
		 * It MUST change if another fs plans to support them, which
		 * may also require adjusting FILESYSTEM_MAX_STACK_DEPTH.
		 */
		if (erofs_is_fileio_mode(sbi)) {
			sb->s_stack_depth =
				file_inode(sbi->dif0.file)->i_sb->s_stack_depth + 1;
			if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
				erofs_err(sb, "maximum fs stacking depth exceeded");
			inode = file_inode(sbi->dif0.file);
			if ((inode->i_sb->s_op == &erofs_sops && !sb->s_bdev) ||
			    inode->i_sb->s_stack_depth) {
				erofs_err(sb, "file-backed mounts cannot be applied to stacked fses");
				return -ENOTBLK;
			}
		}