Skip to contentSkip to conversation

corecommands: label systemd script directories bin_t

PATCH New Nicolas Iooss 3 participants 8 messages Dec 15, 2017 – Dec 20, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 corecommands: label systemd script directories bin_t

systemd defines in /usr/lib/systemd several directories which can contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/ documented in
https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Currently the content of these directories is labelled lib_t, which causes the following AVC on Arch Linux:

avc: denied { execute_no_trans } for pid=10308 comm="systemd" path="/usr/lib/systemd/system-environment-generators/10-arch" dev="vda1" ino=543182 scontext=system_u:system_r:init_t tcontext=system_u:object_r:lib_t tclass=file permissive=1

For information /usr/lib/systemd/system-environment-generators/10-arch only defines $PATH and its content is available on
https://git.archlinux.org/svntogit/packages.git/tree/trunk/env-generator?h=packages/filesystem

---
 policy/modules/kernel/corecommands.fc | 4 ++++
 1 file changed, 4 insertions(+)
policy/modules/kernel/corecommands.fc +4 -0
index c2b93ecf5039..f2e4f5118d5f 100644
@@ -221,7 +221,11 @@ ifdef(`distro_gentoo',`
 /usr/lib/ssh(/.*)?			gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/sudo/sesh		--	gen_context(system_u:object_r:shell_exec_t,s0)
 /usr/lib/systemd/systemd.*	--	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/systemd/system-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-shutdown(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-sleep(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/user-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/systemd/user-generators(/.*)?	gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/tumbler-1/tumblerd	--	gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/udev/[^/]*			--	gen_context(system_u:object_r:bin_t,s0)
Signature · 1 line
2.15.0
#1 lore raw

PATCH 1/1 corecommands: label systemd script directories bin_t

Quoted 10 lines · Nicolas Iooss via refpolicy

systemd defines in /usr/lib/systemd several directories which can contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/ documented in
https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Quoted 7 lines

Currently the content of these directories is labelled lib_t, which causes the following AVC on Arch Linux:

avc: denied { execute_no_trans } for pid=10308 comm="systemd" path="/usr/lib/systemd/system-environment-generators/10-arch" dev="vda1" ino=543182 scontext=system_u:system_r:init_t tcontext=system_u:object_r:lib_t tclass=file permissive=1

Yes, but labeling these bin_t will cause systemd to run these in the initrc_t domain. This might, or might not be what you want.

In my personal policy i created a special type for stuff i want systemd to run in the init_t domain instead of initrc_t: systemd_helper_exec_t.

Then there is basically a rule : allow init_t systemd_helper_exec_t:file execute_no_trans;

Its a matter of taste, subjective.

Quoted 31 lines

For information /usr/lib/systemd/system-environment-generators/10-arch only defines $PATH and its content is available on
https://git.archlinux.org/svntogit/packages.git/tree/trunk/env-generator?h=packages/filesystem

---
 policy/modules/kernel/corecommands.fc | 4 ++++
 1 file changed, 4 insertions(+)
policy/modules/kernel/corecommands.fc +4 -0
index c2b93ecf5039..f2e4f5118d5f 100644
@@ -221,7 +221,11 @@ ifdef(`distro_gentoo',`
 /usr/lib/ssh(/.*)?			gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/sudo/sesh		--	gen_context(system_u:object_r:shell_exec_t,s0)
 /usr/lib/systemd/systemd.*	--	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/systemd/system-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-shutdown(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-sleep(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/user-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/systemd/user-generators(/.*)?	gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/tumbler-1/tumblerd	--	gen_context(system_u:object_r:bin_t,s0)
 /usr/lib/udev/[^/]*			--	gen_context(system_u:object_r:bin_t,s0)
Signature · 6 lines
2.15.0

_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy
Signature · 10 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: not available
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20171216/3a23b676/attachment.bin 
#2 lore raw

PATCH 1/1 corecommands: label systemd script directories bin_t

Quoted 19 lines · Dominick Grift via refpolicy
Quoted 10 lines · Nicolas Iooss via refpolicy

systemd defines in /usr/lib/systemd several directories which can contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/ documented in
https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Quoted 7 lines

Currently the content of these directories is labelled lib_t, which causes the following AVC on Arch Linux:

avc: denied { execute_no_trans } for pid=10308 comm="systemd" path="/usr/lib/systemd/system-environment-generators/10-arch" dev="vda1" ino=543182 scontext=system_u:system_r:init_t tcontext=system_u:object_r:lib_t tclass=file permissive=1

Quoted 7 lines

Yes, but labeling these bin_t will cause systemd to run these in the initrc_t domain. This might, or might not be what you want.

In my personal policy i created a special type for stuff i want systemd to run in the init_t domain instead of initrc_t: systemd_helper_exec_t.

Then there is basically a rule : allow init_t systemd_helper_exec_t:file execute_no_trans;

Its a matter of taste, subjective.

I don't think it's as subjective as you think. It keeps init_t from getting extra permissions over time which PID 1 doesn't need. initrc_t gets big, yes, but those are short-running processes, while init_t is long-running.

Quoted 23 lines
Quoted 23 lines

For information /usr/lib/systemd/system-environment-generators/10-arch only defines $PATH and its content is available on
https://git.archlinux.org/svntogit/packages.git/tree/trunk/env-generator?h=packages/filesystem

---
  policy/modules/kernel/corecommands.fc | 4 ++++
  1 file changed, 4 insertions(+)
policy/modules/kernel/corecommands.fc +4 -0
index c2b93ecf5039..f2e4f5118d5f 100644
@@ -221,7 +221,11 @@ ifdef(`distro_gentoo',`
  /usr/lib/ssh(/.*)?			gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/sudo/sesh		--	gen_context(system_u:object_r:shell_exec_t,s0)
  /usr/lib/systemd/systemd.*	--	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/systemd/system-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-shutdown(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-sleep(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/user-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/systemd/user-generators(/.*)?	gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/tumbler-1/tumblerd	--	gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/udev/[^/]*			--	gen_context(system_u:object_r:bin_t,s0)
Signature · 1 line
Chris PeBenito
#3 lore raw

PATCH 1/1 corecommands: label systemd script directories bin_t

Quoted 24 lines · Chris PeBenito via refpolicy
Quoted 23 lines · Dominick Grift via refpolicy
Quoted 10 lines · Nicolas Iooss via refpolicy

systemd defines in /usr/lib/systemd several directories which can contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/ documented in
https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Quoted 7 lines

Currently the content of these directories is labelled lib_t, which causes the following AVC on Arch Linux:

avc: denied { execute_no_trans } for pid=10308 comm="systemd" path="/usr/lib/systemd/system-environment-generators/10-arch" dev="vda1" ino=543182 scontext=system_u:system_r:init_t tcontext=system_u:object_r:lib_t tclass=file permissive=1

Yes, but labeling these bin_t will cause systemd to run these in the initrc_t domain. This might, or might not be what you want.

In my personal policy i created a special type for stuff i want systemd to run in the init_t domain instead of initrc_t: systemd_helper_exec_t.

Quoted 8 lines
Quoted 3 lines

Then there is basically a rule : allow init_t systemd_helper_exec_t:file execute_no_trans;

Its a matter of taste, subjective.

I don't think it's as subjective as you think. It keeps init_t from getting extra permissions over time which PID 1 doesn't need. initrc_t gets big, yes, but those are short-running processes, while init_t is long-running.

Yes except in practice it does not:

take:

cat /usr/lib/systemd/system-shutdown/mdadm.shutdown #!/bin/sh
# We need to ensure all md arrays with external metadata # (e.g. IMSM, DDF) are clean before completing the shutdown. /usr/sbin/mdadm --wait-clean --scan

If you run the above in initrc_t then mdadm has free reign, if you run it in init_t then systemd will run mdadm with a domain transition to mdadm_t

Quoted 33 lines
Quoted 25 lines
Quoted 25 lines

For information /usr/lib/systemd/system-environment-generators/10-arch only defines $PATH and its content is available on
https://git.archlinux.org/svntogit/packages.git/tree/trunk/env-generator?h=packages/filesystem

---
  policy/modules/kernel/corecommands.fc | 4 ++++
  1 file changed, 4 insertions(+)
policy/modules/kernel/corecommands.fc +4 -0
index c2b93ecf5039..f2e4f5118d5f 100644
@@ -221,7 +221,11 @@ ifdef(`distro_gentoo',`
  /usr/lib/ssh(/.*)?			gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/sudo/sesh		--	gen_context(system_u:object_r:shell_exec_t,s0)
  /usr/lib/systemd/systemd.*	--	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/systemd/system-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-shutdown(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-sleep(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/user-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/systemd/user-generators(/.*)?	gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/tumbler-1/tumblerd	--	gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/udev/[^/]*			--	gen_context(system_u:object_r:bin_t,s0)
Signature · 5 lines
Chris PeBenito
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy
Signature · 10 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: not available
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20171220/6e0d044f/attachment.bin 
#4 lore raw

PATCH 1/1 corecommands: label systemd script directories bin_t

Quoted 38 lines · Dominick Grift
Quoted 24 lines · Chris PeBenito via refpolicy
Quoted 23 lines · Dominick Grift via refpolicy
Quoted 10 lines · Nicolas Iooss via refpolicy

systemd defines in /usr/lib/systemd several directories which can contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/ documented in
https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Quoted 7 lines

Currently the content of these directories is labelled lib_t, which causes the following AVC on Arch Linux:

avc: denied { execute_no_trans } for pid=10308 comm="systemd" path="/usr/lib/systemd/system-environment-generators/10-arch" dev="vda1" ino=543182 scontext=system_u:system_r:init_t tcontext=system_u:object_r:lib_t tclass=file permissive=1

Yes, but labeling these bin_t will cause systemd to run these in the initrc_t domain. This might, or might not be what you want.

In my personal policy i created a special type for stuff i want systemd to run in the init_t domain instead of initrc_t: systemd_helper_exec_t.

Quoted 8 lines
Quoted 3 lines

Then there is basically a rule : allow init_t systemd_helper_exec_t:file execute_no_trans;

Its a matter of taste, subjective.

I don't think it's as subjective as you think. It keeps init_t from getting extra permissions over time which PID 1 doesn't need. initrc_t gets big, yes, but those are short-running processes, while init_t is long-running.

Yes except in practice it does not:

take:

Quoted 7 lines

cat /usr/lib/systemd/system-shutdown/mdadm.shutdown #!/bin/sh
# We need to ensure all md arrays with external metadata # (e.g. IMSM, DDF) are clean before completing the shutdown. /usr/sbin/mdadm --wait-clean --scan

If you run the above in initrc_t then mdadm has free reign, if you run it in init_t then systemd will run mdadm with a domain transition to mdadm_t

Actually 's/systemd/systemd-shutdown/' but in refpolicies case it does not matter since systemd-shutdown_t runs in init_t

Quoted 39 lines
Quoted 34 lines
Quoted 26 lines
Quoted 26 lines

For information /usr/lib/systemd/system-environment-generators/10-arch only defines $PATH and its content is available on
https://git.archlinux.org/svntogit/packages.git/tree/trunk/env-generator?h=packages/filesystem

---
  policy/modules/kernel/corecommands.fc | 4 ++++
  1 file changed, 4 insertions(+)
policy/modules/kernel/corecommands.fc +4 -0
index c2b93ecf5039..f2e4f5118d5f 100644
@@ -221,7 +221,11 @@ ifdef(`distro_gentoo',`
  /usr/lib/ssh(/.*)?			gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/sudo/sesh		--	gen_context(system_u:object_r:shell_exec_t,s0)
  /usr/lib/systemd/systemd.*	--	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/systemd/system-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-shutdown(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-sleep(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/user-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/systemd/user-generators(/.*)?	gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/tumbler-1/tumblerd	--	gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/udev/[^/]*			--	gen_context(system_u:object_r:bin_t,s0)
Signature · 5 lines
Chris PeBenito
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy
Signature · 3 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
Signature · 10 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: not available
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20171220/ef2ddf77/attachment-0001.bin 
#5 lore raw

PATCH 1/1 corecommands: label systemd script directories bin_t

In reply to Dominick Grift
Quoted 38 lines · Dominick Grift via refpolicy
Quoted 24 lines · Chris PeBenito via refpolicy
Quoted 23 lines · Dominick Grift via refpolicy
Quoted 10 lines · Nicolas Iooss via refpolicy

systemd defines in /usr/lib/systemd several directories which can contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/ documented in
https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Quoted 7 lines

Currently the content of these directories is labelled lib_t, which causes the following AVC on Arch Linux:

avc: denied { execute_no_trans } for pid=10308 comm="systemd" path="/usr/lib/systemd/system-environment-generators/10-arch" dev="vda1" ino=543182 scontext=system_u:system_r:init_t tcontext=system_u:object_r:lib_t tclass=file permissive=1

Yes, but labeling these bin_t will cause systemd to run these in the initrc_t domain. This might, or might not be what you want.

In my personal policy i created a special type for stuff i want systemd to run in the init_t domain instead of initrc_t: systemd_helper_exec_t.

Quoted 8 lines
Quoted 3 lines

Then there is basically a rule : allow init_t systemd_helper_exec_t:file execute_no_trans;

Its a matter of taste, subjective.

I don't think it's as subjective as you think. It keeps init_t from getting extra permissions over time which PID 1 doesn't need. initrc_t gets big, yes, but those are short-running processes, while init_t is long-running.

Yes except in practice it does not:

take:

Quoted 7 lines

cat /usr/lib/systemd/system-shutdown/mdadm.shutdown #!/bin/sh
# We need to ensure all md arrays with external metadata # (e.g. IMSM, DDF) are clean before completing the shutdown. /usr/sbin/mdadm --wait-clean --scan

If you run the above in initrc_t then mdadm has free reign, if you run it in init_t then systemd will run mdadm with a domain transition to mdadm_t

No. The script transitions to initrc_t, and when the script execs mdadm, that process transitions to mdadm_t.

Signature · 1 line
Chris PeBenito
#6 lore raw

PATCH 1/1 corecommands: label systemd script directories bin_t

Quoted 46 lines · Chris PeBenito via refpolicy
Quoted 45 lines · Dominick Grift via refpolicy
Quoted 25 lines · Chris PeBenito via refpolicy
Quoted 24 lines · Dominick Grift via refpolicy
Quoted 11 lines · Nicolas Iooss via refpolicy

systemd defines in /usr/lib/systemd several directories which can contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/ documented in
https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in

https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Quoted 7 lines

Currently the content of these directories is labelled lib_t, which causes the following AVC on Arch Linux:

avc: denied { execute_no_trans } for pid=10308 comm="systemd" path="/usr/lib/systemd/system-environment-generators/10-arch" dev="vda1" ino=543182 scontext=system_u:system_r:init_t tcontext=system_u:object_r:lib_t tclass=file permissive=1

Yes, but labeling these bin_t will cause systemd to run these in the initrc_t domain. This might, or might not be what you want.

In my personal policy i created a special type for stuff i want systemd to run in the init_t domain instead of initrc_t: systemd_helper_exec_t.

Quoted 8 lines
Quoted 3 lines

Then there is basically a rule : allow init_t systemd_helper_exec_t:file execute_no_trans;

Its a matter of taste, subjective.

I don't think it's as subjective as you think. It keeps init_t from getting extra permissions over time which PID 1 doesn't need. initrc_t gets big, yes, but those are short-running processes, while init_t is long-running.

Yes except in practice it does not:

take:

cat /usr/lib/systemd/system-shutdown/mdadm.shutdown #!/bin/sh
# We need to ensure all md arrays with external metadata # (e.g. IMSM, DDF) are clean before completing the shutdown. /usr/sbin/mdadm --wait-clean --scan

Quoted 4 lines
Quoted 1 line

If you run the above in initrc_t then mdadm has free reign, if you run it in init_t then systemd will run mdadm with a domain transition to mdadm_t

No. The script transitions to initrc_t, and when the script execs mdadm, that process transitions to mdadm_t.

Yes my bad, i overlooked that part.

Quoted 7 lines
Signature · 6 lines
-- 
Chris PeBenito
_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy
Signature · 10 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: not available
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20171220/70c9acf9/attachment.bin 
#7 lore raw

PATCH 1/1 corecommands: label systemd script directories bin_t

In reply to Nicolas Iooss
Quoted 31 lines · Nicolas Iooss via refpolicy

systemd defines in /usr/lib/systemd several directories which can contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/ documented in
https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in
https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Currently the content of these directories is labelled lib_t, which causes the following AVC on Arch Linux:

avc: denied { execute_no_trans } for pid=10308 comm="systemd" path="/usr/lib/systemd/system-environment-generators/10-arch" dev="vda1" ino=543182 scontext=system_u:system_r:init_t tcontext=system_u:object_r:lib_t tclass=file permissive=1

For information /usr/lib/systemd/system-environment-generators/10-arch only defines $PATH and its content is available on
https://git.archlinux.org/svntogit/packages.git/tree/trunk/env-generator?h=packages/filesystem

---
  policy/modules/kernel/corecommands.fc | 4 ++++
  1 file changed, 4 insertions(+)
policy/modules/kernel/corecommands.fc +0 -0
index c2b93ecf5039..f2e4f5118d5f 100644
@@ -221,7 +221,11 @@ ifdef(`distro_gentoo',`
  /usr/lib/ssh(/.*)?			gen_context(system_u:object_r:bin_t,s0)

policy/modules/kernel/corecommands.fc ifdef(`distro_gentoo',` · line 231

Quoted 10 lines
policy/modules/kernel/corecommands.fc +4 -0
  /usr/lib/sudo/sesh		--	gen_context(system_u:object_r:shell_exec_t,s0)
  /usr/lib/systemd/systemd.*	--	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/systemd/system-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-shutdown(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/system-sleep(/.*)?	gen_context(system_u:object_r:bin_t,s0)
+/usr/lib/systemd/user-environment-generators(/.*)? gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/systemd/user-generators(/.*)?	gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/tumbler-1/tumblerd	--	gen_context(system_u:object_r:bin_t,s0)
  /usr/lib/udev/[^/]*			--	gen_context(system_u:object_r:bin_t,s0)

Merged.

Signature · 1 line
Chris PeBenito