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"
32 #if CAP_LAST_CAP > CAP_AUDIT_READ
33 #error New capability defined, please update COMMON_CAP2_PERMS.
37 * Note: The name for any socket class should be suffixed by "socket",
38 * and doesn't contain more than one substr of "socket".
40 struct security_class_mapping secclass_map
[] = {
42 { "compute_av", "compute_create", "compute_member",
43 "check_context", "load_policy", "compute_relabel",
44 "compute_user", "setenforce", "setbool", "setsecparam",
45 "setcheckreqprot", "read_policy", "validate_trans", NULL
} },
47 { "fork", "transition", "sigchld", "sigkill",
48 "sigstop", "signull", "signal", "ptrace", "getsched", "setsched",
49 "getsession", "getpgid", "setpgid", "getcap", "setcap", "share",
50 "getattr", "setexec", "setfscreate", "noatsecure", "siginh",
51 "setrlimit", "rlimitinh", "dyntransition", "setcurrent",
52 "execmem", "execstack", "execheap", "setkeycreate",
53 "setsockcreate", "getrlimit", NULL
} },
55 { "nnp_transition", "nosuid_transition", NULL
} },
57 { "ipc_info", "syslog_read", "syslog_mod",
58 "syslog_console", "module_request", "module_load", NULL
} },
60 { COMMON_CAP_PERMS
, NULL
} },
62 { "mount", "remount", "unmount", "getattr",
63 "relabelfrom", "relabelto", "associate", "quotamod",
64 "quotaget", "watch", NULL
} },
67 "execute_no_trans", "entrypoint", NULL
} },
69 { COMMON_FILE_PERMS
, "add_name", "remove_name",
70 "reparent", "search", "rmdir", NULL
} },
71 { "fd", { "use", NULL
} },
73 { COMMON_FILE_PERMS
, NULL
} },
75 { COMMON_FILE_PERMS
, NULL
} },
77 { COMMON_FILE_PERMS
, NULL
} },
79 { COMMON_FILE_PERMS
, NULL
} },
81 { COMMON_FILE_PERMS
, NULL
} },
83 { COMMON_SOCK_PERMS
, NULL
} },
86 "node_bind", "name_connect",
90 "node_bind", NULL
} },
93 "node_bind", NULL
} },
95 { "recvfrom", "sendto", NULL
} },
97 { "ingress", "egress", NULL
} },
99 { COMMON_SOCK_PERMS
, NULL
} },
101 { COMMON_SOCK_PERMS
, NULL
} },
103 { COMMON_SOCK_PERMS
, NULL
} },
104 { "unix_stream_socket",
105 { COMMON_SOCK_PERMS
, "connectto", NULL
} },
106 { "unix_dgram_socket",
107 { COMMON_SOCK_PERMS
, NULL
} },
109 { COMMON_IPC_PERMS
, NULL
} },
110 { "msg", { "send", "receive", NULL
} },
112 { COMMON_IPC_PERMS
, "enqueue", NULL
} },
114 { COMMON_IPC_PERMS
, "lock", NULL
} },
116 { COMMON_IPC_PERMS
, NULL
} },
117 { "netlink_route_socket",
119 "nlmsg_read", "nlmsg_write", NULL
} },
120 { "netlink_tcpdiag_socket",
122 "nlmsg_read", "nlmsg_write", NULL
} },
123 { "netlink_nflog_socket",
124 { COMMON_SOCK_PERMS
, NULL
} },
125 { "netlink_xfrm_socket",
127 "nlmsg_read", "nlmsg_write", NULL
} },
128 { "netlink_selinux_socket",
129 { COMMON_SOCK_PERMS
, NULL
} },
130 { "netlink_iscsi_socket",
131 { COMMON_SOCK_PERMS
, NULL
} },
132 { "netlink_audit_socket",
134 "nlmsg_read", "nlmsg_write", "nlmsg_relay", "nlmsg_readpriv",
135 "nlmsg_tty_audit", NULL
} },
136 { "netlink_fib_lookup_socket",
137 { COMMON_SOCK_PERMS
, NULL
} },
138 { "netlink_connector_socket",
139 { COMMON_SOCK_PERMS
, NULL
} },
140 { "netlink_netfilter_socket",
141 { COMMON_SOCK_PERMS
, NULL
} },
142 { "netlink_dnrt_socket",
143 { COMMON_SOCK_PERMS
, NULL
} },
145 { "sendto", "recvfrom", "setcontext", "polmatch", NULL
} },
146 { "netlink_kobject_uevent_socket",
147 { COMMON_SOCK_PERMS
, NULL
} },
148 { "netlink_generic_socket",
149 { COMMON_SOCK_PERMS
, NULL
} },
150 { "netlink_scsitransport_socket",
151 { COMMON_SOCK_PERMS
, NULL
} },
152 { "netlink_rdma_socket",
153 { COMMON_SOCK_PERMS
, NULL
} },
154 { "netlink_crypto_socket",
155 { COMMON_SOCK_PERMS
, NULL
} },
156 { "appletalk_socket",
157 { COMMON_SOCK_PERMS
, NULL
} },
159 { "send", "recv", "relabelto", "forward_in", "forward_out", NULL
} },
161 { "view", "read", "write", "search", "link", "setattr", "create",
165 "node_bind", "name_connect", NULL
} },
166 { "memprotect", { "mmap_zero", NULL
} },
167 { "peer", { "recv", NULL
} },
169 { COMMON_CAP2_PERMS
, NULL
} },
170 { "kernel_service", { "use_as_override", "create_files_as", NULL
} },
172 { COMMON_SOCK_PERMS
, "attach_queue", NULL
} },
173 { "binder", { "impersonate", "call", "set_context_mgr", "transfer",
176 { COMMON_CAP_PERMS
, NULL
} },
178 { COMMON_CAP2_PERMS
, NULL
} },
181 "node_bind", "name_connect", "association", NULL
} },
184 "node_bind", NULL
} },
186 { COMMON_SOCK_PERMS
, NULL
} },
188 { COMMON_SOCK_PERMS
, NULL
} },
190 { COMMON_SOCK_PERMS
, NULL
} },
192 { COMMON_SOCK_PERMS
, NULL
} },
194 { COMMON_SOCK_PERMS
, NULL
} },
196 { COMMON_SOCK_PERMS
, NULL
} },
198 { COMMON_SOCK_PERMS
, NULL
} },
200 { COMMON_SOCK_PERMS
, NULL
} },
202 { COMMON_SOCK_PERMS
, NULL
} },
204 { COMMON_SOCK_PERMS
, NULL
} },
206 { COMMON_SOCK_PERMS
, NULL
} },
208 { COMMON_SOCK_PERMS
, NULL
} },
210 { COMMON_SOCK_PERMS
, NULL
} },
212 { COMMON_SOCK_PERMS
, NULL
} },
213 { "bluetooth_socket",
214 { COMMON_SOCK_PERMS
, NULL
} },
216 { COMMON_SOCK_PERMS
, NULL
} },
218 { COMMON_SOCK_PERMS
, NULL
} },
220 { COMMON_SOCK_PERMS
, NULL
} },
222 { COMMON_SOCK_PERMS
, NULL
} },
223 { "ieee802154_socket",
224 { COMMON_SOCK_PERMS
, NULL
} },
226 { COMMON_SOCK_PERMS
, NULL
} },
228 { COMMON_SOCK_PERMS
, NULL
} },
230 { COMMON_SOCK_PERMS
, NULL
} },
232 { COMMON_SOCK_PERMS
, NULL
} },
234 { COMMON_SOCK_PERMS
, NULL
} },
236 { COMMON_SOCK_PERMS
, NULL
} },
238 { COMMON_SOCK_PERMS
, NULL
} },
240 { "access", NULL
} },
241 { "infiniband_endport",
242 { "manage_subnet", NULL
} },
244 {"map_create", "map_read", "map_write", "prog_load", "prog_run"} },
246 { COMMON_SOCK_PERMS
, NULL
} },
248 {"open", "cpu", "kernel", "tracepoint", "read", "write"} },
250 { "integrity", "confidentiality", NULL
} },
255 #error New address family defined, please update secclass_map.