2018-06-06 14:25:05

by Sugar, David

[permalink] [raw]
Subject: [refpolicy] [PATCH 0/4] systemd-resolved policy updates

Updates to allow systemd-resolved to start without denials

Dave Sugar (4):
Allow systemd-resolved to read sysctl
Allow systemd_resolved to read systemd_networkd runtime files
Allow systemd-resolved to connect to system dbusd
systemd-resolved uses notify to indicate status

policy/modules/system/systemd.if | 19 +++++++++++++++++++
policy/modules/system/systemd.te | 8 ++++++++
2 files changed, 27 insertions(+)

--
2.14.3


2018-06-06 14:25:06

by Sugar, David

[permalink] [raw]
Subject: [refpolicy] [PATCH 1/4] Allow systemd-resolved to read sysctl

type=AVC msg=audit(1527698300.007:150): avc: denied { search } for pid=1193 comm="systemd-resolve" name="net" dev="proc" ino=8515 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:sysctl_net_t:s0 tclass=dir
type=AVC msg=audit(1527698300.007:150): avc: denied { read } for pid=1193 comm="systemd-resolve" name="disable_ipv6" dev="proc" ino=7988 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:sysctl_net_t:s0 tclass=file
type=AVC msg=audit(1527698300.007:150): avc: denied { open } for pid=1193 comm="systemd-resolve" path="/proc/sys/net/ipv6/conf/all/disable_ipv6" dev="proc" ino=7988 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:sysctl_net_t:s0 tclass=file
type=AVC msg=audit(1527698300.007:151): avc: denied { getattr } for pid=1193 comm="systemd-resolve" path="/proc/sys/net/ipv6/conf/all/disable_ipv6" dev="proc" ino=7988 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:sysctl_net_t:s0 tclass=file

type=AVC msg=audit(1527698300.006:148): avc: denied { read } for pid=1193 comm="systemd-resolve" name="disable" dev="sysfs" ino=2111 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file
type=AVC msg=audit(1527698300.006:148): avc: denied { open } for pid=1193 comm="systemd-resolve" path="/sys/module/ipv6/parameters/disable" dev="sysfs" ino=2111 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file
type=AVC msg=audit(1527698300.007:149): avc: denied { getattr } for pid=1193 comm="systemd-resolve" path="/sys/module/ipv6/parameters/disable" dev="sysfs" ino=2111 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file

Signed-off-by: Dave Sugar <[email protected]>
---
policy/modules/system/systemd.te | 3 +++
1 file changed, 3 insertions(+)

diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te
index 0cf54f54..708b9f23 100644
--- a/policy/modules/system/systemd.te
+++ b/policy/modules/system/systemd.te
@@ -842,8 +842,11 @@ manage_dirs_pattern(systemd_resolved_t, systemd_resolved_var_run_t, systemd_reso
manage_files_pattern(systemd_resolved_t, systemd_resolved_var_run_t, systemd_resolved_var_run_t)
init_pid_filetrans(systemd_resolved_t, systemd_resolved_var_run_t, dir)

+dev_read_sysfs(systemd_resolved_t)
+
kernel_read_crypto_sysctls(systemd_resolved_t)
kernel_read_kernel_sysctls(systemd_resolved_t)
+kernel_read_net_sysctls(systemd_resolved_t)

corenet_tcp_bind_generic_node(systemd_resolved_t)
corenet_tcp_bind_llmnr_port(systemd_resolved_t)
--
2.14.3

2018-06-06 14:25:07

by Sugar, David

[permalink] [raw]
Subject: [refpolicy] [PATCH 2/4] Allow systemd_resolved to read systemd_networkd runtime files

type=AVC msg=audit(1527698299.999:144): avc: denied { read } for pid=1193 comm="systemd-resolve" name="links" dev="tmpfs" ino=16229 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:systemd_networkd_var_run_t:s0 tclass=dir
type=AVC msg=audit(1527698299.999:145): avc: denied { read } for pid=1193 comm="systemd-resolve" name="3" dev="tmpfs" ino=18857 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:systemd_networkd_var_run_t:s0 tclass=file
type=AVC msg=audit(1527698299.999:145): avc: denied { open } for pid=1193 comm="systemd-resolve" path="/run/systemd/netif/links/3" dev="tmpfs" ino=18857 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:systemd_networkd_var_run_t:s0 tclass=file
type=AVC msg=audit(1527698300.000:146): avc: denied { getattr } for pid=1193 comm="systemd-resolve" path="/run/systemd/netif/links/3" dev="tmpfs" ino=18857 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:systemd_networkd_var_run_t:s0 tclass=file
type=AVC msg=audit(1527702014.276:183): avc: denied { search } for pid=1180 comm="systemd-resolve" name="netif" dev="tmpfs" ino=16878 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:systemd_networkd_var_run_t:s0 tclass=dir
type=AVC msg=audit(1527704163.181:152): avc: denied { open } for pid=1236 comm="systemd-resolve" path="/run/systemd/netif/links/5" dev="tmpfs" ino=19562 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:systemd_networkd_var_run_t:s0 tclass=file
type=AVC msg=audit(1527704163.181:153): avc: denied { getattr } for pid=1236 comm="systemd-resolve" path="/run/systemd/netif/links/5" dev="tmpfs" ino=19562 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:systemd_networkd_var_run_t:s0 tclass=file
type=AVC msg=audit(1527704163.604:173): avc: denied { read } for pid=1236 comm="systemd-resolve" name="5" dev="tmpfs" ino=19562 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:systemd_networkd_var_run_t:s0 tclass=file

Signed-off-by: Dave Sugar <[email protected]>
---
policy/modules/system/systemd.if | 19 +++++++++++++++++++
policy/modules/system/systemd.te | 1 +
2 files changed, 20 insertions(+)

diff --git a/policy/modules/system/systemd.if b/policy/modules/system/systemd.if
index 866838fe..c605602a 100644
--- a/policy/modules/system/systemd.if
+++ b/policy/modules/system/systemd.if
@@ -523,6 +523,25 @@ interface(`systemd_rw_networkd_netlink_route_sockets',`
allow $1 systemd_networkd_t:netlink_route_socket client_stream_socket_perms;
')

+#######################################
+## <summary>
+## Allow domain to read files generated by systemd_networkd
+## </summary>
+## <param name="domain">
+## <summary>
+## domain allowed access
+## </summary>
+## </param>
+#
+
+interface(`systemd_read_networkd_runtime',`
+ gen_require(`
+ type systemd_networkd_var_run_t;
+ ')
+
+ list_dirs_pattern($1, systemd_networkd_var_run_t, systemd_networkd_var_run_t)
+ read_files_pattern($1, systemd_networkd_var_run_t, systemd_networkd_var_run_t)
+')

########################################
## <summary>
diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te
index 708b9f23..79774dd3 100644
--- a/policy/modules/system/systemd.te
+++ b/policy/modules/system/systemd.te
@@ -858,6 +858,7 @@ auth_use_nsswitch(systemd_resolved_t)
seutil_read_file_contexts(systemd_resolved_t)

systemd_log_parse_environment(systemd_resolved_t)
+systemd_read_networkd_runtime(systemd_resolved_t)

optional_policy(`
dbus_system_bus_client(systemd_resolved_t)
--
2.14.3

2018-06-06 14:25:08

by Sugar, David

[permalink] [raw]
Subject: [refpolicy] [PATCH 3/4] Allow systemd-resolved to connect to system dbusd

type=USER_AVC msg=audit(1527726267.150:134): pid=1170 uid=81 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc: denied { acquire_svc } for service=org.freedesktop.resolve1 spid=1208 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tclass=dbus exe="/usr/bin/dbus-daemon" sauid=81 hostname=? addr=? terminal=?'

Signed-off-by: Dave Sugar <[email protected]>
---
policy/modules/system/systemd.te | 1 +
1 file changed, 1 insertion(+)

diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te
index 79774dd3..60651a9e 100644
--- a/policy/modules/system/systemd.te
+++ b/policy/modules/system/systemd.te
@@ -861,6 +861,7 @@ systemd_log_parse_environment(systemd_resolved_t)
systemd_read_networkd_runtime(systemd_resolved_t)

optional_policy(`
+ dbus_connect_system_bus(systemd_resolved_t)
dbus_system_bus_client(systemd_resolved_t)
')

--
2.14.3

2018-06-06 14:25:09

by Sugar, David

[permalink] [raw]
Subject: [refpolicy] [PATCH 4/4] systemd-resolved uses notify to indicate status

type=AVC msg=audit(1528207926.219:1609): avc: denied { write } for pid=2689 comm="systemd-resolve" name="notify" dev="tmpfs" ino=6277 scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:object_r:init_var_run_t:s0 tclass=sock_file
type=AVC msg=audit(1528208016.448:1702): avc: denied { sendto } for pid=2689 comm="systemd-resolve" path="/run/systemd/notify" scontext=system_u:system_r:systemd_resolved_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=unix_dgram_socket

Signed-off-by: Dave Sugar <[email protected]>
---
policy/modules/system/systemd.te | 3 +++
1 file changed, 3 insertions(+)

diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te
index 60651a9e..cf2c3296 100644
--- a/policy/modules/system/systemd.te
+++ b/policy/modules/system/systemd.te
@@ -844,6 +844,7 @@ init_pid_filetrans(systemd_resolved_t, systemd_resolved_var_run_t, dir)

dev_read_sysfs(systemd_resolved_t)

+kernel_dgram_send(systemd_resolved_t)
kernel_read_crypto_sysctls(systemd_resolved_t)
kernel_read_kernel_sysctls(systemd_resolved_t)
kernel_read_net_sysctls(systemd_resolved_t)
@@ -855,6 +856,8 @@ corenet_udp_bind_llmnr_port(systemd_resolved_t)

auth_use_nsswitch(systemd_resolved_t)

+init_dgram_send(systemd_resolved_t)
+
seutil_read_file_contexts(systemd_resolved_t)

systemd_log_parse_environment(systemd_resolved_t)
--
2.14.3

2018-06-07 23:55:13

by Chris PeBenito

[permalink] [raw]
Subject: [refpolicy] [PATCH 0/4] systemd-resolved policy updates

On 06/06/2018 10:25 AM, Dave Sugar via refpolicy wrote:
> Updates to allow systemd-resolved to start without denials
>
> Dave Sugar (4):
> Allow systemd-resolved to read sysctl
> Allow systemd_resolved to read systemd_networkd runtime files
> Allow systemd-resolved to connect to system dbusd
> systemd-resolved uses notify to indicate status
>
> policy/modules/system/systemd.if | 19 +++++++++++++++++++
> policy/modules/system/systemd.te | 8 ++++++++
> 2 files changed, 27 insertions(+)

Merged.

--
Chris PeBenito