https://bugs.kde.org/show_bug.cgi?id=529050
Bug ID: 529050
Summary: Syscall param socketcall.bind(my_addr.sun_path) points
to uninitialised byte(s) false positive with non-nul
terminated path
Classification: Developer tools
Product: valgrind
Version First 3.27 GIT
Reported In:
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: memcheck
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 198619
--> https://bugs.kde.org/attachment.cgi?id=198619&action=edit
Minimal reproducer program
If I call `bind()` with a `struct sockaddr_un` whose `sun_path` is full but not
nul terminated (because it’s full), memcheck gives the following error, which I
believe is a false positive:
```
==174001== Using Valgrind-3.27.1 and LibVEX; rerun with -h for copyright info
==174001== Command: ./valgrind-test
==174001==
Start of sockaddr: 0x1ffeffed70
==174001== Syscall param socketcall.bind(my_addr.sun_path) points to
uninitialised byte(s)
==174001== at 0x497BF4B: bind (in /usr/lib64/libc.so.6)
==174001== by 0x4005D8: main (valgrind.c:41)
==174001== Address 0x1ffeffedde is on thread 1's stack
==174001== in frame #1, created by main (valgrind.c:15)
```
This is despite the `addrlen` argument of `bind()` correctly giving the extent
of the valid sockaddr bytes.
I don’t believe glibc is itself reading off the end of the sockaddr, as it just
passes the arguments through to a syscall without doing any processing of its
own:
https://github.com/bminor/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bind.c#L22
STEPS TO REPRODUCE
I’ve attached a minimal reproducer program.
This was originally found in the GLib unit tests (which are all run under
valgrind), in https://gitlab.gnome.org/GNOME/glib/-/work_items/4128
SOFTWARE/OS VERSIONS
Valgrind version: valgrind-3.27.1
OS: Fedora 44
--
You are receiving this mail because:
You are watching all bug changes.