[PATCH RFC v3 41/44] usb: gadget: f_mass_storage: refuse files on pseudo filesystems
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Mon Nov 16 11:26:26 UTC 2026
> fsg_lun_open() takes any regular file as the backing file of a LUN. The
> file-storage kthread then reads and writes it with kernel_read() and
> kernel_write() on behalf of the USB host. With a procfs or sysfs file
> behind a LUN the host gets to read and write kernel interfaces with
> kernel credentials. Refuse files on pseudo filesystems just like loop
> does by switching to file_check_backing().
>
> The helper also does the file type and readability checks. So the
> messages for an unsuitable backing file become one. It looks at the
> inode of the file instead of the host of ->f_mapping. For regular files
> and block devices both have the same type. It also wants ->read_iter()
> where FMODE_CAN_READ was enough so far. But kernel_read() never worked
> without ->read_iter() anyway.
>
> Reviewed-by: Alexander Mikhalitsyn <alex at amutable.com>
> Reviewed-by: Chris Down <chris at chrisdown.name>
> 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/20261116-work-loop-pseudo-v3-0-8cbbea1cf34f@kernel.org?part=41
More information about the Linux-security-module-archive
mailing list