Skip to contentSkip to conversation

insmod01.sh: Skip test on enabled lockdown

PATCH In review Petr Vorel 1 participant 4 messages Mar 8, 2023

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover insmod01.sh: Skip test on enabled lockdown

Petr Vorel (2):
lib: shell: Add tst_lockdown_enabled.c
insmod01.sh: Skip test on enabled lockdown

 doc/test-writing-guidelines.txt       |  2 +-
 testcases/commands/insmod/insmod01.sh |  2 ++
 testcases/lib/.gitignore              |  1 +
 testcases/lib/Makefile                |  2 +-
 testcases/lib/tst_lockdown_enabled.c  | 12 ++++++++++++
 testcases/lib/tst_test.sh             |  6 +++++-
 6 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 testcases/lib/tst_lockdown_enabled.c
Signature · 5 lines
2.39.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH 1/2 lib: shell: Add tst_lockdown_enabled.c

Detection is needed for insmod01.sh.

---
 doc/test-writing-guidelines.txt      |  2 +-
 testcases/lib/.gitignore             |  1 +
 testcases/lib/Makefile               |  2 +-
 testcases/lib/tst_lockdown_enabled.c | 12 ++++++++++++
 testcases/lib/tst_test.sh            |  6 +++++-
 5 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 testcases/lib/tst_lockdown_enabled.c
doc/test-writing-guidelines.txt +1 -1
index b83a6fdb6..875c20eae 100644
@@ -392,7 +392,7 @@ https://github.com/linux-test-project/ltp/wiki/Shell-Test-API[Shell Test API].
 | '.setup' | 'TST_SETUP'
 | '.skip_filesystems' | 'TST_SKIP_FILESYSTEMS'
 | '.skip_in_compat' | –
-| '.skip_in_lockdown' | –
+| '.skip_in_lockdown' | 'TST_SKIP_IN_LOCKDOWN'
 | '.supported_archs' | not applicable
 | '.tags' | –
 | '.taint_check' | –
testcases/lib/.gitignore +1 -0
index 34dea272d..61cf05226 100644
@@ -8,6 +8,7 @@
 /tst_get_median
 /tst_get_unused_port
 /tst_kvcmp
+/tst_lockdown_enabled
 /tst_net_iface_prefix
 /tst_net_ip_prefix
 /tst_net_vars
testcases/lib/Makefile +1 -1
index f4f8c8524..6fd58b3ab 100644
@@ -12,6 +12,6 @@ MAKE_TARGETS		:= tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\
 			   tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars\
 			   tst_getconf tst_supported_fs tst_check_drivers tst_get_unused_port\
 			   tst_get_median tst_hexdump tst_get_free_pids tst_timeout_kill\
-			   tst_check_kconfigs tst_cgctl
+			   tst_check_kconfigs tst_cgctl tst_lockdown_enabled
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/lib/tst_lockdown_enabled.c new file +12 -0
new file mode 100644
index 000000000..0e40c428c
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 Petr Vorel <[email protected]>
+ */
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+int main(void)
+{
+	return !tst_lockdown_enabled();
+}
testcases/lib/tst_test.sh +5 -1
index c817eec77..50939d4e4 100644
@@ -678,7 +678,7 @@ tst_run()
 			CHECKPOINT_WAIT|CHECKPOINT_WAKE);;
 			CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);;
 			DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);;
-			SKIP_FILESYSTEMS);;
+			SKIP_FILESYSTEMS|SKIP_IN_LOCKDOWN);;
 			*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
 			esac
 		done
@@ -698,6 +698,10 @@ tst_run()
 
 	[ "$TST_NEEDS_ROOT" = 1 ] && tst_require_root
 
+	if [ "$TST_SKIP_IN_LOCKDOWN" = 1 ] && tst_lockdown_enabled; then
+		tst_brk TCONF "Kernel is locked down, skipping test"
+	fi
+
 	[ "$TST_DISABLE_APPARMOR" = 1 ] && tst_disable_apparmor
 	[ "$TST_DISABLE_SELINUX" = 1 ] && tst_disable_selinux
 
Signature · 5 lines
2.39.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#2 lore raw

PATCH 2/2 insmod01.sh: Skip test on enabled lockdown

In reply to Petr Vorel

Lockdown patchset does not allow to install LTP kernel module:

insmod: ERROR: could not insert module ltp_insmod01.ko: Operation not permitted insmod01 1 TFAIL: insmod failed

Therefore skip the test on enabled lockdown.

---
 testcases/commands/insmod/insmod01.sh | 2 ++
 1 file changed, 2 insertions(+)
testcases/commands/insmod/insmod01.sh +2 -0
index 1881ba389..fb1e56459 100755
@@ -1,6 +1,7 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) 2016 Fujitsu Ltd.
+# Copyright (c) Linux Test Project, 2016-2023
 # Author: Guangwen Feng <[email protected]>
 #
 # Test basic functionality of insmod command.
@@ -10,6 +11,7 @@ TST_TESTFUNC=do_test
 TST_NEEDS_ROOT=1
 TST_NEEDS_CMDS="rmmod insmod"
 TST_NEEDS_MODULE="ltp_insmod01.ko"
+TST_SKIP_IN_LOCKDOWN=1
 
 inserted=0
 
Signature · 5 lines
2.39.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

Hi all,

Quoted 8 lines

Lockdown patchset does not allow to install LTP kernel module:

insmod: ERROR: could not insert module ltp_insmod01.ko: Operation not permitted insmod01 1 TFAIL: insmod failed

Therefore skip the test on enabled lockdown.

OK, this is probably our downstream issue in openSUSE.
And because insmod01.sh was the only one shell test which needed this, even previous commit would not be used.
Thus marking whole patchset as rejected.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp