Skip to contentSkip to conversation

lib: tst_test: Fix lockdown detection on missing sysfs

PATCH In review Cyril Hrubis 3 participants 4 messages Sep 21, 2023 – Sep 22, 2023 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lib: tst_test: Fix lockdown detection on missing sysfs

The lockdown detection function reports -1 when secure boot sysfs file is not present, which is later mistakenly interpreted as secure boot enabled in tst_test.c.

This causes regression in *_module sycall tests executed on systems when secureboot is not compiled-in or supported at all.

Check properly if secure boot is enabled by checking that the return value from these functions is positive.

---
 lib/tst_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/tst_test.c +2 -2
index 2e58cad33..e2c195645 100644
@@ -1163,10 +1163,10 @@ static void do_setup(int argc, char *argv[])
 	if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
 		tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);
 
-	if (tst_test->skip_in_lockdown && tst_lockdown_enabled())
+	if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0)
 		tst_brk(TCONF, "Kernel is locked down, skipping test");
 
-	if (tst_test->skip_in_secureboot && tst_secureboot_enabled())
+	if (tst_test->skip_in_secureboot && tst_secureboot_enabled() > 0)
 		tst_brk(TCONF, "SecureBoot enabled, skipping test");
 
 	if (tst_test->skip_in_compat && TST_ABI != tst_kernel_bits())
Signature · 5 lines
2.41.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Cyril Hrubis

The lockdown detection function reports -1 when secure boot sysfs file is not present, which is later mistakenly interpreted as secure boot enabled in tst_test.c.

This causes regression in *_module sycall tests executed on systems when secureboot is not compiled-in or supported at all.

Check properly if secure boot is enabled by checking that the return value from these functions is positive.

Should we fix the detection of additional those too?
finit_module02.c, init_module02.c, madvise11.c

Otherwise, this method looks good.

Quoted 33 lines
---
 lib/tst_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/tst_test.c +2 -2
index 2e58cad33..e2c195645 100644
@@ -1163,10 +1163,10 @@ static void do_setup(int argc, char *argv[])
        if (tst_test->supported_archs &&
 !tst_is_on_arch(tst_test->supported_archs))
                tst_brk(TCONF, "This arch '%s' is not supported for
 test!", tst_arch.name);
 
-       if (tst_test->skip_in_lockdown && tst_lockdown_enabled())
+       if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0)
                tst_brk(TCONF, "Kernel is locked down, skipping test");
 
-       if (tst_test->skip_in_secureboot && tst_secureboot_enabled())
+       if (tst_test->skip_in_secureboot && tst_secureboot_enabled() > 0)
                tst_brk(TCONF, "SecureBoot enabled, skipping test");
        if (tst_test->skip_in_compat && TST_ABI != tst_kernel_bits())

--
2.41.0

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang

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

Hi!

Quoted 5 lines

Should we fix the detection of additional those too?
finit_module02.c, init_module02.c, madvise11.c

Otherwise, this method looks good.

Pushed as well as patches from martin the fixed the rest.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 1/1
#3 lore raw
In reply to Cyril Hrubis

Hi,

Quoted 32 lines · Cyril Hrubis

The lockdown detection function reports -1 when secure boot sysfs file is not present, which is later mistakenly interpreted as secure boot enabled in tst_test.c.

This causes regression in *_module sycall tests executed on systems when secureboot is not compiled-in or supported at all.

Check properly if secure boot is enabled by checking that the return value from these functions is positive.

---
  lib/tst_test.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/tst_test.c +2 -2
index 2e58cad33..e2c195645 100644
@@ -1163,10 +1163,10 @@ static void do_setup(int argc, char *argv[])
  	if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
  		tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);
 
-	if (tst_test->skip_in_lockdown && tst_lockdown_enabled())
+	if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0)
  		tst_brk(TCONF, "Kernel is locked down, skipping test");
 
-	if (tst_test->skip_in_secureboot && tst_secureboot_enabled())
+	if (tst_test->skip_in_secureboot && tst_secureboot_enabled() > 0)
  		tst_brk(TCONF, "SecureBoot enabled, skipping test");
 
  	if (tst_test->skip_in_compat && TST_ABI != tst_kernel_bits())
Signature · 11 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp