lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250211-work-acct-v1-2-1c16aecab8b3@kernel.org>
Date: Tue, 11 Feb 2025 18:16:00 +0100
From: Christian Brauner <brauner@...nel.org>
To: Zicheng Qu <quzicheng@...wei.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Christian Brauner <brauner@...nel.org>,
	jlayton@...nel.org,
	axboe@...nel.dk,
	joel.granados@...nel.org,
	tglx@...utronix.de,
	viro@...iv.linux.org.uk,
	hch@....de,
	len.brown@...el.com,
	pavel@....cz,
	pengfei.xu@...el.com,
	rafael@...nel.org,
	tanghui20@...wei.com,
	zhangqiao22@...wei.com,
	judy.chenhui@...wei.com,
	linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org,
	syzkaller-bugs@...glegroups.com,
	linux-pm@...r.kernel.org,
	stable@...r.kernel.org
Subject: [PATCH 2/2] acct: block access to kernel internal filesystems

There's no point in allowing anything kernel internal nor procfs or
sysfs.

Reported-by: Zicheng Qu <quzicheng@...wei.com>
Link: https://lore.kernel.org/r/20250127091811.3183623-1-quzicheng@huawei.com
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: <stable@...r.kernel.org>
Signed-off-by: Christian Brauner <brauner@...nel.org>
---
 kernel/acct.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/kernel/acct.c b/kernel/acct.c
index 48283efe8a12..6520baa13669 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -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);

-- 
2.47.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ