Skip to contentSkip to conversation

lib: lockdown: Report lockdown as disabled on missing sysfs

PATCH In review Cyril Hrubis 2 participants 4 messages Sep 20, 2023 – Sep 21, 2023 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: lockdown: Report lockdown as disabled on missing sysfs

We currently report -1 when secure boot sysfs file is not present which is later interpreted as secure boot enabled. This causes regression in *_module sycall tests executed on systems when secureboot is not compiled-in or supported at all.

---
 lib/tst_lockdown.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_lockdown.c +1 -1
index 38d830886..7613092ec 100644
@@ -29,7 +29,7 @@ int tst_secureboot_enabled(void)
 
 	if (access(SECUREBOOT_VAR, F_OK)) {
 		tst_res(TINFO, "SecureBoot sysfs file not available");
-		return -1;
+		return 0;
 	}
 
 	fd = open(SECUREBOOT_VAR, O_RDONLY);
Signature · 5 lines
2.41.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw
Quoted 4 lines · Cyril Hrubis

We currently report -1 when secure boot sysfs file is not present which is later interpreted as secure boot enabled. This causes regression in *_module sycall tests executed on systems when secureboot is not compiled-in or supported at all.

That's incorrect usage then. The tests should check tst_secureboot_enabled() > 0 instead. I think it will be useful to know whether the function found that secureboot is disabled, or could not check at all. We should just document it better.

Quoted 19 lines
---
  lib/tst_lockdown.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_lockdown.c +1 -1
index 38d830886..7613092ec 100644
@@ -29,7 +29,7 @@ int tst_secureboot_enabled(void)
 
  	if (access(SECUREBOOT_VAR, F_OK)) {
  		tst_res(TINFO, "SecureBoot sysfs file not available");
-		return -1;
+		return 0;
  	}
 
  	fd = open(SECUREBOOT_VAR, O_RDONLY);
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
#2 lore raw

Hi!

Quoted 9 lines
Quoted 4 lines

We currently report -1 when secure boot sysfs file is not present which is later interpreted as secure boot enabled. This causes regression in *_module sycall tests executed on systems when secureboot is not compiled-in or supported at all.

That's incorrect usage then. The tests should check tst_secureboot_enabled() > 0 instead. I think it will be useful to know whether the function found that secureboot is disabled, or could not check at all. We should just document it better.

Yes, the functions do not seem to have any documentation.

So I guess that we need:

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
Cyril Hrubis
[email protected]

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

Hi,

Quoted 23 lines · Cyril Hrubis

Hi!

Quoted 9 lines
Quoted 4 lines

We currently report -1 when secure boot sysfs file is not present which is later interpreted as secure boot enabled. This causes regression in *_module sycall tests executed on systems when secureboot is not compiled-in or supported at all.

That's incorrect usage then. The tests should check tst_secureboot_enabled() > 0 instead. I think it will be useful to know whether the function found that secureboot is disabled, or could not check at all. We should just document it better.

Yes, the functions do not seem to have any documentation.

So I guess that we need:

lib/tst_test.c +0 -0
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);

lib/tst_test.c static void do_setup(int argc, char *argv[]) · line 1172

Quoted 10 lines
lib/tst_test.c +2 -2
 
-       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())

Yes, this is the correct fix.

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