Skip to content
  1. Apr 08, 2021
  2. Apr 07, 2021
  3. Apr 06, 2021
  4. Apr 03, 2021
  5. Apr 02, 2021
    • David S. Miller's avatar
      Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue · 9256ce33
      David S. Miller authored
      
      
      Tony Nguyen says:
      
      ====================
      Intel Wired LAN Driver Updates 2021-04-01
      
      This series contains updates to i40e driver only.
      
      Arkadiusz fixes warnings for inconsistent indentation.
      
      Magnus fixes an issue on xsk receive where single packets over time
      are batched rather than received immediately.
      
      Eryk corrects warnings and reporting of veb-stats.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9256ce33
    • David S. Miller's avatar
      Merge branch 'mptcp-deadlock' · efd2e92d
      David S. Miller authored
      
      
      Paolo Abeni says:
      
      ====================
      mptcp: mptcp: fix deadlock in mptcp{,6}_release
      
      syzkaller has reported a few deadlock triggered by
      mptcp{,6}_release.
      
      These patches address the issue in the easy way - blocking
      the relevant, multicast related, sockopt options on MPTCP
      sockets.
      
      Note that later on net-next we are going to revert patch 1/2,
      as a part of a larger MPTCP sockopt implementation refactor
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      efd2e92d
    • Paolo Abeni's avatar
      mptcp: revert "mptcp: provide subflow aware release function" · 0a3cc579
      Paolo Abeni authored
      This change reverts commit ad98dd37 ("mptcp: provide subflow aware
      release function"). The latter introduced a deadlock spotted by
      syzkaller and is not needed anymore after the previous commit.
      
      Fixes: ad98dd37
      
       ("mptcp: provide subflow aware release function")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0a3cc579
    • Paolo Abeni's avatar
      mptcp: forbit mcast-related sockopt on MPTCP sockets · 86581852
      Paolo Abeni authored
      Unrolling mcast state at msk dismantel time is bug prone, as
      syzkaller reported:
      
      ======================================================
      WARNING: possible circular locking dependency detected
      5.11.0-syzkaller #0 Not tainted
      ------------------------------------------------------
      syz-executor905/8822 is trying to acquire lock:
      ffffffff8d678fe8 (rtnl_mutex){+.+.}-{3:3}, at: ipv6_sock_mc_close+0xd7/0x110 net/ipv6/mcast.c:323
      
      but task is already holding lock:
      ffff888024390120 (sk_lock-AF_INET6){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1600 [inline]
      ffff888024390120 (sk_lock-AF_INET6){+.+.}-{0:0}, at: mptcp6_release+0x57/0x130 net/mptcp/protocol.c:3507
      
      which lock already depends on the new lock.
      
      Instead we can simply forbit any mcast-related setsockopt
      
      Fixes: 717e79c8
      
       ("mptcp: Add setsockopt()/getsockopt() socket operations")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      86581852
    • Pavel Skripkin's avatar
      drivers: net: fix memory leak in peak_usb_create_dev · a0b96b4a
      Pavel Skripkin authored
      
      
      syzbot reported memory leak in peak_usb.
      The problem was in case of failure after calling
      ->dev_init()[2] in peak_usb_create_dev()[1]. The data
      allocated int dev_init() wasn't freed, so simple
      ->dev_free() call fix this problem.
      
      backtrace:
          [<0000000079d6542a>] kmalloc include/linux/slab.h:552 [inline]
          [<0000000079d6542a>] kzalloc include/linux/slab.h:682 [inline]
          [<0000000079d6542a>] pcan_usb_fd_init+0x156/0x210 drivers/net/can/usb/peak_usb/pcan_usb_fd.c:868   [2]
          [<00000000c09f9057>] peak_usb_create_dev drivers/net/can/usb/peak_usb/pcan_usb_core.c:851 [inline] [1]
          [<00000000c09f9057>] peak_usb_probe+0x389/0x490 drivers/net/can/usb/peak_usb/pcan_usb_core.c:949
      
      Reported-by: default avatar <syzbot+91adee8d9ebb9193d22d@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a0b96b4a
    • Norman Maurer's avatar
      net: udp: Add support for getsockopt(..., ..., UDP_GRO, ..., ...); · 98184612
      Norman Maurer authored
      Support for UDP_GRO was added in the past but the implementation for
      getsockopt was missed which did lead to an error when we tried to
      retrieve the setting for UDP_GRO. This patch adds the missing switch
      case for UDP_GRO
      
      Fixes: e20cf8d3
      
       ("udp: implement GRO for plain UDP sockets.")
      Signed-off-by: default avatarNorman Maurer <norman_maurer@apple.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      98184612
    • Pavel Skripkin's avatar
      drivers: net: fix memory leak in atusb_probe · 6b9fbe16
      Pavel Skripkin authored
      
      
      syzbot reported memory leak in atusb_probe()[1].
      The problem was in atusb_alloc_urbs().
      Since urb is anchored, we need to release the reference
      to correctly free the urb
      
      backtrace:
          [<ffffffff82ba0466>] kmalloc include/linux/slab.h:559 [inline]
          [<ffffffff82ba0466>] usb_alloc_urb+0x66/0xe0 drivers/usb/core/urb.c:74
          [<ffffffff82ad3888>] atusb_alloc_urbs drivers/net/ieee802154/atusb.c:362 [inline][2]
          [<ffffffff82ad3888>] atusb_probe+0x158/0x820 drivers/net/ieee802154/atusb.c:1038 [1]
      
      Reported-by: default avatar <syzbot+28a246747e0a465127f3@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6b9fbe16
    • Alexei Starovoitov's avatar
      Merge branch 'AF_XDP Socket Creation Fixes' · 6dcc4e38
      Alexei Starovoitov authored
      
      
      Ciara Loftus says:
      
      ====================
      
      This series fixes some issues around socket creation for AF_XDP.
      
      Patch 1 fixes a potential NULL pointer dereference in
      xsk_socket__create_shared.
      
      Patch 2 ensures that the umem passed to xsk_socket__create(_shared)
      remains unchanged in event of failure.
      
      Patch 3 makes it possible for xsk_socket__create(_shared) to
      succeed even if the rx and tx XDP rings have already been set up by
      introducing a new fields to struct xsk_umem which represent the ring
      setup status for the xsk which shares the fd with the umem.
      
      v3->v4:
      * Reduced nesting in xsk_put_ctx as suggested by Alexei.
      * Use bools instead of a u8 and flags to represent the
        ring setup status as suggested by Björn.
      
      v2->v3:
      * Instead of ignoring the return values of the setsockopt calls, introduce
        a new flag to determine whether or not to call them based on the ring
        setup status as suggested by Alexei.
      
      v1->v2:
      * Simplified restoring the _save pointers as suggested by Magnus.
      * Fixed the condition which determines whether to unmap umem rings
       when socket create fails.
      
      ====================
      
      Acked-by: default avatarBjörn Töpel <bjorn@kernel.org>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      6dcc4e38
    • Ciara Loftus's avatar
      libbpf: Only create rx and tx XDP rings when necessary · ca7a83e2
      Ciara Loftus authored
      Prior to this commit xsk_socket__create(_shared) always attempted to create
      the rx and tx rings for the socket. However this causes an issue when the
      socket being setup is that which shares the fd with the UMEM. If a
      previous call to this function failed with this socket after the rings were
      set up, a subsequent call would always fail because the rings are not torn
      down after the first call and when we try to set them up again we encounter
      an error because they already exist. Solve this by remembering whether the
      rings were set up by introducing new bools to struct xsk_umem which
      represent the ring setup status and using them to determine whether or
      not to set up the rings.
      
      Fixes: 1cad0788
      
       ("libbpf: add support for using AF_XDP sockets")
      Signed-off-by: default avatarCiara Loftus <ciara.loftus@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210331061218.1647-4-ciara.loftus@intel.com
      ca7a83e2
    • Ciara Loftus's avatar
      libbpf: Restore umem state after socket create failure · 43f1bc1e
      Ciara Loftus authored
      If the call to xsk_socket__create fails, the user may want to retry the
      socket creation using the same umem. Ensure that the umem is in the
      same state on exit if the call fails by:
      1. ensuring the umem _save pointers are unmodified.
      2. not unmapping the set of umem rings that were set up with the umem
      during xsk_umem__create, since those maps existed before the call to
      xsk_socket__create and should remain in tact even in the event of
      failure.
      
      Fixes: 2f6324a3
      
       ("libbpf: Support shared umems between queues and devices")
      Signed-off-by: default avatarCiara Loftus <ciara.loftus@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210331061218.1647-3-ciara.loftus@intel.com
      43f1bc1e
    • Ciara Loftus's avatar
      libbpf: Ensure umem pointer is non-NULL before dereferencing · df662016
      Ciara Loftus authored
      Calls to xsk_socket__create dereference the umem to access the
      fill_save and comp_save pointers. Make sure the umem is non-NULL
      before doing this.
      
      Fixes: 2f6324a3
      
       ("libbpf: Support shared umems between queues and devices")
      Signed-off-by: default avatarCiara Loftus <ciara.loftus@intel.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Link: https://lore.kernel.org/bpf/20210331061218.1647-2-ciara.loftus@intel.com
      df662016
    • Lorenz Bauer's avatar
      bpf: program: Refuse non-O_RDWR flags in BPF_OBJ_GET · d37300ed
      Lorenz Bauer authored
      
      
      As for bpf_link, refuse creating a non-O_RDWR fd. Since program fds
      currently don't allow modifications this is a precaution, not a
      straight up bug fix.
      
      Signed-off-by: default avatarLorenz Bauer <lmb@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20210326160501.46234-2-lmb@cloudflare.com
      d37300ed
    • Lorenz Bauer's avatar
      bpf: link: Refuse non-O_RDWR flags in BPF_OBJ_GET · 25fc94b2
      Lorenz Bauer authored
      Invoking BPF_OBJ_GET on a pinned bpf_link checks the path access
      permissions based on file_flags, but the returned fd ignores flags.
      This means that any user can acquire a "read-write" fd for a pinned
      link with mode 0664 by invoking BPF_OBJ_GET with BPF_F_RDONLY in
      file_flags. The fd can be used to invoke BPF_LINK_DETACH, etc.
      
      Fix this by refusing non-O_RDWR flags in BPF_OBJ_GET. This works
      because OBJ_GET by default returns a read write mapping and libbpf
      doesn't expose a way to override this behaviour for programs
      and links.
      
      Fixes: 70ed506c
      
       ("bpf: Introduce pinnable bpf_link abstraction")
      Signed-off-by: default avatarLorenz Bauer <lmb@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20210326160501.46234-1-lmb@cloudflare.com
      25fc94b2
    • Dave Marchevsky's avatar
      bpf: Refcount task stack in bpf_get_task_stack · 06ab134c
      Dave Marchevsky authored
      On x86 the struct pt_regs * grabbed by task_pt_regs() points to an
      offset of task->stack. The pt_regs are later dereferenced in
      __bpf_get_stack (e.g. by user_mode() check). This can cause a fault if
      the task in question exits while bpf_get_task_stack is executing, as
      warned by task_stack_page's comment:
      
      * When accessing the stack of a non-current task that might exit, use
      * try_get_task_stack() instead.  task_stack_page will return a pointer
      * that could get freed out from under you.
      
      Taking the comment's advice and using try_get_task_stack() and
      put_task_stack() to hold task->stack refcount, or bail early if it's
      already 0. Incrementing stack_refcount will ensure the task's stack
      sticks around while we're using its data.
      
      I noticed this bug while testing a bpf task iter similar to
      bpf_iter_task_stack in selftests, except mine grabbed user stack, and
      getting intermittent crashes, which resulted in dumps like:
      
        BUG: unable to handle page fault for address: 0000000000003fe0
        \#PF: supervisor read access in kernel mode
        \#PF: error_code(0x0000) - not-present page
        RIP: 0010:__bpf_get_stack+0xd0/0x230
        <snip...>
        Call Trace:
        bpf_prog_0a2be35c092cb190_get_task_stacks+0x5d/0x3ec
        bpf_iter_run_prog+0x24/0x81
        __task_seq_show+0x58/0x80
        bpf_seq_read+0xf7/0x3d0
        vfs_read+0x91/0x140
        ksys_read+0x59/0xd0
        do_syscall_64+0x48/0x120
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: fa28dcb8
      
       ("bpf: Introduce helper bpf_get_task_stack()")
      Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20210401000747.3648767-1-davemarchevsky@fb.com
      06ab134c