]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD regtest: add a testcase for exterrctl
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 20 Jul 2025 16:56:44 +0000 (18:56 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 20 Jul 2025 16:56:44 +0000 (18:56 +0200)
This is a function for libc internal use only, so this
test doesn't really add much compared to the scalar test.

.gitignore
configure.ac
memcheck/tests/freebsd/Makefile.am
memcheck/tests/freebsd/exterrctl.cpp [new file with mode: 0644]
memcheck/tests/freebsd/exterrctl.stderr.exp [new file with mode: 0644]
memcheck/tests/freebsd/exterrctl.vgtest [new file with mode: 0644]

index 0da54a7ebf8d1116bb9ca8faa536aa55056cece4..0283b8d5b7e99f2db79dae0a1361781f1629dbcf 100644 (file)
 /memcheck/tests/freebsd/eventfd1
 /memcheck/tests/freebsd/eventfd2
 /memcheck/tests/freebsd/extattr
+/memcheck/tests/freebsd/exterrctl
 /memcheck/tests/freebsd/fbsd278566
 /memcheck/tests/freebsd/fchroot
 /memcheck/tests/freebsd/fexecve
index d64782728b372f51761e69c59b94d1b277a438af..804493c2f20025a5507c8e3aa73a3aebb8d32b11 100755 (executable)
@@ -5008,7 +5008,8 @@ AC_CHECK_FUNCS([     \
         getrlimitusage \
         timer_delete \
         fchroot      \
-        setcred
+        setcred      \
+        exterrctl
         ])
 
 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
@@ -5070,6 +5071,8 @@ AM_CONDITIONAL([HAVE_FCHROOT],
                [test x$ac_cv_func_fchroot = xyes])
 AM_CONDITIONAL([HAVE_SETCRED],
                [test x$ac_cv_func_setcred = xyes])
+AM_CONDITIONAL([HAVE_EXTERRCTL],
+               [test x$ac_cv_func_exterrctl = xyes])
 
 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
index d96cde1b1bba6445630788fa31213eee1098a17f..0f00d67a4aa8a3c4d529ca4518195609503dd61b 100644 (file)
@@ -51,6 +51,8 @@ EXTRA_DIST = \
        eventfd2.stderr.exp \
        extattr.vgtest \
        extattr.stderr.exp \
+       exterrctl.vgtest \
+       exterrctl.stderr.exp \
        fbsd278566.vgtest \
        fbsd278566.stderr.exp \
        fchroot.vgtest \
@@ -183,6 +185,10 @@ if HAVE_AIO_READV
 check_PROGRAMS += aiov
 endif
 
+if HAVE_EXTERRCTL
+check_PROGRAMS += exterrctl
+endif
+
 if HAVE_FCHROOT
 check_PROGRAMS += fchroot
 fchroot_SOURCES = fchroot.cpp
@@ -236,6 +242,9 @@ delete_sized_mismatch_CXXFLAGS      = ${AM_CXXFLAGS} --std=c++14
 delete_sized_mismatch_SOURCES  = delete_sized_mismatch.cpp
 errno_aligned_allocs_CFLAGS    = ${AM_CFLAGS} @FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT@
 extattr_CFLAGS                 = ${AM_CFLAGS} @FLAG_W_NO_UNUSED_BUT_SET_VARIABLE@ @FLAG_W_NO_UNINITIALIZED@ @FLAG_W_NO_USE_AFTER_FREE@
+if HAVE_EXTERRCTL
+exterrctl_SOURCES = exterrctl.cpp
+endif
 get_set_login_CFLAGS           = ${AM_CFLAGS} @FLAG_W_NO_USE_AFTER_FREE@
 getfh_CFLAGS                   = ${AM_CFLAGS} @FLAG_W_NO_USE_AFTER_FREE@
 getfsstat_CFLAGS               = ${AM_CFLAGS} @FLAG_W_NO_UNINITIALIZED@ @FLAG_W_NO_USE_AFTER_FREE@
diff --git a/memcheck/tests/freebsd/exterrctl.cpp b/memcheck/tests/freebsd/exterrctl.cpp
new file mode 100644 (file)
index 0000000..c93af33
--- /dev/null
@@ -0,0 +1,20 @@
+#include <sys/exterrvar.h>
+#include <cstdlib>
+
+static long x0;
+
+int main()
+{
+   // int exterrctl(u_int op, u_int flags, void *ptr);
+   // op should be 0 or EXTERRCTLF_FORCE (1)
+   // flags EXTERRCTL_ENABLE EXTERRCTL_DISABLE EXTERRCTL_UD (1 2 3) 
+   // see sys/sys/_uexterror.h for ptr
+   long *px{static_cast<long*>(malloc(2*sizeof(long)))};
+   x0 = px[0];
+
+   char *foo = new char [48+128];
+   delete [] foo;
+
+   exterrctl(x0, x0+2, x0+foo); 
+}
+
diff --git a/memcheck/tests/freebsd/exterrctl.stderr.exp b/memcheck/tests/freebsd/exterrctl.stderr.exp
new file mode 100644 (file)
index 0000000..59c7f2d
--- /dev/null
@@ -0,0 +1,22 @@
+Syscall param exterrctl(op) contains uninitialised byte(s)
+   at 0x........: exterrctl (in /...libc...)
+   by 0x........: main (exterrctl.cpp:18)
+
+Syscall param exterrctl(flags) contains uninitialised byte(s)
+   at 0x........: exterrctl (in /...libc...)
+   by 0x........: main (exterrctl.cpp:18)
+
+Syscall param exterrctl(ptr) contains uninitialised byte(s)
+   at 0x........: exterrctl (in /...libc...)
+   by 0x........: main (exterrctl.cpp:18)
+
+Syscall param exterrctl(ptr) points to unaddressable byte(s)
+   at 0x........: exterrctl (in /...libc...)
+   by 0x........: main (exterrctl.cpp:18)
+ Address 0x........ is 0 bytes inside a block of size 176 free'd
+   at 0x........: ...operator delete[]... (vg_replace_malloc.c:...)
+   by 0x........: main (exterrctl.cpp:16)
+ Block was alloc'd at
+   at 0x........: ...operator new[]... (vg_replace_malloc.c:...)
+   by 0x........: main (exterrctl.cpp:15)
+
diff --git a/memcheck/tests/freebsd/exterrctl.vgtest b/memcheck/tests/freebsd/exterrctl.vgtest
new file mode 100644 (file)
index 0000000..53d929b
--- /dev/null
@@ -0,0 +1,3 @@
+prereq: test -x ./exterrctl
+prog: exterrctl
+vgopts: -q