syscalls/madvise11: Ignore unpoison failure under kernel lockdown
PATCH v2 1/1 syscalls/madvise11: Ignore unpoison failure under kernel lockdown
When newer kernels are under lockdown, the unpoison-pfn sysfile still appears writable to root but open() will always return EPERM. This causes madvise11 to fail with TWARN during cleanup when run with SecureBoot enabled.
Ignore the open(unpoison-pfn) failure due to lockdown and exit successfully without cleanup. The test should not be skipped because the leftover soft-offlined pages can trigger failures in later tests and indirectly expose kernel bugs in hwpoison.
---
Changes since v1: Print invalid return value in the error message
testcases/kernel/syscalls/madvise/madvise11.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/madvise/madvise11.c +16 -1
@@ -323,7 +323,22 @@ static int open_unpoison_pfn(void)if (!mnt)return -1 ; -return SAFE_OPEN (debugfs_fp,O_WRONLY ); +TEST (open (debugfs_fp,O_WRONLY )); + +if (TST_RET ==-1 &&TST_ERR ==EPERM &&tst_lockdown_enabled ()) { +tst_res (TINFO , +"Cannot restore soft-offlined memory due to lockdown" ); +return TST_RET ; + } + +if (TST_RET ==-1 ) { +tst_brk (TBROK |TTERRNO ,"open(%s) failed" , debugfs_fp); + }else if (TST_RET <0 ) { +tst_brk (TBROK |TTERRNO ,"Invalid open() return value %ld" , +TST_RET ); + } + +return TST_RET ; }/*
Signature · 5 lines
2.41.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Martin,
Thanks!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Pushed, thank you both!
Quoted 13 lines · Petr Vorel
Hi Martin,
Reviewed-by Petr Vorel <[email protected]>Thanks!
Kind regards,
Petr--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp