]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD regtest: tweak setcred test
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 10 Oct 2025 18:57:26 +0000 (20:57 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 10 Oct 2025 18:57:26 +0000 (20:57 +0200)
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.

memcheck/tests/freebsd/setcred.cpp
memcheck/tests/freebsd/setcred.stderr.exp

index 619d1959f1ccccb17d9a313fbbef86202a9d41ac..1ae28f7f047e6e16c7b6a043e54ee83eb280fa89 100644 (file)
@@ -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);
index 8766361c0908dc243e06c7d1fbb07ed809998e21..5f84b4f2883cf72b4bb19944681884055ff2af24 100644 (file)
@@ -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