1. Jan 19, 2024
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Fix NULL pointer dereference in error path · efeb7dfe
      Ido Schimmel authored
      When calling mlxsw_sp_acl_tcam_region_destroy() from an error path after
      failing to attach the region to an ACL group, we hit a NULL pointer
      dereference upon 'region->group->tcam' [1].
      
      Fix by retrieving the 'tcam' pointer using mlxsw_sp_acl_to_tcam().
      
      [1]
      BUG: kernel NULL pointer dereference, address: 0000000000000000
      [...]
      RIP: 0010:mlxsw_sp_acl_tcam_region_destroy+0xa0/0xd0
      [...]
      Call Trace:
       mlxsw_sp_acl_tcam_vchunk_get+0x88b/0xa20
       mlxsw_sp_acl_tcam_ventry_add+0x25/0xe0
       mlxsw_sp_acl_rule_add+0x47/0x240
       mlxsw_sp_flower_replace+0x1a9/0x1d0
       tc_setup_cb_add+0xdc/0x1c0
       fl_hw_replace_filter+0x146/0x1f0
       fl_change+0xc17/0x1360
       tc_new_tfilter+0x472/0xb90
       rtnetlink_rcv_msg+0x313/0x3b0
       netlink_rcv_skb+0x58/0x100
       netlink_unicast+0x244/0x390
       netlink_sendmsg+0x1e4/0x440
       ____sys_sendmsg+0x164/0x260
       ___sys_sendmsg+0x9a/0xe0
       __sys_sendmsg+0x7a/0xc0
       do_syscall_64+0x40/0xe0
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Fixes: 22a67766
      
       ("mlxsw: spectrum: Introduce ACL core with simple TCAM implementation")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarAmit Cohen <amcohen@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/fb6a4542bbc9fcab5a523802d97059bffbca7126.1705502064.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      efeb7dfe
    • Amit Cohen's avatar
      mlxsw: spectrum_acl_erp: Fix error flow of pool allocation failure · 6d6eeabc
      Amit Cohen authored
      Lately, a bug was found when many TC filters are added - at some point,
      several bugs are printed to dmesg [1] and the switch is crashed with
      segmentation fault.
      
      The issue starts when gen_pool_free() fails because of unexpected
      behavior - a try to free memory which is already freed, this leads to BUG()
      call which crashes the switch and makes many other bugs.
      
      Trying to track down the unexpected behavior led to a bug in eRP code. The
      function mlxsw_sp_acl_erp_table_alloc() gets a pointer to the allocated
      index, sets the value and returns an error code. When gen_pool_alloc()
      fails it returns address 0, we track it and return -ENOBUFS outside, BUT
      the call for gen_pool_alloc() already override the index in erp_table
      structure. This is a problem when such allocation is done as part of
      table expansion. This is not a new table, which will not be used in case
      of allocation failure. We try to expand eRP table and override the
      current index (non-zero) with zero. Then, it leads to an unexpected
      behavior when address 0 is freed twice. Note that address 0 is valid in
      erp_table->base_index and indeed other tables use it.
      
      gen_pool_alloc() fails in case that there is no space left in the
      pre-allocated pool, in our case, the pool is limited to
      ACL_MAX_ERPT_BANK_SIZE, which is read from hardware. When more than max
      erp entries are required, we exceed the limit and return an error, this
      error leads to "Failed to migrate vregion" print.
      
      Fix this by changing erp_table->base_index only in case of a successful
      allocation.
      
      Add a test case for such a scenario. Without this fix it causes
      segmentation fault:
      
      $ TESTS="max_erp_entries_test" ./tc_flower.sh
      ./tc_flower.sh: line 988:  1560 Segmentation fault      tc filter del dev $h2 ingress chain $i protocol ip pref $i handle $j flower &>/dev/null
      
      [1]:
      kernel BUG at lib/genalloc.c:508!
      invalid opcode: 0000 [#1] PREEMPT SMP
      CPU: 6 PID: 3531 Comm: tc Not tainted 6.7.0-rc5-custom-ga6893f479f5e #1
      Hardware name: Mellanox Technologies Ltd. MSN4700/VMOD0010, BIOS 5.11 07/12/2021
      RIP: 0010:gen_pool_free_owner+0xc9/0xe0
      ...
      Call Trace:
       <TASK>
       __mlxsw_sp_acl_erp_table_other_dec+0x70/0xa0 [mlxsw_spectrum]
       mlxsw_sp_acl_erp_mask_destroy+0xf5/0x110 [mlxsw_spectrum]
       objagg_obj_root_destroy+0x18/0x80 [objagg]
       objagg_obj_destroy+0x12c/0x130 [objagg]
       mlxsw_sp_acl_erp_mask_put+0x37/0x50 [mlxsw_spectrum]
       mlxsw_sp_acl_ctcam_region_entry_remove+0x74/0xa0 [mlxsw_spectrum]
       mlxsw_sp_acl_ctcam_entry_del+0x1e/0x40 [mlxsw_spectrum]
       mlxsw_sp_acl_tcam_ventry_del+0x78/0xd0 [mlxsw_spectrum]
       mlxsw_sp_flower_destroy+0x4d/0x70 [mlxsw_spectrum]
       mlxsw_sp_flow_block_cb+0x73/0xb0 [mlxsw_spectrum]
       tc_setup_cb_destroy+0xc1/0x180
       fl_hw_destroy_filter+0x94/0xc0 [cls_flower]
       __fl_delete+0x1ac/0x1c0 [cls_flower]
       fl_destroy+0xc2/0x150 [cls_flower]
       tcf_proto_destroy+0x1a/0xa0
      ...
      mlxsw_spectrum3 0000:07:00.0: Failed to migrate vregion
      mlxsw_spectrum3 0000:07:00.0: Failed to migrate vregion
      
      Fixes: f465261a
      
       ("mlxsw: spectrum_acl: Implement common eRP core")
      Signed-off-by: default avatarAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/4cfca254dfc0e5d283974801a24371c7b6db5989.1705502064.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      6d6eeabc
  2. Jan 18, 2024
  3. Jan 17, 2024
  4. Jan 16, 2024
  5. Jan 15, 2024
  6. Jan 14, 2024
    • Marcin Wojtas's avatar
      MAINTAINERS: eth: mvneta: update entry · c061be1b
      Marcin Wojtas authored
      
      
      Add myself as driver maintainer and restore the maintained status.
      While at it, update the file field to cover mvneta_bm part of the driver.
      
      Signed-off-by: default avatarMarcin Wojtas <marcin.s.wojtas@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c061be1b
    • David S. Miller's avatar
      Merge branch 'tls-splice-hint-fixes' · 5ef7f6b3
      David S. Miller authored
      
      
      John Fastabend says:
      
      ====================
      tls fixes for SPLICE with more hint
      
      Syzbot found a splat where it tried to splice data over a tls socket
      with the more hint and sending greater than the number of frags that
      fit in a msg scatterlist. This resulted in an error where we do not
      correctly send the data when the msg sg is full. The more flag being
      just a hint not a strict contract. This then results in the syzbot
      warning on the next send.
      
      Edward generated an initial patch for this which checked for a full
      msg on entry to the sendmsg hook.  This fixed the WARNING, but didn't
      fully resolve the issue because the full msg_pl scatterlist was never
      sent resulting in a stuck socket. In this series instead avoid the
      situation by forcing the send on the splice that fills the scatterlist.
      
      Also in original thread I mentioned it didn't seem to be enough to
      simply fix the send on full sg problem. That was incorrect and was
      really a bug in my test program that was hanging the test program.
      I had setup a repair socket and wasn't handling it correctly so my
      tester got stuck.
      
      Thanks. Please review. Fix in patch 1 and test in patch 2.
      
      v2: use SPLICE_F_ flag names instead of cryptic 0xe
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5ef7f6b3
    • John Fastabend's avatar
      net: tls, add test to capture error on large splice · 034ea130
      John Fastabend authored
      
      
      syzbot found an error with how splice() is handled with a msg greater
      than 32. This was fixed in previous patch, but lets add a test for
      it to ensure it continues to work.
      
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      034ea130
    • John Fastabend's avatar
      net: tls, fix WARNIING in __sk_msg_free · dc9dfc8d
      John Fastabend authored
      
      
      A splice with MSG_SPLICE_PAGES will cause tls code to use the
      tls_sw_sendmsg_splice path in the TLS sendmsg code to move the user
      provided pages from the msg into the msg_pl. This will loop over the
      msg until msg_pl is full, checked by sk_msg_full(msg_pl). The user
      can also set the MORE flag to hint stack to delay sending until receiving
      more pages and ideally a full buffer.
      
      If the user adds more pages to the msg than can fit in the msg_pl
      scatterlist (MAX_MSG_FRAGS) we should ignore the MORE flag and send
      the buffer anyways.
      
      What actually happens though is we abort the msg to msg_pl scatterlist
      setup and then because we forget to set 'full record' indicating we
      can no longer consume data without a send we fallthrough to the 'continue'
      path which will check if msg_data_left(msg) has more bytes to send and
      then attempts to fit them in the already full msg_pl. Then next
      iteration of sender doing send will encounter a full msg_pl and throw
      the warning in the syzbot report.
      
      To fix simply check if we have a full_record in splice code path and
      if not send the msg regardless of MORE flag.
      
      Reported-and-tested-by: default avatar <syzbot+f2977222e0e95cec15c8@syzkaller.appspotmail.com>
      Reported-by: default avatarEdward Adam Davis <eadavis@qq.com>
      Fixes: fe1e81d4
      
       ("tls/sw: Support MSG_SPLICE_PAGES")
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dc9dfc8d
    • Marc Kleine-Budde's avatar
      net: netdev_queue: netdev_txq_completed_mb(): fix wake condition · 894d7508
      Marc Kleine-Budde authored
      netif_txq_try_stop() uses "get_desc >= start_thrs" as the check for
      the call to netif_tx_start_queue().
      
      Use ">=" i netdev_txq_completed_mb(), too.
      
      Fixes: c91c46de
      
       ("net: provide macros for commonly copied lockless queue stop/wake code")
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      894d7508
    • Eric Dumazet's avatar
      net: add more sanity check in virtio_net_hdr_to_skb() · 9181d6f8
      Eric Dumazet authored
      syzbot/KMSAN reports access to uninitialized data from gso_features_check() [1]
      
      The repro use af_packet, injecting a gso packet and hdrlen == 0.
      
      We could fix the issue making gso_features_check() more careful
      while dealing with NETIF_F_TSO_MANGLEID in fast path.
      
      Or we can make sure virtio_net_hdr_to_skb() pulls minimal network and
      transport headers as intended.
      
      Note that for GSO packets coming from untrusted sources, SKB_GSO_DODGY
      bit forces a proper header validation (and pull) before the packet can
      hit any device ndo_start_xmit(), thus we do not need a precise disection
      at virtio_net_hdr_to_skb() stage.
      
      [1]
      BUG: KMSAN: uninit-value in skb_gso_segment include/net/gso.h:83 [inline]
      BUG: KMSAN: uninit-value in validate_xmit_skb+0x10f2/0x1930 net/core/dev.c:3629
       skb_gso_segment include/net/gso.h:83 [inline]
       validate_xmit_skb+0x10f2/0x1930 net/core/dev.c:3629
       __dev_queue_xmit+0x1eac/0x5130 net/core/dev.c:4341
       dev_queue_xmit include/linux/netdevice.h:3134 [inline]
       packet_xmit+0x9c/0x6b0 net/packet/af_packet.c:276
       packet_snd net/packet/af_packet.c:3087 [inline]
       packet_sendmsg+0x8b1d/0x9f30 net/packet/af_packet.c:3119
       sock_sendmsg_nosec net/socket.c:730 [inline]
       __sock_sendmsg net/socket.c:745 [inline]
       ____sys_sendmsg+0x9c2/0xd60 net/socket.c:2584
       ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2638
       __sys_sendmsg net/socket.c:2667 [inline]
       __do_sys_sendmsg net/socket.c:2676 [inline]
       __se_sys_sendmsg net/socket.c:2674 [inline]
       __x64_sys_sendmsg+0x307/0x490 net/socket.c:2674
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0x44/0x110 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Uninit was created at:
       slab_post_alloc_hook+0x129/0xa70 mm/slab.h:768
       slab_alloc_node mm/slub.c:3478 [inline]
       kmem_cache_alloc_node+0x5e9/0xb10 mm/slub.c:3523
       kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:560
       __alloc_skb+0x318/0x740 net/core/skbuff.c:651
       alloc_skb include/linux/skbuff.h:1286 [inline]
       alloc_skb_with_frags+0xc8/0xbd0 net/core/skbuff.c:6334
       sock_alloc_send_pskb+0xa80/0xbf0 net/core/sock.c:2780
       packet_alloc_skb net/packet/af_packet.c:2936 [inline]
       packet_snd net/packet/af_packet.c:3030 [inline]
       packet_sendmsg+0x70e8/0x9f30 net/packet/af_packet.c:3119
       sock_sendmsg_nosec net/socket.c:730 [inline]
       __sock_sendmsg net/socket.c:745 [inline]
       ____sys_sendmsg+0x9c2/0xd60 net/socket.c:2584
       ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2638
       __sys_sendmsg net/socket.c:2667 [inline]
       __do_sys_sendmsg net/socket.c:2676 [inline]
       __se_sys_sendmsg net/socket.c:2674 [inline]
       __x64_sys_sendmsg+0x307/0x490 net/socket.c:2674
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0x44/0x110 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      CPU: 0 PID: 5025 Comm: syz-executor279 Not tainted 6.7.0-rc7-syzkaller-00003-gfbafc3e6
      
       #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
      
      Reported-by: default avatar <syzbot+7f4d0ea3df4d4fa9a65f@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/netdev/0000000000005abd7b060eb160cd@google.com/
      Fixes: 9274124f
      
       ("net: stricter validation of untrusted gso packets")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9181d6f8
  7. Jan 13, 2024
  8. Jan 12, 2024
    • Jakub Kicinski's avatar
      net: fill in MODULE_DESCRIPTION()s for wx_lib · 907ee668
      Jakub Kicinski authored
      
      
      W=1 builds now warn if module is built without a MODULE_DESCRIPTION().
      Add a description to Wangxun's common code lib.
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      907ee668
    • Claudiu Beznea's avatar
      net: phy: micrel: populate .soft_reset for KSZ9131 · e398822c
      Claudiu Beznea authored
      The RZ/G3S SMARC Module has 2 KSZ9131 PHYs. In this setup, the KSZ9131 PHY
      is used with the ravb Ethernet driver. It has been discovered that when
      bringing the Ethernet interface down/up continuously, e.g., with the
      following sh script:
      
      $ while :; do ifconfig eth0 down; ifconfig eth0 up; done
      
      the link speed and duplex are wrong after interrupting the bring down/up
      operation even though the Ethernet interface is up. To recover from this
      state the following configuration sequence is necessary (executed
      manually):
      
      $ ifconfig eth0 down
      $ ifconfig eth0 up
      
      The behavior has been identified also on the Microchip SAMA7G5-EK board
      which runs the macb driver and uses the same PHY.
      
      The order of PHY-related operations in ravb_open() is as follows:
      ravb_open() ->
        ravb_phy_start() ->
          ravb_phy_init() ->
            of_phy_connect() ->
              phy_connect_direct() ->
      	  phy_attach_direct() ->
      	    phy_init_hw() ->
      	      phydev->drv->soft_reset()
      	      phydev->drv->config_init()
      	      phydev->drv->config_intr()
      	    phy_resume()
      	      kszphy_resume()
      
      The order of PHY-related operations in ravb_close is as follows:
      ravb_close() ->
        phy_stop() ->
          phy_suspend() ->
            kszphy_suspend() ->
              genphy_suspend()
      	  // set BMCR_PDOWN bit in MII_BMCR
      
      In genphy_suspend() setting the BMCR_PDWN bit in MII_BMCR switches the PHY
      to Software Power-Down (SPD) mode (according to the KSZ9131 datasheet).
      Thus, when opening the interface after it has been  previously closed (via
      ravb_close()), the phydev->drv->config_init() and
      phydev->drv->config_intr() reach the KSZ9131 PHY driver via the
      ksz9131_config_init() and kszphy_config_intr() functions.
      
      KSZ9131 specifies that the MII management interface remains operational
      during SPD (Software Power-Down), but (according to manual):
      - Only access to the standard registers (0 through 31) is supported.
      - Access to MMD address spaces other than MMD address space 1 is possible
        if the spd_clock_gate_override bit is set.
      - Access to MMD address space 1 is not possible.
      
      The spd_clock_gate_override bit is not used in the KSZ9131 driver.
      
      ksz9131_config_init() configures RGMII delay, pad skews and LEDs by
      accessesing MMD registers other than those in address space 1.
      
      The datasheet for the KSZ9131 does not specify what happens if registers
      from an unsupported address space are accessed while the PHY is in SPD.
      
      To fix the issue the .soft_reset method has been instantiated for KSZ9131,
      too. This resets the PHY to the default state before doing any
      configurations to it, thus switching it out of SPD.
      
      Fixes: bff5b4b3
      
       ("net: phy: micrel: add Microchip KSZ9131 initial driver")
      Signed-off-by: default avatarClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
      Reviewed-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e398822c
    • Horatiu Vultur's avatar
      net: micrel: Fix PTP frame parsing for lan8841 · acd66c21
      Horatiu Vultur authored
      The HW has the capability to check each frame if it is a PTP frame,
      which domain it is, which ptp frame type it is, different ip address in
      the frame. And if one of these checks fail then the frame is not
      timestamp. Most of these checks were disabled except checking the field
      minorVersionPTP inside the PTP header. Meaning that once a partner sends
      a frame compliant to 8021AS which has minorVersionPTP set to 1, then the
      frame was not timestamp because the HW expected by default a value of 0
      in minorVersionPTP.
      Fix this issue by removing this check so the userspace can decide on this.
      
      Fixes: cafc3662
      
       ("net: micrel: Add PHC support for lan8841")
      Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Reviewed-by: default avatarDivya Koppera <divya.koppera@microchip.com>
      Reviewed-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      acd66c21
    • Taehee Yoo's avatar
      amt: do not use overwrapped cb area · bec161ad
      Taehee Yoo authored
      amt driver uses skb->cb for storing tunnel information.
      This job is worked before TC layer and then amt driver load tunnel info
      from skb->cb after TC layer.
      So, its cb area should not be overwrapped with CB area used by TC.
      In order to not use cb area used by TC, it skips the biggest cb
      structure used by TC, which was qdisc_skb_cb.
      But it's not anymore.
      Currently, biggest structure of TC's CB is tc_skb_cb.
      So, it should skip size of tc_skb_cb instead of qdisc_skb_cb.
      
      Fixes: ec624fe7
      
       ("net/sched: Extend qdisc control block with tc control block")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Link: https://lore.kernel.org/r/20240107144241.4169520-1-ap420073@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      bec161ad
    • Jakub Kicinski's avatar
      Merge branch 'net-ethernet-ti-am65-cpsw-allow-for-mtu-values' · 66cee759
      Jakub Kicinski authored
      Sanjuán García, Jorge says:
      
      ====================
      net: ethernet: ti: am65-cpsw: Allow for MTU values
      
      The am65-cpsw-nuss driver has a fixed definition for the maximum ethernet
      frame length of 1522 bytes (AM65_CPSW_MAX_PACKET_SIZE). This limits the switch
      ports to only operate at a maximum MTU of 1500 bytes. When combining this CPSW
      switch with a DSA switch connected to one of its ports this limitation shows up.
      The extra 8 bytes the DSA subsystem adds internally to the ethernet frame
      create resulting frames bigger than 1522 bytes (1518 for non VLAN + 8 for DSA
      stuff) so they get dropped by the switch.
      
      One of the issues with the the am65-cpsw-nuss driver is that the network device
      max_mtu was being set to the same fixed value defined for the max total frame
      length (1522 bytes). This makes the DSA subsystem believe that the MTU of the
      interface can be set to 1508 bytes to make room for the extra 8 bytes of the DSA
      headers. However, all packages created assuming the 1500 bytes payload get
      dropped by the switch as oversized.
      
      This series offers a solution to this problem. The max_mtu advertised on the
      network device and the actual max frame size configured on the switch registers
      are made consistent by letting the extra room needed for the ethernet headers
      and the frame checksum (22 bytes including VLAN).
      ====================
      
      Link: https://lore.kernel.org/r/20240105085530.14070-1-jorge.sanjuangarcia@duagon.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      66cee759