Skip to contentSkip to conversation

proc01: fix selinux attributes without libselinux-dev

PATCH New Krzysztof Kozlowski 2 participants 5 messages Jul 1, 2021 – Jul 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 proc01: fix selinux attributes without libselinux-dev

SELinux can be enabled on the system which does not have development selinux libraries. Such case was already done for Smack and Apparmor where we unconditionally accept their attribute failures. Do the same for SELinux to fix failures like:

    proc01      1  TFAIL  :  proc01.c:404: read failed: /proc/self/task/29986/attr/selinux/current: errno=EINVAL(22): Invalid argument
    proc01      2  TFAIL  :  proc01.c:404: read failed: /proc/self/task/29986/attr/selinux/prev: errno=EINVAL(22): Invalid argument
    proc01      3  TFAIL  :  proc01.c:404: read failed: /proc/self/task/29986/attr/selinux/exec: errno=EINVAL(22): Invalid argument
    proc01      4  TFAIL  :  proc01.c:404: read failed: /proc/self/task/29986/attr/selinux/fscreate: errno=EINVAL(22): Invalid argument
    proc01      5  TFAIL  :  proc01.c:404: read failed: /proc/self/task/29986/attr/selinux/keycreate: errno=EINVAL(22): Invalid argument
    proc01      6  TFAIL  :  proc01.c:404: read failed: /proc/self/task/29986/attr/selinux/sockcreate: errno=EINVAL(22): Invalid argument

...
proc01 7 TFAIL : proc01.c:404: read failed: /proc/self/attr/selinux/current: errno=EINVAL(22): Invalid argument
proc01 8 TFAIL : proc01.c:404: read failed: /proc/self/attr/selinux/prev: errno=EINVAL(22): Invalid argument
proc01 9 TFAIL : proc01.c:404: read failed: /proc/self/attr/selinux/exec: errno=EINVAL(22): Invalid argument
proc01 10 TFAIL : proc01.c:404: read failed: /proc/self/attr/selinux/fscreate: errno=EINVAL(22): Invalid argument
proc01 11 TFAIL : proc01.c:404: read failed: /proc/self/attr/selinux/keycreate: errno=EINVAL(22): Invalid argument
proc01 12 TFAIL : proc01.c:404: read failed: /proc/self/attr/selinux/sockcreate: errno=EINVAL(22): Invalid argument

---
 testcases/kernel/fs/proc/proc01.c | 4 ++++
 1 file changed, 4 insertions(+)
testcases/kernel/fs/proc/proc01.c +4 -0
index 0fae6754f7f7..6ddb6682f38b 100644
@@ -97,10 +97,12 @@ static const struct mapping known_issues[] = {
 	{"read", "/proc/self/mem", EIO},
 	{"read", "/proc/self/task/[0-9]*/mem", EIO},
 	{"read", "/proc/self/attr/*", EINVAL},
+	{"read", "/proc/self/attr/selinux/*", EINVAL},
 	{"read", "/proc/self/attr/smack/*", EINVAL},
 	{"read", "/proc/self/attr/apparmor/*", EINVAL},
 	{"read", "/proc/self/task/[0-9]*/attr/*", EINVAL},
 	{"read", "/proc/self/task/[0-9]*/attr/smack/*", EINVAL},
+	{"read", "/proc/self/task/[0-9]*/attr/selinux/*", EINVAL},
 	{"read", "/proc/self/task/[0-9]*/attr/apparmor/*", EINVAL},
 	{"read", "/proc/self/ns/*", EINVAL},
 	{"read", "/proc/self/task/[0-9]*/ns/*", EINVAL},
@@ -133,7 +135,9 @@ static const struct mapping known_issues[] = {
 #ifdef HAVE_LIBSELINUX_DEVEL
 static const char lsm_should_work[][PATH_MAX] = {
 	"/proc/self/attr/*",
+	"/proc/self/attr/selinux/*",
 	"/proc/self/task/[0-9]*/attr/*",
+	"/proc/self/task/[0-9]*/attr/selinux/*",
 	""
 };
 
Signature · 1 line
2.27.0
#1 lore raw

PATCH v2 2/2 proc01: remove unused lsm_should_work (-Wunused-const-variable)

Recent refactoring made the "lsm_should_work" unused without libselinux-dev:

proc01.c:142:19: warning: ?lsm_should_work? defined but not used [-Wunused-const-variable=]

---

Changes since v1:
1. Fixup part of #1 patch.

---
 testcases/kernel/fs/proc/proc01.c | 6 ------
 1 file changed, 6 deletions(-)
testcases/kernel/fs/proc/proc01.c +0 -6
index 6ddb6682f38b..c90e509a3243 100644
@@ -140,12 +140,6 @@ static const char lsm_should_work[][PATH_MAX] = {
 	"/proc/self/task/[0-9]*/attr/selinux/*",
 	""
 };
-
-/* Place holder for none of LSM is detected. */
-#else
-static const char lsm_should_work[][PATH_MAX] = {
-	""
-};
 #endif
 
 /* Known files that does not honor O_NONBLOCK, so they will hang
Signature · 1 line
2.27.0
#4 lore raw

PATCH v2 1/2 proc01: fix selinux attributes without libselinux-dev

In reply to Krzysztof Kozlowski
Quoted 4 lines

SELinux can be enabled on the system which does not have development selinux libraries. Such case was already done for Smack and Apparmor where we unconditionally accept their attribute failures. Do the same for SELinux to fix failures like:

Kind regards,
Petr