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