Skip to contentSkip to conversation

testsuite: fix cap_userns for kernels >= v5.12

PATCH In review Paul Moore 2 participants 4 messages Apr 27, 2021 – Apr 28, 2021 SELinux security module

lore
Share & tools
lore

Paul Moore

author maintainer
#0 lore raw

PATCH 1/1 testsuite: fix cap_userns for kernels >= v5.12

Starting with Linux v5.12 CAP_SETFCAP is required to map UID 0/root. This is due to kernel commit db2e718a4798 ("capabilities: require CAP_SETFCAP to map uid 0"). In order to resolve this in the test suite allow the cap_userns test domains to exercise the setfcap capability.

---
 policy/test_cap_userns.te |    3 +++
 1 file changed, 3 insertions(+)
policy/test_cap_userns.te +3 -0
index ab74325..9683870 100644
@@ -12,6 +12,9 @@ unconfined_runs_test(test_cap_userns_t)
 typeattribute test_cap_userns_t testdomain;
 typeattribute test_cap_userns_t capusernsdomain;
 
+# linux >= v5.12 needs setfcap to map UID 0
+allow capusernsdomain self:capability setfcap;
+
 # This domain is allowed sys_admin on non-init userns for mount.
 allow test_cap_userns_t self:cap_userns sys_admin;
 
#1 lore raw
Quoted 16 lines · Paul Moore

Starting with Linux v5.12 CAP_SETFCAP is required to map UID 0/root. This is due to kernel commit db2e718a4798 ("capabilities: require CAP_SETFCAP to map uid 0"). In order to resolve this in the test suite allow the cap_userns test domains to exercise the setfcap capability.

---
 policy/test_cap_userns.te |    3 +++
 1 file changed, 3 insertions(+)
policy/test_cap_userns.te +0 -0
index ab74325..9683870 100644

policy/test_cap_userns.te unconfined_runs_test(test_cap_userns_t) · line 19

Quoted 8 lines
policy/test_cap_userns.te +3 -0
@@ -12,6 +12,9 @@ unconfined_runs_test(test_cap_userns_t)
 typeattribute test_cap_userns_t testdomain;
 typeattribute test_cap_userns_t capusernsdomain;
 
+# linux >= v5.12 needs setfcap to map UID 0
+allow capusernsdomain self:capability setfcap;
+
 # This domain is allowed sys_admin on non-init userns for mount.
 allow test_cap_userns_t self:cap_userns sys_admin;

Thanks! Would you mind if I move the new rule to the end of the file (where other rules for the attribute live) and tweak the subject line? The final commit is available for preview here:
https://github.com/WOnder93/selinux-testsuite/commit/fd4254f09316f6db0410a9187cb8866571f109b5

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Linux Security - SELinux kernel
Red Hat, Inc.
author maintainer
#2 lore raw
Quoted 20 lines · Ondrej Mosnacek
Quoted 19 lines · Paul Moore

Starting with Linux v5.12 CAP_SETFCAP is required to map UID 0/root. This is due to kernel commit db2e718a4798 ("capabilities: require CAP_SETFCAP to map uid 0"). In order to resolve this in the test suite allow the cap_userns test domains to exercise the setfcap capability.

---
 policy/test_cap_userns.te |    3 +++
 1 file changed, 3 insertions(+)
policy/test_cap_userns.te +0 -0
index ab74325..9683870 100644
@@ -12,6 +12,9 @@ unconfined_runs_test(test_cap_userns_t)
 typeattribute test_cap_userns_t testdomain;
 typeattribute test_cap_userns_t capusernsdomain;
 
Quoted 10 lines

policy/test_cap_userns.te unconfined_runs_test(test_cap_userns_t) · line 19

Quoted 5 lines
policy/test_cap_userns.te +3 -0
+# linux >= v5.12 needs setfcap to map UID 0
+allow capusernsdomain self:capability setfcap;
+
 # This domain is allowed sys_admin on non-init userns for mount.
 allow test_cap_userns_t self:cap_userns sys_admin;

Thanks! Would you mind if I move the new rule to the end of the file (where other rules for the attribute live) and tweak the subject line? The final commit is available for preview here:
https://github.com/WOnder93/selinux-testsuite/commit/fd4254f09316f6db0410a9187cb8866571f109b5

Sure, do whatever you think is best; you can even replace my little patch with another that you like better. My main concern is just making sure the test suite is fixed and working :)

Signature · 2 lines
paul moore
www.paul-moore.com
#3 lore raw
Quoted 32 lines · Paul Moore
Quoted 20 lines · Ondrej Mosnacek
Quoted 19 lines · Paul Moore

Starting with Linux v5.12 CAP_SETFCAP is required to map UID 0/root. This is due to kernel commit db2e718a4798 ("capabilities: require CAP_SETFCAP to map uid 0"). In order to resolve this in the test suite allow the cap_userns test domains to exercise the setfcap capability.

---
 policy/test_cap_userns.te |    3 +++
 1 file changed, 3 insertions(+)
policy/test_cap_userns.te +0 -0
index ab74325..9683870 100644
@@ -12,6 +12,9 @@ unconfined_runs_test(test_cap_userns_t)
 typeattribute test_cap_userns_t testdomain;
 typeattribute test_cap_userns_t capusernsdomain;
 
Quoted 10 lines

policy/test_cap_userns.te unconfined_runs_test(test_cap_userns_t) · line 19

Quoted 5 lines
policy/test_cap_userns.te +3 -0
+# linux >= v5.12 needs setfcap to map UID 0
+allow capusernsdomain self:capability setfcap;
+
 # This domain is allowed sys_admin on non-init userns for mount.
 allow test_cap_userns_t self:cap_userns sys_admin;

Thanks! Would you mind if I move the new rule to the end of the file (where other rules for the attribute live) and tweak the subject line? The final commit is available for preview here:
https://github.com/WOnder93/selinux-testsuite/commit/fd4254f09316f6db0410a9187cb8866571f109b5

Quoted 3 lines

Sure, do whatever you think is best; you can even replace my little patch with another that you like better. My main concern is just making sure the test suite is fixed and working :)

Ok, I have just pushed it:
https://github.com/SELinuxProject/selinux-testsuite/commit/fd4254f09316f6db0410a9187cb8866571f109b5

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Linux Security - SELinux kernel
Red Hat, Inc.