Skip to content
Snippets Groups Projects
  1. Jan 23, 2025
    • Artem Chernyshev's avatar
      pktgen: Avoid out-of-bounds access in get_imix_entries · e5d24a70
      Artem Chernyshev authored
      
      [ Upstream commit 76201b59 ]
      
      Passing a sufficient amount of imix entries leads to invalid access to the
      pkt_dev->imix_entries array because of the incorrect boundary check.
      
      UBSAN: array-index-out-of-bounds in net/core/pktgen.c:874:24
      index 20 is out of range for type 'imix_pkt [20]'
      CPU: 2 PID: 1210 Comm: bash Not tainted 6.10.0-rc1 #121
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
      Call Trace:
      <TASK>
      dump_stack_lvl lib/dump_stack.c:117
      __ubsan_handle_out_of_bounds lib/ubsan.c:429
      get_imix_entries net/core/pktgen.c:874
      pktgen_if_write net/core/pktgen.c:1063
      pde_write fs/proc/inode.c:334
      proc_reg_write fs/proc/inode.c:346
      vfs_write fs/read_write.c:593
      ksys_write fs/read_write.c:644
      do_syscall_64 arch/x86/entry/common.c:83
      entry_SYSCALL_64_after_hwframe arch/x86/entry/entry_64.S:130
      
      Found by Linux Verification Center (linuxtesting.org) with SVACE.
      
      Fixes: 52a62f86 ("pktgen: Parse internet mix (imix) input")
      Signed-off-by: default avatarArtem Chernyshev <artem.chernyshev@red-soft.ru>
      [ fp: allow to fill the array completely; minor changelog cleanup ]
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e5d24a70
    • Ilya Maximets's avatar
      openvswitch: fix lockup on tx to unregistering netdev with carrier · ea9e9903
      Ilya Maximets authored
      
      [ Upstream commit 47e55e4b ]
      
      Commit in a fixes tag attempted to fix the issue in the following
      sequence of calls:
      
          do_output
          -> ovs_vport_send
             -> dev_queue_xmit
                -> __dev_queue_xmit
                   -> netdev_core_pick_tx
                      -> skb_tx_hash
      
      When device is unregistering, the 'dev->real_num_tx_queues' goes to
      zero and the 'while (unlikely(hash >= qcount))' loop inside the
      'skb_tx_hash' becomes infinite, locking up the core forever.
      
      But unfortunately, checking just the carrier status is not enough to
      fix the issue, because some devices may still be in unregistering
      state while reporting carrier status OK.
      
      One example of such device is a net/dummy.  It sets carrier ON
      on start, but it doesn't implement .ndo_stop to set the carrier off.
      And it makes sense, because dummy doesn't really have a carrier.
      Therefore, while this device is unregistering, it's still easy to hit
      the infinite loop in the skb_tx_hash() from the OVS datapath.  There
      might be other drivers that do the same, but dummy by itself is
      important for the OVS ecosystem, because it is frequently used as a
      packet sink for tcpdump while debugging OVS deployments.  And when the
      issue is hit, the only way to recover is to reboot.
      
      Fix that by also checking if the device is running.  The running
      state is handled by the net core during unregistering, so it covers
      unregistering case better, and we don't really need to send packets
      to devices that are not running anyway.
      
      While only checking the running state might be enough, the carrier
      check is preserved.  The running and the carrier states seem disjoined
      throughout the code and different drivers.  And other core functions
      like __dev_direct_xmit() check both before attempting to transmit
      a packet.  So, it seems safer to check both flags in OVS as well.
      
      Fixes: 066b8678 ("net: openvswitch: fix race on port output")
      Reported-by: default avatarFriedrich Weber <f.weber@proxmox.com>
      Closes: https://mail.openvswitch.org/pipermail/ovs-discuss/2025-January/053423.html
      
      
      Signed-off-by: default avatarIlya Maximets <i.maximets@ovn.org>
      Tested-by: default avatarFriedrich Weber <f.weber@proxmox.com>
      Reviewed-by: default avatarAaron Conole <aconole@redhat.com>
      Link: https://patch.msgid.link/20250109122225.4034688-1-i.maximets@ovn.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ea9e9903
    • Michal Luczaj's avatar
      bpf: Fix bpf_sk_select_reuseport() memory leak · d0a3b3d1
      Michal Luczaj authored
      
      [ Upstream commit b3af6092 ]
      
      As pointed out in the original comment, lookup in sockmap can return a TCP
      ESTABLISHED socket. Such TCP socket may have had SO_ATTACH_REUSEPORT_EBPF
      set before it was ESTABLISHED. In other words, a non-NULL sk_reuseport_cb
      does not imply a non-refcounted socket.
      
      Drop sk's reference in both error paths.
      
      unreferenced object 0xffff888101911800 (size 2048):
        comm "test_progs", pid 44109, jiffies 4297131437
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          80 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace (crc 9336483b):
          __kmalloc_noprof+0x3bf/0x560
          __reuseport_alloc+0x1d/0x40
          reuseport_alloc+0xca/0x150
          reuseport_attach_prog+0x87/0x140
          sk_reuseport_attach_bpf+0xc8/0x100
          sk_setsockopt+0x1181/0x1990
          do_sock_setsockopt+0x12b/0x160
          __sys_setsockopt+0x7b/0xc0
          __x64_sys_setsockopt+0x1b/0x30
          do_syscall_64+0x93/0x180
          entry_SYSCALL_64_after_hwframe+0x76/0x7e
      
      Fixes: 64d85290 ("bpf: Allow bpf_map_lookup_elem for SOCKMAP and SOCKHASH")
      Signed-off-by: default avatarMichal Luczaj <mhal@rbox.co>
      Reviewed-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      Link: https://patch.msgid.link/20250110-reuseport-memleak-v1-1-fa1ddab0adfe@rbox.co
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d0a3b3d1
    • Sudheer Kumar Doredla's avatar
      net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field() · 07524817
      Sudheer Kumar Doredla authored
      
      [ Upstream commit 03d120f2 ]
      
      CPSW ALE has 75-bit ALE entries stored across three 32-bit words.
      The cpsw_ale_get_field() and cpsw_ale_set_field() functions support
      ALE field entries spanning up to two words at the most.
      
      The cpsw_ale_get_field() and cpsw_ale_set_field() functions work as
      expected when ALE field spanned across word1 and word2, but fails when
      ALE field spanned across word2 and word3.
      
      For example, while reading the ALE field spanned across word2 and word3
      (i.e. bits 62 to 64), the word3 data shifted to an incorrect position
      due to the index becoming zero while flipping.
      The same issue occurred when setting an ALE entry.
      
      This issue has not been seen in practice but will be an issue in the future
      if the driver supports accessing ALE fields spanning word2 and word3
      
      Fix the methods to handle getting/setting fields spanning up to two words.
      
      Fixes: b685f1a5 ("net: ethernet: ti: cpsw_ale: Fix cpsw_ale_get_field()/cpsw_ale_set_field()")
      Signed-off-by: default avatarSudheer Kumar Doredla <s-doredla@ti.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Reviewed-by: default avatarRoger Quadros <rogerq@kernel.org>
      Reviewed-by: default avatarSiddharth Vadapalli <s-vadapalli@ti.com>
      Link: https://patch.msgid.link/20250108172433.311694-1-s-doredla@ti.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      07524817
  2. Jan 19, 2025
  3. Jan 17, 2025
Loading