1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #include <linux/capability.h> 3 #include <linux/socket.h> 4 5 #define COMMON_FILE_SOCK_PERMS "ioctl", "read", "write", "create", \ 6 "getattr", "setattr", "lock", "relabelfrom", "relabelto", "append", "map" 7 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" 12 13 #define COMMON_SOCK_PERMS COMMON_FILE_SOCK_PERMS, "bind", "connect", \ 14 "listen", "accept", "getopt", "setopt", "shutdown", "recvfrom", \ 15 "sendto", "name_bind" 16 17 #define COMMON_IPC_PERMS "create", "destroy", "getattr", "setattr", "read", \ 18 "write", "associate", "unix_read", "unix_write" 19 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" 28 29 #define COMMON_CAP2_PERMS "mac_override", "mac_admin", "syslog", \ 30 "wake_alarm", "block_suspend", "audit_read", "perfmon", "bpf", \ 31 "checkpoint_restore" 32 33 #if CAP_LAST_CAP > CAP_CHECKPOINT_RESTORE 34 #error New capability defined, please update COMMON_CAP2_PERMS. 35 #endif 36 37 /* 38 * Note: The name for any socket class should be suffixed by "socket", 39 * and doesn't contain more than one substr of "socket". 40 */ 41 const struct security_class_mapping secclass_map[] = { 42 { "security", 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 } }, 47 { "process", 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 } }, 55 { "process2", 56 { "nnp_transition", "nosuid_transition", NULL } }, 57 { "system", 58 { "ipc_info", "syslog_read", "syslog_mod", 59 "syslog_console", "module_request", "module_load", NULL } }, 60 { "capability", 61 { COMMON_CAP_PERMS, NULL } }, 62 { "filesystem", 63 { "mount", "remount", "unmount", "getattr", 64 "relabelfrom", "relabelto", "associate", "quotamod", 65 "quotaget", "watch", NULL } }, 66 { "file", 67 { COMMON_FILE_PERMS, 68 "execute_no_trans", "entrypoint", NULL } }, 69 { "dir", 70 { COMMON_FILE_PERMS, "add_name", "remove_name", 71 "reparent", "search", "rmdir", NULL } }, 72 { "fd", { "use", NULL } }, 73 { "lnk_file", 74 { COMMON_FILE_PERMS, NULL } }, 75 { "chr_file", 76 { COMMON_FILE_PERMS, NULL } }, 77 { "blk_file", 78 { COMMON_FILE_PERMS, NULL } }, 79 { "sock_file", 80 { COMMON_FILE_PERMS, NULL } }, 81 { "fifo_file", 82 { COMMON_FILE_PERMS, NULL } }, 83 { "socket", 84 { COMMON_SOCK_PERMS, NULL } }, 85 { "tcp_socket", 86 { COMMON_SOCK_PERMS, 87 "node_bind", "name_connect", 88 NULL } }, 89 { "udp_socket", 90 { COMMON_SOCK_PERMS, 91 "node_bind", NULL } }, 92 { "rawip_socket", 93 { COMMON_SOCK_PERMS, 94 "node_bind", NULL } }, 95 { "node", 96 { "recvfrom", "sendto", NULL } }, 97 { "netif", 98 { "ingress", "egress", NULL } }, 99 { "netlink_socket", 100 { COMMON_SOCK_PERMS, NULL } }, 101 { "packet_socket", 102 { COMMON_SOCK_PERMS, NULL } }, 103 { "key_socket", 104 { COMMON_SOCK_PERMS, NULL } }, 105 { "unix_stream_socket", 106 { COMMON_SOCK_PERMS, "connectto", NULL } }, 107 { "unix_dgram_socket", 108 { COMMON_SOCK_PERMS, NULL } }, 109 { "sem", 110 { COMMON_IPC_PERMS, NULL } }, 111 { "msg", { "send", "receive", NULL } }, 112 { "msgq", 113 { COMMON_IPC_PERMS, "enqueue", NULL } }, 114 { "shm", 115 { COMMON_IPC_PERMS, "lock", NULL } }, 116 { "ipc", 117 { COMMON_IPC_PERMS, NULL } }, 118 { "netlink_route_socket", 119 { COMMON_SOCK_PERMS, 120 "nlmsg_read", "nlmsg_write", "nlmsg_readpriv", "nlmsg_getneigh", 121 NULL } }, 122 { "netlink_tcpdiag_socket", 123 { COMMON_SOCK_PERMS, 124 "nlmsg_read", "nlmsg_write", NULL } }, 125 { "netlink_nflog_socket", 126 { COMMON_SOCK_PERMS, NULL } }, 127 { "netlink_xfrm_socket", 128 { COMMON_SOCK_PERMS, 129 "nlmsg_read", "nlmsg_write", NULL } }, 130 { "netlink_selinux_socket", 131 { COMMON_SOCK_PERMS, NULL } }, 132 { "netlink_iscsi_socket", 133 { COMMON_SOCK_PERMS, NULL } }, 134 { "netlink_audit_socket", 135 { COMMON_SOCK_PERMS, 136 "nlmsg_read", "nlmsg_write", "nlmsg_relay", "nlmsg_readpriv", 137 "nlmsg_tty_audit", NULL } }, 138 { "netlink_fib_lookup_socket", 139 { COMMON_SOCK_PERMS, NULL } }, 140 { "netlink_connector_socket", 141 { COMMON_SOCK_PERMS, NULL } }, 142 { "netlink_netfilter_socket", 143 { COMMON_SOCK_PERMS, NULL } }, 144 { "netlink_dnrt_socket", 145 { COMMON_SOCK_PERMS, NULL } }, 146 { "association", 147 { "sendto", "recvfrom", "setcontext", "polmatch", NULL } }, 148 { "netlink_kobject_uevent_socket", 149 { COMMON_SOCK_PERMS, NULL } }, 150 { "netlink_generic_socket", 151 { COMMON_SOCK_PERMS, NULL } }, 152 { "netlink_scsitransport_socket", 153 { COMMON_SOCK_PERMS, NULL } }, 154 { "netlink_rdma_socket", 155 { COMMON_SOCK_PERMS, NULL } }, 156 { "netlink_crypto_socket", 157 { COMMON_SOCK_PERMS, NULL } }, 158 { "appletalk_socket", 159 { COMMON_SOCK_PERMS, NULL } }, 160 { "packet", 161 { "send", "recv", "relabelto", "forward_in", "forward_out", NULL } }, 162 { "key", 163 { "view", "read", "write", "search", "link", "setattr", "create", 164 NULL } }, 165 { "dccp_socket", 166 { COMMON_SOCK_PERMS, 167 "node_bind", "name_connect", NULL } }, 168 { "memprotect", { "mmap_zero", NULL } }, 169 { "peer", { "recv", NULL } }, 170 { "capability2", 171 { COMMON_CAP2_PERMS, NULL } }, 172 { "kernel_service", { "use_as_override", "create_files_as", NULL } }, 173 { "tun_socket", 174 { COMMON_SOCK_PERMS, "attach_queue", NULL } }, 175 { "binder", { "impersonate", "call", "set_context_mgr", "transfer", 176 NULL } }, 177 { "cap_userns", 178 { COMMON_CAP_PERMS, NULL } }, 179 { "cap2_userns", 180 { COMMON_CAP2_PERMS, NULL } }, 181 { "sctp_socket", 182 { COMMON_SOCK_PERMS, 183 "node_bind", "name_connect", "association", NULL } }, 184 { "icmp_socket", 185 { COMMON_SOCK_PERMS, 186 "node_bind", NULL } }, 187 { "ax25_socket", 188 { COMMON_SOCK_PERMS, NULL } }, 189 { "ipx_socket", 190 { COMMON_SOCK_PERMS, NULL } }, 191 { "netrom_socket", 192 { COMMON_SOCK_PERMS, NULL } }, 193 { "atmpvc_socket", 194 { COMMON_SOCK_PERMS, NULL } }, 195 { "x25_socket", 196 { COMMON_SOCK_PERMS, NULL } }, 197 { "rose_socket", 198 { COMMON_SOCK_PERMS, NULL } }, 199 { "decnet_socket", 200 { COMMON_SOCK_PERMS, NULL } }, 201 { "atmsvc_socket", 202 { COMMON_SOCK_PERMS, NULL } }, 203 { "rds_socket", 204 { COMMON_SOCK_PERMS, NULL } }, 205 { "irda_socket", 206 { COMMON_SOCK_PERMS, NULL } }, 207 { "pppox_socket", 208 { COMMON_SOCK_PERMS, NULL } }, 209 { "llc_socket", 210 { COMMON_SOCK_PERMS, NULL } }, 211 { "can_socket", 212 { COMMON_SOCK_PERMS, NULL } }, 213 { "tipc_socket", 214 { COMMON_SOCK_PERMS, NULL } }, 215 { "bluetooth_socket", 216 { COMMON_SOCK_PERMS, NULL } }, 217 { "iucv_socket", 218 { COMMON_SOCK_PERMS, NULL } }, 219 { "rxrpc_socket", 220 { COMMON_SOCK_PERMS, NULL } }, 221 { "isdn_socket", 222 { COMMON_SOCK_PERMS, NULL } }, 223 { "phonet_socket", 224 { COMMON_SOCK_PERMS, NULL } }, 225 { "ieee802154_socket", 226 { COMMON_SOCK_PERMS, NULL } }, 227 { "caif_socket", 228 { COMMON_SOCK_PERMS, NULL } }, 229 { "alg_socket", 230 { COMMON_SOCK_PERMS, NULL } }, 231 { "nfc_socket", 232 { COMMON_SOCK_PERMS, NULL } }, 233 { "vsock_socket", 234 { COMMON_SOCK_PERMS, NULL } }, 235 { "kcm_socket", 236 { COMMON_SOCK_PERMS, NULL } }, 237 { "qipcrtr_socket", 238 { COMMON_SOCK_PERMS, NULL } }, 239 { "smc_socket", 240 { COMMON_SOCK_PERMS, NULL } }, 241 { "infiniband_pkey", 242 { "access", NULL } }, 243 { "infiniband_endport", 244 { "manage_subnet", NULL } }, 245 { "bpf", 246 { "map_create", "map_read", "map_write", "prog_load", "prog_run", 247 NULL } }, 248 { "xdp_socket", 249 { COMMON_SOCK_PERMS, NULL } }, 250 { "mctp_socket", 251 { COMMON_SOCK_PERMS, NULL } }, 252 { "perf_event", 253 { "open", "cpu", "kernel", "tracepoint", "read", "write", NULL } }, 254 { "anon_inode", 255 { COMMON_FILE_PERMS, NULL } }, 256 { "io_uring", 257 { "override_creds", "sqpoll", "cmd", NULL } }, 258 { "user_namespace", 259 { "create", NULL } }, 260 { NULL } 261 }; 262 263 #if PF_MAX > 46 264 #error New address family defined, please update secclass_map. 265 #endif 266