1. Mar 06, 2024
    • Steffen Klassert's avatar
      Merge branch 'Improve packet offload for dual stack' · 2ce0eae6
      Steffen Klassert authored
      
      
      Mike Yu says:
      ====================
      In the XFRM stack, whether a packet is forwarded to the IPv4
      or IPv6 stack depends on the family field of the matched SA.
      This does not completely work for IPsec packet offload in some
      scenario, for example, sending an IPv6 packet that will be
      encrypted and encapsulated as an IPv4 packet in HW.
      
      Here are the patches to make IPsec packet offload work on the
      mentioned scenario.
      ====================
      
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      2ce0eae6
  2. Mar 05, 2024
    • Mike Yu's avatar
      xfrm: set skb control buffer based on packet offload as well · 8688ab21
      Mike Yu authored
      
      
      In packet offload, packets are not encrypted in XFRM stack, so
      the next network layer which the packets will be forwarded to
      should depend on where the packet came from (either xfrm4_output
      or xfrm6_output) rather than the matched SA's family type.
      
      Test: verified IPv6-in-IPv4 packets on Android device with
            IPsec packet offload enabled
      Signed-off-by: default avatarMike Yu <yumike@google.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      8688ab21
    • Mike Yu's avatar
      xfrm: fix xfrm child route lookup for packet offload · d4872d70
      Mike Yu authored
      
      
      In current code, xfrm_bundle_create() always uses the matched
      SA's family type to look up a xfrm child route for the skb.
      The route returned by xfrm_dst_lookup() will eventually be
      used in xfrm_output_resume() (skb_dst(skb)->ops->local_out()).
      
      If packet offload is used, the above behavior can lead to
      calling ip_local_out() for an IPv6 packet or calling
      ip6_local_out() for an IPv4 packet, which is likely to fail.
      
      This change fixes the behavior by checking if the matched SA
      has packet offload enabled. If not, keep the same behavior;
      if yes, use the matched SP's family type for the lookup.
      
      Test: verified IPv6-in-IPv4 packets on Android device with
            IPsec packet offload enabled
      Signed-off-by: default avatarMike Yu <yumike@google.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      d4872d70
  3. Feb 26, 2024
    • Nathan Chancellor's avatar
      xfrm: Avoid clang fortify warning in copy_to_user_tmpl() · 1a807e46
      Nathan Chancellor authored
      After a couple recent changes in LLVM, there is a warning (or error with
      CONFIG_WERROR=y or W=e) from the compile time fortify source routines,
      specifically the memset() in copy_to_user_tmpl().
      
        In file included from net/xfrm/xfrm_user.c:14:
        ...
        include/linux/fortify-string.h:438:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
          438 |                         __write_overflow_field(p_size_field, size);
              |                         ^
        1 error generated.
      
      While ->xfrm_nr has been validated against XFRM_MAX_DEPTH when its value
      is first assigned in copy_templates() by calling validate_tmpl() first
      (so there should not be any issue in practice), LLVM/clang cannot really
      deduce that across the boundaries of these functions. Without that
      knowledge, it cannot assume that the loop stops before i is greater than
      XFRM_MAX_DEPTH, which would indeed result a stack buffer overflow in the
      memset().
      
      To make the bounds of ->xfrm_nr clear to the compiler and add additional
      defense in case copy_to_user_tmpl() is ever used in a path where
      ->xfrm_nr has not been properly validated against XFRM_MAX_DEPTH first,
      add an explicit bound check and early return, which clears up the
      warning.
      
      Cc: stable@vger.kernel.org
      Link: https://github.com/ClangBuiltLinux/linux/issues/1985
      
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      1a807e46
  4. Jan 25, 2024
  5. Jan 17, 2024
  6. Jan 15, 2024
  7. 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
  8. Jan 13, 2024
  9. 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
    • Sanjuán García, Jorge's avatar
      net: ethernet: ti: am65-cpsw: Fix max mtu to fit ethernet frames · 64e47d8a
      Sanjuán García, Jorge authored
      The value of AM65_CPSW_MAX_PACKET_SIZE represents the maximum length
      of a received frame. This value is written to the register
      AM65_CPSW_PORT_REG_RX_MAXLEN.
      
      The maximum MTU configured on the network device should then leave
      some room for the ethernet headers and frame check. Otherwise, if
      the network interface is configured to its maximum mtu possible,
      the frames will be larger than AM65_CPSW_MAX_PACKET_SIZE and will
      get dropped as oversized.
      
      The switch supports ethernet frame sizes between 64 and 2024 bytes
      (including VLAN) as stated in the technical reference manual, so
      define AM65_CPSW_MAX_PACKET_SIZE with that maximum size.
      
      Fixes: 93a76530
      
       ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
      Signed-off-by: default avatarJorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
      Reviewed-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Reviewed-by: default avatarSiddharth Vadapalli <s-vadapalli@ti.com>
      Link: https://lore.kernel.org/r/20240105085530.14070-2-jorge.sanjuangarcia@duagon.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      64e47d8a
    • Zhu Yanjun's avatar
      virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings · e3fe8d28
      Zhu Yanjun authored
      
      
      Fix the warnings when building virtio_net driver.
      
      "
      drivers/net/virtio_net.c: In function ‘init_vqs’:
      drivers/net/virtio_net.c:4551:48: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Wformat-overflow=]
       4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
            |                                                ^~
      In function ‘virtnet_find_vqs’,
          inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8:
      drivers/net/virtio_net.c:4551:41: note: directive argument in the range [-2147483643, 65534]
       4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
            |                                         ^~~~~~~~~~
      drivers/net/virtio_net.c:4551:17: note: ‘sprintf’ output between 8 and 18 bytes into a destination of size 16
       4551 |                 sprintf(vi->rq[i].name, "input.%d", i);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/net/virtio_net.c: In function ‘init_vqs’:
      drivers/net/virtio_net.c:4552:49: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 9 [-Wformat-overflow=]
       4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
            |                                                 ^~
      In function ‘virtnet_find_vqs’,
          inlined from ‘init_vqs’ at drivers/net/virtio_net.c:4645:8:
      drivers/net/virtio_net.c:4552:41: note: directive argument in the range [-2147483643, 65534]
       4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
            |                                         ^~~~~~~~~~~
      drivers/net/virtio_net.c:4552:17: note: ‘sprintf’ output between 9 and 19 bytes into a destination of size 16
       4552 |                 sprintf(vi->sq[i].name, "output.%d", i);
      
      "
      
      Reviewed-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarZhu Yanjun <yanjun.zhu@linux.dev>
      Link: https://lore.kernel.org/r/20240104020902.2753599-1-yanjun.zhu@intel.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e3fe8d28
    • Nithin Dabilpuram's avatar
      octeontx2-af: CN10KB: Fix FIFO length calculation for RPM2 · a0cb76a7
      Nithin Dabilpuram authored
      RPM0 and RPM1 on the CN10KB SoC have 8 LMACs each, whereas RPM2
      has only 4 LMACs. Similarly, the RPM0 and RPM1 have 256KB FIFO,
      whereas RPM2 has 128KB FIFO. This patch fixes an issue with
      improper TX credit programming for the RPM2 link.
      
      Fixes: b9d0fedc
      
       ("octeontx2-af: cn10kb: Add RPM_USX MAC support")
      Signed-off-by: default avatarNithin Dabilpuram <ndabilpuram@marvell.com>
      Signed-off-by: default avatarNaveen Mamindlapalli <naveenm@marvell.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20240108073036.8766-1-naveenm@marvell.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a0cb76a7
    • Jakub Kicinski's avatar
      Merge branch 'rtnetlink-allow-to-enslave-with-one-msg-an-up-interface' · 3722a987
      Jakub Kicinski authored
      Nicolas Dichtel says:
      
      ====================
      rtnetlink: allow to enslave with one msg an up interface
      
      The first patch fixes a regression, introduced in linux v6.1, by reverting
      a patch. The second patch adds a test to verify this API.
      ====================
      
      Link: https://lore.kernel.org/r/20240108094103.2001224-1-nicolas.dichtel@6wind.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      3722a987
    • Nicolas Dichtel's avatar
      selftests: rtnetlink: check enslaving iface in a bond · a159cbe8
      Nicolas Dichtel authored
      
      
      The goal is to check the following two sequences:
      > ip link set dummy0 up
      > ip link set dummy0 master bond0 down
      
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Link: https://lore.kernel.org/r/20240108094103.2001224-3-nicolas.dichtel@6wind.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a159cbe8
    • Nicolas Dichtel's avatar
      Revert "net: rtnetlink: Enslave device before bringing it up" · ec4ffd10
      Nicolas Dichtel authored
      This reverts commit a4abfa62.
      
      The patch broke:
      > ip link set dummy0 up
      > ip link set dummy0 master bond0 down
      
      This last command is useful to be able to enslave an interface with only
      one netlink message.
      
      After discussion, there is no good reason to support:
      > ip link set dummy0 down
      > ip link set dummy0 master bond0 up
      because the bond interface already set the slave up when it is up.
      
      Cc: stable@vger.kernel.org
      Fixes: a4abfa62
      
       ("net: rtnetlink: Enslave device before bringing it up")
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Link: https://lore.kernel.org/r/20240108094103.2001224-2-nicolas.dichtel@6wind.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      ec4ffd10
    • David Howells's avatar
      rxrpc: Fix use of Don't Fragment flag · 87220143
      David Howells authored
      rxrpc normally has the Don't Fragment flag set on the UDP packets it
      transmits, except when it has decided that DATA packets aren't getting
      through - in which case it turns it off just for the DATA transmissions.
      This can be a problem, however, for RESPONSE packets that convey
      authentication and crypto data from the client to the server as ticket may
      be larger than can fit in the MTU.
      
      In such a case, rxrpc gets itself into an infinite loop as the sendmsg
      returns an error (EMSGSIZE), which causes rxkad_send_response() to return
      -EAGAIN - and the CHALLENGE packet is put back on the Rx queue to retry,
      leading to the I/O thread endlessly attempting to perform the transmission.
      
      Fix this by disabling DF on RESPONSE packets for now.  The use of DF and
      best data MTU determination needs reconsidering at some point in the
      future.
      
      Fixes: 17926a79
      
       ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both")
      Reported-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: linux-afs@lists.infradead.org
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/1581852.1704813048@warthog.procyon.org.uk
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      87220143
    • Vladimir Oltean's avatar
      net: dsa: fix netdev_priv() dereference before check on non-DSA netdevice events · 844f1047
      Vladimir Oltean authored
      After the blamed commit, we started doing this dereference for every
      NETDEV_CHANGEUPPER and NETDEV_PRECHANGEUPPER event in the system.
      
      static inline struct dsa_port *dsa_user_to_port(const struct net_device *dev)
      {
      	struct dsa_user_priv *p = netdev_priv(dev);
      
      	return p->dp;
      }
      
      Which is obviously bogus, because not all net_devices have a netdev_priv()
      of type struct dsa_user_priv. But struct dsa_user_priv is fairly small,
      and p->dp means dereferencing 8 bytes starting with offset 16. Most
      drivers allocate that much private memory anyway, making our access not
      fault, and we discard the bogus data quickly afterwards, so this wasn't
      caught.
      
      But the dummy interface is somewhat special in that it calls
      alloc_netdev() with a priv size of 0. So every netdev_priv() dereference
      is invalid, and we get this when we emit a NETDEV_PRECHANGEUPPER event
      with a VLAN as its new upper:
      
      $ ip link add dummy1 type dummy
      $ ip link add link dummy1 name dummy1.100 type vlan id 100
      [   43.309174] ==================================================================
      [   43.316456] BUG: KASAN: slab-out-of-bounds in dsa_user_prechangeupper+0x30/0xe8
      [   43.323835] Read of size 8 at addr ffff3f86481d2990 by task ip/374
      [   43.330058]
      [   43.342436] Call trace:
      [   43.366542]  dsa_user_prechangeupper+0x30/0xe8
      [   43.371024]  dsa_user_netdevice_event+0xb38/0xee8
      [   43.375768]  notifier_call_chain+0xa4/0x210
      [   43.379985]  raw_notifier_call_chain+0x24/0x38
      [   43.384464]  __netdev_upper_dev_link+0x3ec/0x5d8
      [   43.389120]  netdev_upper_dev_link+0x70/0xa8
      [   43.393424]  register_vlan_dev+0x1bc/0x310
      [   43.397554]  vlan_newlink+0x210/0x248
      [   43.401247]  rtnl_newlink+0x9fc/0xe30
      [   43.404942]  rtnetlink_rcv_msg+0x378/0x580
      
      Avoid the kernel oops by dereferencing after the type check, as customary.
      
      Fixes: 4c3f80d2
      
       ("net: dsa: walk through all changeupper notifier functions")
      Reported-and-tested-by: default avatar <syzbot+d81bcd883824180500c8@syzkaller.appspotmail.com>
      Closes: https://lore.kernel.org/netdev/0000000000001d4255060e87545c@google.com/
      
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20240110003354.2796778-1-vladimir.oltean@nxp.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      844f1047
    • Lin Ma's avatar
      net: qualcomm: rmnet: fix global oob in rmnet_policy · b33fb5b8
      Lin Ma authored
      The variable rmnet_link_ops assign a *bigger* maxtype which leads to a
      global out-of-bounds read when parsing the netlink attributes. See bug
      trace below:
      
      ==================================================================
      BUG: KASAN: global-out-of-bounds in validate_nla lib/nlattr.c:386 [inline]
      BUG: KASAN: global-out-of-bounds in __nla_validate_parse+0x24af/0x2750 lib/nlattr.c:600
      Read of size 1 at addr ffffffff92c438d0 by task syz-executor.6/84207
      
      CPU: 0 PID: 84207 Comm: syz-executor.6 Tainted: G                 N 6.1.0 #3
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x8b/0xb3 lib/dump_stack.c:106
       print_address_description mm/kasan/report.c:284 [inline]
       print_report+0x172/0x475 mm/kasan/report.c:395
       kasan_report+0xbb/0x1c0 mm/kasan/report.c:495
       validate_nla lib/nlattr.c:386 [inline]
       __nla_validate_parse+0x24af/0x2750 lib/nlattr.c:600
       __nla_parse+0x3e/0x50 lib/nlattr.c:697
       nla_parse_nested_deprecated include/net/netlink.h:1248 [inline]
       __rtnl_newlink+0x50a/0x1880 net/core/rtnetlink.c:3485
       rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3594
       rtnetlink_rcv_msg+0x43c/0xd70 net/core/rtnetlink.c:6091
       netlink_rcv_skb+0x14f/0x410 net/netlink/af_netlink.c:2540
       netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
       netlink_unicast+0x54e/0x800 net/netlink/af_netlink.c:1345
       netlink_sendmsg+0x930/0xe50 net/netlink/af_netlink.c:1921
       sock_sendmsg_nosec net/socket.c:714 [inline]
       sock_sendmsg+0x154/0x190 net/socket.c:734
       ____sys_sendmsg+0x6df/0x840 net/socket.c:2482
       ___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
       __sys_sendmsg+0xf3/0x1c0 net/socket.c:2565
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7fdcf2072359
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007fdcf13e3168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007fdcf219ff80 RCX: 00007fdcf2072359
      RDX: 0000000000000000 RSI: 0000000020000200 RDI: 0000000000000003
      RBP: 00007fdcf20bd493 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 00007fffbb8d7bdf R14: 00007fdcf13e3300 R15: 0000000000022000
       </TASK>
      
      The buggy address belongs to the variable:
       rmnet_policy+0x30/0xe0
      
      The buggy address belongs to the physical page:
      page:0000000065bdeb3c refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x155243
      flags: 0x200000000001000(reserved|node=0|zone=2)
      raw: 0200000000001000 ffffea00055490c8 ffffea00055490c8 0000000000000000
      raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffffffff92c43780: f9 f9 f9 f9 00 00 00 02 f9 f9 f9 f9 00 00 00 07
       ffffffff92c43800: f9 f9 f9 f9 00 00 00 05 f9 f9 f9 f9 06 f9 f9 f9
      >ffffffff92c43880: f9 f9 f9 f9 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9
                                                       ^
       ffffffff92c43900: 00 00 00 00 00 00 00 00 07 f9 f9 f9 f9 f9 f9 f9
       ffffffff92c43980: 00 00 00 07 f9 f9 f9 f9 00 00 00 05 f9 f9 f9 f9
      
      According to the comment of `nla_parse_nested_deprecated`, the maxtype
      should be len(destination array) - 1. Hence use `IFLA_RMNET_MAX` here.
      
      Fixes: 14452ca3
      
       ("net: qualcomm: rmnet: Export mux_id and flags to netlink")
      Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
      Reviewed-by: default avatarSubash Abhinov Kasiviswanathan <quic_subashab@quicinc.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Link: https://lore.kernel.org/r/20240110061400.3356108-1-linma@zju.edu.cn
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b33fb5b8
    • Dmitry Safonov's avatar
      selftests/net/tcp-ao: Use LDLIBS instead of LDFLAGS · e689a876
      Dmitry Safonov authored
      The rules to link selftests are:
      
      > $(OUTPUT)/%_ipv4: %.c
      > 	$(LINK.c) $^ $(LDLIBS) -o $@
      >
      > $(OUTPUT)/%_ipv6: %.c
      > 	$(LINK.c) -DIPV6_TEST $^ $(LDLIBS) -o $@
      
      The intel test robot uses only selftest's Makefile, not the top linux
      Makefile:
      
      > make W=1 O=/tmp/kselftest -C tools/testing/selftests
      
      So, $(LINK.c) is determined by environment, rather than by kernel
      Makefiles. On my machine (as well as other people that ran tcp-ao
      selftests) GNU/Make implicit definition does use $(LDFLAGS):
      
      > [dima@Mindolluin ~]$ make -p -f/dev/null | grep '^LINK.c\>'
      > make: *** No targets.  Stop.
      > LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
      
      But, according to build robot report, it's not the case for them.
      While I could just avoid using pre-defined $(LINK.c), it's also used by
      selftests/lib.mk by default.
      
      Anyways, according to GNU/Make documentation [1], I should have used
      $(LDLIBS) instead of $(LDFLAGS) in the first place, so let's just do it:
      
      > LDFLAGS
      >     Extra flags to give to compilers when they are supposed to invoke
      >     the linker, ‘ld’, such as -L. Libraries (-lfoo) should be added
      >     to the LDLIBS variable instead.
      > LDLIBS
      >     Library flags or names given to compilers when they are supposed
      >     to invoke the linker, ‘ld’. LOADLIBES is a deprecated (but still
      >     supported) alternative to LDLIBS. Non-library linker flags, such
      >     as -L, should go in the LDFLAGS variable.
      
      [1]: https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
      
      Fixes: cfbab37b
      
       ("selftests/net: Add TCP-AO library")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/oe-kbuild-all/202401011151.veyYTJzq-lkp@intel.com/
      
      
      Signed-off-by: default avatarDmitry Safonov <dima@arista.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/20240110-tcp_ao-selftests-makefile-v1-1-aa07d043f052@arista.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e689a876
    • Arnd Bergmann's avatar
      wangxunx: select CONFIG_PHYLINK where needed · b3739fb3
      Arnd Bergmann authored
      The ngbe driver needs phylink:
      
      arm-linux-gnueabi-ld: drivers/net/ethernet/wangxun/libwx/wx_ethtool.o: in function `wx_nway_reset':
      wx_ethtool.c:(.text+0x458): undefined reference to `phylink_ethtool_nway_reset'
      arm-linux-gnueabi-ld: drivers/net/ethernet/wangxun/ngbe/ngbe_main.o: in function `ngbe_remove':
      ngbe_main.c:(.text+0x7c): undefined reference to `phylink_destroy'
      arm-linux-gnueabi-ld: drivers/net/ethernet/wangxun/ngbe/ngbe_main.o: in function `ngbe_open':
      ngbe_main.c:(.text+0xf90): undefined reference to `phylink_connect_phy'
      arm-linux-gnueabi-ld: drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.o: in function `ngbe_mdio_init':
      ngbe_mdio.c:(.text+0x314): undefined reference to `phylink_create'
      
      Add the missing Kconfig description for this.
      
      Fixes: bc2426d7
      
       ("net: ngbe: convert phylib to phylink")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20240111162828.68564-1-arnd@kernel.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b3739fb3
    • Jakub Kicinski's avatar
      MAINTAINERS: ibmvnic: drop Dany from reviewers · f9678f58
      Jakub Kicinski authored
      
      
      I missed that Dany uses a different email address
      when tagging patches (drt@linux.ibm.com)
      and asked him if he's still actively working on ibmvnic.
      He doesn't really fall under our removal criteria,
      but he admitted that he already moved on to other projects.
      
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20240109164517.3063131-8-kuba@kernel.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f9678f58