]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Linux regtest: openat2 not available on older systems
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 10 Jan 2023 20:00:22 +0000 (21:00 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 10 Jan 2023 20:00:22 +0000 (21:00 +0100)
The x86-linux/scalar testcase fas failing to compile.
So split out openat2 into a separate test with a condfigure test.

.gitignore
configure.ac
memcheck/tests/x86-linux/Makefile.am
memcheck/tests/x86-linux/scalar.c
memcheck/tests/x86-linux/scalar.stderr.exp
memcheck/tests/x86-linux/scalar_openat2.c [new file with mode: 0644]
memcheck/tests/x86-linux/scalar_openat2.stderr.exp [new file with mode: 0644]
memcheck/tests/x86-linux/scalar_openat2.vgtest [new file with mode: 0644]

index 4277dd2a6f035e7457442ec74f27865d754dde20..66a221fb4989d3f0ac01b63be2f9e2a13995db3b 100644 (file)
 /memcheck/tests/x86-linux/Makefile.in
 /memcheck/tests/x86-linux/scalar
 /memcheck/tests/x86-linux/scalar_exit_group
+/memcheck/tests/x86-linux/scalar_openat2
 /memcheck/tests/x86-linux/scalar_fork
 /memcheck/tests/x86-linux/scalar_supp
 /memcheck/tests/x86-linux/scalar_vfork
index 206f54d61f6c1431abaf484eea38d3cd1d2efeb7..47b2a5fe8f0377b1dbcfd4df47bd42bdc53c19a5 100755 (executable)
@@ -5228,6 +5228,21 @@ fi
 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
                [test x$ac_have_builtin_atomic64 = xyes])
 
+               
+AC_MSG_CHECKING([if platform has openat2 syscall])
+
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+  #include <sys/syscall.h>
+]], [[
+  return __NR_openat2
+]])], [
+  ac_have_openat2=yes
+], [
+  ac_have_openat2=no
+])
+
+AM_CONDITIONAL([HAVE_OPENAT2],
+               [test x$ac_have_openat2 = xyes])
 
 # does g++ have built-in functions for atomic memory access ?
 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
index 6f9b2d4da6f415e43c9c8190b6cfcc841ea25f61..7e91aaf8b4382215cf8194b5d493229cb8b925cd 100644 (file)
@@ -16,13 +16,17 @@ EXTRA_DIST = \
        scalar_exit_group.vgtest \
        scalar_supp.stderr.exp \
        scalar_supp.vgtest scalar_supp.supp \
-       scalar_vfork.stderr.exp scalar_vfork.vgtest
+       scalar_vfork.stderr.exp scalar_vfork.vgtest \
+       scalar_openat2.vgtest scalar_openat2.stderr.exp
 
 check_PROGRAMS = \
        bug133694 \
        int3-x86 \
        scalar scalar_exit_group scalar_fork scalar_supp scalar_vfork
 
+if HAVE_OPENAT2
+check_PROGRAMS += scalar_openat2
+endif
 
 AM_CFLAGS    += @FLAG_M32@ $(FLAG_MMMX) $(FLAG_MSSE)
 AM_CXXFLAGS  += @FLAG_M32@ $(FLAG_MMMX) $(FLAG_MSSE)
@@ -30,4 +34,7 @@ AM_CCASFLAGS += @FLAG_M32@
 
 scalar_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
 scalar_exit_group_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
+if HAVE_OPENAT2
+scalar_openat2_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
+endif
 scalar_supp_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
index 58b042ab77869b799e63e00d9c0fd2bf0affa638..54d0e0443ae2c77197fee16f42a2557aef6ac5b0 100644 (file)
@@ -1276,10 +1276,6 @@ int main(void)
    GO(__NR_epoll_create1, "1s 0m");
    SY(__NR_epoll_create1, x0); SUCC_OR_FAIL;
 
-   // __NR_openat2 337
-   GO(__NR_openat2, "4s 2m");
-   SY(__NR_openat2, x0, x0+1, x0+1, x0); FAIL;
-
    // __NR_process_vm_readv 347
    GO(__NR_process_vm_readv, "6s 2m");
    SY(__NR_process_vm_readv, x0, x0, x0+1, x0, x0+1, x0); FAIL;
index b12ca0cf41adb06ff217f5f536c1b223714f1bb9..b9202a8c2f9cacf8c8812671584c3b2aa599d6f5 100644 (file)
@@ -4145,70 +4145,41 @@ Syscall param epoll_create1(flags) contains uninitialised byte(s)
    ...
    by 0x........: main (scalar.c:1277)
 
------------------------------------------------------
-437:        __NR_openat2 4s 2m
------------------------------------------------------
-Syscall param openat2(dfd) contains uninitialised byte(s)
-   ...
-   by 0x........: main (scalar.c:1281)
-
-Syscall param openat2(filename) contains uninitialised byte(s)
-   ...
-   by 0x........: main (scalar.c:1281)
-
-Syscall param openat2(how) contains uninitialised byte(s)
-   ...
-   by 0x........: main (scalar.c:1281)
-
-Syscall param openat2(size) contains uninitialised byte(s)
-   ...
-   by 0x........: main (scalar.c:1281)
-
-Syscall param openat2(filename) points to unaddressable byte(s)
-   ...
-   by 0x........: main (scalar.c:1281)
- Address 0x........ is not stack'd, malloc'd or (recently) free'd
-
-Syscall param openat2(how) points to unaddressable byte(s)
-   ...
-   by 0x........: main (scalar.c:1281)
- Address 0x........ is not stack'd, malloc'd or (recently) free'd
-
 -----------------------------------------------------
 347:__NR_process_vm_readv 6s 2m
 -----------------------------------------------------
 Syscall param process_vm_readv(pid) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1285)
+   by 0x........: main (scalar.c:1281)
 
 Syscall param process_vm_readv(lvec) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1285)
+   by 0x........: main (scalar.c:1281)
 
 Syscall param process_vm_readv(liovcnt) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1285)
+   by 0x........: main (scalar.c:1281)
 
 Syscall param process_vm_readv(rvec) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1285)
+   by 0x........: main (scalar.c:1281)
 
 Syscall param process_vm_readv(riovcnt) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1285)
+   by 0x........: main (scalar.c:1281)
 
 Syscall param process_vm_readv(flags) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1285)
+   by 0x........: main (scalar.c:1281)
 
 Syscall param process_vm_readv(lvec) points to unaddressable byte(s)
    ...
-   by 0x........: main (scalar.c:1285)
+   by 0x........: main (scalar.c:1281)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 Syscall param process_vm_readv(rvec) points to unaddressable byte(s)
    ...
-   by 0x........: main (scalar.c:1285)
+   by 0x........: main (scalar.c:1281)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 -----------------------------------------------------
@@ -4216,36 +4187,36 @@ Syscall param process_vm_readv(rvec) points to unaddressable byte(s)
 -----------------------------------------------------
 Syscall param process_vm_writev(pid) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1289)
+   by 0x........: main (scalar.c:1285)
 
 Syscall param process_vm_writev(lvec) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1289)
+   by 0x........: main (scalar.c:1285)
 
 Syscall param process_vm_writev(liovcnt) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1289)
+   by 0x........: main (scalar.c:1285)
 
 Syscall param process_vm_writev(rvec) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1289)
+   by 0x........: main (scalar.c:1285)
 
 Syscall param process_vm_writev(riovcnt) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1289)
+   by 0x........: main (scalar.c:1285)
 
 Syscall param process_vm_writev(flags) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1289)
+   by 0x........: main (scalar.c:1285)
 
 Syscall param process_vm_writev(lvec) points to unaddressable byte(s)
    ...
-   by 0x........: main (scalar.c:1289)
+   by 0x........: main (scalar.c:1285)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 Syscall param process_vm_writev(rvec) points to unaddressable byte(s)
    ...
-   by 0x........: main (scalar.c:1289)
+   by 0x........: main (scalar.c:1285)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 -----------------------------------------------------
@@ -4261,5 +4232,5 @@ it at http://valgrind.org/support/bug_reports.html.
 -----------------------------------------------------
 Syscall param exit(status) contains uninitialised byte(s)
    ...
-   by 0x........: main (scalar.c:1297)
+   by 0x........: main (scalar.c:1293)
 
diff --git a/memcheck/tests/x86-linux/scalar_openat2.c b/memcheck/tests/x86-linux/scalar_openat2.c
new file mode 100644 (file)
index 0000000..1e508e1
--- /dev/null
@@ -0,0 +1,17 @@
+#define _GNU_SOURCE
+
+#include "../../memcheck.h"
+#include "scalar.h"
+
+int main(void)
+{
+   // uninitialised, but we know px[0] is 0x0
+   long* px  = malloc(sizeof(long));
+   long  x0  = px[0];
+   long  res;
+
+   // __NR_openat2 337
+   GO(__NR_openat2, "4s 2m");
+   SY(__NR_openat2, x0, x0+1, x0+1, x0); FAIL;
+}
+
diff --git a/memcheck/tests/x86-linux/scalar_openat2.stderr.exp b/memcheck/tests/x86-linux/scalar_openat2.stderr.exp
new file mode 100644 (file)
index 0000000..367da9d
--- /dev/null
@@ -0,0 +1,29 @@
+-----------------------------------------------------
+437:        __NR_openat2 4s 2m
+-----------------------------------------------------
+Syscall param openat2(dfd) contains uninitialised byte(s)
+   ...
+   by 0x........: main (scalar_openat2.c:15)
+
+Syscall param openat2(filename) contains uninitialised byte(s)
+   ...
+   by 0x........: main (scalar_openat2.c:15)
+
+Syscall param openat2(how) contains uninitialised byte(s)
+   ...
+   by 0x........: main (scalar_openat2.c:15)
+
+Syscall param openat2(size) contains uninitialised byte(s)
+   ...
+   by 0x........: main (scalar_openat2.c:15)
+
+Syscall param openat2(filename) points to unaddressable byte(s)
+   ...
+   by 0x........: main (scalar_openat2.c:15)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param openat2(how) points to unaddressable byte(s)
+   ...
+   by 0x........: main (scalar_openat2.c:15)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
diff --git a/memcheck/tests/x86-linux/scalar_openat2.vgtest b/memcheck/tests/x86-linux/scalar_openat2.vgtest
new file mode 100644 (file)
index 0000000..517c797
--- /dev/null
@@ -0,0 +1,2 @@
+prog: scalar_openat2
+vgopts: -q