linux/drivers/mtd/ubi
ZhaoLong Wang 2de203d8ab ubi: Fix permission display of the debugfs files
Some interface files in debugfs support the read method
dfs_file_read(), but their rwx permissions is shown as
unreadable.

In the user mode, the following problem can be clearly seen:

 # ls -l /sys/kernel/debug/ubi/ubi0/
 total 0
 --w------- 1 root root 0 Oct 22 16:26 chk_fastmap
 --w------- 1 root root 0 Oct 22 16:26 chk_gen
 --w------- 1 root root 0 Oct 22 16:26 chk_io
 -r-------- 1 root root 0 Oct 22 16:26 detailed_erase_block_info
 --w------- 1 root root 0 Oct 22 16:26 tst_disable_bgt
 --w------- 1 root root 0 Oct 22 16:26 tst_emulate_bitflips
 --w------- 1 root root 0 Oct 22 16:26 tst_emulate_io_failures
 --w------- 1 root root 0 Oct 22 16:26 tst_emulate_power_cut
 --w------- 1 root root 0 Oct 22 16:26 tst_emulate_power_cut_max
 --w------- 1 root root 0 Oct 22 16:26 tst_emulate_power_cut_min

It shows that these files do not have read permission 'r',
but we can actually read their contents.

 # echo 1 > /sys/kernel/debug/ubi/ubi0/chk_io
 # cat /sys/kernel/debug/ubi/ubi0/chk_io
 1

User's permission access is determined by capabilities.
Of course, the root user is not restricted from reading
these files.

When reading a debugfs file, the process is as follows:

 ksys_read()
   vfs_read()
     if (file->f_op->read)
       file->f_op->read()
         full_proxy_open()
           real_fops->read()
             dfs_file_read() -- Read method of debugfs file.
     else if (file->f_op->read_iter)
       new_sync_read()
     else
       ret = -EINVAL -- Return -EINVAL if no read method.

This indicates that the debugfs file can be read as long as the read
method of the debugfs file is registered. This patch adds the read
permission display for file that support the read method.

Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2023-02-02 21:13:45 +01:00
..
attach.c mtd: Convert fallthrough comments into statements 2020-03-30 10:14:54 +02:00
block.c ubi: block: Reduce warning print to info for static volumes 2023-02-02 21:13:35 +01:00
build.c ubi: Fix possible null-ptr-deref in ubi_free_volume() 2023-02-02 21:13:44 +01:00
cdev.c ubi: fastmap: Add fastmap control support for 'UBI_IOCATT' ioctl 2022-09-21 18:29:18 +02:00
debug.c ubi: Fix permission display of the debugfs files 2023-02-02 21:13:45 +01:00
debug.h treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
eba.c ubi: Fix repeated words in comments 2022-09-21 11:32:27 +02:00
fastmap-wl.c ubi: fastmap: Check wl_pool for free peb before wear leveling 2022-05-27 16:49:07 +02:00
fastmap.c ubi: fastmap: Use the bitmap API to allocate bitmaps 2022-09-21 11:32:58 +02:00
gluebi.c mtd: ubi: gluebi: Fix misnamed function parameter documentation 2020-11-20 12:37:32 +01:00
io.c ubi: Fix repeated words in comments 2022-09-21 11:32:27 +02:00
kapi.c mtd: ubi: kapi: Correct documentation for 'ubi_leb_read_sg's 'sgl' parameter 2020-11-20 12:37:31 +01:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
misc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
ubi-media.h ubi: ubi-media.h: Fix comment typo 2022-09-21 11:12:18 +02:00
ubi.h ubi: fastmap: Add fastmap control support for 'UBI_IOCATT' ioctl 2022-09-21 18:29:18 +02:00
upd.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
vmt.c ubi: Fix possible null-ptr-deref in ubi_free_volume() 2023-02-02 21:13:44 +01:00
vtbl.c ubi: Free the normal volumes in error paths of ubi_attach_mtd_dev() 2020-01-16 23:35:59 +01:00
wl.c ubi: fastmap: Fix typo in comments 2022-09-21 11:32:27 +02:00
wl.h ubi: fastmap: Check wl_pool for free peb before wear leveling 2022-05-27 16:49:07 +02:00