Skip to content
  1. May 08, 2021
    • Magnus Karlsson's avatar
      i40e: fix broken XDP support · ae4393df
      Magnus Karlsson authored
      Commit 12738ac4 ("i40e: Fix sparse errors in i40e_txrx.c") broke
      XDP support in the i40e driver. That commit was fixing a sparse error
      in the code by introducing a new variable xdp_res instead of
      overloading this into the skb pointer. The problem is that the code
      later uses the skb pointer in if statements and these where not
      extended to also test for the new xdp_res variable. Fix this by adding
      the correct tests for xdp_res in these places.
      
      The skb pointer was used to store the result of the XDP program by
      overloading the results in the error pointer
      ERR_PTR(-result). Therefore, the allocation failure test that used to
      only test for !skb now need to be extended to also consider !xdp_res.
      
      i40e_cleanup_headers() had a check that based on the skb value being
      an error pointer, i.e. a result from the XDP program != XDP_PASS, and
      if so start to process a new packet immediately, instead of populating
      skb fields and sending the skb to the stack. This check is not needed
      anymore, since we have added an explicit test for xdp_res being set
      and if so just do continue to pick the next packet from the NIC.
      
      Fixes: 12738ac4
      
       ("i40e: Fix sparse errors in i40e_txrx.c")
      Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Tested-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Reported-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Reviewed-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      ae4393df
  2. May 07, 2021
  3. May 06, 2021
  4. May 05, 2021
  5. May 04, 2021
  6. May 03, 2021
    • Daniel Borkmann's avatar
      bpf: Fix leakage of uninitialized bpf stack under speculation · 801c6058
      Daniel Borkmann authored
      The current implemented mechanisms to mitigate data disclosure under
      speculation mainly address stack and map value oob access from the
      speculative domain. However, Piotr discovered that uninitialized BPF
      stack is not protected yet, and thus old data from the kernel stack,
      potentially including addresses of kernel structures, could still be
      extracted from that 512 bytes large window. The BPF stack is special
      compared to map values since it's not zero initialized for every
      program invocation, whereas map values /are/ zero initialized upon
      their initial allocation and thus cannot leak any prior data in either
      domain. In the non-speculative domain, the verifier ensures that every
      stack slot read must have a prior stack slot write by the BPF program
      to avoid such data leaking issue.
      
      However, this is not enough: for example, when the pointer arithmetic
      operation moves the stack pointer from the last valid stack offset to
      the first valid offset, the sanitation logic allows for any intermediate
      offsets during speculative execution, which could then be used to
      extract any restricted stack content via side-channel.
      
      Given for unprivileged stack pointer arithmetic the use of unknown
      but bounded scalars is generally forbidden, we can simply turn the
      register-based arithmetic operation into an immediate-based arithmetic
      operation without the need for masking. This also gives the benefit
      of reducing the needed instructions for the operation. Given after
      the work in 7fedb63a
      
       ("bpf: Tighten speculative pointer arithmetic
      mask"), the aux->alu_limit already holds the final immediate value for
      the offset register with the known scalar. Thus, a simple mov of the
      immediate to AX register with using AX as the source for the original
      instruction is sufficient and possible now in this case.
      
      Reported-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Reviewed-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Reviewed-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      801c6058
    • Daniel Borkmann's avatar
      bpf: Fix masking negation logic upon negative dst register · b9b34ddb
      Daniel Borkmann authored
      The negation logic for the case where the off_reg is sitting in the
      dst register is not correct given then we cannot just invert the add
      to a sub or vice versa. As a fix, perform the final bitwise and-op
      unconditionally into AX from the off_reg, then move the pointer from
      the src to dst and finally use AX as the source for the original
      pointer arithmetic operation such that the inversion yields a correct
      result. The single non-AX mov in between is possible given constant
      blinding is retaining it as it's not an immediate based operation.
      
      Fixes: 979d63d5
      
       ("bpf: prevent out of bounds speculation on pointer arithmetic")
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Reviewed-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Reviewed-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b9b34ddb
  7. May 01, 2021