From: Christoph Hellwig <hch@infradead.org>
To: Deepanshu Kartikey <kartikey406@gmail.com>
Cc: axboe@kernel.dk, tytso@mit.edu, hch@infradead.org,
dvyukov@google.com, adilger.kernel@dilger.ca,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+fb32afec111a7d61b939@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] loop: block changing lo_offset/lo_sizelimit on mounted device
Date: Tue, 31 Mar 2026 00:22:18 -0700 [thread overview]
Message-ID: <act2Kh8u2I5HPVlv@infradead.org> (raw)
In-Reply-To: <20260331054648.4548-1-kartikey406@gmail.com>
On Tue, Mar 31, 2026 at 11:16:48AM +0530, Deepanshu Kartikey wrote:
> LOOP_SET_STATUS{64} allows changing lo_offset and shrinking
> lo_sizelimit while a filesystem is mounted on the loop device.
> This effectively mutates the data visible to the mounted filesystem,
> which is equivalent to writing directly to the block device.
>
> When CONFIG_BLK_DEV_WRITE_MOUNTED is disabled, direct writes to a
> mounted block device are blocked. However, LOOP_SET_STATUS{64}
> bypasses this protection because it modifies the loop configuration
> through an ioctl rather than opening the block device for writing.
>
> Fix this by checking bdev_writes_blocked() before allowing changes
> to lo_offset or shrinking lo_sizelimit. If the loop device has
> writes blocked, return -EBUSY. Increasing lo_sizelimit is still
> allowed since growing the device is harmless and has legitimate
> use cases such as online resize.
>
> Move bdev_writes_blocked() from block/bdev.c to
> include/linux/blk_types.h as a static inline function so it can
> be used from the loop driver without exporting a symbol.
I still think this is a very bad idea for the reasons explained before.
And I would not be surprised if this breaks something in blktests or
xfstests as they heavily rely on resizing block devices. Did you
do full runs of those? Especially with xfs and btrfs for xfstests
as they do a lot more loop based tests?
next prev parent reply other threads:[~2026-03-31 7:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 5:46 [PATCH v2] loop: block changing lo_offset/lo_sizelimit on mounted device Deepanshu Kartikey
2026-03-31 7:22 ` Christoph Hellwig [this message]
2026-03-31 12:24 ` Theodore Tso
2026-03-31 15:02 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=act2Kh8u2I5HPVlv@infradead.org \
--to=hch@infradead.org \
--cc=adilger.kernel@dilger.ca \
--cc=axboe@kernel.dk \
--cc=dvyukov@google.com \
--cc=kartikey406@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+fb32afec111a7d61b939@syzkaller.appspotmail.com \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox