1. 24 Jun, 2021 1 commit
  2. 23 Jun, 2021 1 commit
  3. 22 Jun, 2021 2 commits
    • Kumar Kartikeya Dwivedi's avatar
      libbpf: Switch to void * casting in netlink helpers · ee62a5c6
      Kumar Kartikeya Dwivedi authored
      Netlink helpers I added in 8bbb77b7 ("libbpf: Add various netlink
      helpers") used char * casts everywhere, and there were a few more that
      existed from before.
      
      Convert all of them to void * cast, as it is treated equivalently by
      clang/gcc for the purposes of pointer arithmetic and to follow the
      convention elsewhere in the kernel/libbpf.
      Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20210619041454.417577-2-memxor@gmail.com
      ee62a5c6
    • Kumar Kartikeya Dwivedi's avatar
      libbpf: Add request buffer type for netlink messages · 0ae64fb6
      Kumar Kartikeya Dwivedi authored
      Coverity complains about OOB writes to nlmsghdr. There is no OOB as we
      write to the trailing buffer, but static analyzers and compilers may
      rightfully be confused as the nlmsghdr pointer has subobject provenance
      (and hence subobject bounds).
      
      Fix this by using an explicit request structure containing the nlmsghdr,
      struct tcmsg/ifinfomsg, and attribute buffer.
      
      Also switch nh_tail (renamed to req_tail) to cast req * to char * so
      that it can be understood as arithmetic on pointer to the representation
      array (hence having same bound as request structure), which should
      further appease analyzers.
      
      As a bonus, callers don't have to pass sizeof(req) all the time now, as
      size is implicitly obtained using the pointer. While at it, also reduce
      the size of attribute buffer to 128 bytes (132 for ifinfomsg using
      functions due to the padding).
      
      Summary of problem:
      
        Even though C standard allows interconvertibility of pointer to first
        member and pointer to struct, for the purposes of alias analysis it
        would still consider the first as having pointer value "pointer to T"
        where T is type of first member hence having subobject bounds,
        allowing analyzers within reason to complain when object is accessed
        beyond the size of pointed to object.
      
        The only exception to this rule may be when a char * is formed to a
        member subobject. It is not possible for the compiler to be able to
        tell the intent of the programmer that it is a pointer to member
        object or the underlying representation array of the containing
        object, so such diagnosis is suppressed.
      
      Fixes: 715c5ce4 ("libbpf: Add low level TC-BPF management API")
      Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20210619041454.417577-1-memxor@gmail.com
      0ae64fb6
  4. 21 Jun, 2021 1 commit
  5. 18 Jun, 2021 4 commits
  6. 17 Jun, 2021 31 commits