1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #include <linux/capability.h> 3 4 #define COMMON_FILE_SOCK_PERMS "ioctl", "read", "write", "create", \ 5 "getattr", "setattr", "lock", "relabelfrom", "relabelto", "append", "map" 6 7 #define COMMON_FILE_PERMS COMMON_FILE_SOCK_PERMS, "unlink", "link", \ 8 "rename", "execute", "quotaon", "mounton", "audit_access", \ 9 "open", "execmod" 10 11 #define COMMON_SOCK_PERMS COMMON_FILE_SOCK_PERMS, "bind", "connect", \ 12 "listen", "accept", "getopt", "setopt", "shutdown", "recvfrom", \ 13 "sendto", "name_bind" 14 15 #define COMMON_IPC_PERMS "create", "destroy", "getattr", "setattr", "read", \ 16 "write", "associate", "unix_read", "unix_write" 17 18 #define COMMON_CAP_PERMS "chown", "dac_override", "dac_read_search", \ 19 "fowner", "fsetid", "kill", "setgid", "setuid", "setpcap", \ 20 "linux_immutable", "net_bind_service", "net_broadcast", \ 21 "net_admin", "net_raw", "ipc_lock", "ipc_owner", "sys_module", \ 22 "sys_rawio", "sys_chroot", "sys_ptrace", "sys_pacct", "sys_admin", \ 23 "sys_boot", "sys_nice", "sys_resource", "sys_time", \ 24 "sys_tty_config", "mknod", "lease", "audit_write", \ 25 "audit_control", "setfcap" 26 27 #define COMMON_CAP2_PERMS "mac_override", "mac_admin", "syslog", \ 28 "wake_alarm", "block_suspend", "audit_read" 29 30 #if CAP_LAST_CAP > CAP_AUDIT_READ 31 #error New capability defined, please update COMMON_CAP2_PERMS. 32 #endif 33 34 /* 35 * Note: The name for any socket class should be suffixed by "socket", 36 * and doesn't contain more than one substr of "socket". 37 */ 38 struct security_class_mapping secclass_map[] = { 39 { "security", 40 { "compute_av", "compute_create", "compute_member", 41 "check_context", "load_policy", "compute_relabel", 42 "compute_user", "setenforce", "setbool", "setsecparam", 43 "setcheckreqprot", "read_policy", "validate_trans", NULL } }, 44 { "process", 45 { "fork", "transition", "sigchld", "sigkill", 46 "sigstop", "signull", "signal", "ptrace", "getsched", "setsched", 47 "getsession", "getpgid", "setpgid", "getcap", "setcap", "share", 48 "getattr", "setexec", "setfscreate", "noatsecure", "siginh", 49 "setrlimit", "rlimitinh", "dyntransition", "setcurrent", 50 "execmem", "execstack", "execheap", "setkeycreate", 51 "setsockcreate", "getrlimit", NULL } }, 52 { "process2", 53 { "nnp_transition", "nosuid_transition", NULL } }, 54 { "system", 55 { "ipc_info", "syslog_read", "syslog_mod", 56 "syslog_console", "module_request", "module_load", NULL } }, 57 { "capability", 58 { COMMON_CAP_PERMS, NULL } }, 59 { "filesystem", 60 { "mount", "remount", "unmount", "getattr", 61 "relabelfrom", "relabelto", "associate", "quotamod", 62 "quotaget", NULL } }, 63 { "file", 64 { COMMON_FILE_PERMS, 65 "execute_no_trans", "entrypoint", NULL } }, 66 { "dir", 67 { COMMON_FILE_PERMS, "add_name", "remove_name", 68 "reparent", "search", "rmdir", NULL } }, 69 { "fd", { "use", NULL } }, 70 { "lnk_file", 71 { COMMON_FILE_PERMS, NULL } }, 72 { "chr_file", 73 { COMMON_FILE_PERMS, NULL } }, 74 { "blk_file", 75 { COMMON_FILE_PERMS, NULL } }, 76 { "sock_file", 77 { COMMON_FILE_PERMS, NULL } }, 78 { "fifo_file", 79 { COMMON_FILE_PERMS, NULL } }, 80 { "socket", 81 { COMMON_SOCK_PERMS, NULL } }, 82 { "tcp_socket", 83 { COMMON_SOCK_PERMS, 84 "node_bind", "name_connect", 85 NULL } }, 86 { "udp_socket", 87 { COMMON_SOCK_PERMS, 88 "node_bind", NULL } }, 89 { "rawip_socket", 90 { COMMON_SOCK_PERMS, 91 "node_bind", NULL } }, 92 { "node", 93 { "recvfrom", "sendto", NULL } }, 94 { "netif", 95 { "ingress", "egress", NULL } }, 96 { "netlink_socket", 97 { COMMON_SOCK_PERMS, NULL } }, 98 { "packet_socket", 99 { COMMON_SOCK_PERMS, NULL } }, 100 { "key_socket", 101 { COMMON_SOCK_PERMS, NULL } }, 102 { "unix_stream_socket", 103 { COMMON_SOCK_PERMS, "connectto", NULL } }, 104 { "unix_dgram_socket", 105 { COMMON_SOCK_PERMS, NULL } }, 106 { "sem", 107 { COMMON_IPC_PERMS, NULL } }, 108 { "msg", { "send", "receive", NULL } }, 109 { "msgq", 110 { COMMON_IPC_PERMS, "enqueue", NULL } }, 111 { "shm", 112 { COMMON_IPC_PERMS, "lock", NULL } }, 113 { "ipc", 114 { COMMON_IPC_PERMS, NULL } }, 115 { "netlink_route_socket", 116 { COMMON_SOCK_PERMS, 117 "nlmsg_read", "nlmsg_write", NULL } }, 118 { "netlink_tcpdiag_socket", 119 { COMMON_SOCK_PERMS, 120 "nlmsg_read", "nlmsg_write", NULL } }, 121 { "netlink_nflog_socket", 122 { COMMON_SOCK_PERMS, NULL } }, 123 { "netlink_xfrm_socket", 124 { COMMON_SOCK_PERMS, 125 "nlmsg_read", "nlmsg_write", NULL } }, 126 { "netlink_selinux_socket", 127 { COMMON_SOCK_PERMS, NULL } }, 128 { "netlink_iscsi_socket", 129 { COMMON_SOCK_PERMS, NULL } }, 130 { "netlink_audit_socket", 131 { COMMON_SOCK_PERMS, 132 "nlmsg_read", "nlmsg_write", "nlmsg_relay", "nlmsg_readpriv", 133 "nlmsg_tty_audit", NULL } }, 134 { "netlink_fib_lookup_socket", 135 { COMMON_SOCK_PERMS, NULL } }, 136 { "netlink_connector_socket", 137 { COMMON_SOCK_PERMS, NULL } }, 138 { "netlink_netfilter_socket", 139 { COMMON_SOCK_PERMS, NULL } }, 140 { "netlink_dnrt_socket", 141 { COMMON_SOCK_PERMS, NULL } }, 142 { "association", 143 { "sendto", "recvfrom", "setcontext", "polmatch", NULL } }, 144 { "netlink_kobject_uevent_socket", 145 { COMMON_SOCK_PERMS, NULL } }, 146 { "netlink_generic_socket", 147 { COMMON_SOCK_PERMS, NULL } }, 148 { "netlink_scsitransport_socket", 149 { COMMON_SOCK_PERMS, NULL } }, 150 { "netlink_rdma_socket", 151 { COMMON_SOCK_PERMS, NULL } }, 152 { "netlink_crypto_socket", 153 { COMMON_SOCK_PERMS, NULL } }, 154 { "appletalk_socket", 155 { COMMON_SOCK_PERMS, NULL } }, 156 { "packet", 157 { "send", "recv", "relabelto", "forward_in", "forward_out", NULL } }, 158 { "key", 159 { "view", "read", "write", "search", "link", "setattr", "create", 160 NULL } }, 161 { "dccp_socket", 162 { COMMON_SOCK_PERMS, 163 "node_bind", "name_connect", NULL } }, 164 { "memprotect", { "mmap_zero", NULL } }, 165 { "peer", { "recv", NULL } }, 166 { "capability2", 167 { COMMON_CAP2_PERMS, NULL } }, 168 { "kernel_service", { "use_as_override", "create_files_as", NULL } }, 169 { "tun_socket", 170 { COMMON_SOCK_PERMS, "attach_queue", NULL } }, 171 { "binder", { "impersonate", "call", "set_context_mgr", "transfer", 172 NULL } }, 173 { "cap_userns", 174 { COMMON_CAP_PERMS, NULL } }, 175 { "cap2_userns", 176 { COMMON_CAP2_PERMS, NULL } }, 177 { "sctp_socket", 178 { COMMON_SOCK_PERMS, 179 "node_bind", NULL } }, 180 { "icmp_socket", 181 { COMMON_SOCK_PERMS, 182 "node_bind", NULL } }, 183 { "ax25_socket", 184 { COMMON_SOCK_PERMS, NULL } }, 185 { "ipx_socket", 186 { COMMON_SOCK_PERMS, NULL } }, 187 { "netrom_socket", 188 { COMMON_SOCK_PERMS, NULL } }, 189 { "atmpvc_socket", 190 { COMMON_SOCK_PERMS, NULL } }, 191 { "x25_socket", 192 { COMMON_SOCK_PERMS, NULL } }, 193 { "rose_socket", 194 { COMMON_SOCK_PERMS, NULL } }, 195 { "decnet_socket", 196 { COMMON_SOCK_PERMS, NULL } }, 197 { "atmsvc_socket", 198 { COMMON_SOCK_PERMS, NULL } }, 199 { "rds_socket", 200 { COMMON_SOCK_PERMS, NULL } }, 201 { "irda_socket", 202 { COMMON_SOCK_PERMS, NULL } }, 203 { "pppox_socket", 204 { COMMON_SOCK_PERMS, NULL } }, 205 { "llc_socket", 206 { COMMON_SOCK_PERMS, NULL } }, 207 { "can_socket", 208 { COMMON_SOCK_PERMS, NULL } }, 209 { "tipc_socket", 210 { COMMON_SOCK_PERMS, NULL } }, 211 { "bluetooth_socket", 212 { COMMON_SOCK_PERMS, NULL } }, 213 { "iucv_socket", 214 { COMMON_SOCK_PERMS, NULL } }, 215 { "rxrpc_socket", 216 { COMMON_SOCK_PERMS, NULL } }, 217 { "isdn_socket", 218 { COMMON_SOCK_PERMS, NULL } }, 219 { "phonet_socket", 220 { COMMON_SOCK_PERMS, NULL } }, 221 { "ieee802154_socket", 222 { COMMON_SOCK_PERMS, NULL } }, 223 { "caif_socket", 224 { COMMON_SOCK_PERMS, NULL } }, 225 { "alg_socket", 226 { COMMON_SOCK_PERMS, NULL } }, 227 { "nfc_socket", 228 { COMMON_SOCK_PERMS, NULL } }, 229 { "vsock_socket", 230 { COMMON_SOCK_PERMS, NULL } }, 231 { "kcm_socket", 232 { COMMON_SOCK_PERMS, NULL } }, 233 { "qipcrtr_socket", 234 { COMMON_SOCK_PERMS, NULL } }, 235 { "smc_socket", 236 { COMMON_SOCK_PERMS, NULL } }, 237 { "infiniband_pkey", 238 { "access", NULL } }, 239 { "infiniband_endport", 240 { "manage_subnet", NULL } }, 241 { "bpf", 242 {"map_create", "map_read", "map_write", "prog_load", "prog_run"} }, 243 { NULL } 244 }; 245 246 #if PF_MAX > 44 247 #error New address family defined, please update secclass_map. 248 #endif 249