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-next>] [day] [month] [year] [list]
Message-Id: <20240827081133.872741-1-sunyiqixm@gmail.com>
Date: Tue, 27 Aug 2024 16:11:33 +0800
From: sunyiqi <sunyiqixm@...il.com>
To: gregkh@...uxfoundation.org,
	rafael@...nel.org
Cc: linux-kernel@...r.kernel.org,
	sunyiqi <sunyiqixm@...il.com>
Subject: [PATCH] cpu: add CAP_SYSLOG check for reading crash_notes address

CPU crash_notes value can be obtained through /sys/devices/system/cpu/\
cpu[NUM]/crash_notes for leaking the phys address(introduced in kernel
5.10-rc1, but some distributions may migrate this feature to 4.x
  kernel).
The relevant function is crash_notes_show() in file drivers/base/cpu.c.

Though crash_notes file permission is 400 and owner is root:root,
but in container, the root user can also read crash_notes which leads to
information leak as most of kernel pointer value can not by read for
root user in container without CAP_SYSLOG capability.

In current linux kernel implementation, kernel pointer value or address
printked by %pK is not directly exposed to root user in container. For
kernel interface which includes those values, like /sys/kallsyms,
/proc/net/packet, etc., address values are guarded by kernel function
restricted_pointer(). Without CAP_SYSLOG capability, value 0 or NULL
will be returned for reading those interfaces in container using root
user.

In restricted_pointer() and container, address values only returned by
kernel when root user has CAP_SYSLOG capability which is not the default
capabilities for Docker container. CAP_SYSLOG prevents root user in
container to get kernel pointer from lots of interfaces based on printk,
but not for cpu crash_notes.

Add CAP_SYSLOG permission check in crash_notes_show() for viewing kernel
address.

Fixes: aa838896d87a ("drivers core: Use sysfs_emit and sysfs_emit_at for show(device *...) functions")
Signed-off-by: sunyiqi <sunyiqixm@...il.com>
---
 drivers/base/cpu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index fdaa24bb641a..a2f27bb0ffe6 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -156,6 +156,9 @@ static ssize_t crash_notes_show(struct device *dev,
 	unsigned long long addr;
 	int cpunum;
 
+	if (!has_capability_noaudit(current, CAP_SYSLOG))
+		return sysfs_emit(buf, "%llx\n", 0ull);
+
 	cpunum = cpu->dev.id;
 
 	/*
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ