Skip to content

Commit d42aff8

Browse files
pebenitojslobodzian
authored andcommitted
selinux-policy: Clean up testing rules and add systemd fix. (#9911)
Signed-off-by: Chris PeBenito <[email protected]>
1 parent 1bf3f8b commit d42aff8

6 files changed

+178
-108
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,28 @@
1-
From 87a23a94731c5bb6979d27ef81e470b84cfc4bfe Mon Sep 17 00:00:00 2001
1+
From f6c4470e528370d5b6e8cf25b86e753c98022592 Mon Sep 17 00:00:00 2001
22
From: Chris PeBenito <[email protected]>
33
Date: Mon, 25 Mar 2024 09:50:17 -0400
4-
Subject: [PATCH 17/24] various: Add additional logging access for domains run
4+
Subject: [PATCH 17/33] various: Add additional logging access for domains run
55
from cloud_init.
66

77
Signed-off-by: Chris PeBenito <[email protected]>
88
---
9-
policy/modules/admin/bootloader.te | 6 ++++++
10-
policy/modules/admin/cloudinit.if | 19 +++++++++++++++++++
9+
policy/modules/admin/bootloader.te | 2 ++
1110
policy/modules/admin/rpm.if | 2 +-
1211
policy/modules/system/selinuxutil.te | 10 ++++++++++
1312
policy/modules/system/udev.te | 5 +++++
14-
5 files changed, 41 insertions(+), 1 deletion(-)
13+
4 files changed, 18 insertions(+), 1 deletion(-)
1514

1615
diff --git a/policy/modules/admin/bootloader.te b/policy/modules/admin/bootloader.te
17-
index 84b243c0c..4e097a1b9 100644
16+
index 84b243c0c..af162dd9b 100644
1817
--- a/policy/modules/admin/bootloader.te
1918
+++ b/policy/modules/admin/bootloader.te
20-
@@ -227,6 +227,10 @@ ifdef(`init_systemd',`
21-
init_rw_inherited_stream_socket(bootloader_t)
22-
')
23-
24-
+optional_policy(`
25-
+ cloudinit_write_inherited_tmp_files(bootloader_t)
26-
+')
27-
+
28-
optional_policy(`
29-
fstools_exec(bootloader_t)
30-
')
31-
@@ -258,4 +262,6 @@ optional_policy(`
19+
@@ -258,4 +258,6 @@ optional_policy(`
3220

3321
optional_policy(`
3422
rpm_rw_pipes(bootloader_t)
3523
+ rpm_read_inherited_tmp_files(bootloader_t)
3624
+ rpm_append_inherited_tmp_files(bootloader_t)
3725
')
38-
diff --git a/policy/modules/admin/cloudinit.if b/policy/modules/admin/cloudinit.if
39-
index 6d427e771..e69698fae 100644
40-
--- a/policy/modules/admin/cloudinit.if
41-
+++ b/policy/modules/admin/cloudinit.if
42-
@@ -181,6 +181,25 @@ interface(`cloudinit_getattr_state_files',`
43-
allow $1 cloud_init_state_t:file getattr;
44-
')
45-
46-
+########################################
47-
+## <summary>
48-
+## Append inherited cloud-init temporary files.
49-
+## </summary>
50-
+## <param name="domain">
51-
+## <summary>
52-
+## Domain allowed access.
53-
+## </summary>
54-
+## </param>
55-
+#
56-
+interface(`cloudinit_append_inherited_tmp_files',`
57-
+ gen_require(`
58-
+ type cloud_init_t, cloud_init_tmp_t;
59-
+ ')
60-
+
61-
+ allow $1 cloud_init_t:fd use;
62-
+ allow $1 cloud_init_tmp_t:file append_inherited_file_perms;
63-
+')
64-
+
65-
########################################
66-
## <summary>
67-
## Write inherited cloud-init temporary files.
6826
diff --git a/policy/modules/admin/rpm.if b/policy/modules/admin/rpm.if
6927
index b20c3cd3d..19943a0ae 100644
7028
--- a/policy/modules/admin/rpm.if
@@ -120,5 +78,5 @@ index bebefdda8..8af0d90e0 100644
12078
+ rpm_append_inherited_tmp_files(udevadm_t)
12179
+')
12280
--
123-
2.44.0
81+
2.45.2
12482

SPECS/selinux-policy/0033-cloud-init-and-kmod-fixes.patch

-57
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From e02c2eb0ad3e43df71c27a8f9c5ae7150add310a Mon Sep 17 00:00:00 2001
2+
From: Chris PeBenito <[email protected]>
3+
Date: Mon, 1 Jul 2024 09:27:04 -0400
4+
Subject: [PATCH 33/33] kmod fix for /run/modprobe.d.
5+
6+
Signed-off-by: Chris PeBenito <[email protected]>
7+
---
8+
policy/modules/system/modutils.fc | 2 ++
9+
1 file changed, 2 insertions(+)
10+
11+
diff --git a/policy/modules/system/modutils.fc b/policy/modules/system/modutils.fc
12+
index 323120062..de9f88fa8 100644
13+
--- a/policy/modules/system/modutils.fc
14+
+++ b/policy/modules/system/modutils.fc
15+
@@ -8,6 +8,8 @@ ifdef(`distro_gentoo',`
16+
/etc/modprobe\.devfs.* -- gen_context(system_u:object_r:modules_conf_t,s0)
17+
')
18+
19+
+/run/modprobe\.d(/.*)? gen_context(system_u:object_r:modules_conf_t,s0)
20+
+
21+
ifdef(`init_systemd',`
22+
/run/tmpfiles\.d/kmod\.conf -- gen_context(system_u:object_r:kmod_tmpfiles_conf_t,s0)
23+
/run/tmpfiles\.d/static-nodes\.conf -- gen_context(system_u:object_r:kmod_tmpfiles_conf_t,s0)
24+
--
25+
2.45.2
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From aff599f9d5186afad60703f3f9bc5ad75df63899 Mon Sep 17 00:00:00 2001
2+
From: Chris PeBenito <[email protected]>
3+
Date: Thu, 18 Jul 2024 15:51:20 -0400
4+
Subject: [PATCH 34/34] systemd: Fix dac_override use in
5+
systemd-machine-id-setup.
6+
7+
Signed-off-by: Chris PeBenito <[email protected]>
8+
---
9+
policy/modules/system/systemd.te | 2 +-
10+
1 file changed, 1 insertion(+), 1 deletion(-)
11+
12+
diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te
13+
index f64c29cc3..664f4f31a 100644
14+
--- a/policy/modules/system/systemd.te
15+
+++ b/policy/modules/system/systemd.te
16+
@@ -1170,7 +1170,7 @@ optional_policy(`
17+
# machine-id-setup local policy
18+
#
19+
20+
-allow systemd_machine_id_setup_t self:capability { setgid sys_admin sys_chroot };
21+
+allow systemd_machine_id_setup_t self:capability { dac_override setgid sys_admin sys_chroot };
22+
23+
files_list_var(systemd_machine_id_setup_t)
24+
files_mounton_root(systemd_machine_id_setup_t)
25+
--
26+
2.45.2
27+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
From 97b37cca000c83e0cbc36479fff5cf8491a67d43 Mon Sep 17 00:00:00 2001
2+
From: Chris PeBenito <[email protected]>
3+
Date: Fri, 19 Jul 2024 10:39:54 -0400
4+
Subject: [PATCH 35/35] rpm: Run systemd-sysctl from %post.
5+
6+
Run commands such as:
7+
8+
/usr/lib/systemd/systemd-sysctl /etc/sysctl.d/10-default-yama-scope.conf
9+
10+
Signed-off-by: Chris PeBenito <[email protected]>
11+
---
12+
policy/modules/admin/rpm.te | 4 +++
13+
policy/modules/system/systemd.if | 44 ++++++++++++++++++++++++++++++++
14+
policy/modules/system/systemd.te | 2 ++
15+
3 files changed, 50 insertions(+)
16+
17+
diff --git a/policy/modules/admin/rpm.te b/policy/modules/admin/rpm.te
18+
index 41253a4e2..809e8c573 100644
19+
--- a/policy/modules/admin/rpm.te
20+
+++ b/policy/modules/admin/rpm.te
21+
@@ -416,6 +416,10 @@ optional_policy(`
22+
ntp_domtrans(rpm_script_t)
23+
')
24+
25+
+optional_policy(`
26+
+ systemd_run_sysctl(rpm_script_t, rpm_roles)
27+
+')
28+
+
29+
optional_policy(`
30+
tzdata_run(rpm_t, rpm_roles)
31+
tzdata_run(rpm_script_t, rpm_roles)
32+
diff --git a/policy/modules/system/systemd.if b/policy/modules/system/systemd.if
33+
index b7a392a13..2cb5ae2ed 100644
34+
--- a/policy/modules/system/systemd.if
35+
+++ b/policy/modules/system/systemd.if
36+
@@ -2629,6 +2629,50 @@ interface(`systemd_read_resolved_runtime',`
37+
read_files_pattern($1, systemd_resolved_runtime_t, systemd_resolved_runtime_t)
38+
')
39+
40+
+########################################
41+
+## <summary>
42+
+## Execute systemd-sysctl in the systemd sysctl domain.
43+
+## </summary>
44+
+## <param name="domain">
45+
+## <summary>
46+
+## Domain allowed access.
47+
+## </summary>
48+
+## </param>
49+
+#
50+
+interface(`systemd_domtrans_sysctl', `
51+
+ gen_require(`
52+
+ type systemd_sysctl_t, systemd_sysctl_exec_t;
53+
+ ')
54+
+
55+
+ corecmd_search_bin($1)
56+
+ domtrans_pattern($1, systemd_sysctl_exec_t, systemd_sysctl_t)
57+
+')
58+
+
59+
+########################################
60+
+## <summary>
61+
+## Run systemd-sysctl with a domain transition.
62+
+## </summary>
63+
+## <param name="domain">
64+
+## <summary>
65+
+## Domain allowed access.
66+
+## </summary>
67+
+## </param>
68+
+## <param name="role">
69+
+## <summary>
70+
+## Role allowed access.
71+
+## </summary>
72+
+## </param>
73+
+## <rolecap/>
74+
+#
75+
+interface(`systemd_run_sysctl', `
76+
+ gen_require(`
77+
+ attribute_role systemd_sysctl_roles;
78+
+ ')
79+
+
80+
+ systemd_domtrans_sysctl($1)
81+
+ roleattribute $2 systemd_sysctl_roles;
82+
+')
83+
+
84+
########################################
85+
## <summary>
86+
## Execute the systemctl program.
87+
diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te
88+
index 664f4f31a..3ad5bb651 100644
89+
--- a/policy/modules/system/systemd.te
90+
+++ b/policy/modules/system/systemd.te
91+
@@ -58,6 +58,7 @@ attribute systemd_user_session_type;
92+
attribute systemd_user_activated_sock_file_type;
93+
attribute systemd_user_unix_stream_activated_socket_type;
94+
95+
+attribute_role systemd_sysctl_roles;
96+
attribute_role systemd_sysusers_roles;
97+
98+
type systemd_activate_t;
99+
@@ -288,6 +289,7 @@ init_unit_file(systemd_socket_proxyd_unit_file_t)
100+
type systemd_sysctl_t;
101+
type systemd_sysctl_exec_t;
102+
init_daemon_domain(systemd_sysctl_t, systemd_sysctl_exec_t)
103+
+role systemd_sysctl_roles types systemd_sysctl_t;
104+
105+
type systemd_sysusers_t;
106+
type systemd_sysusers_exec_t;
107+
--
108+
2.45.2
109+

SPECS/selinux-policy/selinux-policy.spec

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Summary: SELinux policy
1010
Name: selinux-policy
1111
Version: %{refpolicy_major}.%{refpolicy_minor}
12-
Release: 5%{?dist}
12+
Release: 6%{?dist}
1313
License: GPLv2
1414
Vendor: Microsoft Corporation
1515
Distribution: Azure Linux
@@ -51,7 +51,9 @@ Patch29: 0029-filesystem-systemd-memory.pressure-fixes.patch
5151
Patch30: 0030-init-Add-homectl-dbus-access.patch
5252
Patch31: 0031-Temporary-workaround-for-memory.pressure-labeling-is.patch
5353
Patch32: 0032-rpm-Fixes-from-various-post-scripts.patch
54-
Patch33: 0033-cloud-init-and-kmod-fixes.patch
54+
Patch33: 0033-kmod-fix-for-run-modprobe.d.patch
55+
Patch34: 0034-systemd-Fix-dac_override-use-in-systemd-machine-id-s.patch
56+
Patch35: 0035-rpm-Run-systemd-sysctl-from-post.patch
5557
BuildRequires: bzip2
5658
BuildRequires: checkpolicy >= %{CHECKPOLICYVER}
5759
BuildRequires: m4
@@ -335,6 +337,11 @@ exit 0
335337
selinuxenabled && semodule -nB
336338
exit 0
337339
%changelog
340+
* Thu Jul 18 2024 Chris PeBenito <[email protected]> - 2.20240226-6
341+
- Drop rules that are specific to AzureLinux testing systems.
342+
- Add fix for systemd-machine-id-setup CAP_DAC_OVERRIDE use.
343+
- Run systemd-sysctl from RPM scripts.
344+
338345
* Tue Jul 16 2024 Chris PeBenito <[email protected]> - 2.20240226-5
339346
- Change unconfined to a separate module so it can be disabled.
340347

0 commit comments

Comments
 (0)