Skip to content
  1. Oct 05, 2023
    • Benjamin Poirier's avatar
      ipv4: Set offload_failed flag in fibmatch results · 0add5c59
      Benjamin Poirier authored
      Due to a small omission, the offload_failed flag is missing from ipv4
      fibmatch results. Make sure it is set correctly.
      
      The issue can be witnessed using the following commands:
      echo "1 1" > /sys/bus/netdevsim/new_device
      ip link add dummy1 up type dummy
      ip route add 192.0.2.0/24 dev dummy1
      echo 1 > /sys/kernel/debug/netdevsim/netdevsim1/fib/fail_route_offload
      ip route add 198.51.100.0/24 dev dummy1
      ip route
      	# 192.168.15.0/24 has rt_trap
      	# 198.51.100.0/24 has rt_offload_failed
      ip route get 192.168.15.1 fibmatch
      	# Result has rt_trap
      ip route get 198.51.100.1 fibmatch
      	# Result differs from the route shown by `ip route`, it is missing
      	# rt_offload_failed
      ip link del dev dummy1
      echo 1 > /sys/bus/netdevsim/del_device
      
      Fixes: 36c5100e
      
       ("IPv4: Add "offload failed" indication to routes")
      Signed-off-by: default avatarBenjamin Poirier <bpoirier@nvidia.com>
      Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20230926182730.231208-1-bpoirier@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      0add5c59
    • Jakub Kicinski's avatar
      Merge tag 'wireless-2023-09-27' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless · 72897b29
      Jakub Kicinski authored
      Johannes Berg says:
      
      ====================
      
      Quite a collection of fixes this time, really too many
      to list individually. Many stack fixes, even rfkill
      (found by simulation and the new eevdf scheduler)!
      
      Also a bigger maintainers file cleanup, to remove old
      and redundant information.
      
      * tag 'wireless-2023-09-27' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless: (32 commits)
        wifi: iwlwifi: mvm: Fix incorrect usage of scan API
        wifi: mac80211: Create resources for disabled links
        wifi: cfg80211: avoid leaking stack data into trace
        wifi: mac80211: allow transmitting EAPOL frames with tainted key
        wifi: mac80211: work around Cisco AP 9115 VHT MPDU length
        wifi: cfg80211: Fix 6GHz scan configuration
        wifi: mac80211: fix potential key leak
        wifi: mac80211: fix potential key use-after-free
        wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling
        wifi: brcmfmac: Replace 1-element arrays with flexible arrays
        wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet
        wifi: rtw88: rtw8723d: Fix MAC address offset in EEPROM
        rfkill: sync before userspace visibility/changes
        wifi: mac80211: fix mesh id corruption on 32 bit systems
        wifi: cfg80211: add missing kernel-doc for cqm_rssi_work
        wifi: cfg80211: fix cqm_config access race
        wifi: iwlwifi: mvm: Fix a memory corruption issue
        wifi: iwlwifi: Ensure ack flag is properly cleared.
        wifi: iwlwifi: dbg_ini: fix structure packing
        iwlwifi: mvm: handle PS changes in vif_cfg_changed
        ...
      ====================
      
      Link: https://lore.kernel.org/r/20230927095835.25803-2-johannes@sipsolutions.net
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      72897b29
  2. Oct 04, 2023
  3. Oct 03, 2023
    • Jeremy Cline's avatar
      net: nfc: llcp: Add lock when modifying device list · dfc7f7a9
      Jeremy Cline authored
      
      
      The device list needs its associated lock held when modifying it, or the
      list could become corrupted, as syzbot discovered.
      
      Reported-and-tested-by: default avatar <syzbot+c1d0a03d305972dbbe14@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=c1d0a03d305972dbbe14
      
      
      Signed-off-by: default avatarJeremy Cline <jeremy@jcline.org>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Fixes: 6709d4b7 ("net: nfc: Fix use-after-free caused by nfc_llcp_find_local")
      Link: https://lore.kernel.org/r/20230908235853.1319596-1-jeremy@jcline.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      dfc7f7a9
    • Parthiban Veerasooran's avatar
      ethtool: plca: fix plca enable data type while parsing the value · 8957261c
      Parthiban Veerasooran authored
      The ETHTOOL_A_PLCA_ENABLED data type is u8. But while parsing the
      value from the attribute, nla_get_u32() is used in the plca_update_sint()
      function instead of nla_get_u8(). So plca_cfg.enabled variable is updated
      with some garbage value instead of 0 or 1 and always enables plca even
      though plca is disabled through ethtool application. This bug has been
      fixed by parsing the values based on the attributes type in the policy.
      
      Fixes: 8580e16c
      
       ("net/ethtool: add netlink interface for the PLCA RS")
      Signed-off-by: default avatarParthiban Veerasooran <Parthiban.Veerasooran@microchip.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20230908044548.5878-1-Parthiban.Veerasooran@microchip.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8957261c
    • Gustavo A. R. Silva's avatar
      qed/red_ll2: Fix undefined behavior bug in struct qed_ll2_info · eea03d18
      Gustavo A. R. Silva authored
      The flexible structure (a structure that contains a flexible-array member
      at the end) `qed_ll2_tx_packet` is nested within the second layer of
      `struct qed_ll2_info`:
      
      struct qed_ll2_tx_packet {
      	...
              /* Flexible Array of bds_set determined by max_bds_per_packet */
              struct {
                      struct core_tx_bd *txq_bd;
                      dma_addr_t tx_frag;
                      u16 frag_len;
              } bds_set[];
      };
      
      struct qed_ll2_tx_queue {
      	...
      	struct qed_ll2_tx_packet cur_completing_packet;
      };
      
      struct qed_ll2_info {
      	...
      	struct qed_ll2_tx_queue tx_queue;
              struct qed_ll2_cbs cbs;
      };
      
      The problem is that member `cbs` in `struct qed_ll2_info` is placed just
      after an object of type `struct qed_ll2_tx_queue`, which is in itself
      an implicit flexible structure, which by definition ends in a flexible
      array member, in this case `bds_set`. This causes an undefined behavior
      bug at run-time when dynamic memory is allocated for `bds_set`, which
      could lead to a serious issue if `cbs` in `struct qed_ll2_info` is
      overwritten by the contents of `bds_set`. Notice that the type of `cbs`
      is a structure full of function pointers (and a cookie :) ):
      
      include/linux/qed/qed_ll2_if.h:
      107 typedef
      108 void (*qed_ll2_complete_rx_packet_cb)(void *cxt,
      109                                       struct qed_ll2_comp_rx_data *data);
      110
      111 typedef
      112 void (*qed_ll2_release_rx_packet_cb)(void *cxt,
      113                                      u8 connection_handle,
      114                                      void *cookie,
      115                                      dma_addr_t rx_buf_addr,
      116                                      bool b_last_packet);
      117
      118 typedef
      119 void (*qed_ll2_complete_tx_packet_cb)(void *cxt,
      120                                       u8 connection_handle,
      121                                       void *cookie,
      122                                       dma_addr_t first_frag_addr,
      123                                       bool b_last_fragment,
      124                                       bool b_last_packet);
      125
      126 typedef
      127 void (*qed_ll2_release_tx_packet_cb)(void *cxt,
      128                                      u8 connection_handle,
      129                                      void *cookie,
      130                                      dma_addr_t first_frag_addr,
      131                                      bool b_last_fragment, bool b_last_packet);
      132
      133 typedef
      134 void (*qed_ll2_slowpath_cb)(void *cxt, u8 connection_handle,
      135                             u32 opaque_data_0, u32 opaque_data_1);
      136
      137 struct qed_ll2_cbs {
      138         qed_ll2_complete_rx_packet_cb rx_comp_cb;
      139         qed_ll2_release_rx_packet_cb rx_release_cb;
      140         qed_ll2_complete_tx_packet_cb tx_comp_cb;
      141         qed_ll2_release_tx_packet_cb tx_release_cb;
      142         qed_ll2_slowpath_cb slowpath_cb;
      143         void *cookie;
      144 };
      
      Fix this by moving the declaration of `cbs` to the  middle of its
      containing structure `qed_ll2_info`, preventing it from being
      overwritten by the contents of `bds_set` at run-time.
      
      This bug was introduced in 2017, when `bds_set` was converted to a
      one-element array, and started to be used as a Variable Length Object
      (VLO) at run-time.
      
      Fixes: f5823fe6
      
       ("qed: Add ll2 option to limit the number of bds per packet")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/ZQ+Nz8DfPg56pIzr@work
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      eea03d18
    • Shigeru Yoshida's avatar
      net: usb: smsc75xx: Fix uninit-value access in __smsc75xx_read_reg · e9c65989
      Shigeru Yoshida authored
      syzbot reported the following uninit-value access issue:
      
      =====================================================
      BUG: KMSAN: uninit-value in smsc75xx_wait_ready drivers/net/usb/smsc75xx.c:975 [inline]
      BUG: KMSAN: uninit-value in smsc75xx_bind+0x5c9/0x11e0 drivers/net/usb/smsc75xx.c:1482
      CPU: 0 PID: 8696 Comm: kworker/0:3 Not tainted 5.8.0-rc5-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Workqueue: usb_hub_wq hub_event
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x21c/0x280 lib/dump_stack.c:118
       kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:121
       __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215
       smsc75xx_wait_ready drivers/net/usb/smsc75xx.c:975 [inline]
       smsc75xx_bind+0x5c9/0x11e0 drivers/net/usb/smsc75xx.c:1482
       usbnet_probe+0x1152/0x3f90 drivers/net/usb/usbnet.c:1737
       usb_probe_interface+0xece/0x1550 drivers/usb/core/driver.c:374
       really_probe+0xf20/0x20b0 drivers/base/dd.c:529
       driver_probe_device+0x293/0x390 drivers/base/dd.c:701
       __device_attach_driver+0x63f/0x830 drivers/base/dd.c:807
       bus_for_each_drv+0x2ca/0x3f0 drivers/base/bus.c:431
       __device_attach+0x4e2/0x7f0 drivers/base/dd.c:873
       device_initial_probe+0x4a/0x60 drivers/base/dd.c:920
       bus_probe_device+0x177/0x3d0 drivers/base/bus.c:491
       device_add+0x3b0e/0x40d0 drivers/base/core.c:2680
       usb_set_configuration+0x380f/0x3f10 drivers/usb/core/message.c:2032
       usb_generic_driver_probe+0x138/0x300 drivers/usb/core/generic.c:241
       usb_probe_device+0x311/0x490 drivers/usb/core/driver.c:272
       really_probe+0xf20/0x20b0 drivers/base/dd.c:529
       driver_probe_device+0x293/0x390 drivers/base/dd.c:701
       __device_attach_driver+0x63f/0x830 drivers/base/dd.c:807
       bus_for_each_drv+0x2ca/0x3f0 drivers/base/bus.c:431
       __device_attach+0x4e2/0x7f0 drivers/base/dd.c:873
       device_initial_probe+0x4a/0x60 drivers/base/dd.c:920
       bus_probe_device+0x177/0x3d0 drivers/base/bus.c:491
       device_add+0x3b0e/0x40d0 drivers/base/core.c:2680
       usb_new_device+0x1bd4/0x2a30 drivers/usb/core/hub.c:2554
       hub_port_connect drivers/usb/core/hub.c:5208 [inline]
       hub_port_connect_change drivers/usb/core/hub.c:5348 [inline]
       port_event drivers/usb/core/hub.c:5494 [inline]
       hub_event+0x5e7b/0x8a70 drivers/usb/core/hub.c:5576
       process_one_work+0x1688/0x2140 kernel/workqueue.c:2269
       worker_thread+0x10bc/0x2730 kernel/workqueue.c:2415
       kthread+0x551/0x590 kernel/kthread.c:292
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293
      
      Local variable ----buf.i87@smsc75xx_bind created at:
       __smsc75xx_read_reg drivers/net/usb/smsc75xx.c:83 [inline]
       smsc75xx_wait_ready drivers/net/usb/smsc75xx.c:968 [inline]
       smsc75xx_bind+0x485/0x11e0 drivers/net/usb/smsc75xx.c:1482
       __smsc75xx_read_reg drivers/net/usb/smsc75xx.c:83 [inline]
       smsc75xx_wait_ready drivers/net/usb/smsc75xx.c:968 [inline]
       smsc75xx_bind+0x485/0x11e0 drivers/net/usb/smsc75xx.c:1482
      
      This issue is caused because usbnet_read_cmd() reads less bytes than requested
      (zero byte in the reproducer). In this case, 'buf' is not properly filled.
      
      This patch fixes the issue by returning -ENODATA if usbnet_read_cmd() reads
      less bytes than requested.
      
      Fixes: d0cad871
      
       ("smsc75xx: SMSC LAN75xx USB gigabit ethernet adapter driver")
      Reported-and-tested-by: default avatar <syzbot+6966546b78d050bb0b5d@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=6966546b78d050bb0b5d
      
      
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20230923173549.3284502-1-syoshida@redhat.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      e9c65989
    • Ilya Maximets's avatar
      ipv6: tcp: add a missing nf_reset_ct() in 3WHS handling · 9593c7cb
      Ilya Maximets authored
      Commit b0e214d2 ("netfilter: keep conntrack reference until
      IPsecv6 policy checks are done") is a direct copy of the old
      commit b59c2701 ("[NETFILTER]: Keep conntrack reference until
      IPsec policy checks are done") but for IPv6.  However, it also
      copies a bug that this old commit had.  That is: when the third
      packet of 3WHS connection establishment contains payload, it is
      added into socket receive queue without the XFRM check and the
      drop of connection tracking context.
      
      That leads to nf_conntrack module being impossible to unload as
      it waits for all the conntrack references to be dropped while
      the packet release is deferred in per-cpu cache indefinitely, if
      not consumed by the application.
      
      The issue for IPv4 was fixed in commit 6f0012e3 ("tcp: add a
      missing nf_reset_ct() in 3WHS handling") by adding a missing XFRM
      check and correctly dropping the conntrack context.  However, the
      issue was introduced to IPv6 code afterwards.  Fixing it the
      same way for IPv6 now.
      
      Fixes: b0e214d2 ("netfilter: keep conntrack reference until IPsecv6 policy checks are done")
      Link: https://lore.kernel.org/netdev/d589a999-d4dd-2768-b2d5-89dec64a4a42@ovn.org/
      
      
      Signed-off-by: default avatarIlya Maximets <i.maximets@ovn.org>
      Acked-by: default avatarFlorian Westphal <fw@strlen.de>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20230922210530.2045146-1-i.maximets@ovn.org
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      9593c7cb
    • Hangbin Liu's avatar
      ipv4/fib: send notify when delete source address routes · 4b2b6060
      Hangbin Liu authored
      After deleting an interface address in fib_del_ifaddr(), the function
      scans the fib_info list for stray entries and calls fib_flush() and
      fib_table_flush(). Then the stray entries will be deleted silently and no
      RTM_DELROUTE notification will be sent.
      
      This lack of notification can make routing daemons, or monitor like
      `ip monitor route` miss the routing changes. e.g.
      
      + ip link add dummy1 type dummy
      + ip link add dummy2 type dummy
      + ip link set dummy1 up
      + ip link set dummy2 up
      + ip addr add 192.168.5.5/24 dev dummy1
      + ip route add 7.7.7.0/24 dev dummy2 src 192.168.5.5
      + ip -4 route
      7.7.7.0/24 dev dummy2 scope link src 192.168.5.5
      192.168.5.0/24 dev dummy1 proto kernel scope link src 192.168.5.5
      + ip monitor route
      + ip addr del 192.168.5.5/24 dev dummy1
      Deleted 192.168.5.0/24 dev dummy1 proto kernel scope link src 192.168.5.5
      Deleted broadcast 192.168.5.255 dev dummy1 table local proto kernel scope link src 192.168.5.5
      Deleted local 192.168.5.5 dev dummy1 table local proto kernel scope host src 192.168.5.5
      
      As Ido reminded, fib_table_flush() isn't only called when an address is
      deleted, but also when an interface is deleted or put down. The lack of
      notification in these cases is deliberate. And commit 7c6bb7d2
      
      
      ("net/ipv6: Add knob to skip DELROUTE message on device down") introduced
      a sysctl to make IPv6 behave like IPv4 in this regard. So we can't send
      the route delete notify blindly in fib_table_flush().
      
      To fix this issue, let's add a new flag in "struct fib_info" to track the
      deleted prefer source address routes, and only send notify for them.
      
      After update:
      + ip monitor route
      + ip addr del 192.168.5.5/24 dev dummy1
      Deleted 192.168.5.0/24 dev dummy1 proto kernel scope link src 192.168.5.5
      Deleted broadcast 192.168.5.255 dev dummy1 table local proto kernel scope link src 192.168.5.5
      Deleted local 192.168.5.5 dev dummy1 table local proto kernel scope host src 192.168.5.5
      Deleted 7.7.7.0/24 dev dummy2 scope link src 192.168.5.5
      
      Suggested-by: default avatarThomas Haller <thaller@redhat.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Acked-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20230922075508.848925-1-liuhangbin@gmail.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      4b2b6060
  4. Oct 02, 2023
  5. Oct 01, 2023
    • Eric Dumazet's avatar
      net: fix possible store tearing in neigh_periodic_work() · 25563b58
      Eric Dumazet authored
      While looking at a related syzbot report involving neigh_periodic_work(),
      I found that I forgot to add an annotation when deleting an
      RCU protected item from a list.
      
      Readers use rcu_deference(*np), we need to use either
      rcu_assign_pointer() or WRITE_ONCE() on writer side
      to prevent store tearing.
      
      I use rcu_assign_pointer() to have lockdep support,
      this was the choice made in neigh_flush_dev().
      
      Fixes: 767e97e1
      
       ("neigh: RCU conversion of struct neighbour")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      25563b58
    • David S. Miller's avatar
      Merge tag 'for-net-2023-09-20' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth · c15cd642
      David S. Miller authored
      
      
      bluetooth pull request for net:
      
       - Fix handling of HCI_QUIRK_STRICT_DUPLICATE_FILTER
       - Fix handling of listen for ISO unicast
       - Fix build warnings
       - Fix leaking content of local_codecs
       - Add shutdown function for QCA6174
       - Delete unused hci_req_prepare_suspend() declaration
       - Fix hci_link_tx_to RCU lock usage
       - Avoid redundant authentication
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c15cd642
    • Clark Wang's avatar
      net: stmmac: platform: fix the incorrect parameter · 6b09edc1
      Clark Wang authored
      The second parameter of stmmac_pltfr_init() needs the pointer of
      "struct plat_stmmacenet_data". So, correct the parameter typo when calling the
      function.
      
      Otherwise, it may cause this alignment exception when doing suspend/resume.
      [   49.067201] CPU1 is up
      [   49.135258] Internal error: SP/PC alignment exception: 000000008a000000 [#1] PREEMPT SMP
      [   49.143346] Modules linked in: soc_imx9 crct10dif_ce polyval_ce nvmem_imx_ocotp_fsb_s400 polyval_generic layerscape_edac_mod snd_soc_fsl_asoc_card snd_soc_imx_audmux snd_soc_imx_card snd_soc_wm8962 el_enclave snd_soc_fsl_micfil rtc_pcf2127 rtc_pcf2131 flexcan can_dev snd_soc_fsl_xcvr snd_soc_fsl_sai imx8_media_dev(C) snd_soc_fsl_utils fuse
      [   49.173393] CPU: 0 PID: 565 Comm: sh Tainted: G         C         6.5.0-rc4-next-20230804-05047-g5781a6249dae #677
      [   49.183721] Hardware name: NXP i.MX93 11X11 EVK board (DT)
      [   49.189190] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [   49.196140] pc : 0x80800052
      [   49.198931] lr : stmmac_pltfr_resume+0x34/0x50
      [   49.203368] sp : ffff800082f8bab0
      [   49.206670] x29: ffff800082f8bab0 x28: ffff0000047d0ec0 x27: ffff80008186c170
      [   49.213794] x26: 0000000b5e4ff1ba x25: ffff800081e5fa74 x24: 0000000000000010
      [   49.220918] x23: ffff800081fe0000 x22: 0000000000000000 x21: 0000000000000000
      [   49.228042] x20: ffff0000001b4010 x19: ffff0000001b4010 x18: 0000000000000006
      [   49.235166] x17: ffff7ffffe007000 x16: ffff800080000000 x15: 0000000000000000
      [   49.242290] x14: 00000000000000fc x13: 0000000000000000 x12: 0000000000000000
      [   49.249414] x11: 0000000000000001 x10: 0000000000000a60 x9 : ffff800082f8b8c0
      [   49.256538] x8 : 0000000000000008 x7 : 0000000000000001 x6 : 000000005f54a200
      [   49.263662] x5 : 0000000001000000 x4 : ffff800081b93680 x3 : ffff800081519be0
      [   49.270786] x2 : 0000000080800052 x1 : 0000000000000000 x0 : ffff0000001b4000
      [   49.277911] Call trace:
      [   49.280346]  0x80800052
      [   49.282781]  platform_pm_resume+0x2c/0x68
      [   49.286785]  dpm_run_callback.constprop.0+0x74/0x134
      [   49.291742]  device_resume+0x88/0x194
      [   49.295391]  dpm_resume+0x10c/0x230
      [   49.298866]  dpm_resume_end+0x18/0x30
      [   49.302515]  suspend_devices_and_enter+0x2b8/0x624
      [   49.307299]  pm_suspend+0x1fc/0x348
      [   49.310774]  state_store+0x80/0x104
      [   49.314258]  kobj_attr_store+0x18/0x2c
      [   49.318002]  sysfs_kf_write+0x44/0x54
      [   49.321659]  kernfs_fop_write_iter+0x120/0x1ec
      [   49.326088]  vfs_write+0x1bc/0x300
      [   49.329485]  ksys_write+0x70/0x104
      [   49.332874]  __arm64_sys_write+0x1c/0x28
      [   49.336783]  invoke_syscall+0x48/0x114
      [   49.340527]  el0_svc_common.constprop.0+0xc4/0xe4
      [   49.345224]  do_el0_svc+0x38/0x98
      [   49.348526]  el0_svc+0x2c/0x84
      [   49.351568]  el0t_64_sync_handler+0x100/0x12c
      [   49.355910]  el0t_64_sync+0x190/0x194
      [   49.359567] Code: ???????? ???????? ???????? ???????? (????????)
      [   49.365644] ---[ end trace 0000000000000000 ]---
      
      Fixes: 97117eb5
      
       ("net: stmmac: platform: provide stmmac_pltfr_init()")
      Signed-off-by: default avatarClark Wang <xiaoning.wang@nxp.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6b09edc1
    • Hou Tao's avatar
      bpf: Use kmalloc_size_roundup() to adjust size_index · 9077fc22
      Hou Tao authored
      Commit d52b5931 ("bpf: Adjust size_index according to the value of
      KMALLOC_MIN_SIZE") uses KMALLOC_MIN_SIZE to adjust size_index, but as
      reported by Nathan, the adjustment is not enough, because
      __kmalloc_minalign() also decides the minimal alignment of slab object
      as shown in new_kmalloc_cache() and its value may be greater than
      KMALLOC_MIN_SIZE (e.g., 64 bytes vs 8 bytes under a riscv QEMU VM).
      
      Instead of invoking __kmalloc_minalign() in bpf subsystem to find the
      maximal alignment, just using kmalloc_size_roundup() directly to get the
      corresponding slab object size for each allocation size. If these two
      sizes are unmatched, adjust size_index to select a bpf_mem_cache with
      unit_size equal to the object_size of the underlying slab cache for the
      allocation size.
      
      Fixes: 822fb26b
      
       ("bpf: Add a hint to allocated objects.")
      Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
      Closes: https://lore.kernel.org/bpf/20230914181407.GA1000274@dev-arch.thelio-3990X/
      
      
      Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
      Tested-by: default avatarEmil Renner Berthing <emil.renner.berthing@canonical.com>
      Link: https://lore.kernel.org/r/20230928101558.2594068-1-houtao@huaweicloud.com
      
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      9077fc22
  6. Sep 30, 2023
  7. Sep 29, 2023
    • Jakub Sitnicki's avatar
      bpf, sockmap: Reject sk_msg egress redirects to non-TCP sockets · b80e31ba
      Jakub Sitnicki authored
      With a SOCKMAP/SOCKHASH map and an sk_msg program user can steer messages
      sent from one TCP socket (s1) to actually egress from another TCP
      socket (s2):
      
      tcp_bpf_sendmsg(s1)		// = sk_prot->sendmsg
        tcp_bpf_send_verdict(s1)	// __SK_REDIRECT case
          tcp_bpf_sendmsg_redir(s2)
            tcp_bpf_push_locked(s2)
      	tcp_bpf_push(s2)
      	  tcp_rate_check_app_limited(s2) // expects tcp_sock
      	  tcp_sendmsg_locked(s2)	 // ditto
      
      There is a hard-coded assumption in the call-chain, that the egress
      socket (s2) is a TCP socket.
      
      However in commit 122e6c79 ("sock_map: Update sock type checks for
      UDP") we have enabled redirects to non-TCP sockets. This was done for the
      sake of BPF sk_skb programs. There was no indention to support sk_msg
      send-to-egress use case.
      
      As a result, attempts to send-to-egress through a non-TCP socket lead to a
      crash due to invalid downcast from sock to tcp_sock:
      
       BUG: kernel NULL pointer dereference, address: 000000000000002f
       ...
       Call Trace:
        <TASK>
        ? show_regs+0x60/0x70
        ? __die+0x1f/0x70
        ? page_fault_oops+0x80/0x160
        ? do_user_addr_fault+0x2d7/0x800
        ? rcu_is_watching+0x11/0x50
        ? exc_page_fault+0x70/0x1c0
        ? asm_exc_page_fault+0x27/0x30
        ? tcp_tso_segs+0x14/0xa0
        tcp_write_xmit+0x67/0xce0
        __tcp_push_pending_frames+0x32/0xf0
        tcp_push+0x107/0x140
        tcp_sendmsg_locked+0x99f/0xbb0
        tcp_bpf_push+0x19d/0x3a0
        tcp_bpf_sendmsg_redir+0x55/0xd0
        tcp_bpf_send_verdict+0x407/0x550
        tcp_bpf_sendmsg+0x1a1/0x390
        inet_sendmsg+0x6a/0x70
        sock_sendmsg+0x9d/0xc0
        ? sockfd_lookup_light+0x12/0x80
        __sys_sendto+0x10e/0x160
        ? syscall_enter_from_user_mode+0x20/0x60
        ? __this_cpu_preempt_check+0x13/0x20
        ? lockdep_hardirqs_on+0x82/0x110
        __x64_sys_sendto+0x1f/0x30
        do_syscall_64+0x38/0x90
        entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Reject selecting a non-TCP sockets as redirect target from a BPF sk_msg
      program to prevent the crash. When attempted, user will receive an EACCES
      error from send/sendto/sendmsg() syscall.
      
      Fixes: 122e6c79
      
       ("sock_map: Update sock type checks for UDP")
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/bpf/20230920102055.42662-1-jakub@cloudflare.com
      b80e31ba
    • John Fastabend's avatar
      bpf, sockmap: Add tests for MSG_F_PEEK · 5f405c0c
      John Fastabend authored
      
      
      Test that we can read with MSG_F_PEEK and then still get correct number
      of available bytes through FIONREAD. The recv() (without PEEK) then
      returns the bytes as expected. The recv() always worked though because
      it was just the available byte reporting that was broke before latest
      fixes.
      
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20230926035300.135096-4-john.fastabend@gmail.com
      5f405c0c
    • John Fastabend's avatar
      bpf, sockmap: Do not inc copied_seq when PEEK flag set · da9e915e
      John Fastabend authored
      When data is peek'd off the receive queue we shouldn't considered it
      copied from tcp_sock side. When we increment copied_seq this will confuse
      tcp_data_ready() because copied_seq can be arbitrarily increased. From
      application side it results in poll() operations not waking up when
      expected.
      
      Notice tcp stack without BPF recvmsg programs also does not increment
      copied_seq.
      
      We broke this when we moved copied_seq into recvmsg to only update when
      actual copy was happening. But, it wasn't working correctly either before
      because the tcp_data_ready() tried to use the copied_seq value to see
      if data was read by user yet. See fixes tags.
      
      Fixes: e5c6de5f ("bpf, sockmap: Incorrectly handling copied_seq")
      Fixes: 04919bed
      
       ("tcp: Introduce tcp_read_skb()")
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20230926035300.135096-3-john.fastabend@gmail.com
      da9e915e
    • John Fastabend's avatar
      bpf: tcp_read_skb needs to pop skb regardless of seq · 9b7177b1
      John Fastabend authored
      Before fix e5c6de5f tcp_read_skb() would increment the tp->copied-seq
      value. This (as described in the commit) would cause an error for apps
      because once that is incremented the application might believe there is no
      data to be read. Then some apps would stall or abort believing no data is
      available.
      
      However, the fix is incomplete because it introduces another issue in
      the skb dequeue. The loop does tcp_recv_skb() in a while loop to consume
      as many skbs as possible. The problem is the call is ...
      
        tcp_recv_skb(sk, seq, &offset)
      
      ... where 'seq' is:
      
        u32 seq = tp->copied_seq;
      
      Now we can hit a case where we've yet incremented copied_seq from BPF side,
      but then tcp_recv_skb() fails this test ...
      
       if (offset < skb->len || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN))
      
      ... so that instead of returning the skb we call tcp_eat_recv_skb() which
      frees the skb. This is because the routine believes the SKB has been collapsed
      per comment:
      
       /* This looks weird, but this can happen if TCP collapsing
        * splitted a fat GRO packet, while we released socket lock
        * in skb_splice_bits()
        */
      
      This can't happen here we've unlinked the full SKB and orphaned it. Anyways
      it would confuse any BPF programs if the data were suddenly moved underneath
      it.
      
      To fix this situation do simpler operation and just skb_peek() the data
      of the queue followed by the unlink. It shouldn't need to check this
      condition and tcp_read_skb() reads entire skbs so there is no need to
      handle the 'offset!=0' case as we would see in tcp_read_sock().
      
      Fixes: e5c6de5f ("bpf, sockmap: Incorrectly handling copied_seq")
      Fixes: 04919bed
      
       ("tcp: Introduce tcp_read_skb()")
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20230926035300.135096-2-john.fastabend@gmail.com
      9b7177b1
  8. Sep 28, 2023
    • Michal Schmidt's avatar
      ice: always add legacy 32byte RXDID in supported_rxdids · c070e51d
      Michal Schmidt authored
      When the PF and VF drivers both support flexible rx descriptors and have
      negotiated the VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC capability, the VF driver
      queries the PF for the list of supported descriptor formats
      (VIRTCHNL_OP_GET_SUPPORTED_RXDIDS). The PF driver is supposed to set the
      supported_rxdids bits that correspond to the descriptor formats the
      firmware implements. The legacy 32-byte rx desc format is always
      supported, even though it is not expressed in GLFLXP_RXDID_FLAGS.
      
      The ice driver does not advertise the legacy 32-byte rx desc support,
      which leads to this failure to bring up the VF using the Intel
      out-of-tree iavf driver:
       iavf 0000:41:01.0: PF does not list support for default Rx descriptor format
       ...
       iavf 0000:41:01.0: PF returned error -5 (VIRTCHNL_STATUS_ERR_PARAM) to our request 6
      
      The in-tree iavf driver does not expose this bug, because it does not
      yet implement VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC.
      
      The ice driver must always set the ICE_RXDID_LEGACY_1 bit in
      supported_rxdids. The Intel out-of-tree ice driver and the ice driver in
      DPDK both do this.
      
      I copied this piece of the code and the comment text from the Intel
      out-of-tree driver.
      
      Fixes: e753df8f
      
       ("ice: Add support Flex RXD")
      Signed-off-by: default avatarMichal Schmidt <mschmidt@redhat.com>
      Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
      Link: https://lore.kernel.org/r/20230920115439.61172-1-mschmidt@redhat.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      c070e51d
  9. Sep 27, 2023
  10. Sep 26, 2023
  11. Sep 25, 2023
    • Wen Gong's avatar
      wifi: mac80211: allow transmitting EAPOL frames with tainted key · 61304336
      Wen Gong authored
      
      
      Lower layer device driver stop/wake TX by calling ieee80211_stop_queue()/
      ieee80211_wake_queue() while hw scan. Sometimes hw scan and PTK rekey are
      running in parallel, when M4 sent from wpa_supplicant arrive while the TX
      queue is stopped, then the M4 will pending send, and then new key install
      from wpa_supplicant. After TX queue wake up by lower layer device driver,
      the M4 will be dropped by below call stack.
      
      When key install started, the current key flag is set KEY_FLAG_TAINTED in
      ieee80211_pairwise_rekey(), and then mac80211 wait key install complete by
      lower layer device driver. Meanwhile ieee80211_tx_h_select_key() will return
      TX_DROP for the M4 in step 12 below, and then ieee80211_free_txskb() called
      by ieee80211_tx_dequeue(), so the M4 will not send and free, then the rekey
      process failed becaue AP not receive M4. Please see details in steps below.
      
      There are a interval between KEY_FLAG_TAINTED set for current key flag and
      install key complete by lower layer device driver, the KEY_FLAG_TAINTED is
      set in this interval, all packet including M4 will be dropped in this
      interval, the interval is step 8~13 as below.
      
      issue steps:
            TX thread                 install key thread
      1.   stop_queue                      -idle-
      2.   sending M4                      -idle-
      3.   M4 pending                      -idle-
      4.     -idle-                  starting install key from wpa_supplicant
      5.     -idle-                  =>ieee80211_key_replace()
      6.     -idle-                  =>ieee80211_pairwise_rekey() and set
                                       currently key->flags |= KEY_FLAG_TAINTED
      7.     -idle-                  =>ieee80211_key_enable_hw_accel()
      8.     -idle-                  =>drv_set_key() and waiting key install
                                       complete from lower layer device driver
      9.   wake_queue                     -waiting state-
      10.  re-sending M4                  -waiting state-
      11.  =>ieee80211_tx_h_select_key()  -waiting state-
      12.  drop M4 by KEY_FLAG_TAINTED    -waiting state-
      13.    -idle-                   install key complete with success/fail
                                        success: clear flag KEY_FLAG_TAINTED
                                        fail: start disconnect
      
      Hence add check in step 11 above to allow the EAPOL send out in the
      interval. If lower layer device driver use the old key/cipher to encrypt
      the M4, then AP received/decrypt M4 correctly, after M4 send out, lower
      layer device driver install the new key/cipher to hardware and return
      success.
      
      If lower layer device driver use new key/cipher to send the M4, then AP
      will/should drop the M4, then it is same result with this issue, AP will/
      should kick out station as well as this issue.
      
      issue log:
      kworker/u16:4-5238  [000]  6456.108926: stop_queue:           phy1 queue:0, reason:0
      wpa_supplicant-961  [003]  6456.119737: rdev_tx_control_port: wiphy_name=phy1 name=wlan0 ifindex=6 dest=ARRAY[9e, 05, 31, 20, 9b, d0] proto=36488 unencrypted=0
      wpa_supplicant-961  [003]  6456.119839: rdev_return_int_cookie: phy1, returned 0, cookie: 504
      wpa_supplicant-961  [003]  6456.120287: rdev_add_key:         phy1, netdev:wlan0(6), key_index: 0, mode: 0, pairwise: true, mac addr: 9e:05:31:20:9b:d0
      wpa_supplicant-961  [003]  6456.120453: drv_set_key:          phy1 vif:wlan0(2) sta:9e:05:31:20:9b:d0 cipher:0xfac04, flags=0x9, keyidx=0, hw_key_idx=0
      kworker/u16:9-3829  [001]  6456.168240: wake_queue:           phy1 queue:0, reason:0
      kworker/u16:9-3829  [001]  6456.168255: drv_wake_tx_queue:    phy1 vif:wlan0(2) sta:9e:05:31:20:9b:d0 ac:0 tid:7
      kworker/u16:9-3829  [001]  6456.168305: cfg80211_control_port_tx_status: wdev(1), cookie: 504, ack: false
      wpa_supplicant-961  [003]  6459.167982: drv_return_int:       phy1 - -110
      
      issue call stack:
      nl80211_frame_tx_status+0x230/0x340 [cfg80211]
      cfg80211_control_port_tx_status+0x1c/0x28 [cfg80211]
      ieee80211_report_used_skb+0x374/0x3e8 [mac80211]
      ieee80211_free_txskb+0x24/0x40 [mac80211]
      ieee80211_tx_dequeue+0x644/0x954 [mac80211]
      ath10k_mac_tx_push_txq+0xac/0x238 [ath10k_core]
      ath10k_mac_op_wake_tx_queue+0xac/0xe0 [ath10k_core]
      drv_wake_tx_queue+0x80/0x168 [mac80211]
      __ieee80211_wake_txqs+0xe8/0x1c8 [mac80211]
      _ieee80211_wake_txqs+0xb4/0x120 [mac80211]
      ieee80211_wake_txqs+0x48/0x80 [mac80211]
      tasklet_action_common+0xa8/0x254
      tasklet_action+0x2c/0x38
      __do_softirq+0xdc/0x384
      
      Signed-off-by: default avatarWen Gong <quic_wgong@quicinc.com>
      Link: https://lore.kernel.org/r/20230801064751.25803-1-quic_wgong@quicinc.com
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      61304336
    • Johannes Berg's avatar
      wifi: mac80211: work around Cisco AP 9115 VHT MPDU length · 084cf2ae
      Johannes Berg authored
      
      
      Cisco AP module 9115 with FW 17.3 has a bug and sends a too
      large maximum MPDU length in the association response
      (indicating 12k) that it cannot actually process.
      
      Work around that by taking the minimum between what's in the
      association response and the BSS elements (from beacon or
      probe response).
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Link: https://lore.kernel.org/r/20230918140607.d1966a9a532e.I090225babb7cd4d1081ee9acd40e7de7e41c15ae@changeid
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      084cf2ae
    • Ilan Peer's avatar
      wifi: cfg80211: Fix 6GHz scan configuration · 0914468a
      Ilan Peer authored
      
      
      When the scan request includes a non broadcast BSSID, when adding the
      scan parameters for 6GHz collocated scanning, do not include entries
      that do not match the given BSSID.
      
      Signed-off-by: default avatarIlan Peer <ilan.peer@intel.com>
      Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Link: https://lore.kernel.org/r/20230918140607.6d31d2a96baf.I6c4e3e3075d1d1878ee41f45190fdc6b86f18708@changeid
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      0914468a