[PATCH] selftests/ptrace: Fix error handling in peeksiginfo test

From: zhou xu

Date: Tue Nov 10 2026 - 09:05:20 EST


From: Zkingom <15024777017@xxxxxxx>

check_error_paths() expects PTRACE_PEEKSIGINFO to return -1 with errno
set to EFAULT when the output buffer is read-only. The current condition
uses &&, so it only reports a failure when both expectations are violated.
It accepts -1 with the wrong errno, as well as an unexpected return value
when errno is EFAULT.

Use || so that either mismatch causes the test to fail.

Verified all four return-value/errno combinations with syscall fault
injection into check_error_paths(). peeksiginfo also passes on x86_64
WSL2 (6.6.87.2). The full ptrace suite has the same two failures before
and after this change: set_syscall_info returns EIO and vmaccess.attach
times out.

The requester supplied the suspect condition, proposed replacement and
required return-value/errno cases. OpenAI Codex assisted with the history
and code checks, applying this one-operator change, drafting the changelog,
and preparing and running the temporary fault-injection and selftest
checks.

Fixes: 17afab1de422 ("selftest: add a test case for PTRACE_PEEKSIGINFO")
Signed-off-by: Zkingom <15024777017@xxxxxxx>
---
tools/testing/selftests/ptrace/peeksiginfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ptrace/peeksiginfo.c b/tools/testing/selftests/ptrace/peeksiginfo.c
index 2f345d11..46fed27f 100644
--- a/tools/testing/selftests/ptrace/peeksiginfo.c
+++ b/tools/testing/selftests/ptrace/peeksiginfo.c
@@ -89,7 +89,7 @@ static int check_error_paths(pid_t child)

/* Read-only buffer */
ret = sys_ptrace(PTRACE_PEEKSIGINFO, child, &arg, addr_ro);
- if (ret != -1 && errno != EFAULT) {
+ if (ret != -1 || errno != EFAULT) {
err("sys_ptrace() returns %d (expected -1),"
" errno %d (expected %d): %m\n",
ret, errno, EFAULT);

base-commit: f66469d9905b39d2c260a15d7d6db450f4db67c1
--
2.53.0.windows.1