• Ilya Maximets's avatar
    libbpf: fix using uninitialized ioctl results · decb705e
    Ilya Maximets authored
    'channels.max_combined' initialized only on ioctl success and
    errno is only valid on ioctl failure.
    
    The code doesn't produce any runtime issues, but makes memory
    sanitizers angry:
    
     Conditional jump or move depends on uninitialised value(s)
        at 0x55C056F: xsk_get_max_queues (xsk.c:336)
        by 0x55C05B2: xsk_create_bpf_maps (xsk.c:354)
        by 0x55C089F: xsk_setup_xdp_prog (xsk.c:447)
        by 0x55C0E57: xsk_socket__create (xsk.c:601)
      Uninitialised value was created by a stack allocation
        at 0x55C04CD: xsk_get_max_queues (xsk.c:318)
    
    Additionally fixed warning on uninitialized bytes in ioctl arguments:
    
     Syscall param ioctl(SIOCETHTOOL) points to uninitialised byte(s)
        at 0x648D45B: ioctl (in /usr/lib64/libc-2.28.so)
        by 0x55C0546: xsk_get_max_queues (xsk.c:330)
        by 0x55C05B2: xsk_create_bpf_maps (xsk.c:354)
        by 0x55C089F: xsk_setup_xdp_prog (xsk.c:447)
        by 0x55C0E57: xsk_socket__create (xsk.c:601)
      Address 0x1ffefff378 is on thread 1's stack
      in frame #1, created by xsk_get_max_queues (xsk.c:318)
      Uninitialised value was created by a stack allocation
        at 0x55C04CD: xsk_get_max_queues (xsk.c:318)
    
    CC: Magnus Karlsson <magnus.karlsson@intel.com>
    Fixes: 1cad0788 ("libbpf: add support for using AF_XDP sockets")
    Signed-off-by: default avatarIlya Maximets <i.maximets@samsung.com>
    Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    decb705e
xsk.c 15.3 KB