aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-07-03 19:28:22 +0000
committerMark Johnston <markj@FreeBSD.org>2026-07-03 19:28:30 +0000
commit81cf9a0ca765b48a430da61c221be17c4d0f753a (patch)
tree2e5f36c2b3d47dcc13df9f68aee9105c3d5034b3
parent2de20c5c77cf8d5b2059054cff0e0c1fc124739d (diff)
tests/aslr: Fix spurious test failures
/sbin/ping and /sbin/ping6 are hard-linked, and the vmmap sysctl handler doesn't know which name was used to launch the process. PR: 296116 MFC after: 3 days Fixes: 080a4087014e ("tests: Fix race condition in aslr_setuid")
-rw-r--r--tests/sys/kern/aslr.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/sys/kern/aslr.c b/tests/sys/kern/aslr.c
index 966ea5c3b83a..e0b696c5130a 100644
--- a/tests/sys/kern/aslr.c
+++ b/tests/sys/kern/aslr.c
@@ -88,6 +88,18 @@ text_base(pid_t pid, const char *path)
return (base);
}
+static uint64_t
+ping_text_base(pid_t pid)
+{
+ uint64_t base;
+
+ base = text_base(pid, "/sbin/ping");
+ if (base == 0)
+ /* Work around name cache inconsistency. */
+ base = text_base(pid, "/sbin/ping6");
+ return (base);
+}
+
/*
* Make sure that ASLR can't be disabled for a setuid executable by an
* unprivileged user.
@@ -115,9 +127,9 @@ ATF_TC_BODY(aslr_setuid, tc)
"/sbin/ping is not setuid root");
child = spawn_ping(tc);
- bases[0] = text_base(child, "/sbin/ping");
+ bases[0] = ping_text_base(child);
ATF_REQUIRE_MSG(bases[0] != 0,
- "failed to find /sbin/ping text segment");
+ "failed to find ping text segment");
arg = 0;
error = procctl(P_PID, child, PROC_ASLR_STATUS, &arg);
@@ -137,9 +149,9 @@ ATF_TC_BODY(aslr_setuid, tc)
for (size_t i = 1; i < nitems(bases); i++) {
child = spawn_ping(tc);
- bases[i] = text_base(child, "/sbin/ping");
+ bases[i] = ping_text_base(child);
ATF_REQUIRE_MSG(bases[i] != 0,
- "failed to find /sbin/ping text segment");
+ "failed to find ping text segment");
error = kill(child, SIGTERM);
ATF_REQUIRE(error == 0);
pid = waitpid(child, &st, 0);