[PATCH RFC v2 01/42] loop: refuse backing files that aren't open for reading

sashiko-bot at kernel.org sashiko-bot at kernel.org
Sat Nov 14 13:19:33 UTC 2026


> loop_configure() takes any file as long as it implements ->read_iter().
> Loop itself never checked whether the file was actually opened for
> reading. Buffered I/O went through vfs_iter_read() which refuses files
> without FMODE_READ. Direct I/O has called ->read_iter() of the backing
> file directly ever since loop grew support for it.
> 
> Since commit f2fed441c69b ("loop: stop using vfs_iter_{read,write} for
> buffered I/O") buffered I/O calls ->read_iter() directly as well. That
> commit was about O_DIRECT handling and the FMODE_READ check went away
> as a side effect.
> 
> So whoever can set up a loop device can read a file it was only allowed
> to open for writing. Open the file O_WRONLY, configure a loop device
> with it and read the contents through the loop device.
> 
> Refuse backing files that aren't open for reading. Loop always reads
> from its backing file so a write-only backing file never made sense in
> the first place.
> 
> Fixes: bc07c10a3603 ("block: loop: support DIO & AIO")
> Fixes: f2fed441c69b ("loop: stop using vfs_iter_{read,write} for buffered I/O")
> Cc: stable at vger.kernel.org
> Reviewed-by: Jan Kara <jack at suse.cz>
> Reviewed-by: Christoph Hellwig <hch at lst.de>
> Reviewed-by: Alexander Mikhalitsyn <alex at amutable.com>
> Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261114-work-loop-pseudo-v2-0-98639a2286fb@kernel.org?part=1




More information about the Linux-security-module-archive mailing list