Re: SYZKALLER BUG: messing with a mounted file system via loop ioctls (was: Re: [PATCH] ext4: add bounds check in ext4_xattr_ibody_get() to) prevent out-of-bounds access

From: Deepanshu Kartikey

Date: Mon Mar 30 2026 - 00:48:01 EST


On Sun, Mar 29, 2026 at 7:18 PM Theodore Tso <tytso@xxxxxxx> wrote:
>
> The fix is something like:
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 0000913f7efc..c1d17e2bbd0c 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1238,6 +1238,16 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
> err = -ENXIO;
> goto out_unlock;
> }
> +#ifndef CONFIG_BLK_DEV_WRITE_MOUNTED)
> + /*
> + * bdev_writes_blocked is a static function defiend in
> + * block/bdev.c, so this won't work as-is.
> + */
> + if (bdev_writes_blocked(lo->lo_device)) {
> + err = -EBUSY;
> + goto out_unlock;
> + }
> +#endif
>
> if (lo->lo_offset != info->lo_offset ||
> lo->lo_sizelimit != info->lo_sizelimit) {
>
> Turning this into a real patch that exports bdev_writes_blocked() is
> left as an exercise to the reader.
>
> - Ted

I have sent the patch

Thanks

Deepanshu