https://bugs.kde.org/show_bug.cgi?id=435375

            Bug ID: 435375
           Summary: Syscall param socketcall.setsockopt(optval) points to
                    uninitialised byte(s) (Multicast API)
           Product: valgrind
           Version: 3.14.0
          Platform: Other
                OS: Other
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: memcheck
          Assignee: jsew...@acm.org
          Reporter: uglymo...@wizdom.nu
  Target Milestone: ---

Seems that Valgrind is not recognizing padding in struct group_req and or
struct sockaddr_in/storage.

Code to reproduce:
struct group_req GrpReq;
struct sockaddr_in Grp = { AF_INET, 0, {mcastaddr}, {0} };
GrpReq.gr_interface = IfDp ? if_nametoindex(IfDp->Name) : 0;
memcpy(&GrpReq.gr_group, &Grp, sizeof(Grp));
setsockopt(mrouterFD, IPPROTO_IP, MCAST_JOIN_GROUP, &GrpReq, sizeof(GrpReq))

Valgrind is erroring on:
==30163== Syscall param socketcall.setsockopt(optval) points to uninitialised
byte(s)
==30163==    at 0x4935CD8: setsockopt (syscall-template.S:78)
==30163==    by 0x112177: k_joinleave (kern.c:108)
....
==30163==  Address 0x1ffeffff2c is on thread 1's stack
==30163==  in frame #1, created by k_joinleave (kern.c:92)


Examaning stack frame #1 shows the data used to call setsockopt is perfectly
fine:
#1  0x0000000000112178 in k_joinleave (Cmd=106, IfDp=0x49e3fa0,
mcastaddr=33554656) at kern.c:112
        GrpReq = {gr_interface = 6, gr_group = {ss_family = 2, 
            __ss_padding = "\000\000\340\000\000\002", '\000' <repeats 16
times>,
"hZ\215\004\000\000\000\000\320\377\377\376\037\000\000\000\224\357\020\000\000\000\000\000\240?\236\004\000\000\000\000p\000\000\377\037\000\000\000X\343\022",
'\000' <repeats 14 times>,
"\320\022\000\000\000\000\000\003\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\003\000\000\000\000\000\000",
__ss_align = 1146280}}
        Grp = {sin_family = 2, sin_port = 0, sin_addr = {s_addr = 33554656},
sin_zero = "\000\000\000\000\000\000\000"}
...

__ss_padding = "\000\000\340\000\000\002"
is port 0, and multicast address 224.0.0.2 (mcastaddr=33554656 / 0xE0000002)

All requirements for this setsockopt API are thus satisfied and the error is a
false positive.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to