1. 09 Jun, 2022 16 commits
  2. 08 Jun, 2022 17 commits
  3. 07 Jun, 2022 7 commits
    • Olivier Matz's avatar
      ixgbe: fix unexpected VLAN Rx in promisc mode on VF · 7bb0fb7c
      Olivier Matz authored
      When the promiscuous mode is enabled on a VF, the IXGBE_VMOLR_VPE
      bit (VLAN Promiscuous Enable) is set. This means that the VF will
      receive packets whose VLAN is not the same than the VLAN of the VF.
      
      For instance, in this situation:
      
      ┌────────┐    ┌────────┐    ┌────────┐
      │        │    │        │    │        │
      │        │    │        │    │        │
      │     VF0├────┤VF1  VF2├────┤VF3     │
      │        │    │        │    │        │
      └────────┘    └────────┘    └────────┘
         VM1           VM2           VM3
      
      vf 0:  vlan 1000
      vf 1:  vlan 1000
      vf 2:  vlan 1001
      vf 3:  vlan 1001
      
      If we tcpdump on VF3, we see all the packets, even those transmitted
      on vlan 1000.
      
      This behavior prevents to bridge VF1 and VF2 in VM2, because it will
      create a loop: packets transmitted on VF1 will be received by VF2 and
      vice-versa, and bridged again through the software bridge.
      
      This patch remove the activation of VLAN Promiscuous when a VF enables
      the promiscuous mode. However, the IXGBE_VMOLR_UPE bit (Unicast
      Promiscuous) is kept, so that a VF receives all packets that has the
      same VLAN, whatever the destination MAC address.
      
      Fixes: 8443c1a4 ("ixgbe, ixgbevf: Add new mbox API xcast mode")
      Cc: stable@vger.kernel.org
      Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarOlivier Matz <olivier.matz@6wind.com>
      Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      7bb0fb7c
    • Olivier Matz's avatar
      ixgbe: fix bcast packets Rx on VF after promisc removal · 803e9895
      Olivier Matz authored
      After a VF requested to remove the promiscuous flag on an interface, the
      broadcast packets are not received anymore. This breaks some protocols
      like ARP.
      
      In ixgbe_update_vf_xcast_mode(), we should keep the IXGBE_VMOLR_BAM
      bit (Broadcast Accept) on promiscuous removal.
      
      This flag is already set by default in ixgbe_set_vmolr() on VF reset.
      
      Fixes: 8443c1a4 ("ixgbe, ixgbevf: Add new mbox API xcast mode")
      Cc: stable@vger.kernel.org
      Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarOlivier Matz <olivier.matz@6wind.com>
      Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      803e9895
    • Toke Høiland-Jørgensen's avatar
      selftests/bpf: Add selftest for calling global functions from freplace · 2cf7b7ff
      Toke Høiland-Jørgensen authored
      Add a selftest that calls a global function with a context object parameter
      from an freplace function to check that the program context type is
      correctly converted to the freplace target when fetching the context type
      from the kernel BTF.
      
      v2:
      - Trim includes
      - Get rid of global function
      - Use __noinline
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Link: https://lore.kernel.org/r/20220606075253.28422-2-toke@redhat.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      2cf7b7ff
    • Toke Høiland-Jørgensen's avatar
      bpf: Fix calling global functions from BPF_PROG_TYPE_EXT programs · f858c2b2
      Toke Høiland-Jørgensen authored
      The verifier allows programs to call global functions as long as their
      argument types match, using BTF to check the function arguments. One of the
      allowed argument types to such global functions is PTR_TO_CTX; however the
      check for this fails on BPF_PROG_TYPE_EXT functions because the verifier
      uses the wrong type to fetch the vmlinux BTF ID for the program context
      type. This failure is seen when an XDP program is loaded using
      libxdp (which loads it as BPF_PROG_TYPE_EXT and attaches it to a global XDP
      type program).
      
      Fix the issue by passing in the target program type instead of the
      BPF_PROG_TYPE_EXT type to bpf_prog_get_ctx() when checking function
      argument compatibility.
      
      The first Fixes tag refers to the latest commit that touched the code in
      question, while the second one points to the code that first introduced
      the global function call verification.
      
      v2:
      - Use resolve_prog_type()
      
      Fixes: 3363bd0c ("bpf: Extend kfunc with PTR_TO_CTX, PTR_TO_MEM argument support")
      Fixes: 51c39bb1 ("bpf: Introduce function-by-function verification")
      Reported-by: default avatarSimon Sundberg <simon.sundberg@kau.se>
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Link: https://lore.kernel.org/r/20220606075253.28422-1-toke@redhat.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f858c2b2
    • Dan Carpenter's avatar
      bpf: Use safer kvmalloc_array() where possible · fd58f7df
      Dan Carpenter authored
      The kvmalloc_array() function is safer because it has a check for
      integer overflows.  These sizes come from the user and I was not
      able to see any bounds checking so an integer overflow seems like a
      realistic concern.
      
      Fixes: 0dcac272 ("bpf: Add multi kprobe link")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/Yo9VRVMeHbALyjUH@kiliSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      fd58f7df
    • Eric Dumazet's avatar
      bpf, arm64: Clear prog->jited_len along prog->jited · 10f3b29c
      Eric Dumazet authored
      syzbot reported an illegal copy_to_user() attempt
      from bpf_prog_get_info_by_fd() [1]
      
      There was no repro yet on this bug, but I think
      that commit 0aef499f ("mm/usercopy: Detect vmalloc overruns")
      is exposing a prior bug in bpf arm64.
      
      bpf_prog_get_info_by_fd() looks at prog->jited_len
      to determine if the JIT image can be copied out to user space.
      
      My theory is that syzbot managed to get a prog where prog->jited_len
      has been set to 43, while prog->bpf_func has ben cleared.
      
      It is not clear why copy_to_user(uinsns, NULL, ulen) is triggering
      this particular warning.
      
      I thought find_vma_area(NULL) would not find a vm_struct.
      As we do not hold vmap_area_lock spinlock, it might be possible
      that the found vm_struct was garbage.
      
      [1]
      usercopy: Kernel memory exposure attempt detected from vmalloc (offset 792633534417210172, size 43)!
      kernel BUG at mm/usercopy.c:101!
      Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 0 PID: 25002 Comm: syz-executor.1 Not tainted 5.18.0-syzkaller-10139-g8291eaaf #0
      Hardware name: linux,dummy-virt (DT)
      pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      pc : usercopy_abort+0x90/0x94 mm/usercopy.c:101
      lr : usercopy_abort+0x90/0x94 mm/usercopy.c:89
      sp : ffff80000b773a20
      x29: ffff80000b773a30 x28: faff80000b745000 x27: ffff80000b773b48
      x26: 0000000000000000 x25: 000000000000002b x24: 0000000000000000
      x23: 00000000000000e0 x22: ffff80000b75db67 x21: 0000000000000001
      x20: 000000000000002b x19: ffff80000b75db3c x18: 00000000fffffffd
      x17: 2820636f6c6c616d x16: 76206d6f72662064 x15: 6574636574656420
      x14: 74706d6574746120 x13: 2129333420657a69 x12: 73202c3237313031
      x11: 3237313434333533 x10: 3336323937207465 x9 : 657275736f707865
      x8 : ffff80000a30c550 x7 : ffff80000b773830 x6 : ffff80000b773830
      x5 : 0000000000000000 x4 : ffff00007fbbaa10 x3 : 0000000000000000
      x2 : 0000000000000000 x1 : f7ff000028fc0000 x0 : 0000000000000064
      Call trace:
       usercopy_abort+0x90/0x94 mm/usercopy.c:89
       check_heap_object mm/usercopy.c:186 [inline]
       __check_object_size mm/usercopy.c:252 [inline]
       __check_object_size+0x198/0x36c mm/usercopy.c:214
       check_object_size include/linux/thread_info.h:199 [inline]
       check_copy_size include/linux/thread_info.h:235 [inline]
       copy_to_user include/linux/uaccess.h:159 [inline]
       bpf_prog_get_info_by_fd.isra.0+0xf14/0xfdc kernel/bpf/syscall.c:3993
       bpf_obj_get_info_by_fd+0x12c/0x510 kernel/bpf/syscall.c:4253
       __sys_bpf+0x900/0x2150 kernel/bpf/syscall.c:4956
       __do_sys_bpf kernel/bpf/syscall.c:5021 [inline]
       __se_sys_bpf kernel/bpf/syscall.c:5019 [inline]
       __arm64_sys_bpf+0x28/0x40 kernel/bpf/syscall.c:5019
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x48/0x114 arch/arm64/kernel/syscall.c:52
       el0_svc_common.constprop.0+0x44/0xec arch/arm64/kernel/syscall.c:142
       do_el0_svc+0xa0/0xc0 arch/arm64/kernel/syscall.c:206
       el0_svc+0x44/0xb0 arch/arm64/kernel/entry-common.c:624
       el0t_64_sync_handler+0x1ac/0x1b0 arch/arm64/kernel/entry-common.c:642
       el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:581
      Code: aa0003e3 d00038c0 91248000 97fff65f (d4210000)
      
      Fixes: db496944 ("bpf: arm64: add JIT support for multi-function programs")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20220531215113.1100754-1-eric.dumazet@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      10f3b29c
    • Lina Wang's avatar
      selftests net: fix bpf build error · cf67838c
      Lina Wang authored
      bpf_helpers.h has been moved to tools/lib/bpf since 5.10, so add more
      including path.
      
      Fixes: edae34a3 ("selftests net: add UDP GRO fraglist + bpf self-tests")
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Signed-off-by: default avatarLina Wang <lina.wang@mediatek.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/20220606064517.8175-1-lina.wang@mediatek.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      cf67838c