@@ -243,6 +243,20 @@ static int acct_on(struct filename *pathname)
return -EACCES;
}
+ /* Exclude kernel kernel internal filesystems. */
+ if (file_inode(file)->i_sb->s_flags & (SB_NOUSER | SB_KERNMOUNT)) {
+ kfree(acct);
+ filp_close(file, NULL);
+ return -EINVAL;
+ }
+
+ /* Exclude procfs and sysfs. */
+ if (file_inode(file)->i_sb->s_iflags & SB_I_USERNS_VISIBLE) {
+ kfree(acct);
+ filp_close(file, NULL);
+ return -EINVAL;
+ }
+
if (!(file->f_mode & FMODE_CAN_WRITE)) {
kfree(acct);
filp_close(file, NULL);
There's no point in allowing anything kernel internal nor procfs or sysfs. Reported-by: Zicheng Qu <quzicheng@huawei.com> Link: https://lore.kernel.org/r/20250127091811.3183623-1-quzicheng@huawei.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: <stable@vger.kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org> --- kernel/acct.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)