mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Francis Laniel <flaniel@linux.microsoft.com>
To: linux-kernel@vger.kernel.org
Cc: linux-security-module@vger.kernel.org,
	Serge Hallyn <serge@hallyn.com>,
	Casey Schaufler <casey@schaufler-ca.com>,
	Francis Laniel <flaniel@linux.microsoft.com>
Subject: [RFC PATCH v2 1/2] capability: Add cap_strings.
Date: Mon, 17 Jan 2022 15:12:53 +0100	[thread overview]
Message-ID: <20220117141254.46278-2-flaniel@linux.microsoft.com> (raw)
In-Reply-To: <20220117141254.46278-1-flaniel@linux.microsoft.com>

This array contains the capability names for the given capabilitiy.
For example, index CAP_BPF contains "CAP_BPF".

Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
---
 include/uapi/linux/capability.h |  1 +
 kernel/capability.c             | 44 +++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/include/uapi/linux/capability.h b/include/uapi/linux/capability.h
index 463d1ba2232a..9646654d5111 100644
--- a/include/uapi/linux/capability.h
+++ b/include/uapi/linux/capability.h
@@ -428,5 +428,6 @@ struct vfs_ns_cap_data {
 #define CAP_TO_INDEX(x)     ((x) >> 5)        /* 1 << 5 == bits in __u32 */
 #define CAP_TO_MASK(x)      (1 << ((x) & 31)) /* mask for indexed __u32 */
 
+extern const char *cap_strings[];
 
 #endif /* _UAPI_LINUX_CAPABILITY_H */
diff --git a/kernel/capability.c b/kernel/capability.c
index 46a361dde042..cd386419f2b7 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -27,6 +27,50 @@
 const kernel_cap_t __cap_empty_set = CAP_EMPTY_SET;
 EXPORT_SYMBOL(__cap_empty_set);
 
+const char *cap_strings[] = {
+	[CAP_CHOWN] = "CAP_CHOWN",
+	[CAP_DAC_OVERRIDE] = "CAP_DAC_OVERRIDE",
+	[CAP_DAC_READ_SEARCH] = "CAP_DAC_READ_SEARCH",
+	[CAP_FOWNER] = "CAP_FOWNER",
+	[CAP_FSETID] = "CAP_FSETID",
+	[CAP_KILL] = "CAP_KILL",
+	[CAP_SETGID] = "CAP_SETGID",
+	[CAP_SETUID] = "CAP_SETUID",
+	[CAP_SETPCAP] = "CAP_SETPCAP",
+	[CAP_LINUX_IMMUTABLE] = "CAP_LINUX_IMMUTABLE",
+	[CAP_NET_BIND_SERVICE] = "CAP_NET_BIND_SERVICE",
+	[CAP_NET_BROADCAST] = "CAP_NET_BROADCAST",
+	[CAP_NET_ADMIN] = "CAP_NET_ADMIN",
+	[CAP_NET_RAW] = "CAP_NET_RAW",
+	[CAP_IPC_LOCK] = "CAP_IPC_LOCK",
+	[CAP_IPC_OWNER] = "CAP_IPC_OWNER",
+	[CAP_SYS_MODULE] = "CAP_SYS_MODULE",
+	[CAP_SYS_RAWIO] = "CAP_SYS_RAWIO",
+	[CAP_SYS_CHROOT] = "CAP_SYS_CHROOT",
+	[CAP_SYS_PTRACE] = "CAP_SYS_PTRACE",
+	[CAP_SYS_PACCT] = "CAP_SYS_PACCT",
+	[CAP_SYS_ADMIN] = "CAP_SYS_ADMIN",
+	[CAP_SYS_BOOT] = "CAP_SYS_BOOT",
+	[CAP_SYS_NICE] = "CAP_SYS_NICE",
+	[CAP_SYS_RESOURCE] = "CAP_SYS_RESOURCE",
+	[CAP_SYS_TIME] = "CAP_SYS_TIME",
+	[CAP_SYS_TTY_CONFIG] = "CAP_SYS_TTY_CONFIG",
+	[CAP_MKNOD] = "CAP_MKNOD",
+	[CAP_LEASE] = "CAP_LEASE",
+	[CAP_AUDIT_WRITE] = "CAP_AUDIT_WRITE",
+	[CAP_AUDIT_CONTROL] = "CAP_AUDIT_CONTROL",
+	[CAP_SETFCAP] = "CAP_SETFCAP",
+	[CAP_MAC_OVERRIDE] = "CAP_MAC_OVERRIDE",
+	[CAP_MAC_ADMIN] = "CAP_MAC_ADMIN",
+	[CAP_SYSLOG] = "CAP_SYSLOG",
+	[CAP_WAKE_ALARM] = "CAP_WAKE_ALARM",
+	[CAP_BLOCK_SUSPEND] = "CAP_BLOCK_SUSPEND",
+	[CAP_AUDIT_READ] = "CAP_AUDIT_READ",
+	[CAP_PERFMON] = "CAP_PERFMON",
+	[CAP_BPF] = "CAP_BPF",
+	[CAP_CHECKPOINT_RESTORE] = "CAP_CHECKPOINT_RESTORE",
+};
+
 int file_caps_enabled = 1;
 
 static int __init file_caps_disable(char *str)
-- 
2.30.2


  reply	other threads:[~2022-01-17 14:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 14:12 [RFC PATCH v2 0/2] Add capabilities file to sysfs Francis Laniel
2022-01-17 14:12 ` Francis Laniel [this message]
2022-01-17 14:12 ` [RFC PATCH v2 2/2] kernel/ksysfs.c: Add capabilities attribute Francis Laniel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117141254.46278-2-flaniel@linux.microsoft.com \
    --to=flaniel@linux.microsoft.com \
    --cc=casey@schaufler-ca.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome