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" 31 32 #if CAP_LAST_CAP > CAP_AUDIT_READ 33 #error New capability defined, please update COMMON_CAP2_PERMS. 34 #endif 35 36 /* 37 * Note: The name for any socket class should be suffixed by "socket", 38 * and doesn't contain more than one substr of "socket". 39 */ 40 struct security_class_mapping secclass_map[] = { 41 { "security", 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 } }, 46 { "process", 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 } }, 54 { "process2", 55 { "nnp_transition", "nosuid_transition", NULL } }, 56 { "system", 57 { "ipc_info", "syslog_read", "syslog_mod", 58 "syslog_console", "module_request", "module_load", NULL } }, 59 { "capability", 60 { COMMON_CAP_PERMS, NULL } }, 61 { "filesystem", 62 { "mount", "remount", "unmount", "getattr", 63 "relabelfrom", "relabelto", "associate", "quotamod", 64 "quotaget", "watch", NULL } }, 65 { "file", 66 { COMMON_FILE_PERMS, 67 "execute_no_trans", "entrypoint", NULL } }, 68 { "dir", 69 { COMMON_FILE_PERMS, "add_name", "remove_name", 70 "reparent", "search", "rmdir", NULL } }, 71 { "fd", { "use", NULL } }, 72 { "lnk_file", 73 { COMMON_FILE_PERMS, NULL } }, 74 { "chr_file", 75 { COMMON_FILE_PERMS, NULL } }, 76 { "blk_file", 77 { COMMON_FILE_PERMS, NULL } }, 78 { "sock_file", 79 { COMMON_FILE_PERMS, NULL } }, 80 { "fifo_file", 81 { COMMON_FILE_PERMS, NULL } }, 82 { "socket", 83 { COMMON_SOCK_PERMS, NULL } }, 84 { "tcp_socket", 85 { COMMON_SOCK_PERMS, 86 "node_bind", "name_connect", 87 NULL } }, 88 { "udp_socket", 89 { COMMON_SOCK_PERMS, 90 "node_bind", NULL } }, 91 { "rawip_socket", 92 { COMMON_SOCK_PERMS, 93 "node_bind", NULL } }, 94 { "node", 95 { "recvfrom", "sendto", NULL } }, 96 { "netif", 97 { "ingress", "egress", NULL } }, 98 { "netlink_socket", 99 { COMMON_SOCK_PERMS, NULL } }, 100 { "packet_socket", 101 { COMMON_SOCK_PERMS, NULL } }, 102 { "key_socket", 103 { COMMON_SOCK_PERMS, NULL } }, 104 { "unix_stream_socket", 105 { COMMON_SOCK_PERMS, "connectto", NULL } }, 106 { "unix_dgram_socket", 107 { COMMON_SOCK_PERMS, NULL } }, 108 { "sem", 109 { COMMON_IPC_PERMS, NULL } }, 110 { "msg", { "send", "receive", NULL } }, 111 { "msgq", 112 { COMMON_IPC_PERMS, "enqueue", NULL } }, 113 { "shm", 114 { COMMON_IPC_PERMS, "lock", NULL } }, 115 { "ipc", 116 { COMMON_IPC_PERMS, NULL } }, 117 { "netlink_route_socket", 118 { COMMON_SOCK_PERMS, 119 "nlmsg_read", "nlmsg_write", NULL } }, 120 { "netlink_tcpdiag_socket", 121 { COMMON_SOCK_PERMS, 122 "nlmsg_read", "nlmsg_write", NULL } }, 123 { "netlink_nflog_socket", 124 { COMMON_SOCK_PERMS, NULL } }, 125 { "netlink_xfrm_socket", 126 { COMMON_SOCK_PERMS, 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", 133 { COMMON_SOCK_PERMS, 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 } }, 144 { "association", 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 } }, 158 { "packet", 159 { "send", "recv", "relabelto", "forward_in", "forward_out", NULL } }, 160 { "key", 161 { "view", "read", "write", "search", "link", "setattr", "create", 162 NULL } }, 163 { "dccp_socket", 164 { COMMON_SOCK_PERMS, 165 "node_bind", "name_connect", NULL } }, 166 { "memprotect", { "mmap_zero", NULL } }, 167 { "peer", { "recv", NULL } }, 168 { "capability2", 169 { COMMON_CAP2_PERMS, NULL } }, 170 { "kernel_service", { "use_as_override", "create_files_as", NULL } }, 171 { "tun_socket", 172 { COMMON_SOCK_PERMS, "attach_queue", NULL } }, 173 { "binder", { "impersonate", "call", "set_context_mgr", "transfer", 174 NULL } }, 175 { "cap_userns", 176 { COMMON_CAP_PERMS, NULL } }, 177 { "cap2_userns", 178 { COMMON_CAP2_PERMS, NULL } }, 179 { "sctp_socket", 180 { COMMON_SOCK_PERMS, 181 "node_bind", "name_connect", "association", NULL } }, 182 { "icmp_socket", 183 { COMMON_SOCK_PERMS, 184 "node_bind", NULL } }, 185 { "ax25_socket", 186 { COMMON_SOCK_PERMS, NULL } }, 187 { "ipx_socket", 188 { COMMON_SOCK_PERMS, NULL } }, 189 { "netrom_socket", 190 { COMMON_SOCK_PERMS, NULL } }, 191 { "atmpvc_socket", 192 { COMMON_SOCK_PERMS, NULL } }, 193 { "x25_socket", 194 { COMMON_SOCK_PERMS, NULL } }, 195 { "rose_socket", 196 { COMMON_SOCK_PERMS, NULL } }, 197 { "decnet_socket", 198 { COMMON_SOCK_PERMS, NULL } }, 199 { "atmsvc_socket", 200 { COMMON_SOCK_PERMS, NULL } }, 201 { "rds_socket", 202 { COMMON_SOCK_PERMS, NULL } }, 203 { "irda_socket", 204 { COMMON_SOCK_PERMS, NULL } }, 205 { "pppox_socket", 206 { COMMON_SOCK_PERMS, NULL } }, 207 { "llc_socket", 208 { COMMON_SOCK_PERMS, NULL } }, 209 { "can_socket", 210 { COMMON_SOCK_PERMS, NULL } }, 211 { "tipc_socket", 212 { COMMON_SOCK_PERMS, NULL } }, 213 { "bluetooth_socket", 214 { COMMON_SOCK_PERMS, NULL } }, 215 { "iucv_socket", 216 { COMMON_SOCK_PERMS, NULL } }, 217 { "rxrpc_socket", 218 { COMMON_SOCK_PERMS, NULL } }, 219 { "isdn_socket", 220 { COMMON_SOCK_PERMS, NULL } }, 221 { "phonet_socket", 222 { COMMON_SOCK_PERMS, NULL } }, 223 { "ieee802154_socket", 224 { COMMON_SOCK_PERMS, NULL } }, 225 { "caif_socket", 226 { COMMON_SOCK_PERMS, NULL } }, 227 { "alg_socket", 228 { COMMON_SOCK_PERMS, NULL } }, 229 { "nfc_socket", 230 { COMMON_SOCK_PERMS, NULL } }, 231 { "vsock_socket", 232 { COMMON_SOCK_PERMS, NULL } }, 233 { "kcm_socket", 234 { COMMON_SOCK_PERMS, NULL } }, 235 { "qipcrtr_socket", 236 { COMMON_SOCK_PERMS, NULL } }, 237 { "smc_socket", 238 { COMMON_SOCK_PERMS, NULL } }, 239 { "infiniband_pkey", 240 { "access", NULL } }, 241 { "infiniband_endport", 242 { "manage_subnet", NULL } }, 243 { "bpf", 244 {"map_create", "map_read", "map_write", "prog_load", "prog_run"} }, 245 { "xdp_socket", 246 { COMMON_SOCK_PERMS, NULL } }, 247 { "perf_event", 248 {"open", "cpu", "kernel", "tracepoint", "read", "write"} }, 249 { "lockdown", 250 { "integrity", "confidentiality", NULL } }, 251 { NULL } 252 }; 253 254 #if PF_MAX > 45 255 #error New address family defined, please update secclass_map. 256 #endif 257