加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-libs-sigwait-Workaround-segfault-on-libc-variant-on-.patch 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
woqidaideshi 提交于 2024-12-04 18:19 . init packages
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化