代码拉取完成,页面将自动刷新
From 6dde3bc80fdbd97138ed85b56c5e5ed8acb2d621 Mon Sep 17 00:00:00 2001
From: Petr Vorel <pvorel@suse.cz>
Date: Thu, 14 Nov 2024 14:03:55 +0100
Subject: [PATCH] libs/sigwait: Workaround segfault on libc variant on 32 bit
test_bad_address3() test which tests EFAULT segfaults on newer kernels
(e.g. 6.4) on libc variant on 32bit. Similarly to 1d4d5a0750 use
typical LTP workaround to test by forked child + checking the
terminating signal.
This got broken on sigtimedwait01.c (but not on rt_sigtimedwait01.c).
Link: https://lore.kernel.org/ltp/20241114144029.349559-5-pvorel@suse.cz/
Acked-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
libs/sigwait/sigwait.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/libs/sigwait/sigwait.c b/libs/sigwait/sigwait.c
index 86899954d7..cf3c445b4a 100644
--- a/libs/sigwait/sigwait.c
+++ b/libs/sigwait/sigwait.c
@@ -359,17 +359,27 @@ void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
enum tst_ts_type type LTP_ATTRIBUTE_UNUSED)
{
sigset_t sigs;
+ pid_t pid;
+ int status;
- SAFE_SIGEMPTYSET(&sigs);
- TEST(sigwaitinfo(&sigs, NULL, (void *)1));
- if (TST_RET == -1) {
- if (TST_ERR == EFAULT)
- tst_res(TPASS, "Fault occurred while accessing the buffers");
- else
- tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
- } else {
- tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+ pid = SAFE_FORK();
+ if (pid == 0) {
+ SAFE_SIGEMPTYSET(&sigs);
+ TST_EXP_FAIL(sigwaitinfo(&sigs, NULL, (void *)1), EFAULT);
+ _exit(0);
+ }
+
+ SAFE_WAITPID(pid, &status, 0);
+
+ if (WIFEXITED(status) && !WEXITSTATUS(status))
+ return;
+
+ if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
+ tst_res(TPASS, "Child killed by expected signal");
+ return;
}
+
+ tst_res(TFAIL, "Child %s", tst_strstatus(status));
}
static void empty_handler(int sig LTP_ATTRIBUTE_UNUSED)
--
2.45.2
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。