]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: fix scrub stats file permissions
authorDarrick J. Wong <djwong@kernel.org>
Sat, 24 Feb 2024 06:01:40 +0000 (22:01 -0800)
committerChandan Babu R <chandanbabu@kernel.org>
Mon, 26 Feb 2024 12:28:37 +0000 (17:58 +0530)
When the kernel is in lockdown mode, debugfs will only show files that
are world-readable and cannot be written, mmaped, or used with ioctl.
That more or less describes the scrub stats file, except that the
permissions are wrong -- they should be 0444, not 0644.  You can't write
the stats file, so the 0200 makes no sense.

Meanwhile, the clear_stats file is only writable, but it got mode 0400
instead of 0200, which would make more sense.

Fix both files so that they make sense.

Fixes: d7a74cad8f451 ("xfs: track usage statistics of online fsck")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
fs/xfs/scrub/stats.c

index b4ef1ebe28ab8a8cef742b384d00f1045e861a36..42cafbed94ac6d6a7e5f0c7ad5130bb8039a197f 100644 (file)
@@ -331,9 +331,9 @@ xchk_stats_register(
        if (!cs->cs_debugfs)
                return;
 
-       debugfs_create_file("stats", 0644, cs->cs_debugfs, cs,
+       debugfs_create_file("stats", 0444, cs->cs_debugfs, cs,
                        &scrub_stats_fops);
-       debugfs_create_file("clear_stats", 0400, cs->cs_debugfs, cs,
+       debugfs_create_file("clear_stats", 0200, cs->cs_debugfs, cs,
                        &clear_scrub_stats_fops);
 }