1. 21 Feb, 2023 3 commits
    • Kees Cook's avatar
      net/mlx4_en: Introduce flexible array to silence overflow warning · f8f185e3
      Kees Cook authored
      The call "skb_copy_from_linear_data(skb, inl + 1, spc)" triggers a FORTIFY
      memcpy() warning on ppc64 platform:
      
      In function ‘fortify_memcpy_chk’,
          inlined from ‘skb_copy_from_linear_data’ at ./include/linux/skbuff.h:4029:2,
          inlined from ‘build_inline_wqe’ at drivers/net/ethernet/mellanox/mlx4/en_tx.c:722:4,
          inlined from ‘mlx4_en_xmit’ at drivers/net/ethernet/mellanox/mlx4/en_tx.c:1066:3:
      ./include/linux/fortify-string.h:513:25: error: call to ‘__write_overflow_field’ declared with
      attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()?
      [-Werror=attribute-warning]
        513 |                         __write_overflow_field(p_size_field, size);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Same behaviour on x86 you can get if you use "__always_inline" instead of
      "inline" for skb_copy_from_linear_data() in skbuff.h
      
      The call here copies data into inlined tx destricptor, which has 104
      bytes (MAX_INLINE) space for data payload. In this case "spc" is known
      in compile-time but the destination is used with hidden knowledge
      (real structure of destination is different from that the compiler
      can see). That cause the fortify warning because compiler can check
      bounds, but the real bounds are different.  "spc" can't be bigger than
      64 bytes (MLX4_INLINE_ALIGN), so the data can always fit into inlined
      tx descriptor. The fact that "inl" points into inlined tx descriptor is
      determined earlier in mlx4_en_xmit().
      
      Avoid confusing the compiler with "inl + 1" constructions to get to past
      the inl header by introducing a flexible array "data" to the struct so
      that the compiler can see that we are not dealing with an array of inl
      structs, but rather, arbitrary data following the structure. There are
      no changes to the structure layout reported by pahole, and the resulting
      machine code is actually smaller.
      Reported-by: default avatarJosef Oskera <joskera@redhat.com>
      Link: https://lore.kernel.org/lkml/20230217094541.2362873-1-joskera@redhat.com
      Fixes: f68f2ff9 ("fortify: Detect struct member overflows in memcpy() at compile-time")
      Cc: Yishai Hadas <yishaih@nvidia.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Link: https://lore.kernel.org/r/20230218183842.never.954-kees@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f8f185e3
    • Kuniyuki Iwashima's avatar
      net/ulp: Remove redundant ->clone() test in inet_clone_ulp(). · be9832c2
      Kuniyuki Iwashima authored
      Commit 2c02d41d ("net/ulp: prevent ULP without clone op from entering
      the LISTEN status") guarantees that all ULP listeners have clone() op, so
      we no longer need to test it in inet_clone_ulp().
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Link: https://lore.kernel.org/r/20230217200920.85306-1-kuniyu@amazon.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      be9832c2
    • Jakub Kicinski's avatar
      Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next · ee8d72a1
      Jakub Kicinski authored
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf-next 2023-02-17
      
      We've added 64 non-merge commits during the last 7 day(s) which contain
      a total of 158 files changed, 4190 insertions(+), 988 deletions(-).
      
      The main changes are:
      
      1) Add a rbtree data structure following the "next-gen data structure"
         precedent set by recently-added linked-list, that is, by using
         kfunc + kptr instead of adding a new BPF map type, from Dave Marchevsky.
      
      2) Add a new benchmark for hashmap lookups to BPF selftests,
         from Anton Protopopov.
      
      3) Fix bpf_fib_lookup to only return valid neighbors and add an option
         to skip the neigh table lookup, from Martin KaFai Lau.
      
      4) Add cgroup.memory=nobpf kernel parameter option to disable BPF memory
         accouting for container environments, from Yafang Shao.
      
      5) Batch of ice multi-buffer and driver performance fixes,
         from Alexander Lobakin.
      
      6) Fix a bug in determining whether global subprog's argument is
         PTR_TO_CTX, which is based on type names which breaks kprobe progs,
         from Andrii Nakryiko.
      
      7) Prep work for future -mcpu=v4 LLVM option which includes usage of
         BPF_ST insn. Thus improve BPF_ST-related value tracking in verifier,
         from Eduard Zingerman.
      
      8) More prep work for later building selftests with Memory Sanitizer
         in order to detect usages of undefined memory, from Ilya Leoshkevich.
      
      9) Fix xsk sockets to check IFF_UP earlier to avoid a NULL pointer
         dereference via sendmsg(), from Maciej Fijalkowski.
      
      10) Implement BPF trampoline for RV64 JIT compiler, from Pu Lehui.
      
      11) Fix BPF memory allocator in combination with BPF hashtab where it could
          corrupt special fields e.g. used in bpf_spin_lock, from Hou Tao.
      
      12) Fix LoongArch BPF JIT to always use 4 instructions for function
          address so that instruction sequences don't change between passes,
          from Hengqi Chen.
      
      * tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (64 commits)
        selftests/bpf: Add bpf_fib_lookup test
        bpf: Add BPF_FIB_LOOKUP_SKIP_NEIGH for bpf_fib_lookup
        riscv, bpf: Add bpf trampoline support for RV64
        riscv, bpf: Add bpf_arch_text_poke support for RV64
        riscv, bpf: Factor out emit_call for kernel and bpf context
        riscv: Extend patch_text for multiple instructions
        Revert "bpf, test_run: fix &xdp_frame misplacement for LIVE_FRAMES"
        selftests/bpf: Add global subprog context passing tests
        selftests/bpf: Convert test_global_funcs test to test_loader framework
        bpf: Fix global subprog context argument resolution logic
        LoongArch, bpf: Use 4 instructions for function address in JIT
        bpf: bpf_fib_lookup should not return neigh in NUD_FAILED state
        bpf: Disable bh in bpf_test_run for xdp and tc prog
        xsk: check IFF_UP earlier in Tx path
        Fix typos in selftest/bpf files
        selftests/bpf: Use bpf_{btf,link,map,prog}_get_info_by_fd()
        samples/bpf: Use bpf_{btf,link,map,prog}_get_info_by_fd()
        bpftool: Use bpf_{btf,link,map,prog}_get_info_by_fd()
        libbpf: Use bpf_{btf,link,map,prog}_get_info_by_fd()
        libbpf: Introduce bpf_{btf,link,map,prog}_get_info_by_fd()
        ...
      ====================
      
      Link: https://lore.kernel.org/r/20230217221737.31122-1-daniel@iogearbox.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      ee8d72a1
  2. 20 Feb, 2023 37 commits