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] [day] [month] [year] [list]
Date:   Mon, 17 Jan 2022 15:12:54 +0100
From:   Francis Laniel <flaniel@...ux.microsoft.com>
To:     linux-kernel@...r.kernel.org
Cc:     linux-security-module@...r.kernel.org,
        Serge Hallyn <serge@...lyn.com>,
        Casey Schaufler <casey@...aufler-ca.com>,
        Francis Laniel <flaniel@...ux.microsoft.com>
Subject: [RFC PATCH v2 2/2] kernel/ksysfs.c: Add capabilities attribute.

This new read-only attribute prints the capabilities values with their names:
0       CAP_CHOWN
1       CAP_DAC_OVERRIDE
...
39      CAP_BPF

Signed-off-by: Francis Laniel <flaniel@...ux.microsoft.com>
---
 kernel/ksysfs.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 35859da8bd4f..7d39794a55bc 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -182,6 +182,23 @@ static ssize_t rcu_normal_store(struct kobject *kobj,
 KERNEL_ATTR_RW(rcu_normal);
 #endif /* #ifndef CONFIG_TINY_RCU */
 
+static ssize_t capabilities_show(struct kobject *unused0,
+				struct kobj_attribute *unused1, char *buf)
+{
+	int at = 0;
+	int i;
+
+	for (i = 0; i < CAP_LAST_CAP; i++) {
+		if (at >= PAGE_SIZE)
+			return at;
+
+		at += sysfs_emit_at(buf, at, "%d\t%s\n", i, cap_strings[i]);
+	}
+
+	return at;
+}
+KERNEL_ATTR_RO(capabilities);
+
 /*
  * Make /sys/kernel/notes give the raw contents of our kernel .notes section.
  */
@@ -229,6 +246,7 @@ static struct attribute * kernel_attrs[] = {
 	&rcu_expedited_attr.attr,
 	&rcu_normal_attr.attr,
 #endif
+	&capabilities_attr.attr,
 	NULL
 };
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ