|
From: Paul F. <pa...@so...> - 2025-10-10 18:59:35
|
https://sourceware.org/cgit/valgrind/commit/?id=9640ff697cd9c9be485ea8bffc6381395b3ad1d4 commit 9640ff697cd9c9be485ea8bffc6381395b3ad1d4 Author: Paul Floyd <pj...@wa...> Date: Fri Oct 10 20:57:26 2025 +0200 FreeBSD regtest: tweak setcred test Should now work on both arm64 and amd64 (and with a diff on the size of struct setcred for x86). Still don't see what caused the Conditional jump error. Diff: --- memcheck/tests/freebsd/setcred.cpp | 33 +++++++++++++++++++++---------- memcheck/tests/freebsd/setcred.stderr.exp | 26 ++++++++++++------------ 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/memcheck/tests/freebsd/setcred.cpp b/memcheck/tests/freebsd/setcred.cpp index 619d1959f1..1ae28f7f04 100644 --- a/memcheck/tests/freebsd/setcred.cpp +++ b/memcheck/tests/freebsd/setcred.cpp @@ -19,30 +19,23 @@ int main() std::memset(&cred1, 250, sizeof(cred1)); - // needs to be root to work correctly - ret = setcred(flags1, &cred1, size1); - assert(ret == -1); - assert(errno == EPERM); - - // not accessible - ret = setcred(flags1, nullptr, size1); - assert(ret == -1); - assert(errno == EFAULT); - // uninit ret = setcred(flags2+x0, (struct setcred*)x0, size1+x0); assert(ret == -1); assert(errno == EFAULT); + errno = 0; // invalid flags ret = setcred(9999+x0, &cred1, sizeof(cred1)); assert(ret == -1); assert(errno == EINVAL); + errno = 0; // invalid size ret = setcred(flags1, &cred1, 3+x0); assert(ret == -1); assert(errno == EINVAL); + errno = 0; cred2 = new struct setcred; @@ -50,6 +43,26 @@ int main() ret = setcred(flags1, cred2, size1); assert(ret == -1); assert(errno == EPERM); + errno = 0; + + // PJF these two calls to setcred were before the + // uninit one that is now first + // that was fine on arm64 but on amd64 the uninit + // call generated an extre Conditional jump ... error + + // fairly mysterious, and usually that means that there + // is something wrong with the syscall wrapper + + // needs to be root to work correctly + ret = setcred(flags1, &cred1, size1); + assert(ret == -1); + assert(errno == EPERM); + errno = 0; + + // not accessible + ret = setcred(flags1, nullptr, size1); + assert(ret == -1); + assert(errno == EFAULT); delete cred2; free(px); diff --git a/memcheck/tests/freebsd/setcred.stderr.exp b/memcheck/tests/freebsd/setcred.stderr.exp index 8766361c09..5f84b4f288 100644 --- a/memcheck/tests/freebsd/setcred.stderr.exp +++ b/memcheck/tests/freebsd/setcred.stderr.exp @@ -1,37 +1,37 @@ -Syscall param setcred(wcred) points to unaddressable byte(s) - at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:28) - Address 0x........ is not stack'd, malloc'd or (recently) free'd - Syscall param setcred(flags) contains uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:33) + by 0x........: main (setcred.cpp:23) Syscall param setcred(wcred) contains uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:33) + by 0x........: main (setcred.cpp:23) Syscall param setcred(size) contains uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:33) + by 0x........: main (setcred.cpp:23) Syscall param setcred(wcred) points to unaddressable byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:33) + by 0x........: main (setcred.cpp:23) Address 0x........ is not stack'd, malloc'd or (recently) free'd Syscall param setcred(flags) contains uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:38) + by 0x........: main (setcred.cpp:29) Syscall param setcred(size) contains uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:43) + by 0x........: main (setcred.cpp:35) Syscall param setcred(wcred) points to uninitialised byte(s) at 0x........: setcred (in /...libc...) - by 0x........: main (setcred.cpp:50) + by 0x........: main (setcred.cpp:43) Address 0x........ is 0 bytes inside a block of size 48 alloc'd at 0x........: ...operator new... (vg_replace_malloc.c:...) - by 0x........: main (setcred.cpp:47) + by 0x........: main (setcred.cpp:40) + +Syscall param setcred(wcred) points to unaddressable byte(s) + at 0x........: setcred (in /...libc...) + by 0x........: main (setcred.cpp:63) + Address 0x........ is not stack'd, malloc'd or (recently) free'd |