github.com/reds/docker@v1.11.2-rc1/contrib/docker-engine-selinux/docker.te (about)

     1  policy_module(docker, 1.0.0)
     2  
     3  ########################################
     4  #
     5  # Declarations
     6  #
     7  
     8  ## <desc>
     9  ## <p>
    10  ## Allow sandbox containers manage fuse files
    11  ## </p>
    12  ## </desc>
    13  gen_tunable(virt_sandbox_use_fusefs, false)
    14  
    15  ## <desc>
    16  ##  <p>
    17  ##  Determine whether docker can
    18  ##  connect to all TCP ports.
    19  ##  </p>
    20  ## </desc>
    21  gen_tunable(docker_connect_any, false)
    22  
    23  type docker_t;
    24  type docker_exec_t;
    25  init_daemon_domain(docker_t, docker_exec_t)
    26  domain_subj_id_change_exemption(docker_t)
    27  domain_role_change_exemption(docker_t)
    28  
    29  type spc_t;
    30  domain_type(spc_t)
    31  role system_r types spc_t;
    32  
    33  type spc_var_run_t;
    34  files_pid_file(spc_var_run_t)
    35  
    36  type docker_var_lib_t;
    37  files_type(docker_var_lib_t)
    38  
    39  type docker_home_t;
    40  userdom_user_home_content(docker_home_t)
    41  
    42  type docker_config_t;
    43  files_config_file(docker_config_t)
    44  
    45  type docker_lock_t;
    46  files_lock_file(docker_lock_t)
    47  
    48  type docker_log_t;
    49  logging_log_file(docker_log_t)
    50  
    51  type docker_tmp_t;
    52  files_tmp_file(docker_tmp_t)
    53  
    54  type docker_tmpfs_t;
    55  files_tmpfs_file(docker_tmpfs_t)
    56  
    57  type docker_var_run_t;
    58  files_pid_file(docker_var_run_t)
    59  
    60  type docker_unit_file_t;
    61  systemd_unit_file(docker_unit_file_t)
    62  
    63  type docker_devpts_t;
    64  term_pty(docker_devpts_t)
    65  
    66  type docker_share_t;
    67  files_type(docker_share_t)
    68  
    69  ########################################
    70  #
    71  # docker local policy
    72  #
    73  allow docker_t self:capability { chown kill fowner fsetid mknod net_admin net_bind_service net_raw setfcap };
    74  allow docker_t self:tun_socket relabelto;
    75  allow docker_t self:process { getattr signal_perms setrlimit setfscreate };
    76  allow docker_t self:fifo_file rw_fifo_file_perms;
    77  allow docker_t self:unix_stream_socket create_stream_socket_perms;
    78  allow docker_t self:tcp_socket create_stream_socket_perms;
    79  allow docker_t self:udp_socket create_socket_perms;
    80  allow docker_t self:capability2 block_suspend;
    81  
    82  manage_files_pattern(docker_t, docker_home_t, docker_home_t)
    83  manage_dirs_pattern(docker_t, docker_home_t, docker_home_t)
    84  manage_lnk_files_pattern(docker_t, docker_home_t, docker_home_t)
    85  userdom_admin_home_dir_filetrans(docker_t, docker_home_t, dir, ".docker")
    86  
    87  manage_dirs_pattern(docker_t, docker_config_t, docker_config_t)
    88  manage_files_pattern(docker_t, docker_config_t, docker_config_t)
    89  files_etc_filetrans(docker_t, docker_config_t, dir, "docker")
    90  
    91  manage_dirs_pattern(docker_t, docker_lock_t, docker_lock_t)
    92  manage_files_pattern(docker_t, docker_lock_t, docker_lock_t)
    93  
    94  manage_dirs_pattern(docker_t, docker_log_t, docker_log_t)
    95  manage_files_pattern(docker_t, docker_log_t, docker_log_t)
    96  manage_lnk_files_pattern(docker_t, docker_log_t, docker_log_t)
    97  logging_log_filetrans(docker_t, docker_log_t, { dir file lnk_file })
    98  allow docker_t docker_log_t:dir_file_class_set { relabelfrom relabelto };
    99  
   100  manage_dirs_pattern(docker_t, docker_tmp_t, docker_tmp_t)
   101  manage_files_pattern(docker_t, docker_tmp_t, docker_tmp_t)
   102  manage_lnk_files_pattern(docker_t, docker_tmp_t, docker_tmp_t)
   103  files_tmp_filetrans(docker_t, docker_tmp_t, { dir file lnk_file })
   104  
   105  manage_dirs_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
   106  manage_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
   107  manage_lnk_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
   108  manage_fifo_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
   109  manage_chr_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
   110  manage_blk_files_pattern(docker_t, docker_tmpfs_t, docker_tmpfs_t)
   111  allow docker_t docker_tmpfs_t:dir relabelfrom;
   112  can_exec(docker_t, docker_tmpfs_t)
   113  fs_tmpfs_filetrans(docker_t, docker_tmpfs_t, { dir file })
   114  allow docker_t docker_tmpfs_t:chr_file mounton;
   115  
   116  manage_dirs_pattern(docker_t, docker_share_t, docker_share_t)
   117  manage_files_pattern(docker_t, docker_share_t, docker_share_t)
   118  manage_lnk_files_pattern(docker_t, docker_share_t, docker_share_t)
   119  allow docker_t docker_share_t:dir_file_class_set { relabelfrom relabelto };
   120  
   121  can_exec(docker_t, docker_share_t)
   122  #docker_filetrans_named_content(docker_t)
   123  
   124  manage_dirs_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
   125  manage_chr_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
   126  manage_blk_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
   127  manage_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
   128  manage_lnk_files_pattern(docker_t, docker_var_lib_t, docker_var_lib_t)
   129  allow docker_t docker_var_lib_t:dir_file_class_set { relabelfrom relabelto };
   130  files_var_lib_filetrans(docker_t, docker_var_lib_t, { dir file lnk_file })
   131  
   132  manage_dirs_pattern(docker_t, docker_var_run_t, docker_var_run_t)
   133  manage_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
   134  manage_sock_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
   135  manage_lnk_files_pattern(docker_t, docker_var_run_t, docker_var_run_t)
   136  files_pid_filetrans(docker_t, docker_var_run_t, { dir file lnk_file sock_file })
   137  
   138  allow docker_t docker_devpts_t:chr_file { relabelfrom rw_chr_file_perms setattr_chr_file_perms };
   139  term_create_pty(docker_t, docker_devpts_t)
   140  
   141  kernel_read_system_state(docker_t)
   142  kernel_read_network_state(docker_t)
   143  kernel_read_all_sysctls(docker_t)
   144  kernel_rw_net_sysctls(docker_t)
   145  kernel_setsched(docker_t)
   146  kernel_read_all_proc(docker_t)
   147  
   148  domain_use_interactive_fds(docker_t)
   149  domain_dontaudit_read_all_domains_state(docker_t)
   150  
   151  corecmd_exec_bin(docker_t)
   152  corecmd_exec_shell(docker_t)
   153  
   154  corenet_tcp_bind_generic_node(docker_t)
   155  corenet_tcp_sendrecv_generic_if(docker_t)
   156  corenet_tcp_sendrecv_generic_node(docker_t)
   157  corenet_tcp_sendrecv_generic_port(docker_t)
   158  corenet_tcp_bind_all_ports(docker_t)
   159  corenet_tcp_connect_http_port(docker_t)
   160  corenet_tcp_connect_commplex_main_port(docker_t)
   161  corenet_udp_sendrecv_generic_if(docker_t)
   162  corenet_udp_sendrecv_generic_node(docker_t)
   163  corenet_udp_sendrecv_all_ports(docker_t)
   164  corenet_udp_bind_generic_node(docker_t)
   165  corenet_udp_bind_all_ports(docker_t)
   166  
   167  files_read_config_files(docker_t)
   168  files_dontaudit_getattr_all_dirs(docker_t)
   169  files_dontaudit_getattr_all_files(docker_t)
   170  
   171  fs_read_cgroup_files(docker_t)
   172  fs_read_tmpfs_symlinks(docker_t)
   173  fs_search_all(docker_t)
   174  fs_getattr_all_fs(docker_t)
   175  
   176  storage_raw_rw_fixed_disk(docker_t)
   177  
   178  auth_use_nsswitch(docker_t)
   179  auth_dontaudit_getattr_shadow(docker_t)
   180  
   181  init_read_state(docker_t)
   182  init_status(docker_t)
   183  
   184  logging_send_audit_msgs(docker_t)
   185  logging_send_syslog_msg(docker_t)
   186  
   187  miscfiles_read_localization(docker_t)
   188  
   189  mount_domtrans(docker_t)
   190  
   191  seutil_read_default_contexts(docker_t)
   192  seutil_read_config(docker_t)
   193  
   194  sysnet_dns_name_resolve(docker_t)
   195  sysnet_exec_ifconfig(docker_t)
   196  
   197  optional_policy(`
   198  	rpm_exec(docker_t)
   199  	rpm_read_db(docker_t)
   200  	rpm_exec(docker_t)
   201  ')
   202  
   203  optional_policy(`
   204  	fstools_domtrans(docker_t)
   205  ')
   206  
   207  optional_policy(`
   208  	iptables_domtrans(docker_t)
   209  ')
   210  
   211  optional_policy(`
   212  	openvswitch_stream_connect(docker_t)
   213  ')
   214  
   215  allow docker_t self:capability { dac_override setgid setpcap setuid sys_admin sys_boot sys_chroot sys_ptrace };
   216  
   217  allow docker_t self:process { getcap setcap setexec setpgid setsched signal_perms };
   218  
   219  allow docker_t self:netlink_route_socket rw_netlink_socket_perms;;
   220  allow docker_t self:netlink_audit_socket create_netlink_socket_perms;
   221  allow docker_t self:unix_dgram_socket { create_socket_perms sendto };
   222  allow docker_t self:unix_stream_socket { create_stream_socket_perms connectto };
   223  
   224  allow docker_t docker_var_lib_t:dir mounton;
   225  allow docker_t docker_var_lib_t:chr_file mounton;
   226  can_exec(docker_t, docker_var_lib_t)
   227  
   228  kernel_dontaudit_setsched(docker_t)
   229  kernel_get_sysvipc_info(docker_t)
   230  kernel_request_load_module(docker_t)
   231  kernel_mounton_messages(docker_t)
   232  kernel_mounton_all_proc(docker_t)
   233  kernel_mounton_all_sysctls(docker_t)
   234  kernel_unlabeled_entry_type(spc_t)
   235  kernel_unlabeled_domtrans(docker_t, spc_t)
   236  
   237  dev_getattr_all(docker_t)
   238  dev_getattr_sysfs_fs(docker_t)
   239  dev_read_urand(docker_t)
   240  dev_read_lvm_control(docker_t)
   241  dev_rw_sysfs(docker_t)
   242  dev_rw_loop_control(docker_t)
   243  dev_rw_lvm_control(docker_t)
   244  
   245  files_getattr_isid_type_dirs(docker_t)
   246  files_manage_isid_type_dirs(docker_t)
   247  files_manage_isid_type_files(docker_t)
   248  files_manage_isid_type_symlinks(docker_t)
   249  files_manage_isid_type_chr_files(docker_t)
   250  files_manage_isid_type_blk_files(docker_t)
   251  files_exec_isid_files(docker_t)
   252  files_mounton_isid(docker_t)
   253  files_mounton_non_security(docker_t)
   254  files_mounton_isid_type_chr_file(docker_t)
   255  
   256  fs_mount_all_fs(docker_t)
   257  fs_unmount_all_fs(docker_t)
   258  fs_remount_all_fs(docker_t)
   259  files_mounton_isid(docker_t)
   260  fs_manage_cgroup_dirs(docker_t)
   261  fs_manage_cgroup_files(docker_t)
   262  fs_relabelfrom_xattr_fs(docker_t)
   263  fs_relabelfrom_tmpfs(docker_t)
   264  fs_read_tmpfs_symlinks(docker_t)
   265  fs_list_hugetlbfs(docker_t)
   266  
   267  term_use_generic_ptys(docker_t)
   268  term_use_ptmx(docker_t)
   269  term_getattr_pty_fs(docker_t)
   270  term_relabel_pty_fs(docker_t)
   271  term_mounton_unallocated_ttys(docker_t)
   272  
   273  modutils_domtrans_insmod(docker_t)
   274  
   275  systemd_status_all_unit_files(docker_t)
   276  systemd_start_systemd_services(docker_t)
   277  
   278  userdom_stream_connect(docker_t)
   279  userdom_search_user_home_content(docker_t)
   280  userdom_read_all_users_state(docker_t)
   281  userdom_relabel_user_home_files(docker_t)
   282  userdom_relabel_user_tmp_files(docker_t)
   283  userdom_relabel_user_tmp_dirs(docker_t)
   284  
   285  optional_policy(`
   286  	gpm_getattr_gpmctl(docker_t)
   287  ')
   288  
   289  optional_policy(`
   290  	dbus_system_bus_client(docker_t)
   291  	init_dbus_chat(docker_t)
   292  	init_start_transient_unit(docker_t)
   293  
   294  	optional_policy(`
   295  		systemd_dbus_chat_logind(docker_t)
   296  	')
   297  
   298  	optional_policy(`
   299  		firewalld_dbus_chat(docker_t)
   300  	')
   301  ')
   302  
   303  optional_policy(`
   304  	udev_read_db(docker_t)
   305  ')
   306  
   307  optional_policy(`
   308  	virt_read_config(docker_t)
   309  	virt_exec(docker_t)
   310  	virt_stream_connect(docker_t)
   311  	virt_stream_connect_sandbox(docker_t)
   312  	virt_exec_sandbox_files(docker_t)
   313  	virt_manage_sandbox_files(docker_t)
   314  	virt_relabel_sandbox_filesystem(docker_t)
   315  	virt_transition_svirt_sandbox(docker_t, system_r)
   316  	virt_mounton_sandbox_file(docker_t)
   317  #	virt_attach_sandbox_tun_iface(docker_t)
   318  	allow docker_t svirt_sandbox_domain:tun_socket relabelfrom;
   319  ')
   320  
   321  tunable_policy(`docker_connect_any',`
   322      corenet_tcp_connect_all_ports(docker_t)
   323      corenet_sendrecv_all_packets(docker_t)
   324      corenet_tcp_sendrecv_all_ports(docker_t)
   325  ')
   326  
   327  ########################################
   328  #
   329  # spc local policy
   330  #
   331  domain_entry_file(spc_t, docker_share_t)
   332  domain_entry_file(spc_t, docker_var_lib_t)
   333  role system_r types spc_t;
   334  
   335  domain_entry_file(spc_t, docker_share_t)
   336  domain_entry_file(spc_t, docker_var_lib_t)
   337  domtrans_pattern(docker_t, docker_share_t, spc_t)
   338  domtrans_pattern(docker_t, docker_var_lib_t, spc_t)
   339  allow docker_t spc_t:process { setsched signal_perms };
   340  ps_process_pattern(docker_t, spc_t)
   341  allow docker_t spc_t:socket_class_set { relabelto relabelfrom };
   342  
   343  optional_policy(`
   344  	dbus_chat_system_bus(spc_t)
   345  ')
   346  
   347  optional_policy(`
   348  	unconfined_domain_noaudit(spc_t)
   349  ')
   350  
   351  optional_policy(`
   352  	unconfined_domain(docker_t)
   353  ')
   354  
   355  optional_policy(`
   356  	virt_transition_svirt_sandbox(spc_t, system_r)
   357  ')
   358  
   359  ########################################
   360  #
   361  # docker upstream policy
   362  #
   363  
   364  optional_policy(`
   365  #    domain_stub_named_filetrans_domain()
   366       gen_require(`
   367          attribute named_filetrans_domain;
   368       ')
   369  
   370        docker_filetrans_named_content(named_filetrans_domain)
   371  ')
   372  
   373  optional_policy(`
   374      lvm_stub()
   375      docker_rw_sem(lvm_t)
   376  ')
   377  
   378  optional_policy(`
   379      staff_stub()
   380      docker_stream_connect(staff_t)
   381      docker_exec(staff_t)
   382  ')
   383  
   384  optional_policy(`
   385      virt_stub_svirt_sandbox_domain()
   386      virt_stub_svirt_sandbox_file()
   387      allow svirt_sandbox_domain self:netlink_kobject_uevent_socket create_socket_perms;
   388      docker_read_share_files(svirt_sandbox_domain)
   389      docker_lib_filetrans(svirt_sandbox_domain,svirt_sandbox_file_t, sock_file)
   390      docker_use_ptys(svirt_sandbox_domain)
   391      docker_spc_stream_connect(svirt_sandbox_domain)
   392      fs_list_tmpfs(svirt_sandbox_domain)
   393      fs_rw_hugetlbfs_files(svirt_sandbox_domain)
   394      fs_dontaudit_remount_tmpfs(svirt_sandbox_domain)
   395      dev_dontaudit_mounton_sysfs(svirt_sandbox_domain)
   396  
   397      tunable_policy(`virt_sandbox_use_fusefs',`
   398  	fs_manage_fusefs_dirs(svirt_sandbox_domain)
   399  	fs_manage_fusefs_files(svirt_sandbox_domain)
   400  	fs_manage_fusefs_symlinks(svirt_sandbox_domain)
   401      ')
   402       gen_require(`
   403          attribute domain;
   404       ')
   405  
   406       dontaudit svirt_sandbox_domain domain:key {search link};
   407  ')
   408  
   409  optional_policy(`
   410  	gen_require(`
   411  		type pcp_pmcd_t;
   412  	')
   413  	docker_manage_lib_files(pcp_pmcd_t)
   414  ')