Skip to content
  1. Feb 05, 2024
  2. Feb 04, 2024
  3. Feb 03, 2024
    • Zhipeng Lu's avatar
      octeontx2-pf: Fix a memleak otx2_sq_init · b09b58e3
      Zhipeng Lu authored
      
      
      When qmem_alloc and pfvf->hw_ops->sq_aq_init fails, sq->sg should be
      freed to prevent memleak.
      
      Fixes: c9c12d33 ("octeontx2-pf: Add support for PTP clock")
      Signed-off-by: default avatarZhipeng Lu <alexious@zju.edu.cn>
      Acked-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b09b58e3
    • Zhipeng Lu's avatar
      atm: idt77252: fix a memleak in open_card_ubr0 · f3616173
      Zhipeng Lu authored
      
      
      When alloc_scq fails, card->vcs[0] (i.e. vc) should be freed. Otherwise,
      in the following call chain:
      
      idt77252_init_one
        |-> idt77252_dev_open
              |-> open_card_ubr0
                    |-> alloc_scq [failed]
        |-> deinit_card
              |-> vfree(card->vcs);
      
      card->vcs is freed and card->vcs[0] is leaked.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarZhipeng Lu <alexious@zju.edu.cn>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f3616173
    • Antoine Tenart's avatar
      tunnels: fix out of bounds access when building IPv6 PMTU error · d75abeec
      Antoine Tenart authored
      
      
      If the ICMPv6 error is built from a non-linear skb we get the following
      splat,
      
        BUG: KASAN: slab-out-of-bounds in do_csum+0x220/0x240
        Read of size 4 at addr ffff88811d402c80 by task netperf/820
        CPU: 0 PID: 820 Comm: netperf Not tainted 6.8.0-rc1+ #543
        ...
         kasan_report+0xd8/0x110
         do_csum+0x220/0x240
         csum_partial+0xc/0x20
         skb_tunnel_check_pmtu+0xeb9/0x3280
         vxlan_xmit_one+0x14c2/0x4080
         vxlan_xmit+0xf61/0x5c00
         dev_hard_start_xmit+0xfb/0x510
         __dev_queue_xmit+0x7cd/0x32a0
         br_dev_queue_push_xmit+0x39d/0x6a0
      
      Use skb_checksum instead of csum_partial who cannot deal with non-linear
      SKBs.
      
      Fixes: 4cb47a86 ("tunnels: PMTU discovery support for directly bridged IP packets")
      Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d75abeec
    • Gerhard Engleder's avatar
      tsnep: Fix mapping for zero copy XDP_TX action · d7f5fb33
      Gerhard Engleder authored
      
      
      For XDP_TX action xdp_buff is converted to xdp_frame. The conversion is
      done by xdp_convert_buff_to_frame(). The memory type of the resulting
      xdp_frame depends on the memory type of the xdp_buff. For page pool
      based xdp_buff it produces xdp_frame with memory type
      MEM_TYPE_PAGE_POOL. For zero copy XSK pool based xdp_buff it produces
      xdp_frame with memory type MEM_TYPE_PAGE_ORDER0.
      
      tsnep_xdp_xmit_back() is not prepared for that and uses always the page
      pool buffer type TSNEP_TX_TYPE_XDP_TX. This leads to invalid mappings
      and the transmission of undefined data.
      
      Improve tsnep_xdp_xmit_back() to use the generic buffer type
      TSNEP_TX_TYPE_XDP_NDO for zero copy XDP_TX.
      
      Fixes: 3fc23339 ("tsnep: Add XDP socket zero-copy RX support")
      Signed-off-by: default avatarGerhard Engleder <gerhard@engleder-embedded.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d7f5fb33
    • Jakub Kicinski's avatar
      Merge branch 'selftests-net-more-fixes' · 010e03db
      Jakub Kicinski authored
      Paolo Abeni says:
      
      ====================
      selftests: net: more fixes
      
      Another small bunch of fixes, addressing issues outlined by the
      netdev CI.
      
      The first 2 patches are just rebased.
      
      The following 2 are new fixes, for even more problems that surfaced
      meanwhile.
      ====================
      
      Link: https://lore.kernel.org/r/cover.1706812005.git.pabeni@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      010e03db
    • Paolo Abeni's avatar
      selftests: net: avoid just another constant wait · 691bb4e4
      Paolo Abeni authored
      
      
      Using hard-coded constant timeout to wait for some expected
      event is deemed to fail sooner or later, especially in slow
      env.
      
      Our CI has spotted another of such race:
         # TEST: ipv6: cleanup of cached exceptions - nexthop objects          [FAIL]
         #   can't delete veth device in a timely manner, PMTU dst likely leaked
      
      Replace the crude sleep with a loop looking for the expected condition
      at low interval for a much longer range.
      
      Fixes: b3cc4f8a ("selftests: pmtu: add explicit tests for PMTU exceptions cleanup")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/fd5c745e9bb665b724473af6a9373a8c2a62b247.1706812005.git.pabeni@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      691bb4e4
    • Paolo Abeni's avatar
      selftests: net: fix tcp listener handling in pmtu.sh · e71e016a
      Paolo Abeni authored
      
      
      The pmtu.sh test uses a few TCP listener in a problematic way:
      It hard-codes a constant timeout to wait for the listener starting-up
      in background. That introduces unneeded latency and on very slow and
      busy host it can fail.
      
      Additionally the test starts again the same listener in the same
      namespace on the same port, just after the previous connection
      completed. Fast host can attempt starting the new server before the
      old one really closed the socket.
      
      Address the issues using the wait_local_port_listen helper and
      explicitly waiting for the background listener process exit.
      
      Fixes: 136a1b43 ("selftests: net: test vxlan pmtu exceptions with tcp")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/f8e8f6d44427d8c45e9f6a71ee1a321047452087.1706812005.git.pabeni@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e71e016a
    • Paolo Abeni's avatar
      selftests: net: fix setup_ns usage in rtnetlink.sh · d75df752
      Paolo Abeni authored
      
      
      The setup_ns helper marks the testns global variable as
      readonly. Later attempts to set such variable are unsuccessful,
      causing a couple test failures.
      
      Avoid completely the variable re-initialization and let the
      function access the global value.
      
      Fixes: e9ce7ede ("selftests: rtnetlink: use setup_ns in bonding test")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/6e7c937c8ff73ca52a21a4a536a13a76ec0173a8.1706812005.git.pabeni@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d75df752
    • Paolo Abeni's avatar
      selftests: net: cut more slack for gro fwd tests. · cb9f4a30
      Paolo Abeni authored
      
      
      The udpgro_fwd.sh self-tests are somewhat unstable. There are
      a few timing constraints the we struggle to meet on very slow
      environments.
      
      Instead of skipping the whole tests in such envs, increase the
      test resilience WRT very slow hosts: increase the inter-packets
      timeouts, avoid resetting the counters every second and finally
      disable reduce the background traffic noise.
      
      Tested with:
      
      for I in $(seq 1 100); do
      	./tools/testing/selftests/kselftest_install/run_kselftest.sh \
      		-t net:udpgro_fwd.sh || exit -1
      done
      
      in a slow environment.
      
      Fixes: a062260a ("selftests: net: add UDP GRO forwarding self-tests")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/f4b6b11064a0d39182a9ae6a853abae3e9b4426a.1706812005.git.pabeni@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      cb9f4a30
    • Ivan Vecera's avatar
      net: atlantic: Fix DMA mapping for PTP hwts ring · 2e7d3b67
      Ivan Vecera authored
      
      
      Function aq_ring_hwts_rx_alloc() maps extra AQ_CFG_RXDS_DEF bytes
      for PTP HWTS ring but then generic aq_ring_free() does not take this
      into account.
      Create and use a specific function to free HWTS ring to fix this
      issue.
      
      Trace:
      [  215.351607] ------------[ cut here ]------------
      [  215.351612] DMA-API: atlantic 0000:4b:00.0: device driver frees DMA memory with different size [device address=0x00000000fbdd0000] [map size=34816 bytes] [unmap size=32768 bytes]
      [  215.351635] WARNING: CPU: 33 PID: 10759 at kernel/dma/debug.c:988 check_unmap+0xa6f/0x2360
      ...
      [  215.581176] Call Trace:
      [  215.583632]  <TASK>
      [  215.585745]  ? show_trace_log_lvl+0x1c4/0x2df
      [  215.590114]  ? show_trace_log_lvl+0x1c4/0x2df
      [  215.594497]  ? debug_dma_free_coherent+0x196/0x210
      [  215.599305]  ? check_unmap+0xa6f/0x2360
      [  215.603147]  ? __warn+0xca/0x1d0
      [  215.606391]  ? check_unmap+0xa6f/0x2360
      [  215.610237]  ? report_bug+0x1ef/0x370
      [  215.613921]  ? handle_bug+0x3c/0x70
      [  215.617423]  ? exc_invalid_op+0x14/0x50
      [  215.621269]  ? asm_exc_invalid_op+0x16/0x20
      [  215.625480]  ? check_unmap+0xa6f/0x2360
      [  215.629331]  ? mark_lock.part.0+0xca/0xa40
      [  215.633445]  debug_dma_free_coherent+0x196/0x210
      [  215.638079]  ? __pfx_debug_dma_free_coherent+0x10/0x10
      [  215.643242]  ? slab_free_freelist_hook+0x11d/0x1d0
      [  215.648060]  dma_free_attrs+0x6d/0x130
      [  215.651834]  aq_ring_free+0x193/0x290 [atlantic]
      [  215.656487]  aq_ptp_ring_free+0x67/0x110 [atlantic]
      ...
      [  216.127540] ---[ end trace 6467e5964dd2640b ]---
      [  216.132160] DMA-API: Mapped at:
      [  216.132162]  debug_dma_alloc_coherent+0x66/0x2f0
      [  216.132165]  dma_alloc_attrs+0xf5/0x1b0
      [  216.132168]  aq_ring_hwts_rx_alloc+0x150/0x1f0 [atlantic]
      [  216.132193]  aq_ptp_ring_alloc+0x1bb/0x540 [atlantic]
      [  216.132213]  aq_nic_init+0x4a1/0x760 [atlantic]
      
      Fixes: 94ad9455 ("net: aquantia: add PTP rings infrastructure")
      Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Link: https://lore.kernel.org/r/20240201094752.883026-1-ivecera@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      2e7d3b67
    • Eric Dumazet's avatar
      netdevsim: avoid potential loop in nsim_dev_trap_report_work() · ba5e1272
      Eric Dumazet authored
      
      
      Many syzbot reports include the following trace [1]
      
      If nsim_dev_trap_report_work() can not grab the mutex,
      it should rearm itself at least one jiffie later.
      
      [1]
      Sending NMI from CPU 1 to CPUs 0:
      NMI backtrace for cpu 0
      CPU: 0 PID: 32383 Comm: kworker/0:2 Not tainted 6.8.0-rc2-syzkaller-00031-g861c0981648f #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
      Workqueue: events nsim_dev_trap_report_work
       RIP: 0010:bytes_is_nonzero mm/kasan/generic.c:89 [inline]
       RIP: 0010:memory_is_nonzero mm/kasan/generic.c:104 [inline]
       RIP: 0010:memory_is_poisoned_n mm/kasan/generic.c:129 [inline]
       RIP: 0010:memory_is_poisoned mm/kasan/generic.c:161 [inline]
       RIP: 0010:check_region_inline mm/kasan/generic.c:180 [inline]
       RIP: 0010:kasan_check_range+0x101/0x190 mm/kasan/generic.c:189
      Code: 07 49 39 d1 75 0a 45 3a 11 b8 01 00 00 00 7c 0b 44 89 c2 e8 21 ed ff ff 83 f0 01 5b 5d 41 5c c3 48 85 d2 74 4f 48 01 ea eb 09 <48> 83 c0 01 48 39 d0 74 41 80 38 00 74 f2 eb b6 41 bc 08 00 00 00
      RSP: 0018:ffffc90012dcf998 EFLAGS: 00000046
      RAX: fffffbfff258af1e RBX: fffffbfff258af1f RCX: ffffffff8168eda3
      RDX: fffffbfff258af1f RSI: 0000000000000004 RDI: ffffffff92c578f0
      RBP: fffffbfff258af1e R08: 0000000000000000 R09: fffffbfff258af1e
      R10: ffffffff92c578f3 R11: ffffffff8acbcbc0 R12: 0000000000000002
      R13: ffff88806db38400 R14: 1ffff920025b9f42 R15: ffffffff92c578e8
      FS:  0000000000000000(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 000000c00994e078 CR3: 000000002c250000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <NMI>
       </NMI>
       <TASK>
        instrument_atomic_read include/linux/instrumented.h:68 [inline]
        atomic_read include/linux/atomic/atomic-instrumented.h:32 [inline]
        queued_spin_is_locked include/asm-generic/qspinlock.h:57 [inline]
        debug_spin_unlock kernel/locking/spinlock_debug.c:101 [inline]
        do_raw_spin_unlock+0x53/0x230 kernel/locking/spinlock_debug.c:141
        __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:150 [inline]
        _raw_spin_unlock_irqrestore+0x22/0x70 kernel/locking/spinlock.c:194
        debug_object_activate+0x349/0x540 lib/debugobjects.c:726
        debug_work_activate kernel/workqueue.c:578 [inline]
        insert_work+0x30/0x230 kernel/workqueue.c:1650
        __queue_work+0x62e/0x11d0 kernel/workqueue.c:1802
        __queue_delayed_work+0x1bf/0x270 kernel/workqueue.c:1953
        queue_delayed_work_on+0x106/0x130 kernel/workqueue.c:1989
        queue_delayed_work include/linux/workqueue.h:563 [inline]
        schedule_delayed_work include/linux/workqueue.h:677 [inline]
        nsim_dev_trap_report_work+0x9c0/0xc80 drivers/net/netdevsim/dev.c:842
        process_one_work+0x886/0x15d0 kernel/workqueue.c:2633
        process_scheduled_works kernel/workqueue.c:2706 [inline]
        worker_thread+0x8b9/0x1290 kernel/workqueue.c:2787
        kthread+0x2c6/0x3a0 kernel/kthread.c:388
        ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
        ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242
       </TASK>
      
      Fixes: 012ec02a ("netdevsim: convert driver to use unlocked devlink API during init/fini")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Link: https://lore.kernel.org/r/20240201175324.3752746-1-edumazet@google.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      ba5e1272
  4. Feb 02, 2024