* Should the "loop" driver reject using pseudo files as backing file?
@ 2026-05-27 1:52 Tetsuo Handa
2026-05-27 14:14 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Tetsuo Handa @ 2026-05-27 1:52 UTC (permalink / raw)
To: Jens Axboe, linux-block
I noticed that /dev/loopX accepts pseudo files, for currently
loop_validate_file() does
if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
return -EINVAL;
and pseudo files are treated as S_ISREG().
Reading pseudo files via /dev/loopX causes bogus results (tries to
repeatedly read the entire content up to the size visible to "ls"
command). I think that allowing such usage will confuse userspace
programs.
[root@localhost ~]# ls -l /sys/power/pm_test
-rw-r--r-- 1 root root 4096 May 26 22:14 /sys/power/pm_test
[root@localhost ~]# cat /sys/power/pm_test | wc
1 6 48
[root@localhost ~]# cat $(losetup -f --show /sys/power/pm_test) | wc
85 513 4096
Writing to pseudo files via /dev/loopX seems to work (at least works for
/sys/power/pm_test ), but can/should we forbid binding to pseudo files?
[root@localhost ~]# echo none > /sys/power/pm_test
[root@localhost ~]# echo none > $(losetup -f --show /sys/power/pm_test)
F.Y.I. An analysis by Google AI mode (expires in 7 days) is at https://share.google/aimode/prhETTZMQEzsw5HV9 .
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: Should the "loop" driver reject using pseudo files as backing file?
2026-05-27 1:52 Should the "loop" driver reject using pseudo files as backing file? Tetsuo Handa
@ 2026-05-27 14:14 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2026-05-27 14:14 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: Jens Axboe, linux-block
On Wed, May 27, 2026 at 10:52:02AM +0900, Tetsuo Handa wrote:
> I noticed that /dev/loopX accepts pseudo files, for currently
> loop_validate_file() does
>
> if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
> return -EINVAL;
>
> and pseudo files are treated as S_ISREG().
>
> Reading pseudo files via /dev/loopX causes bogus results (tries to
> repeatedly read the entire content up to the size visible to "ls"
> command). I think that allowing such usage will confuse userspace
> programs.
You get what you pay for. Many other in-kernel and userspace users
will be just as confused by them.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-27 14:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 1:52 Should the "loop" driver reject using pseudo files as backing file? Tetsuo Handa
2026-05-27 14:14 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox