]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
sigaltstack syscall: improve error messages
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 8 Oct 2024 11:19:08 +0000 (13:19 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 8 Oct 2024 11:19:08 +0000 (13:19 +0200)
Previously the same message was generated for the 3 members of
stack_t.

Also on FreeBSD I get a Conditional jump error with this syscall
but not on all platforms, so I've added a suppression.

coregrind/m_syswrap/syswrap-generic.c
memcheck/tests/freebsd/Makefile.am
memcheck/tests/freebsd/scalar.c
memcheck/tests/freebsd/scalar.stderr.exp
memcheck/tests/freebsd/scalar.supp [new file with mode: 0644]
memcheck/tests/freebsd/scalar.vgtest

index 9093b831d6ef9ed8fc7fbd906a2c38911f6b58ab..5434a6836978a4c0ce73546bc04812f566bd1015 100644 (file)
@@ -5033,9 +5033,9 @@ PRE(sys_sigaltstack)
                  const vki_stack_t *, ss, vki_stack_t *, oss);
    if (ARG1 != 0) {
       const vki_stack_t *ss = (vki_stack_t *)(Addr)ARG1;
-      PRE_MEM_READ( "sigaltstack(ss)", (Addr)&ss->ss_sp, sizeof(ss->ss_sp) );
-      PRE_MEM_READ( "sigaltstack(ss)", (Addr)&ss->ss_flags, sizeof(ss->ss_flags) );
-      PRE_MEM_READ( "sigaltstack(ss)", (Addr)&ss->ss_size, sizeof(ss->ss_size) );
+      PRE_MEM_READ( "sigaltstack(ss->ss_sp)", (Addr)&ss->ss_sp, sizeof(ss->ss_sp) );
+      PRE_MEM_READ( "sigaltstack(ss->ss_size)", (Addr)&ss->ss_size, sizeof(ss->ss_size) );
+      PRE_MEM_READ( "sigaltstack(ss->ss_flags)", (Addr)&ss->ss_flags, sizeof(ss->ss_flags) );
    }
    if (ARG2 != 0) {
       PRE_MEM_WRITE( "sigaltstack(oss)", ARG2, sizeof(vki_stack_t) );
index ae4b1aa531e4a731ecc5011c30c046989acc2a71..8329a4377c26e5bdcf4ac49d09252d20de95f77f 100644 (file)
@@ -91,6 +91,7 @@ EXTRA_DIST = \
        scalar.h scalar.vgtest \
        scalar.stderr.exp \
                scalar.stderr.exp-x86 \
+               scalar.supp \
        scalar_abort2.vgtest \
        scalar_13_plus.vgtest \
        scalar_13_plus.stderr.exp \
index ac8edd42aaf567bccd697f514892aaee03f0623b..76a9f651ccb0979e5b13be319b229102b1af2c7c 100644 (file)
@@ -257,14 +257,8 @@ int main(void)
       struct our_sigaltstack oss;
       VALGRIND_MAKE_MEM_NOACCESS(&ss, sizeof(struct our_sigaltstack));
       VALGRIND_MAKE_MEM_NOACCESS(&oss, sizeof(struct our_sigaltstack));
-      GO(SYS_sigaltstack, "0s 2m");
+      GO(SYS_sigaltstack, "2s 4m");
       SY(SYS_sigaltstack, x0+&ss, x0+&oss); FAIL;
-
-      GO(SYS_sigaltstack, "2s 0m");
-      SY(SYS_sigaltstack, x0, x0); SUCC;
-
-      GO(SYS_sigaltstack, "2s 2m");
-      SY(SYS_sigaltstack, x0+1, x0+1); FAIL;
    }
 
    /* SYS_ioctl                   54 */
index f8209228e241dcc1c43e6da0fc8714c965253339..681bb8f2add72389e4481991ad88ba204a446b98 100644 (file)
@@ -440,7 +440,7 @@ Syscall param acct(filename) points to unaddressable byte(s)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 ---------------------------------------------------------
- 53:         SYS_sigaltstack 0s 2m
+ 53:         SYS_sigaltstack 2s 4m
 ---------------------------------------------------------
 Syscall param sigaltstack(ss) contains uninitialised byte(s)
    ...
@@ -448,40 +448,22 @@ Syscall param sigaltstack(ss) contains uninitialised byte(s)
 Syscall param sigaltstack(oss) contains uninitialised byte(s)
    ...
 
-Syscall param sigaltstack(ss) points to unaddressable byte(s)
+Syscall param sigaltstack(ss->ss_sp) points to unaddressable byte(s)
    ...
  Address 0x........ is on thread 1's stack
 
-Syscall param sigaltstack(oss) points to unaddressable byte(s)
+Syscall param sigaltstack(ss->ss_size) points to unaddressable byte(s)
    ...
  Address 0x........ is on thread 1's stack
 
----------------------------------------------------------
- 53:         SYS_sigaltstack 2s 0m
----------------------------------------------------------
-Syscall param sigaltstack(ss) contains uninitialised byte(s)
-   ...
-
-
-Syscall param sigaltstack(oss) contains uninitialised byte(s)
-   ...
-
----------------------------------------------------------
- 53:         SYS_sigaltstack 2s 2m
----------------------------------------------------------
-Syscall param sigaltstack(ss) contains uninitialised byte(s)
-   ...
-
-Syscall param sigaltstack(oss) contains uninitialised byte(s)
+Syscall param sigaltstack(ss->ss_flags) points to unaddressable byte(s)
    ...
+ Address 0x........ is on thread 1's stack
 
-Syscall param sigaltstack(ss) points to unaddressable byte(s)
-   ...
- Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 Syscall param sigaltstack(oss) points to unaddressable byte(s)
    ...
- Address 0x........ is not stack'd, malloc'd or (recently) free'd
+ Address 0x........ is on thread 1's stack
 
 ---------------------------------------------------------
  54:               SYS_ioctl 3s 1m
diff --git a/memcheck/tests/freebsd/scalar.supp b/memcheck/tests/freebsd/scalar.supp
new file mode 100644 (file)
index 0000000..f6b15a3
--- /dev/null
@@ -0,0 +1,11 @@
+# not sure what causes this exactly# on x86 and amd64 (but not arm64)
+# there is an conditional uninit read
+# there are several if statements that use the two pointers to stack
+# structures that probably generate the error
+
+{
+   internal uninitilized read
+   Memcheck:Cond
+   fun:syscall
+   fun:main
+}
index 170c1576e1446bce65be183760884b1e443a4df4..2f433038c784fb6dd05a52efdbfc1998cbe5400d 100644 (file)
@@ -1,5 +1,5 @@
 prog: scalar
-vgopts: -q --error-limit=no
+vgopts: -q --error-limit=no --suppressions=scalar.supp
 stderr_filter: filter_scalar
 # Remove all frames from the stack trace except the first one.
 # This is important because syscall() function on x86 isn't ABI conformant