[PATCH RFC v2 39/42] usb: gadget: f_mass_storage: refuse files on pseudo filesystems

sashiko-bot at kernel.org sashiko-bot at kernel.org
Sat Nov 14 13:23:53 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.
> 
> 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=39




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