]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD regtest: getsockopt and setsockopt scalar tests were wrong
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 9 Nov 2025 08:29:17 +0000 (09:29 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 9 Nov 2025 08:29:17 +0000 (09:29 +0100)
getsockopt was miscopied as setsockopt and the memory checks
weere not good.

coregrind/m_syswrap/syswrap-freebsd.c
memcheck/tests/freebsd/scalar.c
memcheck/tests/freebsd/scalar.stderr.exp
memcheck/tests/freebsd/scalar.stderr.exp-x86

index dce26ba915c97b99c7c5b68a61c48a33f42d5abe..c2fd35d2b1b832e14eebd69e7837937559bc5932 100644 (file)
@@ -1510,7 +1510,7 @@ PRE(sys_getsockopt)
    PRINT("sys_getsockopt ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3,ARG4,ARG5);
    PRE_REG_READ5(int, "getsockopt",
                  int, s, int, level, int, optname,
-                 void *, optval, int, *optlen);
+                 void *, optval, vki_socklen_t, *optlen);
    if (optval_p != (Addr)NULL) {
       ML_(buf_and_len_pre_check) ( tid, optval_p, optlen_p,
                                    "getsockopt(optval)",
index acb4b662e7864b5ca7a6c3246cbd8ee2a6def162..b4d7a46d13dadcba7e55cd3a2959a254d7759bce 100644 (file)
@@ -449,8 +449,8 @@ int main(void)
    SY(SYS_bind, x0, x0, x0); FAIL;
 
    /* SYS_setsockopt              105 */
-   GO(SYS_setsockopt, "5s 0m");
-   SY(SYS_setsockopt, x0, x0, x0, x0, x0); FAIL;
+   GO(SYS_setsockopt, "5s 1m");
+   SY(SYS_setsockopt, x0, x0, x0, px+x0, sizeof(socklen_t)+x0); FAIL;
 
    /* SYS_listen                  106 */
    GO(SYS_listen, "2s 0m");
@@ -482,9 +482,18 @@ int main(void)
    GO(SYS_getrusage, "2s 1m");
    SY(SYS_getrusage, x0, x0); FAIL;
 
+   socklen_t *len = malloc(sizeof(socklen_t));
+   *len = 2*sizeof(long)+x0;
+   free(len);
+   /*
+    * Should be 2m but it is hard to trigger an optval
+    * error in the scalar, len needs to be safe to deref
+    * and the syscall needs to succeed to trigger a write
+    * error to optval
+    */
    /* SYS_getsockopt              118 */
-   GO(SYS_setsockopt, "5s 1m");
-   SY(SYS_setsockopt, x0, x0, x0, x0, x0); FAIL;
+   GO(SYS_getsockopt, "5s 1m");
+   SY(SYS_getsockopt, x0, x0, x0, px+x0, len+x0); FAIL;
 
    /* unimpl resuba               119 */
 
index 2acb864e7366db3f8b4b4d3fb84e0ad19e4d1235..449075f3e02e6ea977a7de843bb138fafcdc9149 100644 (file)
@@ -856,7 +856,7 @@ Syscall param bind(addrlen) contains uninitialised byte(s)
    ...
 
 ---------------------------------------------------------
-105:          SYS_setsockopt 5s 0m
+105:          SYS_setsockopt 5s 1m
 ---------------------------------------------------------
 Syscall param setsockopt(s) contains uninitialised byte(s)
    ...
@@ -873,6 +873,12 @@ Syscall param setsockopt(optval) contains uninitialised byte(s)
 Syscall param setsockopt(optlen) contains uninitialised byte(s)
    ...
 
+Syscall param socketcall.setsockopt(optval) points to uninitialised byte(s)
+   ...
+ Address 0x........ is 0 bytes inside a block of size 16 alloc'd
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   ...
+
 ---------------------------------------------------------
 106:              SYS_listen 2s 0m
 ---------------------------------------------------------
@@ -913,21 +919,30 @@ Syscall param getrusage(usage) points to unaddressable byte(s)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 ---------------------------------------------------------
-105:          SYS_setsockopt 5s 1m
+118:          SYS_getsockopt 5s 1m
 ---------------------------------------------------------
-Syscall param setsockopt(s) contains uninitialised byte(s)
+Syscall param getsockopt(s) contains uninitialised byte(s)
    ...
 
-Syscall param setsockopt(level) contains uninitialised byte(s)
+Syscall param getsockopt(level) contains uninitialised byte(s)
    ...
 
-Syscall param setsockopt(optname) contains uninitialised byte(s)
+Syscall param getsockopt(optname) contains uninitialised byte(s)
    ...
 
-Syscall param setsockopt(optval) contains uninitialised byte(s)
+Syscall param getsockopt(optval) contains uninitialised byte(s)
    ...
 
-Syscall param setsockopt(optlen) contains uninitialised byte(s)
+Syscall param getsockopt(*optlen) contains uninitialised byte(s)
+   ...
+
+Syscall param getsockopt(optlen) points to unaddressable byte(s)
+   ...
+ Address 0x........ is 0 bytes inside a block of size 4 free'd
+   at 0x........: free (vg_replace_malloc.c:...)
+   ...
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
    ...
 
 ---------------------------------------------------------
index 957ffb2058564f363a981176478ccc36f8e97715..e7e2ce0a6bdff6cf9d841783f091d5ed7c0818ae 100644 (file)
@@ -856,7 +856,7 @@ Syscall param bind(addrlen) contains uninitialised byte(s)
    ...
 
 ---------------------------------------------------------
-105:          SYS_setsockopt 5s 0m
+105:          SYS_setsockopt 5s 1m
 ---------------------------------------------------------
 Syscall param setsockopt(s) contains uninitialised byte(s)
    ...
@@ -873,6 +873,12 @@ Syscall param setsockopt(optval) contains uninitialised byte(s)
 Syscall param setsockopt(optlen) contains uninitialised byte(s)
    ...
 
+Syscall param socketcall.setsockopt(optval) points to uninitialised byte(s)
+   ...
+ Address 0x........ is 0 bytes inside a block of size 16 alloc'd
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   ...
+
 ---------------------------------------------------------
 106:              SYS_listen 2s 0m
 ---------------------------------------------------------
@@ -913,21 +919,30 @@ Syscall param getrusage(usage) points to unaddressable byte(s)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
 
 ---------------------------------------------------------
-105:          SYS_setsockopt 5s 1m
+118:          SYS_getsockopt 5s 1m
 ---------------------------------------------------------
-Syscall param setsockopt(s) contains uninitialised byte(s)
+Syscall param getsockopt(s) contains uninitialised byte(s)
    ...
 
-Syscall param setsockopt(level) contains uninitialised byte(s)
+Syscall param getsockopt(level) contains uninitialised byte(s)
    ...
 
-Syscall param setsockopt(optname) contains uninitialised byte(s)
+Syscall param getsockopt(optname) contains uninitialised byte(s)
    ...
 
-Syscall param setsockopt(optval) contains uninitialised byte(s)
+Syscall param getsockopt(optval) contains uninitialised byte(s)
    ...
 
-Syscall param setsockopt(optlen) contains uninitialised byte(s)
+Syscall param getsockopt(*optlen) contains uninitialised byte(s)
+   ...
+
+Syscall param getsockopt(optlen) points to unaddressable byte(s)
+   ...
+ Address 0x........ is 0 bytes inside a block of size 4 free'd
+   at 0x........: free (vg_replace_malloc.c:...)
+   ...
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
    ...
 
 ---------------------------------------------------------