1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/capability.h>
3 #include <linux/socket.h>
5 #define COMMON_FILE_SOCK_PERMS "ioctl", "read", "write", "create", \
6 "getattr", "setattr", "lock", "relabelfrom", "relabelto", "append", "map"
8 #define COMMON_FILE_PERMS COMMON_FILE_SOCK_PERMS, "unlink", "link", \
9 "rename", "execute", "quotaon", "mounton", "audit_access", \
10 "open", "execmod", "watch", "watch_mount", "watch_sb", \
11 "watch_with_perm", "watch_reads"
13 #define COMMON_SOCK_PERMS COMMON_FILE_SOCK_PERMS, "bind", "connect", \
14 "listen", "accept", "getopt", "setopt", "shutdown", "recvfrom", \
17 #define COMMON_IPC_PERMS "create", "destroy", "getattr", "setattr", "read", \
18 "write", "associate", "unix_read", "unix_write"
20 #define COMMON_CAP_PERMS "chown", "dac_override", "dac_read_search", \
21 "fowner", "fsetid", "kill", "setgid", "setuid", "setpcap", \
22 "linux_immutable", "net_bind_service", "net_broadcast", \
23 "net_admin", "net_raw", "ipc_lock", "ipc_owner", "sys_module", \
24 "sys_rawio", "sys_chroot", "sys_ptrace", "sys_pacct", "sys_admin", \
25 "sys_boot", "sys_nice", "sys_resource", "sys_time", \
26 "sys_tty_config", "mknod", "lease", "audit_write", \
27 "audit_control", "setfcap"
29 #define COMMON_CAP2_PERMS "mac_override", "mac_admin", "syslog", \
30 "wake_alarm", "block_suspend", "audit_read", "perfmon", "bpf", \
33 #if CAP_LAST_CAP > CAP_CHECKPOINT_RESTORE
34 #error New capability defined, please update COMMON_CAP2_PERMS.
38 * Note: The name for any socket class should be suffixed by "socket",
39 * and doesn't contain more than one substr of "socket".
41 const struct security_class_mapping secclass_map[] = {
43 { "compute_av", "compute_create", "compute_member",
44 "check_context", "load_policy", "compute_relabel",
45 "compute_user", "setenforce", "setbool", "setsecparam",
46 "setcheckreqprot", "read_policy", "validate_trans", NULL } },
48 { "fork", "transition", "sigchld", "sigkill",
49 "sigstop", "signull", "signal", "ptrace", "getsched", "setsched",
50 "getsession", "getpgid", "setpgid", "getcap", "setcap", "share",
51 "getattr", "setexec", "setfscreate", "noatsecure", "siginh",
52 "setrlimit", "rlimitinh", "dyntransition", "setcurrent",
53 "execmem", "execstack", "execheap", "setkeycreate",
54 "setsockcreate", "getrlimit", NULL } },
56 { "nnp_transition", "nosuid_transition", NULL } },
58 { "ipc_info", "syslog_read", "syslog_mod",
59 "syslog_console", "module_request", "module_load", NULL } },
61 { COMMON_CAP_PERMS, NULL } },
63 { "mount", "remount", "unmount", "getattr",
64 "relabelfrom", "relabelto", "associate", "quotamod",
65 "quotaget", "watch", NULL } },
68 "execute_no_trans", "entrypoint", NULL } },
70 { COMMON_FILE_PERMS, "add_name", "remove_name",
71 "reparent", "search", "rmdir", NULL } },
72 { "fd", { "use", NULL } },
74 { COMMON_FILE_PERMS, NULL } },
76 { COMMON_FILE_PERMS, NULL } },
78 { COMMON_FILE_PERMS, NULL } },
80 { COMMON_FILE_PERMS, NULL } },
82 { COMMON_FILE_PERMS, NULL } },
84 { COMMON_SOCK_PERMS, NULL } },
87 "node_bind", "name_connect",
91 "node_bind", NULL } },
94 "node_bind", NULL } },
96 { "recvfrom", "sendto", NULL } },
98 { "ingress", "egress", NULL } },
100 { COMMON_SOCK_PERMS, NULL } },
102 { COMMON_SOCK_PERMS, NULL } },
104 { COMMON_SOCK_PERMS, NULL } },
105 { "unix_stream_socket",
106 { COMMON_SOCK_PERMS, "connectto", NULL } },
107 { "unix_dgram_socket",
108 { COMMON_SOCK_PERMS, NULL } },
110 { COMMON_IPC_PERMS, NULL } },
111 { "msg", { "send", "receive", NULL } },
113 { COMMON_IPC_PERMS, "enqueue", NULL } },
115 { COMMON_IPC_PERMS, "lock", NULL } },
117 { COMMON_IPC_PERMS, NULL } },
118 { "netlink_route_socket",
120 "nlmsg_read", "nlmsg_write", NULL } },
121 { "netlink_tcpdiag_socket",
123 "nlmsg_read", "nlmsg_write", NULL } },
124 { "netlink_nflog_socket",
125 { COMMON_SOCK_PERMS, NULL } },
126 { "netlink_xfrm_socket",
128 "nlmsg_read", "nlmsg_write", NULL } },
129 { "netlink_selinux_socket",
130 { COMMON_SOCK_PERMS, NULL } },
131 { "netlink_iscsi_socket",
132 { COMMON_SOCK_PERMS, NULL } },
133 { "netlink_audit_socket",
135 "nlmsg_read", "nlmsg_write", "nlmsg_relay", "nlmsg_readpriv",
136 "nlmsg_tty_audit", NULL } },
137 { "netlink_fib_lookup_socket",
138 { COMMON_SOCK_PERMS, NULL } },
139 { "netlink_connector_socket",
140 { COMMON_SOCK_PERMS, NULL } },
141 { "netlink_netfilter_socket",
142 { COMMON_SOCK_PERMS, NULL } },
143 { "netlink_dnrt_socket",
144 { COMMON_SOCK_PERMS, NULL } },
146 { "sendto", "recvfrom", "setcontext", "polmatch", NULL } },
147 { "netlink_kobject_uevent_socket",
148 { COMMON_SOCK_PERMS, NULL } },
149 { "netlink_generic_socket",
150 { COMMON_SOCK_PERMS, NULL } },
151 { "netlink_scsitransport_socket",
152 { COMMON_SOCK_PERMS, NULL } },
153 { "netlink_rdma_socket",
154 { COMMON_SOCK_PERMS, NULL } },
155 { "netlink_crypto_socket",
156 { COMMON_SOCK_PERMS, NULL } },
157 { "appletalk_socket",
158 { COMMON_SOCK_PERMS, NULL } },
160 { "send", "recv", "relabelto", "forward_in", "forward_out", NULL } },
162 { "view", "read", "write", "search", "link", "setattr", "create",
166 "node_bind", "name_connect", NULL } },
167 { "memprotect", { "mmap_zero", NULL } },
168 { "peer", { "recv", NULL } },
170 { COMMON_CAP2_PERMS, NULL } },
171 { "kernel_service", { "use_as_override", "create_files_as", NULL } },
173 { COMMON_SOCK_PERMS, "attach_queue", NULL } },
174 { "binder", { "impersonate", "call", "set_context_mgr", "transfer",
177 { COMMON_CAP_PERMS, NULL } },
179 { COMMON_CAP2_PERMS, NULL } },
182 "node_bind", "name_connect", "association", NULL } },
185 "node_bind", NULL } },
187 { COMMON_SOCK_PERMS, NULL } },
189 { COMMON_SOCK_PERMS, NULL } },
191 { COMMON_SOCK_PERMS, NULL } },
193 { COMMON_SOCK_PERMS, NULL } },
195 { COMMON_SOCK_PERMS, NULL } },
197 { COMMON_SOCK_PERMS, NULL } },
199 { COMMON_SOCK_PERMS, NULL } },
201 { COMMON_SOCK_PERMS, NULL } },
203 { COMMON_SOCK_PERMS, NULL } },
205 { COMMON_SOCK_PERMS, NULL } },
207 { COMMON_SOCK_PERMS, NULL } },
209 { COMMON_SOCK_PERMS, NULL } },
211 { COMMON_SOCK_PERMS, NULL } },
213 { COMMON_SOCK_PERMS, NULL } },
214 { "bluetooth_socket",
215 { COMMON_SOCK_PERMS, NULL } },
217 { COMMON_SOCK_PERMS, NULL } },
219 { COMMON_SOCK_PERMS, NULL } },
221 { COMMON_SOCK_PERMS, NULL } },
223 { COMMON_SOCK_PERMS, NULL } },
224 { "ieee802154_socket",
225 { COMMON_SOCK_PERMS, NULL } },
227 { COMMON_SOCK_PERMS, NULL } },
229 { COMMON_SOCK_PERMS, NULL } },
231 { COMMON_SOCK_PERMS, NULL } },
233 { COMMON_SOCK_PERMS, NULL } },
235 { COMMON_SOCK_PERMS, NULL } },
237 { COMMON_SOCK_PERMS, NULL } },
239 { COMMON_SOCK_PERMS, NULL } },
241 { "access", NULL } },
242 { "infiniband_endport",
243 { "manage_subnet", NULL } },
245 { "map_create", "map_read", "map_write", "prog_load", "prog_run",
248 { COMMON_SOCK_PERMS, NULL } },
250 { COMMON_SOCK_PERMS, NULL } },
252 { "open", "cpu", "kernel", "tracepoint", "read", "write", NULL } },
254 { COMMON_FILE_PERMS, NULL } },
256 { "override_creds", "sqpoll", "cmd", NULL } },
261 #error New address family defined, please update secclass_map.