* [PATCH] erofs: apply the stacked fs check to extra file-backed devices
@ 2026-10-30 3:52 Daejun Park via B4 Relay
2026-11-02 12:01 ` Gao Xiang
0 siblings, 1 reply; 2+ messages in thread
From: Daejun Park via B4 Relay @ 2026-10-30 3:52 UTC (permalink / raw)
To: Gao Xiang, Chao Yu
Cc: Yue Hu, Jingbo Xu, Sandeep Dhavale, Hongbo Li, Chunhai Guo,
linux-erofs, linux-kernel, Daejun Park
From: Daejun Park <daejun7.park@samsung.com>
erofs_fc_fill_super() rejects a file-backed mount whose image is on a
file-backed EROFS or on a filesystem with s_stack_depth set. This
bounds the nesting of reads. Extra devices given by device= are not
checked. File-backed mounts can still nest through them without limit.
Apply the same check to extra devices.
Fixes: fb176750266a ("erofs: add file-backed mount support")
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
---
Tested on erofs dev in a QEMU guest with KASAN and lockdep:
- Blobs on a file-backed EROFS or overlayfs now get -EINVAL.
- Blobs on XFS or a loop-mounted EROFS still mount and read back.
- Lockdep warns about devs->rwsem vs i_rwsem for a device= path inside
an EROFS mount, with or without this patch.
---
| 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
--git a/fs/erofs/super.c b/fs/erofs/super.c
index ce05557bd9..ee01a5ef85 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -122,6 +122,14 @@ void *erofs_read_metadata(struct super_block *sb, struct erofs_buf *buf,
return buffer;
}
+/* see the comment in erofs_fc_fill_super() */
+static bool erofs_is_stacked_file(struct file *file)
+{
+ struct super_block *sb = file_inode(file)->i_sb;
+
+ return (sb->s_op == &erofs_sops && !sb->s_bdev) || sb->s_stack_depth;
+}
+
static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
struct erofs_device_info *dif, erofs_off_t *pos)
{
@@ -161,6 +169,11 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
} else if (!S_ISREG(file_inode(file)->i_mode)) {
fput(file);
return -EINVAL;
+ } else if (erofs_is_stacked_file(file)) {
+ erofs_err(sb, "%s: file-backed devices cannot be on stacked fses",
+ dif->path);
+ fput(file);
+ return -EINVAL;
}
if (!dif->dax_dev && test_opt(&sbi->opt, DAX_ALWAYS)) {
erofs_info(sb, "DAX unsupported by %s. Turning off DAX.",
@@ -701,9 +714,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
* It MUST change if another fs plans to support them, which
* may also require adjusting FILESYSTEM_MAX_STACK_DEPTH.
*/
- inode = file_inode(sbi->dif0.file);
- if ((inode->i_sb->s_op == &erofs_sops &&
- !inode->i_sb->s_bdev) || inode->i_sb->s_stack_depth) {
+ if (erofs_is_stacked_file(sbi->dif0.file)) {
erofs_err(sb, "file-backed mounts cannot be applied to stacked fses");
return -ENOTBLK;
}
---
base-commit: 209108a5456171ab430e25b54b2dfe083455bfb6
change-id: 20261028-erofs-stacked-extra-devices-d7a141da0133
Best regards,
--
Daejun Park <daejun7.park@samsung.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] erofs: apply the stacked fs check to extra file-backed devices
2026-10-30 3:52 [PATCH] erofs: apply the stacked fs check to extra file-backed devices Daejun Park via B4 Relay
@ 2026-11-02 12:01 ` Gao Xiang
0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2026-11-02 12:01 UTC (permalink / raw)
To: daejun7.park
Cc: Gao Xiang, Chao Yu, Yue Hu, Jingbo Xu, Sandeep Dhavale,
Hongbo Li, Chunhai Guo, linux-erofs, linux-kernel
On Fri, Oct 30, 2026 at 12:52:44PM +0900, Daejun Park via B4 Relay wrote:
> From: Daejun Park <daejun7.park@samsung.com>
>
> erofs_fc_fill_super() rejects a file-backed mount whose image is on a
> file-backed EROFS or on a filesystem with s_stack_depth set. This
> bounds the nesting of reads. Extra devices given by device= are not
> checked. File-backed mounts can still nest through them without limit.
>
> Apply the same check to extra devices.
>
> Fixes: fb176750266a ("erofs: add file-backed mount support")
> Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Gao Xiang <xiang@kernel.org>
> ---
> Tested on erofs dev in a QEMU guest with KASAN and lockdep:
>
> - Blobs on a file-backed EROFS or overlayfs now get -EINVAL.
>
> - Blobs on XFS or a loop-mounted EROFS still mount and read back.
>
> - Lockdep warns about devs->rwsem vs i_rwsem for a device= path inside
> an EROFS mount, with or without this patch.
What does that mean? Can you explain more about this lockdep issue?
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-02 12:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 3:52 [PATCH] erofs: apply the stacked fs check to extra file-backed devices Daejun Park via B4 Relay
2026-11-02 12:01 ` Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®