Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3357357pxb; Mon, 17 Jan 2022 18:29:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4Os5rU/Qh+VcsuJm5L6Ude9pHGGN7+MXXJM/qaSehF0TOsjUMRxUf4quBsx/8AQ/tND3m X-Received: by 2002:a17:90b:1b4a:: with SMTP id nv10mr28380530pjb.190.1642472971521; Mon, 17 Jan 2022 18:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642472971; cv=none; d=google.com; s=arc-20160816; b=RPPPSC9ay9PHlVXRkwZSGdiOzw6nTgGsIA9F8PNuwMSAJh0EAQ58AFzT1pg/56dPE3 oUW/il2g8dYJb7pF2JoPUpkdn+7aBK/KyvXExhBHkKKZMLjUJIIPAvqSMJ6r0DAViVLA ZJzzrM6gOe5Z4h/W4rYPYShkDN+11Qmd7mIEzSasCQ+Vyb/8u3hRcUnRPkb9KmvkdE22 dafDkbmYQEJk/ZDp61mGWOE7H18sE2AZJYHFPbi4hA7dPbbxAaXpfdSK1hL1SzdFDWLf ax82i7+5BxlUDMM6MQfG1C+GzJxwn/ZoYYNrBmhMCB9N0dQdUcS1ITgrvZeBJPnRwXtK DLrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=g7N7sfYLlsw3Se/LgOETJWnN/nS4JN3uvztiyC1WyDI=; b=RgwBFMydVZrbIPXQ5oKNoJ/YFY1HMRfstM/qeKU68U+A4tAWKyxvQzXHV2wpEISpp5 4Lm6cDv2rMaubnEXdXM3MCbdw5C0boMir1egGZitEmX1KIATTLWdmYOlBTK6oGg5x4Bo FgqVkSGq6yZktJsQjXRrZw165gnXOMHqScD8tzwkXGVL3B1o0yyUvj69nHNj30sQ0T/O g9h3cTNW7xi7woNWPenwDuNjgcI978tt4nzHHBjhQSZ1CwHQgcd2Ozz56xnWmfZl+MV/ jnsWG1/M1KJxKVlYxb2t5nVn2m+XHo5cZxLAE7RzNLkHago6PArZccdDpitxEA1Njfcu RCjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=QIA4T0tC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 29si16543041pgv.494.2022.01.17.18.29.20; Mon, 17 Jan 2022 18:29:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=QIA4T0tC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237124AbiAQONa (ORCPT + 99 others); Mon, 17 Jan 2022 09:13:30 -0500 Received: from linux.microsoft.com ([13.77.154.182]:54212 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236238AbiAQONX (ORCPT ); Mon, 17 Jan 2022 09:13:23 -0500 Received: from machine.home (lfbn-lyo-1-1484-111.w86-207.abo.wanadoo.fr [86.207.51.111]) by linux.microsoft.com (Postfix) with ESMTPSA id A6C9920B9132; Mon, 17 Jan 2022 06:13:21 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A6C9920B9132 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1642428802; bh=g7N7sfYLlsw3Se/LgOETJWnN/nS4JN3uvztiyC1WyDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QIA4T0tCCem2JnWVe3goJY2Mv06pvKGSoPmBqpxqnHj5b1n6C8Q5qbt+OGB0Rjvuc 8sQF6pTy9UTSdsaUOl1+Lw12kgdR4c7xaqz4NYQX/nt9tXauTYztkxnrWjlI53kRGv a+Jsr9YW6xx9IpMvWXYoJNDWU8xKRuvLIHnxTQV4= From: Francis Laniel To: linux-kernel@vger.kernel.org Cc: linux-security-module@vger.kernel.org, Serge Hallyn , Casey Schaufler , Francis Laniel Subject: [RFC PATCH v2 1/2] capability: Add cap_strings. Date: Mon, 17 Jan 2022 15:12:53 +0100 Message-Id: <20220117141254.46278-2-flaniel@linux.microsoft.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220117141254.46278-1-flaniel@linux.microsoft.com> References: <20220117141254.46278-1-flaniel@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This array contains the capability names for the given capabilitiy. For example, index CAP_BPF contains "CAP_BPF". Signed-off-by: Francis Laniel --- 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