diff options
| author | Clayton Casciato <majortomtosourcecontrol@gmail.com> | 2025-04-07 10:58:35 -0600 |
|---|---|---|
| committer | Yi Zhao <yi.zhao@windriver.com> | 2025-04-08 09:52:51 +0800 |
| commit | 928c820a1d73f217fefbce758eaa7730f0221792 (patch) | |
| tree | e74ad9782e11adbfea80f464a2b9b17354a78c4d | |
| parent | 311c9459007d938af71e37c8574a98fc97a57bb8 (diff) | |
| download | meta-selinux-928c820a1d73f217fefbce758eaa7730f0221792.tar.gz | |
refpolicy: files, init - filetrans /run/machine-id etc_runtime_t
Signed-off-by: Clayton Casciato <majortomtosourcecontrol@gmail.com>
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
| -rw-r--r-- | recipes-security/refpolicy/refpolicy/0062-policy-modules-multiple-filetrans-run_machine_id-etc.patch | 109 | ||||
| -rw-r--r-- | recipes-security/refpolicy/refpolicy_common.inc | 1 |
2 files changed, 110 insertions, 0 deletions
diff --git a/recipes-security/refpolicy/refpolicy/0062-policy-modules-multiple-filetrans-run_machine_id-etc.patch b/recipes-security/refpolicy/refpolicy/0062-policy-modules-multiple-filetrans-run_machine_id-etc.patch new file mode 100644 index 0000000..8cab157 --- /dev/null +++ b/recipes-security/refpolicy/refpolicy/0062-policy-modules-multiple-filetrans-run_machine_id-etc.patch | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | From befa4fcb91c883c9ff93f0080d12d3d5004dc8cc Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Clayton Casciato <ccasciato@21sw.us> | ||
| 3 | Date: Fri, 14 Mar 2025 09:04:49 -0600 | ||
| 4 | Subject: [PATCH] files, init: filetrans /run/machine-id etc_runtime_t | ||
| 5 | |||
| 6 | type=PROCTITLE proctitle=/usr/lib/systemd/systemd-logind | ||
| 7 | |||
| 8 | type=SYSCALL arch=armeb syscall=openat per=PER_LINUX success=yes exit=21 | ||
| 9 | a0=AT_FDCWD a1=0xb6eb6c2c a2=O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC | ||
| 10 | a3=0x0 items=0 ppid=1 pid=435 auid=unset uid=root gid=root euid=root | ||
| 11 | suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset | ||
| 12 | comm=systemd-logind exe=/usr/lib/systemd/systemd-logind | ||
| 13 | subj=system_u:system_r:systemd_logind_t:s0 key=(null) | ||
| 14 | |||
| 15 | type=AVC avc: denied { open } for pid=435 comm=systemd-logind | ||
| 16 | path=/etc/machine-id dev="tmpfs" ino=13 | ||
| 17 | scontext=system_u:system_r:systemd_logind_t:s0 | ||
| 18 | tcontext=system_u:object_r:init_runtime_t:s0 tclass=file | ||
| 19 | |||
| 20 | type=AVC avc: denied { read } for pid=435 comm=systemd-logind | ||
| 21 | name=machine-id dev="tmpfs" ino=13 | ||
| 22 | scontext=system_u:system_r:systemd_logind_t:s0 | ||
| 23 | tcontext=system_u:object_r:init_runtime_t:s0 tclass=file | ||
| 24 | |||
| 25 | -- | ||
| 26 | |||
| 27 | https://www.spinics.net/lists/systemd-devel/msg09631.html | ||
| 28 | Reproduction and suggestion to use dedicated type (TODO) | ||
| 29 | |||
| 30 | -- | ||
| 31 | |||
| 32 | Fedora: | ||
| 33 | |||
| 34 | $ matchpathcon /run/machine-id | ||
| 35 | /run/machine-id system_u:object_r:machineid_t:s0 | ||
| 36 | |||
| 37 | https://github.com/fedora-selinux/selinux-policy/blob/v41.33/policy/modules/system/init.fc#L67 | ||
| 38 | |||
| 39 | $ sesearch --type_transition --class file --source init_t | ||
| 40 | --target var_run_t | grep machine | ||
| 41 | type_transition init_t var_run_t:file machineid_t machine-id; | ||
| 42 | |||
| 43 | https://github.com/fedora-selinux/selinux-policy/blob/v41.33/policy/modules/system/init.te#L241 | ||
| 44 | |||
| 45 | Signed-off-by: Clayton Casciato <ccasciato@21sw.us> | ||
| 46 | |||
| 47 | Upstream-Status: Backport [https://github.com/SELinuxProject/refpolicy/commit/e053fced8c911bc390a81ca5ee7f3baccecb70e1] | ||
| 48 | |||
| 49 | Signed-off-by: Clayton Casciato <majortomtosourcecontrol@gmail.com> | ||
| 50 | --- | ||
| 51 | policy/modules/kernel/files.fc | 1 + | ||
| 52 | policy/modules/kernel/files.if | 19 +++++++++++++++++++ | ||
| 53 | policy/modules/system/init.te | 1 + | ||
| 54 | 3 files changed, 21 insertions(+) | ||
| 55 | |||
| 56 | diff --git a/policy/modules/kernel/files.fc b/policy/modules/kernel/files.fc | ||
| 57 | index c5012e6b4..3cdfd2f80 100644 | ||
| 58 | --- a/policy/modules/kernel/files.fc | ||
| 59 | +++ b/policy/modules/kernel/files.fc | ||
| 60 | @@ -154,6 +154,7 @@ HOME_ROOT/lost\+found/.* <<none>> | ||
| 61 | /run -l gen_context(system_u:object_r:var_run_t,s0) | ||
| 62 | /run/shm -l gen_context(system_u:object_r:var_run_t,s0) | ||
| 63 | /run/.* <<none>> | ||
| 64 | +/run/machine-id -- gen_context(system_u:object_r:etc_runtime_t,s0) | ||
| 65 | |||
| 66 | # | ||
| 67 | # /selinux | ||
| 68 | diff --git a/policy/modules/kernel/files.if b/policy/modules/kernel/files.if | ||
| 69 | index f2c714579..9ade962a9 100644 | ||
| 70 | --- a/policy/modules/kernel/files.if | ||
| 71 | +++ b/policy/modules/kernel/files.if | ||
| 72 | @@ -3734,6 +3734,25 @@ interface(`files_dontaudit_setattr_etc_runtime_files',` | ||
| 73 | dontaudit $1 etc_runtime_t:file setattr; | ||
| 74 | ') | ||
| 75 | |||
| 76 | +######################################## | ||
| 77 | +## <summary> | ||
| 78 | +## Create a machine-id file in | ||
| 79 | +## the runtime directory | ||
| 80 | +## </summary> | ||
| 81 | +## <param name="domain"> | ||
| 82 | +## <summary> | ||
| 83 | +## Domain allowed access. | ||
| 84 | +## </summary> | ||
| 85 | +## </param> | ||
| 86 | +# | ||
| 87 | +interface(`files_runtime_filetrans_machine_id',` | ||
| 88 | + gen_require(` | ||
| 89 | + type etc_runtime_t; | ||
| 90 | + ') | ||
| 91 | + | ||
| 92 | + files_runtime_filetrans($1, etc_runtime_t, file, "machine-id") | ||
| 93 | +') | ||
| 94 | + | ||
| 95 | ######################################## | ||
| 96 | ## <summary> | ||
| 97 | ## Read files in /etc that are dynamically | ||
| 98 | diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te | ||
| 99 | index 8af34aa7e..026f77c16 100644 | ||
| 100 | --- a/policy/modules/system/init.te | ||
| 101 | +++ b/policy/modules/system/init.te | ||
| 102 | @@ -178,6 +178,7 @@ allow init_t init_linkable_keyring_type:key link; | ||
| 103 | # For /var/run/shutdown.pid. | ||
| 104 | allow init_t init_runtime_t:file manage_file_perms; | ||
| 105 | files_runtime_filetrans(init_t, init_runtime_t, file) | ||
| 106 | +files_runtime_filetrans_machine_id(init_t) | ||
| 107 | |||
| 108 | # for /run/initctl | ||
| 109 | allow init_t init_runtime_t:fifo_file manage_fifo_file_perms; | ||
diff --git a/recipes-security/refpolicy/refpolicy_common.inc b/recipes-security/refpolicy/refpolicy_common.inc index 71b143b..c40d6e7 100644 --- a/recipes-security/refpolicy/refpolicy_common.inc +++ b/recipes-security/refpolicy/refpolicy_common.inc | |||
| @@ -77,6 +77,7 @@ SRC_URI += " \ | |||
| 77 | file://0059-policy-modules-system-unconfined-fix-oddjob-security.patch \ | 77 | file://0059-policy-modules-system-unconfined-fix-oddjob-security.patch \ |
| 78 | file://0060-policy-modules-services-firewalld-fix-lib_t-python_c.patch \ | 78 | file://0060-policy-modules-services-firewalld-fix-lib_t-python_c.patch \ |
| 79 | file://0061-policy-modules-services-firewalld-fix-firewalld_t-fi.patch \ | 79 | file://0061-policy-modules-services-firewalld-fix-firewalld_t-fi.patch \ |
| 80 | file://0062-policy-modules-multiple-filetrans-run_machine_id-etc.patch \ | ||
| 80 | " | 81 | " |
| 81 | 82 | ||
| 82 | S = "${WORKDIR}/refpolicy" | 83 | S = "${WORKDIR}/refpolicy" |
