Skip to content

Commit 0fa285a

Browse files
authored
Merge pull request #1062 from 0xC0ncord/various-20251113
Various fixes
2 parents 9a570cd + dc09a75 commit 0fa285a

10 files changed

Lines changed: 207 additions & 2 deletions

File tree

policy/modules/admin/netutils.te

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ init_system_domain(traceroute_t, traceroute_exec_t)
3535
# Perform network administration operations and have raw access to the network.
3636
allow netutils_t self:capability { dac_read_search net_admin net_raw setgid setpcap setuid sys_chroot };
3737
dontaudit netutils_t self:capability { dac_override sys_tty_config };
38+
# For running tcpdump in another namespace.
39+
allow netutils_t self:cap_userns net_raw;
3840
allow netutils_t self:process { getcap setcap signal_perms };
3941
# netlink_generic_socket for nmap.
4042
allow netutils_t self:netlink_generic_socket create_socket_perms;

policy/modules/services/container.te

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,10 @@ allow container_domain container_ro_file_t:dir_file_class_set { watch watch_moun
365365
fs_tmpfs_filetrans(container_domain, container_tmpfs_t, { dir file fifo_file lnk_file sock_file })
366366
manage_dirs_pattern(container_domain, container_tmpfs_t, container_tmpfs_t)
367367
mmap_manage_files_pattern(container_domain, container_tmpfs_t, container_tmpfs_t)
368-
mmap_exec_files_pattern(container_domain, container_tmpfs_t, container_tmpfs_t)
369368
manage_fifo_files_pattern(container_domain, container_tmpfs_t, container_tmpfs_t)
370369
manage_lnk_files_pattern(container_domain, container_tmpfs_t, container_tmpfs_t)
371370
manage_sock_files_pattern(container_domain, container_tmpfs_t, container_tmpfs_t)
371+
can_exec(container_domain, container_tmpfs_t)
372372
allow container_domain container_tmpfs_t:dir_file_class_set { watch watch_mount watch_reads watch_sb watch_with_perm };
373373

374374
can_exec(container_domain, container_file_t)

policy/modules/services/crio.te

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ files_mounton_etc_dirs(crio_t)
3636
# watch /usr/share/containers/oci/hooks.d
3737
files_watch_usr_dirs(crio_t)
3838

39+
fs_create_bpf_dirs(crio_t)
40+
fs_manage_bpf_files(crio_t)
41+
3942
kernel_dgram_send(crio_t)
4043
kernel_read_irq_sysctls(crio_t)
44+
kernel_read_vm_overcommit_sysctl(crio_t)
45+
kernel_request_load_module(crio_t)
4146

4247
auth_use_nsswitch(crio_t)
4348

@@ -50,6 +55,8 @@ container_read_home_config(crio_t)
5055

5156
container_watch_config_dirs(crio_t)
5257

58+
crio_read_conmon_state(crio_t)
59+
5360
# Ensure conmon runs in s0 so that it can talk to the container
5461
podman_spec_rangetrans_conmon(crio_t, s0)
5562

policy/modules/services/kanidm.te

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ miscfiles_read_generic_certs(kanidmd_t)
9797

9898
userdom_use_inherited_user_terminals(kanidmd_t)
9999

100+
ifdef(`init_systemd',`
101+
systemd_StateDirectory(kanidm_var_lib_t)
102+
systemd_RuntimeDirectory(kanidmd_runtime_t)
103+
')
104+
100105
optional_policy(`
101106
certbot_read_lib(kanidmd_t)
102107
')
@@ -151,6 +156,12 @@ logging_send_syslog_msg(kanidm_unixd_t)
151156

152157
userdom_use_inherited_user_terminals(kanidm_unixd_t)
153158

159+
ifdef(`init_systemd',`
160+
systemd_CacheDirectory(kanidm_unixd_cache_t)
161+
systemd_StateDirectory(kanidm_unixd_var_lib_t)
162+
systemd_RuntimeDirectory(kanidm_unixd_runtime_t)
163+
')
164+
154165
########################################
155166
#
156167
# kanidm-unixd-tasks local policy

policy/modules/services/podman.te

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ ifdef(`init_systemd',`
9191
systemd_read_journal_files(podman_t)
9292
systemd_watch_journal_dirs(podman_t)
9393

94+
# aardvark-dns watches resolv.conf
95+
systemd_watch_resolved_runtime(podman_t)
96+
9497
# podman auto-update will restart the unit for
9598
# the container when it is updated
9699
container_start_units(podman_t)

policy/modules/services/tuned.te

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ files_runtime_file(tuned_runtime_t)
2929
# Local policy
3030
#
3131

32-
allow tuned_t self:capability { sys_admin sys_nice };
32+
allow tuned_t self:capability { sys_admin sys_nice sys_ptrace };
3333
dontaudit tuned_t self:capability { dac_override sys_tty_config };
34+
allow tuned_t self:cap_userns sys_ptrace;
3435
allow tuned_t self:process { setsched signal };
3536
allow tuned_t self:fifo_file rw_fifo_file_perms;
37+
allow tuned_t self:netlink_kobject_uevent_socket create_socket_perms;
3638

3739
read_files_pattern(tuned_t, tuned_etc_t, tuned_etc_t)
3840
exec_files_pattern(tuned_t, tuned_etc_t, tuned_etc_t)
@@ -50,12 +52,16 @@ manage_files_pattern(tuned_t, tuned_runtime_t, tuned_runtime_t)
5052
manage_dirs_pattern(tuned_t, tuned_runtime_t, tuned_runtime_t)
5153
files_runtime_filetrans(tuned_t, tuned_runtime_t, { dir file })
5254

55+
kernel_getattr_proc(tuned_t)
5356
kernel_read_system_state(tuned_t)
5457
kernel_read_network_state(tuned_t)
5558
kernel_read_kernel_sysctls(tuned_t)
5659
kernel_request_load_module(tuned_t)
60+
kernel_rw_fs_sysctls(tuned_t)
5761
kernel_rw_kernel_sysctl(tuned_t)
5862
kernel_rw_hotplug_sysctls(tuned_t)
63+
kernel_rw_net_sysctls(tuned_t)
64+
kernel_rw_vm_overcommit_sysctl(tuned_t)
5965
kernel_rw_vm_sysctls(tuned_t)
6066

6167
corecmd_exec_bin(tuned_t)
@@ -67,20 +73,43 @@ dev_read_urand(tuned_t)
6773
dev_rw_sysfs(tuned_t)
6874
dev_rw_pmqos(tuned_t)
6975

76+
# enumerate all running processes
77+
domain_read_all_domains_state(tuned_t)
78+
7079
files_read_usr_files(tuned_t)
7180
files_dontaudit_search_home(tuned_t)
7281
files_dontaudit_list_tmp(tuned_t)
7382

7483
fs_getattr_xattr_fs(tuned_t)
7584

85+
selinux_get_fs_mount(tuned_t)
86+
# set SELinux cache_threshold
87+
selinux_set_parameters(tuned_t)
88+
89+
auth_use_nsswitch(tuned_t)
90+
91+
libs_exec_ldconfig(tuned_t)
92+
7693
logging_send_syslog_msg(tuned_t)
7794

95+
miscfiles_read_generic_certs(tuned_t)
7896
miscfiles_read_localization(tuned_t)
7997

98+
seutil_dontaudit_search_config(tuned_t)
99+
80100
udev_read_runtime_files(tuned_t)
81101

82102
userdom_dontaudit_search_user_home_dirs(tuned_t)
83103

104+
ifdef(`init_systemd',`
105+
init_get_system_status(tuned_t)
106+
')
107+
108+
optional_policy(`
109+
dbus_system_bus_client(tuned_t)
110+
dbus_connect_system_bus(tuned_t)
111+
')
112+
84113
optional_policy(`
85114
fstools_domtrans(tuned_t)
86115
')

policy/modules/system/init.if

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,56 @@ interface(`init_named_socket_activation',`
421421
')
422422
')
423423

424+
#########################################
425+
## <summary>
426+
## Automatic creation of unit directories (systemd).
427+
## This interface should only be used for non-runtime
428+
## directories, as systemd will not automatically
429+
## delete them when the unit is stopped. For runtime
430+
## directories, use init_manage_abstract_unit_dir().
431+
## </summary>
432+
## <param name="type">
433+
## <summary>
434+
## The type of the directory to create.
435+
## </summary>
436+
## </param>
437+
#
438+
interface(`init_create_abstract_unit_dir',`
439+
ifdef(`init_systemd',`
440+
gen_require(`
441+
type init_t;
442+
')
443+
444+
allow init_t $1:dir { create_dir_perms setattr };
445+
')
446+
')
447+
448+
#########################################
449+
## <summary>
450+
## Automatic management of unit directories (systemd).
451+
## This interface should only be used for runtime
452+
## directories, as systemd will automatically delete
453+
## them when the unit is stopped. For non-runtime
454+
## directories, use init_create_abstract_unit_dir().
455+
## </summary>
456+
## <param name="type">
457+
## <summary>
458+
## The type of the directory to manage.
459+
## </summary>
460+
## </param>
461+
#
462+
interface(`init_manage_abstract_unit_dir',`
463+
ifdef(`init_systemd',`
464+
gen_require(`
465+
type init_t;
466+
')
467+
468+
allow init_t $1:dir manage_dir_perms;
469+
allow init_t $1:file delete_file_perms;
470+
allow init_t $1:sock_file delete_sock_file_perms;
471+
')
472+
')
473+
424474
########################################
425475
## <summary>
426476
## Create a domain for short running processes

policy/modules/system/init.te

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,9 @@ ifdef(`init_systemd',`
618618

619619
optional_policy(`
620620
container_remount_fs(init_t)
621+
container_run_system_engine_bpf(init_t)
622+
623+
fs_manage_bpf_files(init_t)
621624
')
622625

623626
optional_policy(`

policy/modules/system/systemd.if

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,86 @@ interface(`systemd_PrivateDevices',`
11821182
fs_read_tmpfs_symlinks($1)
11831183
')
11841184

1185+
######################################
1186+
## <summary>
1187+
## Allow systemd to create a directory with a private type
1188+
## via the CacheDirectory= directive in the [Service] section
1189+
## of the unit.
1190+
## </summary>
1191+
## <param name="type">
1192+
## <summary>
1193+
## Type of the directory to create.
1194+
## </summary>
1195+
## </param>
1196+
#
1197+
interface(`systemd_CacheDirectory',`
1198+
init_create_abstract_unit_dir($1)
1199+
')
1200+
1201+
######################################
1202+
## <summary>
1203+
## Allow systemd to create a directory with a private type
1204+
## via the StateDirectory= directive in the [Service] section
1205+
## of the unit.
1206+
## </summary>
1207+
## <param name="type">
1208+
## <summary>
1209+
## Type of the directory to create.
1210+
## </summary>
1211+
## </param>
1212+
#
1213+
interface(`systemd_StateDirectory',`
1214+
init_create_abstract_unit_dir($1)
1215+
')
1216+
1217+
######################################
1218+
## <summary>
1219+
## Allow systemd to create a directory with a private type
1220+
## via the LogDirectory= directive in the [Service] section
1221+
## of the unit.
1222+
## </summary>
1223+
## <param name="type">
1224+
## <summary>
1225+
## Type of the directory to create.
1226+
## </summary>
1227+
## </param>
1228+
#
1229+
interface(`systemd_LogDirectory',`
1230+
init_create_abstract_unit_dir($1)
1231+
')
1232+
1233+
######################################
1234+
## <summary>
1235+
## Allow systemd to create a directory with a private type
1236+
## via the ConfigurationDirectory= directive in the [Service] section
1237+
## of the unit.
1238+
## </summary>
1239+
## <param name="type">
1240+
## <summary>
1241+
## Type of the directory to create.
1242+
## </summary>
1243+
## </param>
1244+
#
1245+
interface(`systemd_ConfigurationDirectory',`
1246+
init_create_abstract_unit_dir($1)
1247+
')
1248+
1249+
######################################
1250+
## <summary>
1251+
## Allow systemd to manage a directory with a private type
1252+
## via the RuntimeDirectory= directive in the [Service] section
1253+
## of the unit.
1254+
## </summary>
1255+
## <param name="type">
1256+
## <summary>
1257+
## Type of the directory to manage.
1258+
## </summary>
1259+
## </param>
1260+
#
1261+
interface(`systemd_RuntimeDirectory',`
1262+
init_manage_abstract_unit_dir($1)
1263+
')
1264+
11851265
########################################
11861266
## <summary>
11871267
## Send and receive messages from
@@ -2799,6 +2879,24 @@ interface(`systemd_read_resolved_runtime',`
27992879
read_files_pattern($1, systemd_resolved_runtime_t, systemd_resolved_runtime_t)
28002880
')
28012881

2882+
#######################################
2883+
## <summary>
2884+
## Allow domain to watch resolv.conf file generated by systemd_resolved
2885+
## </summary>
2886+
## <param name="domain">
2887+
## <summary>
2888+
## Domain allowed access.
2889+
## </summary>
2890+
## </param>
2891+
#
2892+
interface(`systemd_watch_resolved_runtime',`
2893+
gen_require(`
2894+
type systemd_resolved_runtime_t;
2895+
')
2896+
2897+
allow $1 systemd_resolved_runtime_t:file watch;
2898+
')
2899+
28022900
#######################################
28032901
## <summary>
28042902
## Allow domain to read directory containing resolv.conf

policy/modules/system/systemd.te

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ files_type(systemd_pstore_var_lib_t)
260260
type systemd_resolved_t;
261261
type systemd_resolved_exec_t;
262262
init_daemon_domain(systemd_resolved_t, systemd_resolved_exec_t)
263+
init_named_socket_activation(systemd_resolved_t, systemd_resolved_runtime_t)
263264

264265
type systemd_resolved_runtime_t alias systemd_resolved_var_run_t;
265266
files_runtime_file(systemd_resolved_runtime_t)
@@ -2332,6 +2333,7 @@ can_exec(systemd_user_session_type, systemd_generator_exec_t)
23322333

23332334
dev_write_sysfs_dirs(systemd_user_session_type)
23342335
dev_read_sysfs(systemd_user_session_type)
2336+
dev_dontaudit_getattr_generic_blk_files(systemd_user_session_type)
23352337

23362338
domain_getattr_all_entry_files(systemd_user_session_type)
23372339

0 commit comments

Comments
 (0)