From: Martin Doucha <mdoucha@suse.cz>
To: Petr Vorel <pvorel@suse.cz>, ltp@lists.linux.it
Subject: [LTP] [PATCH v2] syscalls/madvise11: Ignore unpoison failure under kernel lockdown
Date: Tue, 20 Jun 2023 18:29:38 +0200 [thread overview]
Message-ID: <20230620163027.22039-1-mdoucha@suse.cz> (raw)
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.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
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(-)
diff --git a/testcases/kernel/syscalls/madvise/madvise11.c b/testcases/kernel/syscalls/madvise/madvise11.c
index 2cb45d00a..4c960dd35 100644
--- a/testcases/kernel/syscalls/madvise/madvise11.c
+++ b/testcases/kernel/syscalls/madvise/madvise11.c
@@ -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;
}
/*
--
2.41.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2023-06-20 16:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 16:29 Martin Doucha [this message]
2023-06-20 20:18 ` [LTP] [PATCH v2] syscalls/madvise11: Ignore unpoison failure under kernel lockdown Petr Vorel
2023-06-21 3:00 ` Li Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230620163027.22039-1-mdoucha@suse.cz \
--to=mdoucha@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox