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", \
12 #define COMMON_SOCK_PERMS COMMON_FILE_SOCK_PERMS, "bind", "connect", \
13 "listen", "accept", "getopt", "setopt", "shutdown", "recvfrom", \
16 #define COMMON_IPC_PERMS "create", "destroy", "getattr", "setattr", "read", \
17 "write", "associate", "unix_read", "unix_write"
19 #define COMMON_CAP_PERMS "chown", "dac_override", "dac_read_search", \
20 "fowner", "fsetid", "kill", "setgid", "setuid", "setpcap", \
21 "linux_immutable", "net_bind_service", "net_broadcast", \
22 "net_admin", "net_raw", "ipc_lock", "ipc_owner", "sys_module", \
23 "sys_rawio", "sys_chroot", "sys_ptrace", "sys_pacct", "sys_admin", \
24 "sys_boot", "sys_nice", "sys_resource", "sys_time", \
25 "sys_tty_config", "mknod", "lease", "audit_write", \
26 "audit_control", "setfcap"
28 #define COMMON_CAP2_PERMS "mac_override", "mac_admin", "syslog", \
29 "wake_alarm", "block_suspend", "audit_read"
31 #if CAP_LAST_CAP > CAP_AUDIT_READ
32 #error New capability defined, please update COMMON_CAP2_PERMS.
36 * Note: The name for any socket class should be suffixed by "socket",
37 * and doesn't contain more than one substr of "socket".
39 struct security_class_mapping secclass_map
[] = {
41 { "compute_av", "compute_create", "compute_member",
42 "check_context", "load_policy", "compute_relabel",
43 "compute_user", "setenforce", "setbool", "setsecparam",
44 "setcheckreqprot", "read_policy", "validate_trans", NULL
} },
46 { "fork", "transition", "sigchld", "sigkill",
47 "sigstop", "signull", "signal", "ptrace", "getsched", "setsched",
48 "getsession", "getpgid", "setpgid", "getcap", "setcap", "share",
49 "getattr", "setexec", "setfscreate", "noatsecure", "siginh",
50 "setrlimit", "rlimitinh", "dyntransition", "setcurrent",
51 "execmem", "execstack", "execheap", "setkeycreate",
52 "setsockcreate", "getrlimit", NULL
} },
54 { "nnp_transition", "nosuid_transition", NULL
} },
56 { "ipc_info", "syslog_read", "syslog_mod",
57 "syslog_console", "module_request", "module_load", NULL
} },
59 { COMMON_CAP_PERMS
, NULL
} },
61 { "mount", "remount", "unmount", "getattr",
62 "relabelfrom", "relabelto", "associate", "quotamod",
66 "execute_no_trans", "entrypoint", NULL
} },
68 { COMMON_FILE_PERMS
, "add_name", "remove_name",
69 "reparent", "search", "rmdir", NULL
} },
70 { "fd", { "use", NULL
} },
72 { COMMON_FILE_PERMS
, NULL
} },
74 { COMMON_FILE_PERMS
, NULL
} },
76 { COMMON_FILE_PERMS
, NULL
} },
78 { COMMON_FILE_PERMS
, NULL
} },
80 { COMMON_FILE_PERMS
, NULL
} },
82 { COMMON_SOCK_PERMS
, NULL
} },
85 "node_bind", "name_connect",
89 "node_bind", NULL
} },
92 "node_bind", NULL
} },
94 { "recvfrom", "sendto", NULL
} },
96 { "ingress", "egress", NULL
} },
98 { COMMON_SOCK_PERMS
, NULL
} },
100 { COMMON_SOCK_PERMS
, NULL
} },
102 { COMMON_SOCK_PERMS
, NULL
} },
103 { "unix_stream_socket",
104 { COMMON_SOCK_PERMS
, "connectto", NULL
} },
105 { "unix_dgram_socket",
106 { COMMON_SOCK_PERMS
, NULL
} },
108 { COMMON_IPC_PERMS
, NULL
} },
109 { "msg", { "send", "receive", NULL
} },
111 { COMMON_IPC_PERMS
, "enqueue", NULL
} },
113 { COMMON_IPC_PERMS
, "lock", NULL
} },
115 { COMMON_IPC_PERMS
, NULL
} },
116 { "netlink_route_socket",
118 "nlmsg_read", "nlmsg_write", NULL
} },
119 { "netlink_tcpdiag_socket",
121 "nlmsg_read", "nlmsg_write", NULL
} },
122 { "netlink_nflog_socket",
123 { COMMON_SOCK_PERMS
, NULL
} },
124 { "netlink_xfrm_socket",
126 "nlmsg_read", "nlmsg_write", NULL
} },
127 { "netlink_selinux_socket",
128 { COMMON_SOCK_PERMS
, NULL
} },
129 { "netlink_iscsi_socket",
130 { COMMON_SOCK_PERMS
, NULL
} },
131 { "netlink_audit_socket",
133 "nlmsg_read", "nlmsg_write", "nlmsg_relay", "nlmsg_readpriv",
134 "nlmsg_tty_audit", NULL
} },
135 { "netlink_fib_lookup_socket",
136 { COMMON_SOCK_PERMS
, NULL
} },
137 { "netlink_connector_socket",
138 { COMMON_SOCK_PERMS
, NULL
} },
139 { "netlink_netfilter_socket",
140 { COMMON_SOCK_PERMS
, NULL
} },
141 { "netlink_dnrt_socket",
142 { COMMON_SOCK_PERMS
, NULL
} },
144 { "sendto", "recvfrom", "setcontext", "polmatch", NULL
} },
145 { "netlink_kobject_uevent_socket",
146 { COMMON_SOCK_PERMS
, NULL
} },
147 { "netlink_generic_socket",
148 { COMMON_SOCK_PERMS
, NULL
} },
149 { "netlink_scsitransport_socket",
150 { COMMON_SOCK_PERMS
, NULL
} },
151 { "netlink_rdma_socket",
152 { COMMON_SOCK_PERMS
, NULL
} },
153 { "netlink_crypto_socket",
154 { COMMON_SOCK_PERMS
, NULL
} },
155 { "appletalk_socket",
156 { COMMON_SOCK_PERMS
, NULL
} },
158 { "send", "recv", "relabelto", "forward_in", "forward_out", NULL
} },
160 { "view", "read", "write", "search", "link", "setattr", "create",
164 "node_bind", "name_connect", NULL
} },
165 { "memprotect", { "mmap_zero", NULL
} },
166 { "peer", { "recv", NULL
} },
168 { COMMON_CAP2_PERMS
, NULL
} },
169 { "kernel_service", { "use_as_override", "create_files_as", NULL
} },
171 { COMMON_SOCK_PERMS
, "attach_queue", NULL
} },
172 { "binder", { "impersonate", "call", "set_context_mgr", "transfer",
175 { COMMON_CAP_PERMS
, NULL
} },
177 { COMMON_CAP2_PERMS
, NULL
} },
180 "node_bind", "name_connect", "association", NULL
} },
183 "node_bind", NULL
} },
185 { COMMON_SOCK_PERMS
, 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
} },
212 { "bluetooth_socket",
213 { COMMON_SOCK_PERMS
, NULL
} },
215 { COMMON_SOCK_PERMS
, NULL
} },
217 { COMMON_SOCK_PERMS
, NULL
} },
219 { COMMON_SOCK_PERMS
, NULL
} },
221 { COMMON_SOCK_PERMS
, NULL
} },
222 { "ieee802154_socket",
223 { COMMON_SOCK_PERMS
, NULL
} },
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 { "access", NULL
} },
240 { "infiniband_endport",
241 { "manage_subnet", NULL
} },
243 {"map_create", "map_read", "map_write", "prog_load", "prog_run"} },
245 { COMMON_SOCK_PERMS
, NULL
} },
250 #error New address family defined, please update secclass_map.