classmap.h 7.8 KB

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