Skip to contentSkip to conversation

init: update the initrc_t domain policy

PATCH New Guido Trentalancia 3 participants 20 messages Dec 29, 2016 – Dec 31, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Update the initrc_t domain policy in the init module with some missing permissions.

---
 policy/modules/kernel/terminal.if |   21 +++++++++++++++++++++
 policy/modules/system/init.te     |   19 +++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)
policy/modules/kernel/terminal.if +21 -0
diff -pru a/policy/modules/kernel/terminal.if b/policy/modules/kernel/terminal.if
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 
 ########################################
 ## <summary>
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>
 ##	Get the attributes of all unallocated
 ##	tty device nodes.
 ## </summary>
policy/modules/system/init.te +17 -2
diff -pru a/policy/modules/system/init.te b/policy/modules/system/init.te
@@ -415,12 +415,16 @@ kernel_clear_ring_buffer(initrc_t)
 kernel_get_sysvipc_info(initrc_t)
 kernel_read_all_sysctls(initrc_t)
 kernel_rw_all_sysctls(initrc_t)
+kernel_use_fds(initrc_t)
 # for lsof which is used by alsa shutdown:
 kernel_dontaudit_getattr_message_if(initrc_t)
 # cjp: not sure why these are here; should use mount policy
 kernel_list_unlabeled(initrc_t)
 kernel_mounton_unlabeled_dirs(initrc_t)
 
+# plymouth
+kernel_stream_connect(initrc_t)
+
 files_create_lock_dirs(initrc_t)
 files_pid_filetrans_lock_dir(initrc_t, "lock")
 files_read_kernel_symbol_table(initrc_t)
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 dev_getattr_all_chr_files(initrc_t)
 # Early devtmpfs
 dev_rw_generic_chr_files(initrc_t)
+# mcelog service
+dev_read_kmsg(initrc_t)
 
 domain_kill_all_domains(initrc_t)
 domain_signal_all_domains(initrc_t)
@@ -496,6 +502,8 @@ files_exec_etc_files(initrc_t)
 files_read_usr_files(initrc_t)
 files_manage_urandom_seed(initrc_t)
 files_manage_generic_spool(initrc_t)
+# manage the restorecond lock file
+files_manage_generic_locks(initrc_t)
 # Mount and unmount file systems.
 # cjp: not sure why these are here; should use mount policy
 files_list_default(initrc_t)
@@ -532,10 +540,12 @@ storage_setattr_removable_dev(initrc_t)
 
 term_use_all_terms(initrc_t)
 term_reset_tty_labels(initrc_t)
+term_unlink_bsd_ptys(initrc_t)
 
 auth_rw_login_records(initrc_t)
 auth_setattr_login_records(initrc_t)
 auth_rw_lastlog(initrc_t)
+auth_manage_faillog(initrc_t)
 auth_read_pam_pid(initrc_t)
 auth_delete_pam_pid(initrc_t)
 auth_delete_pam_console_data(initrc_t)
@@ -831,12 +841,13 @@ optional_policy(`
 ')
 
 optional_policy(`
-	dev_getattr_printer_dev(initrc_t)
-
+	cups_domtrans(initrc_t)
 	cups_read_log(initrc_t)
 	cups_read_rw_config(initrc_t)
 #cups init script clears error log
 	cups_write_log(initrc_t)
+
+	dev_getattr_printer_dev(initrc_t)
 ')
 
 optional_policy(`
@@ -900,6 +911,10 @@ optional_policy(`
 ')
 
 optional_policy(`
+	iptables_read_config(initrc_t)
+')
+
+optional_policy(`
 	iscsi_stream_connect(initrc_t)
 	iscsi_read_lib_files(initrc_t)
 ')
#1 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 46 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some missing permissions.

---
 policy/modules/kernel/terminal.if |   21 +++++++++++++++++++++
 policy/modules/system/init.te     |   19 +++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff -pru a/policy/modules/kernel/terminal.if b/policy/modules/kernel/terminal.if

policy/modules/kernel/terminal.if +21 -0
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 
 ########################################
 ## <summary>
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>
 ##	Get the attributes of all unallocated
 ##	tty device nodes.
 ## </summary>

diff -pru a/policy/modules/system/init.te b/policy/modules/system/init.te

policy/modules/system/init.te +0 -0
@@ -415,12 +415,16 @@ kernel_clear_ring_buffer(initrc_t)
 kernel_get_sysvipc_info(initrc_t)
 kernel_read_all_sysctls(initrc_t)

policy/modules/system/init.te kernel_clear_ring_buffer(initrc_t) · line 426

Quoted 10 lines
policy/modules/system/init.te +3 -0
 kernel_rw_all_sysctls(initrc_t)
+kernel_use_fds(initrc_t)
 # for lsof which is used by alsa shutdown:
 kernel_dontaudit_getattr_message_if(initrc_t)
 # cjp: not sure why these are here; should use mount policy
 kernel_list_unlabeled(initrc_t)
 kernel_mounton_unlabeled_dirs(initrc_t)
 
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 9 lines
policy/modules/system/init.te +2 -0
 files_create_lock_dirs(initrc_t)
 files_pid_filetrans_lock_dir(initrc_t, "lock")
 files_read_kernel_symbol_table(initrc_t)
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 dev_getattr_all_chr_files(initrc_t)
 # Early devtmpfs
 dev_rw_generic_chr_files(initrc_t)
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

policy/modules/system/init.te files_exec_etc_files(initrc_t) · line 506

Quoted 8 lines
policy/modules/system/init.te +2 -0
 domain_kill_all_domains(initrc_t)
 domain_signal_all_domains(initrc_t)
@@ -496,6 +502,8 @@ files_exec_etc_files(initrc_t)
 files_read_usr_files(initrc_t)
 files_manage_urandom_seed(initrc_t)
 files_manage_generic_spool(initrc_t)
+# manage the restorecond lock file
+files_manage_generic_locks(initrc_t)

initrc_t can already delete all locks. Why does it need to create locks?

Quoted 17 lines
policy/modules/system/init.te +2 -0
 # Mount and unmount file systems.
 # cjp: not sure why these are here; should use mount policy
 files_list_default(initrc_t)
@@ -532,10 +540,12 @@ storage_setattr_removable_dev(initrc_t)
 
 term_use_all_terms(initrc_t)
 term_reset_tty_labels(initrc_t)
+term_unlink_bsd_ptys(initrc_t)
 
 auth_rw_login_records(initrc_t)
 auth_setattr_login_records(initrc_t)
 auth_rw_lastlog(initrc_t)
+auth_manage_faillog(initrc_t)
 auth_read_pam_pid(initrc_t)
 auth_delete_pam_pid(initrc_t)
 auth_delete_pam_console_data(initrc_t)

policy/modules/system/init.te optional_policy(` · line 844

Quoted 6 lines
policy/modules/system/init.te +1 -2
@@ -831,12 +841,13 @@ optional_policy(`
 ')
 
 optional_policy(`
-	dev_getattr_printer_dev(initrc_t)
-
+	cups_domtrans(initrc_t)

This should not be necessary, as cups is already an init_daemon_domain().

Quoted 20 lines
policy/modules/system/init.te +6 -0
 	cups_read_log(initrc_t)
 	cups_read_rw_config(initrc_t)
 #cups init script clears error log
 	cups_write_log(initrc_t)
+
+	dev_getattr_printer_dev(initrc_t)
 ')
 
 optional_policy(`
@@ -900,6 +911,10 @@ optional_policy(`
 ')
 
 optional_policy(`
+	iptables_read_config(initrc_t)
+')
+
+optional_policy(`
 	iscsi_stream_connect(initrc_t)
 	iscsi_read_lib_files(initrc_t)
 ')
Signature · 1 line
Chris PeBenito
#2 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 55 lines · Chris PeBenito via refpolicy
Quoted 54 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some missing permissions.

---
 policy/modules/kernel/terminal.if |   21 +++++++++++++++++++++
 policy/modules/system/init.te     |   19 +++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff -pru a/policy/modules/kernel/terminal.if b/policy/modules/kernel/terminal.if

policy/modules/kernel/terminal.if +21 -0
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 
 ########################################
 ## <summary>
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>
 ##	Get the attributes of all unallocated
 ##	tty device nodes.
 ## </summary>

diff -pru a/policy/modules/system/init.te b/policy/modules/system/init.te

policy/modules/system/init.te +1 -0
@@ -415,12 +415,16 @@ kernel_clear_ring_buffer(initrc_t)
 kernel_get_sysvipc_info(initrc_t)
 kernel_read_all_sysctls(initrc_t)
 kernel_rw_all_sysctls(initrc_t)
+kernel_use_fds(initrc_t)
 # for lsof which is used by alsa shutdown:
 kernel_dontaudit_getattr_message_if(initrc_t)
 # cjp: not sure why these are here; should use mount policy
 kernel_list_unlabeled(initrc_t)
 kernel_mounton_unlabeled_dirs(initrc_t)
 
Quoted 4 lines

policy/modules/system/init.te kernel_clear_ring_buffer(initrc_t) · line 426

Quoted 2 lines
policy/modules/system/init.te +2 -0
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Plymouthd is running from initramfs before policy is loaded. So once the policy gets loaded and root is switched the kernel isid kicks in and associates kernel_t with the process

Quoted 73 lines

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 10 lines
policy/modules/system/init.te +2 -0
 files_create_lock_dirs(initrc_t)
 files_pid_filetrans_lock_dir(initrc_t, "lock")
 files_read_kernel_symbol_table(initrc_t)
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 dev_getattr_all_chr_files(initrc_t)
 # Early devtmpfs
 dev_rw_generic_chr_files(initrc_t)
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

policy/modules/system/init.te files_exec_etc_files(initrc_t) · line 506

Quoted 8 lines
policy/modules/system/init.te +2 -0
 domain_kill_all_domains(initrc_t)
 domain_signal_all_domains(initrc_t)
@@ -496,6 +502,8 @@ files_exec_etc_files(initrc_t)
 files_read_usr_files(initrc_t)
 files_manage_urandom_seed(initrc_t)
 files_manage_generic_spool(initrc_t)
+# manage the restorecond lock file
+files_manage_generic_locks(initrc_t)

initrc_t can already delete all locks. Why does it need to create locks?

Quoted 17 lines
policy/modules/system/init.te +2 -0
 # Mount and unmount file systems.
 # cjp: not sure why these are here; should use mount policy
 files_list_default(initrc_t)
@@ -532,10 +540,12 @@ storage_setattr_removable_dev(initrc_t)
 
 term_use_all_terms(initrc_t)
 term_reset_tty_labels(initrc_t)
+term_unlink_bsd_ptys(initrc_t)
 
 auth_rw_login_records(initrc_t)
 auth_setattr_login_records(initrc_t)
 auth_rw_lastlog(initrc_t)
+auth_manage_faillog(initrc_t)
 auth_read_pam_pid(initrc_t)
 auth_delete_pam_pid(initrc_t)
 auth_delete_pam_console_data(initrc_t)

policy/modules/system/init.te optional_policy(` · line 844

Quoted 6 lines
policy/modules/system/init.te +1 -2
@@ -831,12 +841,13 @@ optional_policy(`
 ')
 
 optional_policy(`
-	dev_getattr_printer_dev(initrc_t)
-
+	cups_domtrans(initrc_t)

This should not be necessary, as cups is already an init_daemon_domain().

Quoted 20 lines
policy/modules/system/init.te +6 -0
 	cups_read_log(initrc_t)
 	cups_read_rw_config(initrc_t)
 #cups init script clears error log
 	cups_write_log(initrc_t)
+
+	dev_getattr_printer_dev(initrc_t)
 ')
 
 optional_policy(`
@@ -900,6 +911,10 @@ optional_policy(`
 ')
 
 optional_policy(`
+	iptables_read_config(initrc_t)
+')
+
+optional_policy(`
 	iscsi_stream_connect(initrc_t)
 	iscsi_read_lib_files(initrc_t)
 ')
Signature · 11 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 648 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20161230/86333304/attachment.bin 
#3 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 69 lines · Dominick Grift via refpolicy
Quoted 63 lines · Chris PeBenito via refpolicy
Quoted 61 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some missing permissions.

---
?policy/modules/kernel/terminal.if |???21 +++++++++++++++++++++ ?policy/modules/system/init.te?????|???19 +++++++++++++++++-- ?2 files changed, 38 insertions(+), 2 deletions(-)

diff -pru a/policy/modules/kernel/terminal.if
b/policy/modules/kernel/terminal.if
--- a/policy/modules/kernel/terminal.if 2016-12-27
22:41:00.664390360 +0100
+++ b/policy/modules/kernel/terminal.if 2016-12-29
23:30:56.342306506 +0100

(quoted diff) +0 -0
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 

?########################################
?## <summary>

policy/modules/kernel/terminal.if +21 -0
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>

?## Get the attributes of all unallocated
?## tty device nodes.
?## </summary>
diff -pru a/policy/modules/system/init.te
b/policy/modules/system/init.te
--- a/policy/modules/system/init.te 2016-12-29
22:48:16.456818544 +0100
+++ b/policy/modules/system/init.te 2016-12-29
23:44:28.212518135 +0100

(quoted diff) +1 -0
@@ -415,12 +415,16 @@ kernel_clear_ring_buffer(initrc_t)
 ?kernel_get_sysvipc_info(initrc_t)
 ?kernel_read_all_sysctls(initrc_t)
 ?kernel_rw_all_sysctls(initrc_t)
+kernel_use_fds(initrc_t)

?# for lsof which is used by alsa shutdown:
?kernel_dontaudit_getattr_message_if(initrc_t)
?# cjp: not sure why these are here; should use mount policy ?kernel_list_unlabeled(initrc_t) ?kernel_mounton_unlabeled_dirs(initrc_t)

Quoted 4 lines

policy/modules/system/init.te kernel_clear_ring_buffer(initrc_t) · line 426

Quoted 2 lines
policy/modules/system/init.te +2 -0
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Quoted 4 lines

Plymouthd is running from initramfs before policy is loaded. So once the
policy gets loaded and root is switched the kernel isid kicks in and associates kernel_t with the process

Yes, I confirm. Plymouthd is running in the kernel_t domain because it is started before the policy is loaded.

Quoted 67 lines
Quoted 67 lines

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 9 lines

?files_create_lock_dirs(initrc_t)
?files_pid_filetrans_lock_dir(initrc_t, "lock")
?files_read_kernel_symbol_table(initrc_t)

(quoted diff) +0 -0
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 ?dev_getattr_all_chr_files(initrc_t)

?# Early devtmpfs
?dev_rw_generic_chr_files(initrc_t)

policy/modules/system/init.te +2 -0
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

Review files_exec_etc_files(initrc_t) · line 506

Quoted 9 lines

?domain_kill_all_domains(initrc_t)
?domain_signal_all_domains(initrc_t)

(quoted diff) +2 -0
@@ -496,6 +502,8 @@ files_exec_etc_files(initrc_t)
 ?files_read_usr_files(initrc_t)
 ?files_manage_urandom_seed(initrc_t)
 ?files_manage_generic_spool(initrc_t)
+# manage the restorecond lock file
+files_manage_generic_locks(initrc_t)

initrc_t can already delete all locks.??Why does it need to create locks?

Quoted 21 lines

?# Mount and unmount file systems.
?# cjp: not sure why these are here; should use mount policy ?files_list_default(initrc_t)

(quoted diff) +2 -0
@@ -532,10 +540,12 @@ storage_setattr_removable_dev(initrc_t)
 
 ?term_use_all_terms(initrc_t)
 ?term_reset_tty_labels(initrc_t)
+term_unlink_bsd_ptys(initrc_t)
 
 ?auth_rw_login_records(initrc_t)
 ?auth_setattr_login_records(initrc_t)
 ?auth_rw_lastlog(initrc_t)
+auth_manage_faillog(initrc_t)
 ?auth_read_pam_pid(initrc_t)
 ?auth_delete_pam_pid(initrc_t)
 ?auth_delete_pam_console_data(initrc_t)
@@ -831,12 +841,13 @@ optional_policy(`
 ?')
 

?optional_policy(`

policy/modules/system/init.te optional_policy(` · line 844

Quoted 3 lines
policy/modules/system/init.te +1 -2
-	dev_getattr_printer_dev(initrc_t)
-
+	cups_domtrans(initrc_t)

This should not be necessary, as cups is already an init_daemon_domain().

Quoted 13 lines

? cups_read_log(initrc_t)
? cups_read_rw_config(initrc_t)
?#cups init script clears error log
? cups_write_log(initrc_t)

policy/modules/system/init.te +2 -0
+
+	dev_getattr_printer_dev(initrc_t)

?')

?optional_policy(`

(quoted diff) +0 -0
@@ -900,6 +911,10 @@ optional_policy(`
 ?')
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

?optional_policy(`

policy/modules/system/init.te +4 -0
+	iptables_read_config(initrc_t)
+')
+
+optional_policy(`

? iscsi_stream_connect(initrc_t)
? iscsi_read_lib_files(initrc_t)
?')

Regards,

Guido

#4 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 70 lines · Guido Trentalancia via refpolicy
Quoted 69 lines · Dominick Grift via refpolicy
Quoted 67 lines · Chris PeBenito via refpolicy
Quoted 53 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some missing permissions.

---
 policy/modules/kernel/terminal.if |   21 +++++++++++++++++++++
 policy/modules/system/init.te     |   19 +++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff -pru a/policy/modules/kernel/terminal.if
b/policy/modules/kernel/terminal.if
--- a/policy/modules/kernel/terminal.if 2016-12-27
22:41:00.664390360 +0100
+++ b/policy/modules/kernel/terminal.if 2016-12-29
23:30:56.342306506 +0100

policy/modules/kernel/terminal.if +21 -0
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 
 ########################################
 ## <summary>
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>
 ##	Get the attributes of all unallocated
 ##	tty device nodes.
 ## </summary>

diff -pru a/policy/modules/system/init.te
b/policy/modules/system/init.te
--- a/policy/modules/system/init.te 2016-12-29
22:48:16.456818544 +0100
+++ b/policy/modules/system/init.te 2016-12-29
23:44:28.212518135 +0100

policy/modules/system/init.te +0 -0
@@ -415,12 +415,16 @@ kernel_clear_ring_buffer(initrc_t)
 kernel_get_sysvipc_info(initrc_t)
 kernel_read_all_sysctls(initrc_t)

policy/modules/system/init.te kernel_clear_ring_buffer(initrc_t) · line 426

Quoted 10 lines
policy/modules/system/init.te +3 -0
 kernel_rw_all_sysctls(initrc_t)
+kernel_use_fds(initrc_t)
 # for lsof which is used by alsa shutdown:
 kernel_dontaudit_getattr_message_if(initrc_t)
 # cjp: not sure why these are here; should use mount policy
 kernel_list_unlabeled(initrc_t)
 kernel_mounton_unlabeled_dirs(initrc_t)
 
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Quoted 8 lines
Quoted 4 lines

Plymouthd is running from initramfs before policy is loaded. So once the
policy gets loaded and root is switched the kernel isid kicks in and associates kernel_t with the process

Yes, I confirm. Plymouthd is running in the kernel_t domain because it is started before the policy is loaded.

The question is then what is running in initrc_t in that event? is it the plymouth client stream connecting to plymouthd?

is the plymouth client an init_system_domain()?

Quoted 84 lines
Quoted 67 lines
Quoted 67 lines

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 9 lines
policy/modules/system/init.te +2 -0
 files_create_lock_dirs(initrc_t)
 files_pid_filetrans_lock_dir(initrc_t, "lock")
 files_read_kernel_symbol_table(initrc_t)
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 dev_getattr_all_chr_files(initrc_t)
 # Early devtmpfs
 dev_rw_generic_chr_files(initrc_t)
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

policy/modules/system/init.te files_exec_etc_files(initrc_t) · line 506

Quoted 9 lines
policy/modules/system/init.te +2 -0
 domain_kill_all_domains(initrc_t)
 domain_signal_all_domains(initrc_t)
@@ -496,6 +502,8 @@ files_exec_etc_files(initrc_t)
 files_read_usr_files(initrc_t)
 files_manage_urandom_seed(initrc_t)
 files_manage_generic_spool(initrc_t)
+# manage the restorecond lock file
+files_manage_generic_locks(initrc_t)

initrc_t can already delete all locks. Why does it need to create locks?

Quoted 18 lines
policy/modules/system/init.te +2 -0
 # Mount and unmount file systems.
 # cjp: not sure why these are here; should use mount policy
 files_list_default(initrc_t)
@@ -532,10 +540,12 @@ storage_setattr_removable_dev(initrc_t)
 
 term_use_all_terms(initrc_t)
 term_reset_tty_labels(initrc_t)
+term_unlink_bsd_ptys(initrc_t)
 
 auth_rw_login_records(initrc_t)
 auth_setattr_login_records(initrc_t)
 auth_rw_lastlog(initrc_t)
+auth_manage_faillog(initrc_t)
 auth_read_pam_pid(initrc_t)
 auth_delete_pam_pid(initrc_t)
 auth_delete_pam_console_data(initrc_t)

policy/modules/system/init.te optional_policy(` · line 844

Quoted 6 lines
policy/modules/system/init.te +1 -2
@@ -831,12 +841,13 @@ optional_policy(`
 ')
 
 optional_policy(`
-	dev_getattr_printer_dev(initrc_t)
-
+	cups_domtrans(initrc_t)

This should not be necessary, as cups is already an init_daemon_domain().

Quoted 13 lines
policy/modules/system/init.te +2 -0
 	cups_read_log(initrc_t)
 	cups_read_rw_config(initrc_t)
 #cups init script clears error log
 	cups_write_log(initrc_t)
+
+	dev_getattr_printer_dev(initrc_t)
 ')
 
 optional_policy(`
@@ -900,6 +911,10 @@ optional_policy(`
 ')
 
Quoted 8 lines
Quoted 8 lines

policy/modules/system/init.te optional_policy(` · line 920

Quoted 8 lines
policy/modules/system/init.te +4 -0
 optional_policy(`
+	iptables_read_config(initrc_t)
+')
+
+optional_policy(`
 	iscsi_stream_connect(initrc_t)
 	iscsi_read_lib_files(initrc_t)
 ')

Regards,

Guido
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 11 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 648 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20161230/fe856286/attachment.bin 
#5 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 21 lines · Dominick Grift via refpolicy
Quoted 20 lines · Guido Trentalancia via refpolicy
Quoted 17 lines · Dominick Grift via refpolicy
Quoted 15 lines · Chris PeBenito via refpolicy
Quoted 12 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some
missing permissions.

---
?policy/modules/kernel/terminal.if |???21
+++++++++++++++++++++
?policy/modules/system/init.te?????|???19 +++++++++++++++++-- ?2 files changed, 38 insertions(+), 2 deletions(-)

[...]

Quoted 17 lines
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines

policy/modules/system/init.te kernel_clear_ring_buffer(initrc_t) · line 426

Quoted 2 lines
policy/modules/system/init.te +2 -0
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Plymouthd is running from initramfs before policy is loaded. So once
the
policy gets loaded and root is switched the kernel isid kicks in and
associates kernel_t with the process

Quoted 4 lines

Yes, I confirm. Plymouthd is running in the kernel_t domain because it
is started before the policy is loaded.

Quoted 4 lines

The question is then what is running in initrc_t in that event? is it the plymouth client stream connecting to plymouthd?

is the plymouth client an init_system_domain()?

The comment is misleading in some sense. It's plymouthd, I wrote "plymouth" referring to the package.

I'll fix the comment in the next version.

Regards,

Guido

#6 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 45 lines · Guido Trentalancia via refpolicy
Quoted 21 lines · Dominick Grift via refpolicy
Quoted 20 lines · Guido Trentalancia via refpolicy
Quoted 17 lines · Dominick Grift via refpolicy
Quoted 15 lines · Chris PeBenito via refpolicy
Quoted 12 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some
missing permissions.

---
 policy/modules/kernel/terminal.if |   21
+++++++++++++++++++++
 policy/modules/system/init.te     |   19 +++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

[...]

Quoted 20 lines
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines

policy/modules/system/init.te kernel_clear_ring_buffer(initrc_t) · line 426

Quoted 2 lines
policy/modules/system/init.te +2 -0
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Plymouthd is running from initramfs before policy is loaded. So once
the
policy gets loaded and root is switched the kernel isid kicks in and
associates kernel_t with the process

Quoted 4 lines

Yes, I confirm. Plymouthd is running in the kernel_t domain because it
is started before the policy is loaded.

The question is then what is running in initrc_t in that event? is it the plymouth client stream connecting to plymouthd?

Quoted 6 lines
Quoted 1 line

is the plymouth client an init_system_domain()?

The comment is misleading in some sense. It's plymouthd, I wrote "plymouth" referring to the package.

I'll fix the comment in the next version.

Yes ok, but then why does a process associated with initrc_t need to stream connect to it?

what is that process running in initrc_t?

Quoted 9 lines

Regards,

Guido
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 11 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 648 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20161230/a3f202b8/attachment.bin 
#7 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 69 lines · Dominick Grift via refpolicy
Quoted 68 lines · Guido Trentalancia via refpolicy
Quoted 28 lines · Dominick Grift via refpolicy
Quoted 26 lines · Guido Trentalancia via refpolicy
Quoted 22 lines · Dominick Grift via refpolicy
Quoted 19 lines · Chris PeBenito via refpolicy
Quoted 15 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some
missing permissions.

Quoted 1 line

---
?policy/modules/kernel/terminal.if |???21
+++++++++++++++++++++
?policy/modules/system/init.te?????|???19
+++++++++++++++++--
?2 files changed, 38 insertions(+), 2 deletions(-)

[...]

Quoted 25 lines
Quoted 19 lines
Quoted 10 lines
Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +2 -0
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Quoted 8 lines

Plymouthd is running from initramfs before policy is loaded. So
once
the
policy gets loaded and root is switched the kernel isid kicks in
and
associates kernel_t with the process

Quoted 5 lines

Yes, I confirm. Plymouthd is running in the kernel_t domain because
it
is started before the policy is loaded.

Quoted 5 lines

The question is then what is running in initrc_t in that event? is it
the plymouth client stream connecting to plymouthd?

is the plymouth client an init_system_domain()?

The comment is misleading in some sense. It's plymouthd, I wrote "plymouth" referring to the package.

Quoted 6 lines
Quoted 1 line

I'll fix the comment in the next version.

Yes ok, but then why does a process associated with initrc_t need to stream connect to it?

what is that process running in initrc_t?

It's actually the other way around. The comment is correct.

The client is eventually running in initrc_t...

Such permission is absolutely necessary for the correct functioning of the plymouth terminal interface.

Regards,

Guido

#8 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 75 lines · Guido Trentalancia via refpolicy
Quoted 74 lines · Dominick Grift via refpolicy
Quoted 63 lines · Guido Trentalancia via refpolicy
Quoted 28 lines · Dominick Grift via refpolicy
Quoted 26 lines · Guido Trentalancia via refpolicy
Quoted 22 lines · Dominick Grift via refpolicy
Quoted 19 lines · Chris PeBenito via refpolicy
Quoted 15 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some
missing permissions.

Quoted 1 line
---
 policy/modules/kernel/terminal.if |   21
+++++++++++++++++++++
 policy/modules/system/init.te     |   19
+++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

[...]

Quoted 29 lines
Quoted 19 lines
Quoted 10 lines
Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +2 -0
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Quoted 8 lines

Plymouthd is running from initramfs before policy is loaded. So
once
the
policy gets loaded and root is switched the kernel isid kicks in
and
associates kernel_t with the process

Quoted 5 lines

Yes, I confirm. Plymouthd is running in the kernel_t domain because
it
is started before the policy is loaded.

The question is then what is running in initrc_t in that event? is it
the plymouth client stream connecting to plymouthd?

Quoted 6 lines
Quoted 1 line

is the plymouth client an init_system_domain()?

The comment is misleading in some sense. It's plymouthd, I wrote "plymouth" referring to the package.

I'll fix the comment in the next version.

Yes ok, but then why does a process associated with initrc_t need to stream connect to it?

Quoted 8 lines
Quoted 1 line

what is that process running in initrc_t?

It's actually the other way around. The comment is correct.

The client is eventually running in initrc_t...

Such permission is absolutely necessary for the correct functioning of the plymouth terminal interface.

ok then i believe you should instead add:

init_system_domain(plymouth_t, plymouth_exec_t)

or somthing along those lines

Quoted 9 lines

Regards,

Guido
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 11 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 648 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20161230/50f33dfa/attachment-0001.bin 
#9 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 1 line · Dominick Grift via refpolicy

On 12/30/2016 09:50 PM, Guido Trentalancia via refpolicy wrote:

[...]

Quoted 50 lines
Quoted 42 lines
Quoted 34 lines
Quoted 34 lines
Quoted 23 lines
Quoted 17 lines
Quoted 6 lines
Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Quoted 10 lines

Plymouthd is running from initramfs before policy is loaded.
So
once
the
policy gets loaded and root is switched the kernel isid kicks
in
and
associates kernel_t with the process

Quoted 5 lines

Yes, I confirm. Plymouthd is running in the kernel_t domain because
it
is started before the policy is loaded.

Quoted 6 lines

The question is then what is running in initrc_t in that event?
is it
the plymouth client stream connecting to plymouthd?

is the plymouth client an init_system_domain()?

The comment is misleading in some sense. It's plymouthd, I wrote
"plymouth" referring to the package.

Quoted 7 lines
Quoted 1 line

I'll fix the comment in the next version.

Yes ok, but then why does a process associated with initrc_t need to
stream connect to it?

what is that process running in initrc_t?

Quoted 7 lines

It's actually the other way around. The comment is correct.

The client is eventually running in initrc_t...

Such permission is absolutely necessary for the correct functioning of
the plymouth terminal interface.

Quoted 5 lines

ok then i believe you should instead add:

init_system_domain(plymouth_t, plymouth_exec_t)

or somthing along those lines

Yes, the above works and is the correct solution, thanks for the tip.

This leads to a new patch for the plymouth module...

Regards,

Guido

#10 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 57 lines · Guido Trentalancia via refpolicy
Quoted 1 line · Dominick Grift via refpolicy

On 12/30/2016 09:50 PM, Guido Trentalancia via refpolicy wrote:

[...]

Quoted 52 lines
Quoted 42 lines
Quoted 34 lines
Quoted 34 lines
Quoted 23 lines
Quoted 17 lines
Quoted 6 lines
Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+# plymouth
+kernel_stream_connect(initrc_t)

Plymouth has a domain, so this seems unnecessary.

Quoted 10 lines

Plymouthd is running from initramfs before policy is loaded.
So
once
the
policy gets loaded and root is switched the kernel isid kicks
in
and
associates kernel_t with the process

Quoted 5 lines

Yes, I confirm. Plymouthd is running in the kernel_t domain because
it
is started before the policy is loaded.

Quoted 6 lines

The question is then what is running in initrc_t in that event?
is it
the plymouth client stream connecting to plymouthd?

is the plymouth client an init_system_domain()?

The comment is misleading in some sense. It's plymouthd, I wrote
"plymouth" referring to the package.

Quoted 7 lines
Quoted 1 line

I'll fix the comment in the next version.

Yes ok, but then why does a process associated with initrc_t need to
stream connect to it?

what is that process running in initrc_t?

Quoted 7 lines

It's actually the other way around. The comment is correct.

The client is eventually running in initrc_t...

Such permission is absolutely necessary for the correct functioning of
the plymouth terminal interface.

ok then i believe you should instead add:

Quoted 7 lines
Quoted 3 lines

init_system_domain(plymouth_t, plymouth_exec_t)

or somthing along those lines

Yes, the above works and is the correct solution, thanks for the tip.

This leads to a new patch for the plymouth module...

So plymouth client stream connects to plymouthd (running with kernel_t because it was already running when the policy got loaded)

Quoted 9 lines

Regards,

Guido
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 11 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 648 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20161230/2f76e8e0/attachment.bin 
#11 lore raw

PATCH 1/1 init: update the initrc_t domain policy

In reply to Chris PeBenito
Quoted 51 lines · Chris PeBenito
Quoted 50 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some missing permissions.

---
?policy/modules/kernel/terminal.if |???21 +++++++++++++++++++++ ?policy/modules/system/init.te?????|???19 +++++++++++++++++-- ?2 files changed, 38 insertions(+), 2 deletions(-)

diff -pru a/policy/modules/kernel/terminal.if
b/policy/modules/kernel/terminal.if
--- a/policy/modules/kernel/terminal.if 2016-12-27
22:41:00.664390360 +0100
+++ b/policy/modules/kernel/terminal.if 2016-12-29
23:30:56.342306506 +0100

(quoted diff) +0 -0
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 

?########################################
?## <summary>

policy/modules/kernel/terminal.if +21 -0
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>

?## Get the attributes of all unallocated
?## tty device nodes.
?## </summary>
diff -pru a/policy/modules/system/init.te
b/policy/modules/system/init.te
--- a/policy/modules/system/init.te 2016-12-29
22:48:16.456818544 +0100
+++ b/policy/modules/system/init.te 2016-12-29
23:44:28.212518135 +0100

[...]

Quoted 11 lines

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 9 lines

?files_create_lock_dirs(initrc_t)
?files_pid_filetrans_lock_dir(initrc_t, "lock")
?files_read_kernel_symbol_table(initrc_t)

(quoted diff) +0 -0
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 ?dev_getattr_all_chr_files(initrc_t)

?# Early devtmpfs
?dev_rw_generic_chr_files(initrc_t)

policy/modules/system/init.te +2 -0
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

You see, unfortunately, the mcelog.init script, has a limitation in that sense because it checks that /dev/mcelog is readable otherwise it exits without starting the mcelog service.

It's not a bug strictly speaking, however, it causes such limitation in the security domain.

Of course, mcelog then runs in its own domain...

Regards,

Guido

#12 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 67 lines · Guido Trentalancia via refpolicy
Quoted 51 lines · Chris PeBenito
Quoted 50 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some missing permissions.

---
 policy/modules/kernel/terminal.if |   21 +++++++++++++++++++++
 policy/modules/system/init.te     |   19 +++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff -pru a/policy/modules/kernel/terminal.if
b/policy/modules/kernel/terminal.if
--- a/policy/modules/kernel/terminal.if 2016-12-27
22:41:00.664390360 +0100
+++ b/policy/modules/kernel/terminal.if 2016-12-29
23:30:56.342306506 +0100

policy/modules/kernel/terminal.if +21 -0
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 
 ########################################
 ## <summary>
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>
 ##	Get the attributes of all unallocated
 ##	tty device nodes.
 ## </summary>

diff -pru a/policy/modules/system/init.te
b/policy/modules/system/init.te
--- a/policy/modules/system/init.te 2016-12-29
22:48:16.456818544 +0100
+++ b/policy/modules/system/init.te 2016-12-29
23:44:28.212518135 +0100

[...]

Quoted 11 lines

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 9 lines

files_create_lock_dirs(initrc_t)
files_pid_filetrans_lock_dir(initrc_t, "lock")
files_read_kernel_symbol_table(initrc_t)

policy/modules/system/init.te +2 -0
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 dev_getattr_all_chr_files(initrc_t)
 # Early devtmpfs
 dev_rw_generic_chr_files(initrc_t)
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

Quoted 6 lines

You see, unfortunately, the mcelog.init script, has a limitation in that sense because it checks that /dev/mcelog is readable otherwise it exits without starting the mcelog service.

It's not a bug strictly speaking, however, it causes such limitation in the security domain.

how about adding a:

dev_audit_read_access_kmsg()

allow ARG1 kmsg_dev_t:chr_file { getattr read };

Quoted 11 lines

Of course, mcelog then runs in its own domain...

Regards,

Guido
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 11 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 648 bytes
Desc: OpenPGP digital signature
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20161230/1933dd40/attachment.bin 
#13 lore raw

PATCH 1/1 init: update the initrc_t domain policy

In reply to Guido Trentalancia
Quoted 76 lines · Guido Trentalancia via refpolicy
Quoted 53 lines · Chris PeBenito
Quoted 51 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some missing permissions.

---
?policy/modules/kernel/terminal.if |???21 +++++++++++++++++++++ ?policy/modules/system/init.te?????|???19 +++++++++++++++++-- ?2 files changed, 38 insertions(+), 2 deletions(-)

diff -pru a/policy/modules/kernel/terminal.if
b/policy/modules/kernel/terminal.if
--- a/policy/modules/kernel/terminal.if 2016-12-27
22:41:00.664390360 +0100
+++ b/policy/modules/kernel/terminal.if 2016-12-29
23:30:56.342306506 +0100

(quoted diff) +0 -0
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 

?########################################
?## <summary>

policy/modules/kernel/terminal.if +21 -0
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>

?## Get the attributes of all unallocated
?## tty device nodes.
?## </summary>
diff -pru a/policy/modules/system/init.te
b/policy/modules/system/init.te
--- a/policy/modules/system/init.te 2016-12-29
22:48:16.456818544 +0100
+++ b/policy/modules/system/init.te 2016-12-29
23:44:28.212518135 +0100

[...]

Quoted 13 lines

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 11 lines

?files_create_lock_dirs(initrc_t)
?files_pid_filetrans_lock_dir(initrc_t, "lock")
?files_read_kernel_symbol_table(initrc_t)

(quoted diff) +0 -0
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 ?dev_getattr_all_chr_files(initrc_t)

?# Early devtmpfs
?dev_rw_generic_chr_files(initrc_t)

policy/modules/system/init.te +2 -0
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

You see, unfortunately, the mcelog.init script, has a limitation in that sense because it checks that /dev/mcelog is readable otherwise it
exits without starting the mcelog service.

Quoted 5 lines

It's not a bug strictly speaking, however, it causes such limitation in
the security domain.

Of course, mcelog then runs in its own domain...

Actually, the mcelog init script does not exit, however it prints an (annoying and false) error message about /dev/mcelog not being active !

I think we'd better keep the dev_read_kmsg(initrc_t) permission, although theoretically it could be removed.

Regards,

Guido

#14 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 23 lines · Guido Trentalancia via refpolicy
Quoted 21 lines · Guido Trentalancia via refpolicy
Quoted 10 lines · Chris PeBenito

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 6 lines · Guido Trentalancia via refpolicy
policy/modules/system/init.te +2 -0
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 dev_getattr_all_chr_files(initrc_t)
 # Early devtmpfs
 dev_rw_generic_chr_files(initrc_t)
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

You see, unfortunately, the mcelog.init script, has a limitation in that sense because it checks that /dev/mcelog is readable otherwise it
exits without starting the mcelog service.

It's not a bug strictly speaking, however, it causes such limitation in
the security domain.

Quoted 7 lines
Quoted 1 line

Of course, mcelog then runs in its own domain...

Actually, the mcelog init script does not exit, however it prints an (annoying and false) error message about /dev/mcelog not being active !

I think we'd better keep the dev_read_kmsg(initrc_t) permission, although theoretically it could be removed.

Which distro is this on? The Gentoo init script doesn't do that.

Signature · 1 line
Chris PeBenito
#15 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Hello !

Quoted 41 lines · Chris PeBenito
Quoted 40 lines · Guido Trentalancia via refpolicy
Quoted 25 lines · Guido Trentalancia via refpolicy
Quoted 7 lines · Chris PeBenito
Quoted 1 line · Guido Trentalancia via refpolicy
Quoted 8 lines

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 6 lines
(quoted diff) +0 -0
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 ?dev_getattr_all_chr_files(initrc_t)

?# Early devtmpfs
?dev_rw_generic_chr_files(initrc_t)

policy/modules/system/init.te +2 -0
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

You see, unfortunately, the mcelog.init script, has a limitation in
that sense because it checks that /dev/mcelog is readable otherwise
it
exits without starting the mcelog service.

Quoted 6 lines

It's not a bug strictly speaking, however, it causes such limitation
in
the security domain.

Of course, mcelog then runs in its own domain...

Actually, the mcelog init script does not exit, however it prints an
(annoying and false) error message about /dev/mcelog not being active !

Quoted 4 lines
Quoted 2 lines

I think we'd better keep the dev_read_kmsg(initrc_t) permission, although theoretically it could be removed.

Which distro is this on???The Gentoo init script doesn't do that.

It is latest mcelog release and latest mcelog git.

Regards,

Guido

#16 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 44 lines · Guido Trentalancia via refpolicy

Hello !

Quoted 41 lines · Chris PeBenito
Quoted 40 lines · Guido Trentalancia via refpolicy
Quoted 25 lines · Guido Trentalancia via refpolicy
Quoted 7 lines · Chris PeBenito
Quoted 1 line · Guido Trentalancia via refpolicy
Quoted 8 lines

policy/modules/system/init.te dev_getattr_all_blk_files(initrc_t) · line 470

Quoted 6 lines
policy/modules/system/init.te +2 -0
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 dev_getattr_all_chr_files(initrc_t)
 # Early devtmpfs
 dev_rw_generic_chr_files(initrc_t)
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

You see, unfortunately, the mcelog.init script, has a limitation in
that sense because it checks that /dev/mcelog is readable otherwise
it
exits without starting the mcelog service.

Quoted 6 lines

It's not a bug strictly speaking, however, it causes such limitation
in
the security domain.

Of course, mcelog then runs in its own domain...

Actually, the mcelog init script does not exit, however it prints an
(annoying and false) error message about /dev/mcelog not being active !

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I think we'd better keep the dev_read_kmsg(initrc_t) permission, although theoretically it could be removed.

Which distro is this on? The Gentoo init script doesn't do that.

It is latest mcelog release and latest mcelog git.

The point is that systemd systems probably don't need this access, nor does Gentoo, so which distro does?

Signature · 1 line
Chris PeBenito
#17 lore raw

PATCH 1/1 init: update the initrc_t domain policy

Quoted 62 lines · Chris PeBenito
Quoted 61 lines · Guido Trentalancia via refpolicy

Hello !

Quoted 57 lines · Chris PeBenito
Quoted 54 lines · Guido Trentalancia via refpolicy
Quoted 33 lines · Guido Trentalancia via refpolicy
Quoted 12 lines · Chris PeBenito
Quoted 2 lines · Guido Trentalancia via refpolicy
Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +0 -0
@@ -462,6 +466,8 @@ dev_getattr_all_blk_files(initrc_t)
 ?dev_getattr_all_chr_files(initrc_t)

?# Early devtmpfs
?dev_rw_generic_chr_files(initrc_t)

(quoted diff) +2 -0
+# mcelog service
+dev_read_kmsg(initrc_t)

mcelog is a service, so it shouldn't be running in initrc_t.

You see, unfortunately, the mcelog.init script, has a limitation
in
that sense because it checks that /dev/mcelog is readable otherwise
it
exits without starting the mcelog service.

Quoted 6 lines

It's not a bug strictly speaking, however, it causes such limitation
in
the security domain.

Of course, mcelog then runs in its own domain...

Actually, the mcelog init script does not exit, however it prints
an
(annoying and false) error message about /dev/mcelog not being active !

I think we'd better keep the dev_read_kmsg(initrc_t) permission,
although theoretically it could be removed.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Which distro is this on???The Gentoo init script doesn't do that.

It is latest mcelog release and latest mcelog git.

The point is that systemd systems probably don't need this access, nor?
does Gentoo, so which distro does?

I do not know precisely.

All systems that do not modify the original mcelog init script are affected.

Regards,

Guido

#18 lore raw

PATCH 1/1 init: update the initrc_t domain policy

In reply to Chris PeBenito

Hello again.

Quoted 13 lines

On the 30th of December 2016 at 20.30 Chris PeBenito <[email protected]> wrote:

Quoted 8 lines · Guido Trentalancia via refpolicy

Update the initrc_t domain policy in the init module with some missing permissions.

---
 policy/modules/kernel/terminal.if |   21 +++++++++++++++++++++
 policy/modules/system/init.te     |   19 +++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

[...]

Quoted 10 lines

policy/modules/system/init.te files_exec_etc_files(initrc_t) · line 506

Quoted 8 lines

domain_kill_all_domains(initrc_t)
domain_signal_all_domains(initrc_t)

policy/modules/system/init.te +2 -0
@@ -496,6 +502,8 @@ files_exec_etc_files(initrc_t)
 files_read_usr_files(initrc_t)
 files_manage_urandom_seed(initrc_t)
 files_manage_generic_spool(initrc_t)
+# manage the restorecond lock file
+files_manage_generic_locks(initrc_t)

initrc_t can already delete all locks. Why does it need to create locks?

The init scripts usually create the lock file upon starting up the service (and delete it when stopping the service).

If you look at the script file restorecond.init from policycoreutils/restorecond, you'll find the following:

touch /var/lock/subsys/restorecond

which implies files_manage_generic_locks(initrc_t).

I hope it helps...

Regards,

Guido

#19 lore raw

PATCH v2 1/1 init: update the initrc_t domain policy

In reply to Guido Trentalancia

Update the initrc_t domain policy in the init module with some missing permissions.

---
 policy/modules/kernel/terminal.if |   21 +++++++++++++++++++++
 policy/modules/system/init.te     |   15 +++++++++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)

diff -pru a/policy/modules/kernel/terminal.if
b/policy/modules/kernel/terminal.if

policy/modules/kernel/terminal.if +21 -0
@@ -1102,6 +1102,27 @@ interface(`term_relabel_all_user_ptys',`
 
 ########################################
 ## <summary>
+##	Unlink BSD-style pty device
+##	nodes.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+## <rolecap/>
+#
+interface(`term_unlink_bsd_ptys',`
+	gen_require(`
+		type bsdpty_device_t;
+	')
+
+	dev_list_all_dev_nodes($1)
+	allow $1 bsdpty_device_t:chr_file { unlink };
+')
+
+########################################
+## <summary>
 ##	Get the attributes of all unallocated
 ##	tty device nodes.
 ## </summary>
policy/modules/system/init.te +13 -2
diff -pru a/policy/modules/system/init.te b/policy/modules/system/init.te
@@ -415,6 +415,7 @@ kernel_clear_ring_buffer(initrc_t)
 kernel_get_sysvipc_info(initrc_t)
 kernel_read_all_sysctls(initrc_t)
 kernel_rw_all_sysctls(initrc_t)
+kernel_use_fds(initrc_t)
 # for lsof which is used by alsa shutdown:
 kernel_dontaudit_getattr_message_if(initrc_t)
 # cjp: not sure why these are here; should use mount policy
@@ -462,6 +463,8 @@ dev_getattr_all_blk_files(initrc_t)
 dev_getattr_all_chr_files(initrc_t)
 # Early devtmpfs
 dev_rw_generic_chr_files(initrc_t)
+# mcelog service
+dev_read_kmsg(initrc_t)
 
 domain_kill_all_domains(initrc_t)
 domain_signal_all_domains(initrc_t)
@@ -496,6 +499,8 @@ files_exec_etc_files(initrc_t)
 files_read_usr_files(initrc_t)
 files_manage_urandom_seed(initrc_t)
 files_manage_generic_spool(initrc_t)
+# manage the restorecond lock file
+files_manage_generic_locks(initrc_t)
 # Mount and unmount file systems.
 # cjp: not sure why these are here; should use mount policy
 files_list_default(initrc_t)
@@ -532,10 +537,12 @@ storage_setattr_removable_dev(initrc_t)
 
 term_use_all_terms(initrc_t)
 term_reset_tty_labels(initrc_t)
+term_unlink_bsd_ptys(initrc_t)
 
 auth_rw_login_records(initrc_t)
 auth_setattr_login_records(initrc_t)
 auth_rw_lastlog(initrc_t)
+auth_manage_faillog(initrc_t)
 auth_read_pam_pid(initrc_t)
 auth_delete_pam_pid(initrc_t)
 auth_delete_pam_console_data(initrc_t)
@@ -831,12 +838,12 @@ optional_policy(`
 ')
 
 optional_policy(`
-	dev_getattr_printer_dev(initrc_t)
-
 	cups_read_log(initrc_t)
 	cups_read_rw_config(initrc_t)
 #cups init script clears error log
 	cups_write_log(initrc_t)
+
+	dev_getattr_printer_dev(initrc_t)
 ')
 
 optional_policy(`
@@ -900,6 +907,10 @@ optional_policy(`
 ')
 
 optional_policy(`
+	iptables_read_config(initrc_t)
+')
+
+optional_policy(`
 	iscsi_stream_connect(initrc_t)
 	iscsi_read_lib_files(initrc_t)
 ')