1. 23 Mar, 2023 20 commits
    • Jakub Kicinski's avatar
      Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf · 1b4ae19e
      Jakub Kicinski authored
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf 2023-03-23
      
      We've added 8 non-merge commits during the last 13 day(s) which contain
      a total of 21 files changed, 238 insertions(+), 161 deletions(-).
      
      The main changes are:
      
      1) Fix verification issues in some BPF programs due to their stack usage
         patterns, from Eduard Zingerman.
      
      2) Fix to add missing overflow checks in xdp_umem_reg and return an error
         in such case, from Kal Conley.
      
      3) Fix and undo poisoning of strlcpy in libbpf given it broke builds for
         libcs which provided the former like uClibc-ng, from Jesus Sanchez-Palencia.
      
      4) Fix insufficient bpf_jit_limit default to avoid users running into hard
         to debug seccomp BPF errors, from Daniel Borkmann.
      
      5) Fix driver return code when they don't support a bpf_xdp_metadata kfunc
         to make it unambiguous from other errors, from Jesper Dangaard Brouer.
      
      6) Two BPF selftest fixes to address compilation errors from recent changes
         in kernel structures, from Alexei Starovoitov.
      
      * tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
        xdp: bpf_xdp_metadata use EOPNOTSUPP for no driver support
        bpf: Adjust insufficient default bpf_jit_limit
        xsk: Add missing overflow check in xdp_umem_reg
        selftests/bpf: Fix progs/test_deny_namespace.c issues.
        selftests/bpf: Fix progs/find_vma_fail1.c build error.
        libbpf: Revert poisoning of strlcpy
        selftests/bpf: Tests for uninitialized stack reads
        bpf: Allow reads from uninit stack
      ====================
      
      Link: https://lore.kernel.org/r/20230323225221.6082-1-daniel@iogearbox.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      1b4ae19e
    • Jakub Kicinski's avatar
      Merge tag 'for-net-2023-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth · 2e63a2df
      Jakub Kicinski authored
      Luiz Augusto von Dentz says:
      
      ====================
      bluetooth pull request for net:
      
       - Fix MGMT add advmon with RSSI command
       - L2CAP: Fix responding with wrong PDU type
       - Fix race condition in hci_cmd_sync_clear
       - ISO: Fix timestamped HCI ISO data packet parsing
       - HCI: Fix global-out-of-bounds
       - hci_sync: Resume adv with no RPA when active scan
      
      * tag 'for-net-2023-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth:
        Bluetooth: HCI: Fix global-out-of-bounds
        Bluetooth: mgmt: Fix MGMT add advmon with RSSI command
        Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work
        Bluetooth: L2CAP: Fix responding with wrong PDU type
        Bluetooth: btqcomsmd: Fix command timeout after setting BD address
        Bluetooth: btinel: Check ACPI handle for NULL before accessing
        Bluetooth: Remove "Power-on" check from Mesh feature
        Bluetooth: Fix race condition in hci_cmd_sync_clear
        Bluetooth: btintel: Iterate only bluetooth device ACPI entries
        Bluetooth: ISO: fix timestamped HCI ISO data packet parsing
        Bluetooth: btusb: Remove detection of ISO packets over bulk
        Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet
        Bluetooth: hci_sync: Resume adv with no RPA when active scan
      ====================
      
      Link: https://lore.kernel.org/r/20230323202335.3380841-1-luiz.dentz@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      2e63a2df
    • Jakub Kicinski's avatar
      Merge tag 'wireless-2023-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless · 4f44d326
      Jakub Kicinski authored
      Kalle Valo says:
      
      ====================
      wireless fixes for v6.3
      
      Third set of fixes for v6.3. mt76 has two kernel crash fixes and
      adding back 160 MHz channel support for mt7915. mac80211 has fixes for
      a race in transmit path and two mesh related fixes. iwlwifi also has
      fixes for races.
      
      * tag 'wireless-2023-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless:
        wifi: mac80211: fix mesh path discovery based on unicast packets
        wifi: mac80211: fix qos on mesh interfaces
        wifi: iwlwifi: mvm: protect TXQ list manipulation
        wifi: iwlwifi: mvm: fix mvmtxq->stopped handling
        wifi: mac80211: Serialize ieee80211_handle_wake_tx_queue()
        wifi: mwifiex: mark OF related data as maybe unused
        wifi: mt76: connac: do not check WED status for non-mmio devices
        wifi: mt76: mt7915: add back 160MHz channel width support for MT7915
        wifi: mt76: do not run mt76_unregister_device() on unregistered hw
      ====================
      
      Link: https://lore.kernel.org/r/20230323110332.C4FE4C433D2@smtp.kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4f44d326
    • Sungwoo Kim's avatar
      Bluetooth: HCI: Fix global-out-of-bounds · bce56405
      Sungwoo Kim authored
      To loop a variable-length array, hci_init_stage_sync(stage) considers
      that stage[i] is valid as long as stage[i-1].func is valid.
      Thus, the last element of stage[].func should be intentionally invalid
      as hci_init0[], le_init2[], and others did.
      However, amp_init1[] and amp_init2[] have no invalid element, letting
      hci_init_stage_sync() keep accessing amp_init1[] over its valid range.
      This patch fixes this by adding {} in the last of amp_init1[] and
      amp_init2[].
      
      ==================================================================
      BUG: KASAN: global-out-of-bounds in hci_dev_open_sync (
      /v6.2-bzimage/net/bluetooth/hci_sync.c:3154
      /v6.2-bzimage/net/bluetooth/hci_sync.c:3343
      /v6.2-bzimage/net/bluetooth/hci_sync.c:4418
      /v6.2-bzimage/net/bluetooth/hci_sync.c:4609
      /v6.2-bzimage/net/bluetooth/hci_sync.c:4689)
      Read of size 8 at addr ffffffffaed1ab70 by task kworker/u5:0/1032
      CPU: 0 PID: 1032 Comm: kworker/u5:0 Not tainted 6.2.0 #3
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04
      Workqueue: hci1 hci_power_on
      Call Trace:
       <TASK>
      dump_stack_lvl (/v6.2-bzimage/lib/dump_stack.c:107 (discriminator 1))
      print_report (/v6.2-bzimage/mm/kasan/report.c:307
        /v6.2-bzimage/mm/kasan/report.c:417)
      ? hci_dev_open_sync (/v6.2-bzimage/net/bluetooth/hci_sync.c:3154
        /v6.2-bzimage/net/bluetooth/hci_sync.c:3343
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4418
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4609
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4689)
      kasan_report (/v6.2-bzimage/mm/kasan/report.c:184
        /v6.2-bzimage/mm/kasan/report.c:519)
      ? hci_dev_open_sync (/v6.2-bzimage/net/bluetooth/hci_sync.c:3154
        /v6.2-bzimage/net/bluetooth/hci_sync.c:3343
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4418
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4609
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4689)
      hci_dev_open_sync (/v6.2-bzimage/net/bluetooth/hci_sync.c:3154
        /v6.2-bzimage/net/bluetooth/hci_sync.c:3343
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4418
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4609
        /v6.2-bzimage/net/bluetooth/hci_sync.c:4689)
      ? __pfx_hci_dev_open_sync (/v6.2-bzimage/net/bluetooth/hci_sync.c:4635)
      ? mutex_lock (/v6.2-bzimage/./arch/x86/include/asm/atomic64_64.h:190
        /v6.2-bzimage/./include/linux/atomic/atomic-long.h:443
        /v6.2-bzimage/./include/linux/atomic/atomic-instrumented.h:1781
        /v6.2-bzimage/kernel/locking/mutex.c:171
        /v6.2-bzimage/kernel/locking/mutex.c:285)
      ? __pfx_mutex_lock (/v6.2-bzimage/kernel/locking/mutex.c:282)
      hci_power_on (/v6.2-bzimage/net/bluetooth/hci_core.c:485
        /v6.2-bzimage/net/bluetooth/hci_core.c:984)
      ? __pfx_hci_power_on (/v6.2-bzimage/net/bluetooth/hci_core.c:969)
      ? read_word_at_a_time (/v6.2-bzimage/./include/asm-generic/rwonce.h:85)
      ? strscpy (/v6.2-bzimage/./arch/x86/include/asm/word-at-a-time.h:62
        /v6.2-bzimage/lib/string.c:161)
      process_one_work (/v6.2-bzimage/kernel/workqueue.c:2294)
      worker_thread (/v6.2-bzimage/./include/linux/list.h:292
        /v6.2-bzimage/kernel/workqueue.c:2437)
      ? __pfx_worker_thread (/v6.2-bzimage/kernel/workqueue.c:2379)
      kthread (/v6.2-bzimage/kernel/kthread.c:376)
      ? __pfx_kthread (/v6.2-bzimage/kernel/kthread.c:331)
      ret_from_fork (/v6.2-bzimage/arch/x86/entry/entry_64.S:314)
       </TASK>
      The buggy address belongs to the variable:
      amp_init1+0x30/0x60
      The buggy address belongs to the physical page:
      page:000000003a157ec6 refcount:1 mapcount:0 mapping:0000000000000000 ia
      flags: 0x200000000001000(reserved|node=0|zone=2)
      raw: 0200000000001000 ffffea0005054688 ffffea0005054688 000000000000000
      raw: 0000000000000000 0000000000000000 00000001ffffffff 000000000000000
      page dumped because: kasan: bad access detected
      Memory state around the buggy address:
       ffffffffaed1aa00: f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9 00 00 00 00
       ffffffffaed1aa80: 00 00 00 00 f9 f9 f9 f9 00 00 00 00 00 00 00 00
      >ffffffffaed1ab00: 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 f9 f9
                                                                   ^
       ffffffffaed1ab80: f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9 00 00 00 f9
       ffffffffaed1ac00: f9 f9 f9 f9 00 06 f9 f9 f9 f9 f9 f9 00 00 02 f9
      
      This bug is found by FuzzBT, a modified version of Syzkaller.
      Other contributors for this bug are Ruoyu Wu and Peng Hui.
      
      Fixes: d0b13706 ("Bluetooth: hci_sync: Rework init stages")
      Signed-off-by: default avatarSungwoo Kim <iam@sung-woo.kim>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      bce56405
    • Howard Chung's avatar
      Bluetooth: mgmt: Fix MGMT add advmon with RSSI command · 1a0291f8
      Howard Chung authored
      The MGMT command: MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI uses variable
      length argument. This causes host not able to register advmon with rssi.
      
      This patch has been locally tested by adding monitor with rssi via
      btmgmt on a kernel 6.1 machine.
      Reviewed-by: default avatarArchie Pusaka <apusaka@chromium.org>
      Fixes: b338d917 ("Bluetooth: Implement support for Mesh")
      Signed-off-by: default avatarHoward Chung <howardchung@google.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      1a0291f8
    • Zheng Wang's avatar
      Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work · 1e9ac114
      Zheng Wang authored
      In btsdio_probe, &data->work was bound with btsdio_work.In
      btsdio_send_frame, it was started by schedule_work.
      
      If we call btsdio_remove with an unfinished job, there may
      be a race condition and cause UAF bug on hdev.
      
      Fixes: ddbaf13e ("[Bluetooth] Add generic driver for Bluetooth SDIO devices")
      Signed-off-by: default avatarZheng Wang <zyytlz.wz@163.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      1e9ac114
    • Luiz Augusto von Dentz's avatar
      Bluetooth: L2CAP: Fix responding with wrong PDU type · 9aa9d947
      Luiz Augusto von Dentz authored
      L2CAP_ECRED_CONN_REQ shall be responded with L2CAP_ECRED_CONN_RSP not
      L2CAP_LE_CONN_RSP:
      
      L2CAP LE EATT Server - Reject - run
        Listening for connections
        New client connection with handle 0x002a
        Sending L2CAP Request from client
        Client received response code 0x15
        Unexpected L2CAP response code (expected 0x18)
      L2CAP LE EATT Server - Reject - test failed
      
      > ACL Data RX: Handle 42 flags 0x02 dlen 26
            LE L2CAP: Enhanced Credit Connection Request (0x17) ident 1 len 18
              PSM: 39 (0x0027)
              MTU: 64
              MPS: 64
              Credits: 5
              Source CID: 65
              Source CID: 66
              Source CID: 67
              Source CID: 68
              Source CID: 69
      < ACL Data TX: Handle 42 flags 0x00 dlen 16
            LE L2CAP: LE Connection Response (0x15) ident 1 len 8
              invalid size
              00 00 00 00 00 00 06 00
      
      L2CAP LE EATT Server - Reject - run
        Listening for connections
        New client connection with handle 0x002a
        Sending L2CAP Request from client
        Client received response code 0x18
      L2CAP LE EATT Server - Reject - test passed
      
      Fixes: 15f02b91 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode")
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      9aa9d947
    • Stephan Gerhold's avatar
      Bluetooth: btqcomsmd: Fix command timeout after setting BD address · 5d44ab9e
      Stephan Gerhold authored
      On most devices using the btqcomsmd driver (e.g. the DragonBoard 410c
      and other devices based on the Qualcomm MSM8916/MSM8909/... SoCs)
      the Bluetooth firmware seems to become unresponsive for a while after
      setting the BD address. On recent kernel versions (at least 5.17+)
      this often causes timeouts for subsequent commands, e.g. the HCI reset
      sent by the Bluetooth core during initialization:
      
          Bluetooth: hci0: Opcode 0x c03 failed: -110
      
      Unfortunately this behavior does not seem to be documented anywhere.
      Experimentation suggests that the minimum necessary delay to avoid
      the problem is ~150us. However, to be sure add a sleep for > 1ms
      in case it is a bit longer on other firmware versions.
      
      Older kernel versions are likely also affected, although perhaps with
      slightly different errors or less probability. Side effects can easily
      hide the issue in most cases, e.g. unrelated incoming interrupts that
      cause the necessary delay.
      
      Fixes: 1511cc75 ("Bluetooth: Introduce Qualcomm WCNSS SMD based HCI driver")
      Signed-off-by: default avatarStephan Gerhold <stephan.gerhold@kernkonzept.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      5d44ab9e
    • Kiran K's avatar
      Bluetooth: btinel: Check ACPI handle for NULL before accessing · 902160cd
      Kiran K authored
      Older platforms and Virtual platforms which doesn't have support for
      bluetooth device in ACPI firmware will not have valid ACPI handle.
      Check for validity of handle before accessing.
      
      dmesg log from simics environment (virtual platform):
      
      BUG: unable to handle kernel NULL pointer dereference at
      0000000000000018
      IP: acpi_ns_walk_namespace+0x5c/0x278
      PGD 0 P4D 0
      Oops: 0000 [#1] SMP PTI
      Modules linked in: bnep intel_powerclamp coretemp kvm_intel
      kvm irqbypass intel_cstate input_leds joydev serio_raw mac_hid
      btusb(OE) btintel(OE) bluetooth(OE) lpc_ich compat(OE) ecdh_generic
      i7core_edac i5500_temp shpchp binfmt_misc sch_fq_codel parport_pc ppdev
      lp parport ip_tables x_tables autofs4 hid_generic usbhid hid e1000e
      psmouse ahci pata_acpi libahci ptp pps_core floppy
      CPU: 0 PID: 35 Comm: kworker/u3:0 Tainted: G           OE
      4.15.0-140-generic #144-Ubuntu
      Hardware name: Simics Simics, BIOS Simics 01/01/2011
      Workqueue: hci0 hci_power_on [bluetooth]
      RIP: 0010:acpi_ns_walk_namespace+0x5c/0x278
      RSP: 0000:ffffaa9c0049bba8 EFLAGS: 00010246
      RAX: 0000000000000001 RBX: 0000000000001001 RCX: 0000000000000010
      RDX: ffffffff92ea7e27 RSI: ffffffff92ea7e10 RDI: 00000000000000c8
      RBP: ffffaa9c0049bbf8 R08: 0000000000000000 R09: ffffffffc05b39d0
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
      R13: 0000000000000000 R14: ffffffffc05b39d0 R15: ffffaa9c0049bc70
      FS:  0000000000000000(0000) GS:ffff8be73fc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000018 CR3: 0000000075f0e000 CR4: 00000000000006f0
      
      Fixes: 294d749b ("Bluetooth: btintel: Iterate only bluetooth device ACPI entries")
      Signed-off-by: default avatarKiran K <kiran.k@intel.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      902160cd
    • Liang He's avatar
      net: mdio: thunder: Add missing fwnode_handle_put() · b1de5c78
      Liang He authored
      In device_for_each_child_node(), we should add fwnode_handle_put()
      when break out of the iteration device_for_each_child_node()
      as it will automatically increase and decrease the refcounter.
      
      Fixes: 379d7ac7 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
      Signed-off-by: default avatarLiang He <windhl@126.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b1de5c78
    • Jakub Kicinski's avatar
      Merge tag 'mlx5-fixes-2023-03-21' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux · fb63d217
      Jakub Kicinski authored
      Saeed Mahameed says:
      
      ====================
      mlx5 fixes 2023-03-21
      
      This series provides bug fixes to mlx5 driver.
      
      * tag 'mlx5-fixes-2023-03-21' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux:
        net/mlx5: E-Switch, Fix an Oops in error handling code
        net/mlx5: Read the TC mapping of all priorities on ETS query
        net/mlx5e: Overcome slow response for first macsec ASO WQE
        net/mlx5e: Initialize link speed to zero
        net/mlx5: Fix steering rules cleanup
        net/mlx5e: Block entering switchdev mode with ns inconsistency
        net/mlx5e: Set uplink rep as NETNS_LOCAL
      ====================
      
      Link: https://lore.kernel.org/r/20230321211135.47711-1-saeed@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      fb63d217
    • Jakub Kicinski's avatar
      Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue · 3e212b0b
      Jakub Kicinski authored
      Tony Nguyen says:
      
      ====================
      Intel Wired LAN Driver Updates 2023-03-21 (ice)
      
      This series contains updates to ice driver only.
      
      Piotr sets first_desc field for proper handling of Flow Director
      packets.
      
      Michal moves error checking for VF earlier in function to properly return
      error before other checks/reporting; he also corrects VSI filter removal to
      be done during VSI removal and not rebuild.
      
      * '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue:
        ice: remove filters only if VSI is deleted
        ice: check if VF exists before mode check
        ice: fix rx buffers handling for flow director packets
      ====================
      
      Link: https://lore.kernel.org/r/20230321183641.2849726-1-anthony.l.nguyen@intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      3e212b0b
    • Jakub Kicinski's avatar
      Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue · cad4fb02
      Jakub Kicinski authored
      Tony Nguyen says:
      
      ====================
      Intel Wired LAN Driver Updates 2023-03-21 (iavf, i40e)
      
      This series contains updates to iavf and i40e drivers.
      
      Stefan Assmann adds check, and return, if driver has already gone
      through remove to prevent hang for iavf.
      
      Radoslaw adds zero initialization to ensure Flow Director packets are
      populated with correct values for i40e.
      
      * '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue:
        i40e: fix flow director packet filter programming
        iavf: fix hang on reboot with ice
      ====================
      
      Link: https://lore.kernel.org/r/20230321183548.2849671-1-anthony.l.nguyen@intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      cad4fb02
    • Arınç ÜNAL's avatar
      net: dsa: mt7530: move setting ssc_delta to PHY_INTERFACE_MODE_TRGMII case · 407b508b
      Arınç ÜNAL authored
      Move setting the ssc_delta variable to under the PHY_INTERFACE_MODE_TRGMII
      case as it's only needed when trgmii is used.
      
      Fixes: b8f126a8 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
      Signed-off-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
      Link: https://lore.kernel.org/r/20230320190520.124513-3-arinc.unal@arinc9.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      407b508b
    • Arınç ÜNAL's avatar
      net: dsa: mt7530: move lowering TRGMII driving to mt7530_setup() · fdcc8ccd
      Arınç ÜNAL authored
      Move lowering the TRGMII Tx clock driving to mt7530_setup(), after setting
      the core clock, as seen on the U-Boot MediaTek ethernet driver.
      
      Move the code which looks like it lowers the TRGMII Rx clock driving to
      after the TRGMII Tx clock driving is lowered. This is run after lowering
      the Tx clock driving on the U-Boot MediaTek ethernet driver as well.
      
      This way, the switch should consume less power regardless of port 6 being
      used.
      
      Update the comment explaining mt7530_pad_clk_setup().
      
      Tested rgmii and trgmii modes of port 6 and rgmii mode of port 5 on MCM
      MT7530 on MT7621AT Unielec U7621-06 and standalone MT7530 on MT7623NI
      Bananapi BPI-R2.
      
      Fixes: b8f126a8 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
      Link: https://source.denx.de/u-boot/u-boot/-/blob/29a48bf9ccba45a5e560bb564bbe76e42629325f/drivers/net/mtk_eth.c#L682Tested-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
      Signed-off-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
      Link: https://lore.kernel.org/r/20230320190520.124513-2-arinc.unal@arinc9.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      fdcc8ccd
    • Arınç ÜNAL's avatar
      net: dsa: mt7530: move enabling disabling core clock to mt7530_pll_setup() · 8f058a6e
      Arınç ÜNAL authored
      Split the code that enables and disables TRGMII clocks and core clock.
      Move enabling and disabling core clock to mt7530_pll_setup() as it's
      supposed to be run there.
      
      Add 20 ms delay before enabling the core clock as seen on the U-Boot
      MediaTek ethernet driver.
      
      Change the comment for enabling and disabling TRGMII clocks as the code
      seems to affect both TXC and RXC.
      
      Tested rgmii and trgmii modes of port 6 and rgmii mode of port 5 on MCM
      MT7530 on MT7621AT Unielec U7621-06 and standalone MT7530 on MT7623NI
      Bananapi BPI-R2.
      
      Fixes: b8f126a8 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
      Link: https://source.denx.de/u-boot/u-boot/-/blob/29a48bf9ccba45a5e560bb564bbe76e42629325f/drivers/net/mtk_eth.c#L589Tested-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
      Signed-off-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
      Link: https://lore.kernel.org/r/20230320190520.124513-1-arinc.unal@arinc9.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8f058a6e
    • Grant Grundler's avatar
      net: asix: fix modprobe "sysfs: cannot create duplicate filename" · 8eac0095
      Grant Grundler authored
      "modprobe asix ; rmmod asix ; modprobe asix" fails with:
         sysfs: cannot create duplicate filename \
         	'/devices/virtual/mdio_bus/usb-003:004'
      
      Issue was originally reported by Anton Lundin on 2022-06-22 (link below).
      
      Chrome OS team hit the same issue in Feb, 2023 when trying to find
      work arounds for other issues with AX88172 devices.
      
      The use of devm_mdiobus_register() with usbnet devices results in the
      MDIO data being associated with the USB device. When the asix driver
      is unloaded, the USB device continues to exist and the corresponding
      "mdiobus_unregister()" is NOT called until the USB device is unplugged
      or unauthorized. So the next "modprobe asix" will fail because the MDIO
      phy sysfs attributes still exist.
      
      The 'easy' (from a design PoV) fix is to use the non-devm variants of
      mdiobus_* functions and explicitly manage this use in the asix_bind
      and asix_unbind function calls. I've not explored trying to fix usbnet
      initialization so devm_* stuff will work.
      
      Fixes: e532a096 ("net: usb: asix: ax88772: add phylib support")
      Reported-by: default avatarAnton Lundin <glance@acc.umu.se>
      Link: https://lore.kernel.org/netdev/20220623063649.GD23685@pengutronix.de/T/Tested-by: default avatarEizan Miyamoto <eizan@chromium.org>
      Signed-off-by: default avatarGrant Grundler <grundler@chromium.org>
      Link: https://lore.kernel.org/r/20230321170539.732147-1-grundler@chromium.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8eac0095
    • Joshua Washington's avatar
      gve: Cache link_speed value from device · 68c3e4fc
      Joshua Washington authored
      The link speed is never changed for the uptime of a VM, and the current
      implementation sends an admin queue command for each call. Admin queue
      command invocations have nontrivial overhead (e.g., VM exits), which can
      be disruptive to users if triggered frequently. Our telemetry data shows
      that there are VMs that make frequent calls to this admin queue command.
      Caching the result of the original admin queue command would eliminate
      the need to send multiple admin queue commands on subsequent calls to
      retrieve link speed.
      
      Fixes: 7e074d5a ("gve: Enable Link Speed Reporting in the driver.")
      Signed-off-by: default avatarJoshua Washington <joshwash@google.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20230321172332.91678-1-joshwash@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      68c3e4fc
    • Donald Hunter's avatar
      tools: ynl: Fix genlmsg header encoding formats · 758d29fb
      Donald Hunter authored
      The pack strings use 'b' signed char for cmd and version but struct
      genlmsghdr defines them as unsigned char. Use 'B' instead.
      
      Fixes: 4e4480e8 ("tools: ynl: move the cli and netlink code around")
      Signed-off-by: default avatarDonald Hunter <donald.hunter@gmail.com>
      Link: https://lore.kernel.org/r/20230319193803.97453-1-donald.hunter@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      758d29fb
    • Vladimir Oltean's avatar
      net: enetc: fix aggregate RMON counters not showing the ranges · c79493c3
      Vladimir Oltean authored
      When running "ethtool -S eno0 --groups rmon" without an explicit "--src
      emac|pmac" argument, the kernel will not report
      rx-rmon-etherStatsPkts64to64Octets, rx-rmon-etherStatsPkts65to127Octets,
      etc. This is because on ETHTOOL_MAC_STATS_SRC_AGGREGATE, we do not
      populate the "ranges" argument.
      
      ocelot_port_get_rmon_stats() does things differently and things work
      there. I had forgotten to make sure that the code is structured the same
      way in both drivers, so do that now.
      
      Fixes: cf52bd23 ("net: enetc: add support for MAC Merge statistics counters")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20230321232831.1200905-1-vladimir.oltean@nxp.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      c79493c3
  2. 22 Mar, 2023 20 commits
    • Brian Gix's avatar
      Bluetooth: Remove "Power-on" check from Mesh feature · 52dd5e96
      Brian Gix authored
      The Bluetooth mesh experimental feature enable was requiring the
      controller to be powered off in order for the Enable to work. Mesh is
      supposed to be enablable regardless of the controller state, and created
      an unintended requirement that the mesh daemon be started before the
      classic bluetoothd daemon.
      
      Fixes: af6bcc19 ("Bluetooth: Add experimental wrapper for MGMT based mesh")
      Signed-off-by: default avatarBrian Gix <brian.gix@gmail.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      52dd5e96
    • Min Li's avatar
      Bluetooth: Fix race condition in hci_cmd_sync_clear · 1c66bee4
      Min Li authored
      There is a potential race condition in hci_cmd_sync_work and
      hci_cmd_sync_clear, and could lead to use-after-free. For instance,
      hci_cmd_sync_work is added to the 'req_workqueue' after cancel_work_sync
      The entry of 'cmd_sync_work_list' may be freed in hci_cmd_sync_clear, and
      causing kernel panic when it is used in 'hci_cmd_sync_work'.
      
      Here's the call trace:
      
      dump_stack_lvl+0x49/0x63
      print_report.cold+0x5e/0x5d3
      ? hci_cmd_sync_work+0x282/0x320
      kasan_report+0xaa/0x120
      ? hci_cmd_sync_work+0x282/0x320
      __asan_report_load8_noabort+0x14/0x20
      hci_cmd_sync_work+0x282/0x320
      process_one_work+0x77b/0x11c0
      ? _raw_spin_lock_irq+0x8e/0xf0
      worker_thread+0x544/0x1180
      ? poll_idle+0x1e0/0x1e0
      kthread+0x285/0x320
      ? process_one_work+0x11c0/0x11c0
      ? kthread_complete_and_exit+0x30/0x30
      ret_from_fork+0x22/0x30
      </TASK>
      
      Allocated by task 266:
      kasan_save_stack+0x26/0x50
      __kasan_kmalloc+0xae/0xe0
      kmem_cache_alloc_trace+0x191/0x350
      hci_cmd_sync_queue+0x97/0x2b0
      hci_update_passive_scan+0x176/0x1d0
      le_conn_complete_evt+0x1b5/0x1a00
      hci_le_conn_complete_evt+0x234/0x340
      hci_le_meta_evt+0x231/0x4e0
      hci_event_packet+0x4c5/0xf00
      hci_rx_work+0x37d/0x880
      process_one_work+0x77b/0x11c0
      worker_thread+0x544/0x1180
      kthread+0x285/0x320
      ret_from_fork+0x22/0x30
      
      Freed by task 269:
      kasan_save_stack+0x26/0x50
      kasan_set_track+0x25/0x40
      kasan_set_free_info+0x24/0x40
      ____kasan_slab_free+0x176/0x1c0
      __kasan_slab_free+0x12/0x20
      slab_free_freelist_hook+0x95/0x1a0
      kfree+0xba/0x2f0
      hci_cmd_sync_clear+0x14c/0x210
      hci_unregister_dev+0xff/0x440
      vhci_release+0x7b/0xf0
      __fput+0x1f3/0x970
      ____fput+0xe/0x20
      task_work_run+0xd4/0x160
      do_exit+0x8b0/0x22a0
      do_group_exit+0xba/0x2a0
      get_signal+0x1e4a/0x25b0
      arch_do_signal_or_restart+0x93/0x1f80
      exit_to_user_mode_prepare+0xf5/0x1a0
      syscall_exit_to_user_mode+0x26/0x50
      ret_from_fork+0x15/0x30
      
      Fixes: 6a98e383 ("Bluetooth: Add helper for serialized HCI command execution")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMin Li <lm0963hack@gmail.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      1c66bee4
    • Kiran K's avatar
      Bluetooth: btintel: Iterate only bluetooth device ACPI entries · 294d749b
      Kiran K authored
      Current flow interates over entire ACPI table entries looking for
      Bluetooth Per Platform Antenna Gain(PPAG) entry. This patch iterates
      over ACPI entries relvant to Bluetooth device only.
      
      Fixes: c585a92b ("Bluetooth: btintel: Set Per Platform Antenna Gain(PPAG)")
      Signed-off-by: default avatarKiran K <kiran.k@intel.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      294d749b
    • Pauli Virtanen's avatar
      Bluetooth: ISO: fix timestamped HCI ISO data packet parsing · 2f10e40a
      Pauli Virtanen authored
      Use correct HCI ISO data packet header struct when the packet has
      timestamp. The timestamp, when present, goes before the other fields
      (Core v5.3 4E 5.4.5), so the structs are not compatible.
      
      Fixes: ccf74f23 ("Bluetooth: Add BTPROTO_ISO socket type")
      Signed-off-by: default avatarPauli Virtanen <pav@iki.fi>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      2f10e40a
    • Luiz Augusto von Dentz's avatar
      Bluetooth: btusb: Remove detection of ISO packets over bulk · efe375b7
      Luiz Augusto von Dentz authored
      This removes the code introduced by
      14202eff as hci_recv_frame is now able
      to detect ACL packets that are in fact ISO packets.
      
      Fixes: 14202eff ("Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet")
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      efe375b7
    • Luiz Augusto von Dentz's avatar
      Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet · 876e7810
      Luiz Augusto von Dentz authored
      Because some transports don't have a dedicated type for ISO packets
      (see 14202eff) they may use ACL type
      when in fact they are ISO packets.
      
      In the past this was left for the driver to detect such thing but it
      creates a problem when using the likes of btproxy when used by a VM as
      the host would not be aware of the connection the guest is doing it
      won't be able to detect such behavior, so this make bt_recv_frame
      detect when it happens as it is the common interface to all drivers
      including guest VMs.
      
      Fixes: 14202eff ("Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet")
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      876e7810
    • Zhengping Jiang's avatar
      Bluetooth: hci_sync: Resume adv with no RPA when active scan · 3c44a431
      Zhengping Jiang authored
      The address resolution should be disabled during the active scan,
      so all the advertisements can reach the host. The advertising
      has to be paused before disabling the address resolution,
      because the advertising will prevent any changes to the resolving
      list and the address resolution status. Skipping this will cause
      the hci error and the discovery failure.
      
      According to the bluetooth specification:
      "7.8.44 LE Set Address Resolution Enable command
      
      This command shall not be used when:
      - Advertising (other than periodic advertising) is enabled,
      - Scanning is enabled, or
      - an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection, or
        HCI_LE_Periodic_Advertising_Create_Sync command is outstanding."
      
      If the host is using RPA, the controller needs to generate RPA for
      the advertising, so the advertising must remain paused during the
      active scan.
      
      If the host is not using RPA, the advertising can be resumed after
      disabling the address resolution.
      
      Fixes: 9afc675e ("Bluetooth: hci_sync: allow advertise when scan without RPA")
      Signed-off-by: default avatarZhengping Jiang <jiangzp@google.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      3c44a431
    • Jesper Dangaard Brouer's avatar
      xdp: bpf_xdp_metadata use EOPNOTSUPP for no driver support · 915efd8a
      Jesper Dangaard Brouer authored
      When driver doesn't implement a bpf_xdp_metadata kfunc the fallback
      implementation returns EOPNOTSUPP, which indicate device driver doesn't
      implement this kfunc.
      
      Currently many drivers also return EOPNOTSUPP when the hint isn't
      available, which is ambiguous from an API point of view. Instead
      change drivers to return ENODATA in these cases.
      
      There can be natural cases why a driver doesn't provide any hardware
      info for a specific hint, even on a frame to frame basis (e.g. PTP).
      Lets keep these cases as separate return codes.
      
      When describing the return values, adjust the function kernel-doc layout
      to get proper rendering for the return values.
      
      Fixes: ab46182d ("net/mlx4_en: Support RX XDP metadata")
      Fixes: bc8d405b ("net/mlx5e: Support RX XDP metadata")
      Fixes: 306531f0 ("veth: Support RX XDP metadata")
      Fixes: 3d76a4d3 ("bpf: XDP metadata RX kfuncs")
      Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Acked-by: default avatarStanislav Fomichev <sdf@google.com>
      Acked-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Acked-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Link: https://lore.kernel.org/r/167940675120.2718408.8176058626864184420.stgit@firesoulSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      915efd8a
    • Ido Schimmel's avatar
      mlxsw: spectrum_fid: Fix incorrect local port type · bb765a74
      Ido Schimmel authored
      Local port is a 10-bit number, but it was mistakenly stored in a u8,
      resulting in firmware errors when using a netdev corresponding to a
      local port higher than 255.
      
      Fix by storing the local port in u16, as is done in the rest of the
      code.
      
      Fixes: bf73904f ("mlxsw: Add support for 802.1Q FID family")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/eace1f9d96545ab8a2775db857cb7e291a9b166b.1679398549.git.petrm@nvidia.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      bb765a74
    • Felix Fietkau's avatar
      wifi: mac80211: fix mesh path discovery based on unicast packets · f355f701
      Felix Fietkau authored
      If a packet has reached its intended destination, it was bumped to the code
      that accepts it, without first checking if a mesh_path needs to be created
      based on the discovered source.
      Fix this by moving the destination address check further down.
      
      Cc: stable@vger.kernel.org
      Fixes: 986e43b1 ("wifi: mac80211: fix receiving A-MSDU frames on mesh interfaces")
      Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
      Link: https://lore.kernel.org/r/20230314095956.62085-3-nbd@nbd.nameSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      f355f701
    • Felix Fietkau's avatar
      wifi: mac80211: fix qos on mesh interfaces · 4e348c6c
      Felix Fietkau authored
      When ieee80211_select_queue is called for mesh, the sta pointer is usually
      NULL, since the nexthop is looked up much later in the tx path.
      Explicitly check for unicast address in that case in order to make qos work
      again.
      
      Cc: stable@vger.kernel.org
      Fixes: 50e2ab39 ("wifi: mac80211: fix queue selection for mesh/OCB interfaces")
      Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
      Link: https://lore.kernel.org/r/20230314095956.62085-1-nbd@nbd.nameSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      4e348c6c
    • Johannes Berg's avatar
      wifi: iwlwifi: mvm: protect TXQ list manipulation · 923bf981
      Johannes Berg authored
      Some recent upstream debugging uncovered the fact that in
      iwlwifi, the TXQ list manipulation is racy.
      
      Introduce a new state bit for when the TXQ is completely
      ready and can be used without locking, and if that's not
      set yet acquire the lock to check everything correctly.
      Reviewed-by: default avatarBenjamin Berg <benjamin.berg@intel.com>
      Tested-by: default avatarJose Ignacio Tornos Martinez <jtornosm@redhat.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      923bf981
    • Johannes Berg's avatar
      wifi: iwlwifi: mvm: fix mvmtxq->stopped handling · b58e3d43
      Johannes Berg authored
      This could race if the queue is redirected while full, then
      the flushing internally would start it while it's not yet
      usable again. Fix it by using two state bits instead of just
      one.
      Reviewed-by: default avatarBenjamin Berg <benjamin.berg@intel.com>
      Tested-by: default avatarJose Ignacio Tornos Martinez <jtornosm@redhat.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      b58e3d43
    • Zhang Changzhong's avatar
      net/sonic: use dma_mapping_error() for error check · 4107b874
      Zhang Changzhong authored
      The DMA address returned by dma_map_single() should be checked with
      dma_mapping_error(). Fix it accordingly.
      
      Fixes: efcce839 ("[PATCH] macsonic/jazzsonic network drivers update")
      Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
      Tested-by: default avatarStan Johnson <userm57@yahoo.com>
      Signed-off-by: default avatarFinn Thain <fthain@linux-m68k.org>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Link: https://lore.kernel.org/r/6645a4b5c1e364312103f48b7b36783b94e197a2.1679370343.git.fthain@linux-m68k.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4107b874
    • Jakub Kicinski's avatar
      Merge branch 'fix-trainwreck-with-ocelot-switch-statistics-counters' · 82463d9d
      Jakub Kicinski authored
      Vladimir Oltean says:
      
      ====================
      Fix trainwreck with Ocelot switch statistics counters
      
      While testing the patch set for preemptible traffic classes with some
      controlled traffic and measuring counter deltas:
      https://lore.kernel.org/netdev/20230220122343.1156614-1-vladimir.oltean@nxp.com/
      
      I noticed that in the output of "ethtool -S swp0 --groups eth-mac
      eth-phy eth-ctrl rmon -- --src emac | grep -v ': 0'", the TX counters
      were off. Quickly I realized that their values were permutated by 1
      compared to their names, and that for example
      tx-rmon-etherStatsPkts64to64Octets was incrementing when
      tx-rmon-etherStatsPkts65to127Octets should have.
      
      Initially I suspected something having to do with the bulk reading
      logic, and indeed I found a bug there (fixed as 1/3), but that was not
      the source of the problems. Instead it revealed other problems.
      
      While dumping the regions created by the driver on my switch, I figured
      out that it sees a discontinuity which shouldn't have existed between
      reg 0x278 and reg 0x280.
      
      Discontinuity between last reg 0x0 and new reg 0x0, creating new region
      Discontinuity between last reg 0x108 and new reg 0x200, creating new region
      Discontinuity between last reg 0x278 and new reg 0x280, creating new region
      Discontinuity between last reg 0x2b0 and new reg 0x400, creating new region
      region of 67 contiguous counters starting with SYS:STAT:CNT[0x000]
      region of 31 contiguous counters starting with SYS:STAT:CNT[0x080]
      region of 13 contiguous counters starting with SYS:STAT:CNT[0x0a0]
      region of 18 contiguous counters starting with SYS:STAT:CNT[0x100]
      
      That is where TX_MM_HOLD should have been, and that was the bug, since
      it was missing. After adding it, the regions look like this and the
      off-by-one issue is resolved:
      
      Discontinuity between last reg 0x000000 and new reg 0x000000, creating new region
      Discontinuity between last reg 0x000108 and new reg 0x000200, creating new region
      Discontinuity between last reg 0x0002b0 and new reg 0x000400, creating new region
      region of 67 contiguous counters starting with SYS:STAT:CNT[0x000]
      region of 45 contiguous counters starting with SYS:STAT:CNT[0x080]
      region of 18 contiguous counters starting with SYS:STAT:CNT[0x100]
      
      However, as I am thinking out loud, it should have not reported the
      other counters as off by one even when skipping TX_MM_HOLD... after all,
      on Ocelot/Seville, there are more counters which need to be skipped.
      
      Which is when I investigated and noticed the bug solved in 2/3.
      I've validated that both on native VSC9959 (which uses
      ocelot_mm_stats_layout) as well as by faking the other switches by
      making VSC9959 use the plain ocelot_stats_layout.
      
      To summarize: on all Ocelot switches, the TX counters and drop counters
      are completely broken. The RX counters are mostly fine.
      
      With this occasion, I have collected more cleanup patches in this area,
      which I'm going to submit after the net -> net-next merge.
      ====================
      
      Link: https://lore.kernel.org/r/20230321010325.897817-1-vladimir.oltean@nxp.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      82463d9d
    • Vladimir Oltean's avatar
      net: mscc: ocelot: add TX_MM_HOLD to ocelot_mm_stats_layout · 5291099e
      Vladimir Oltean authored
      The lack of a definition for this counter is what initially prompted me
      to investigate a problem which really manifested itself as the previous
      change, "net: mscc: ocelot: fix transfer from region->buf to ocelot->stats".
      
      When TX_MM_HOLD is defined in enum ocelot_stat but not in struct
      ocelot_stat_layout ocelot_mm_stats_layout, this creates a hole, which
      due to the aforementioned bug, makes all counters following TX_MM_HOLD
      be recorded off by one compared to their correct position. So for
      example, a non-zero TX_PMAC_OCTETS would be reported as TX_MERGE_FRAGMENTS,
      TX_PMAC_UNICAST would be reported as TX_PMAC_OCTETS, TX_PMAC_64 would be
      reported as TX_PMAC_PAUSE, etc etc. This is because the size of the hole
      (1) is much smaller than the size of the region, so the phenomenon where
      the stats are off-by-one, rather than lost, prevails.
      
      However, the phenomenon where stats are lost can be seen too, for
      example with DROP_LOCAL, which is at the beginning of its own region
      (offset 0x000400 vs the previous 0x0002b0 constitutes a discontinuity).
      This is also reported as off by one and saved to TX_PMAC_1527_MAX, but
      that counter is not reported to the unstructured "ethtool -S", as
      opposed to DROP_LOCAL which is (as "drop_local").
      
      Fixes: ab3f97a9 ("net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      5291099e
    • Vladimir Oltean's avatar
      net: mscc: ocelot: fix transfer from region->buf to ocelot->stats · 17dfd210
      Vladimir Oltean authored
      To understand the problem, we need some definitions.
      
      The driver is aware of multiple counters (enum ocelot_stat), yet not all
      switches supported by the driver implement all counters. There are 2
      statistics layouts: ocelot_stats_layout and ocelot_mm_stats_layout, the
      latter having 36 counters more than the former.
      
      ocelot->stats[] is not a compact array, i.e. there are elements within
      it which are not going to be populated for ocelot_stats_layout. On the
      other hand, ocelot->stats[] is easily indexable, for example "tx_octets"
      for port 3 can be found at ocelot->stats[3 * OCELOT_NUM_STATS +
      OCELOT_STAT_TX_OCTETS], and that is why we keep it sparse.
      
      Regions, as created by ocelot_prepare_stats_regions(), are compact
      (every element from region->buf will correspond to a counter that is
      present in this switch's layout) but are not easily indexable.
      
      Let's define holes as the ranges of values of enum ocelot_stat for which
      ocelot_stats_layout doesn't have a "reg" defined. For example, there is
      a hole between OCELOT_STAT_RX_GREEN_PRIO_7 and OCELOT_STAT_TX_OCTETS
      which is of 23 elements that are only present on ocelot_mm_stats_layout,
      and as such, they are also present in enum ocelot_stat. Let's define the
      left extremity of the hole - the last enum ocelot_stat still defined -
      as A (in this case OCELOT_STAT_RX_GREEN_PRIO_7) and the right extremity -
      the first enum ocelot_stat that is defined after a series of undefined
      ones - as B (in this case OCELOT_STAT_TX_OCTETS).
      
      There is a bug in the procedure which transfers stats from region->buf[]
      to ocelot->stats[].
      
      For each hole in the ocelot_stats_layout, the logic transfers the stats
      starting with enum ocelot_stat B to ocelot->stats[] index A + 1. So all
      stats after a hole are saved to a position which is off by B - A + 1
      elements.
      
      This causes 2 kinds of issues:
      (a) counters which shouldn't increment increment
      (b) counters which should increment don't
      
      Holes in the ocelot_stat_layout automatically imply the end of a region
      and the beginning of a new one; however the reverse is not necessarily
      true. For example, for ocelot_mm_stat_layout, there could be multiple
      regions (which indicate discontinuities in register addresses) while
      there is no hole (which indicates discontinuities in enum ocelot_stat
      values).
      
      In the example above, the stats from the second region->buf[] are not
      transferred to ocelot->stats starting with index
      "port * OCELOT_NUM_STATS + OCELOT_STAT_TX_OCTETS" as they should, but
      rather, starting with element
      "port * OCELOT_NUM_STATS + OCELOT_STAT_RX_GREEN_PRIO_7 + 1".
      
      That stats[] array element is not reported to user space for switches
      that use ocelot_stat_layout, and that is how issue (b) occurs.
      
      However, if the length of the second region is larger than the hole,
      then some stats will start to be transferred to the ocelot->stats[]
      indices which *are* reported to user space, but those indices contain
      wrong values (corresponding to unexpected counters). This is how issue
      (a) occurs.
      
      The procedure, as it was introduced in commit d87b1c08 ("net: mscc:
      ocelot: use bulk reads for stats"), was not buggy, because there were no
      holes in the struct ocelot_stat_layout instances at that time. The
      problem is that when those holes were introduced, the function was not
      updated to take them into consideration.
      
      To update the procedure, we need to know, for each region, which enum
      ocelot_stat corresponds to its region->base. We have no way of deducing
      that based on the contents of struct ocelot_stats_region, so we need to
      add this information.
      
      Fixes: ab3f97a9 ("net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      17dfd210
    • Vladimir Oltean's avatar
      net: mscc: ocelot: fix stats region batching · 6acc72a4
      Vladimir Oltean authored
      The blamed commit changed struct ocelot_stat_layout :: "u32 offset" to
      "u32 reg".
      
      However, "u32 reg" is not quite a register address, but an enum
      ocelot_reg, which in itself encodes an enum ocelot_target target in the
      upper bits, and an index into the ocelot->map[target][] array in the
      lower bits.
      
      So, whereas the previous code comparison between stats_layout[i].offset
      and last + 1 was correct (because those "offsets" at the time were
      32-bit relative addresses), the new code, comparing layout[i].reg to
      last + 4 is not correct, because the "reg" here is an enum/index, not an
      actual register address.
      
      What we want to compare are indeed register addresses, but to do that,
      we need to actually go through the same motions as
      __ocelot_bulk_read_ix() itself.
      
      With this bug, all statistics counters are deemed by
      ocelot_prepare_stats_regions() as constituting their own region.
      (Truncated) log on VSC9959 (Felix) below (prints added by me):
      
      Before:
      
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x000]
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x001]
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x002]
      ...
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x041]
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x042]
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x080]
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x081]
      ...
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x0ac]
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x100]
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x101]
      ...
      region of 1 contiguous counters starting with SYS:STAT:CNT[0x111]
      
      After:
      
      region of 67 contiguous counters starting with SYS:STAT:CNT[0x000]
      region of 45 contiguous counters starting with SYS:STAT:CNT[0x080]
      region of 18 contiguous counters starting with SYS:STAT:CNT[0x100]
      
      Since commit d87b1c08 ("net: mscc: ocelot: use bulk reads for
      stats") intended bulking as a performance improvement, and since now,
      with trivial-sized regions, performance is even worse than without
      bulking at all, this could easily qualify as a performance regression.
      
      Fixes: d4c36765 ("net: mscc: ocelot: keep ocelot_stat_layout by reg address, not offset")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: default avatarColin Foster <colin.foster@in-advantage.com>
      Tested-by: default avatarColin Foster <colin.foster@in-advantage.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      6acc72a4
    • Eric Dumazet's avatar
      erspan: do not use skb_mac_header() in ndo_start_xmit() · 8e50ed77
      Eric Dumazet authored
      Drivers should not assume skb_mac_header(skb) == skb->data in their
      ndo_start_xmit().
      
      Use skb_network_offset() and skb_transport_offset() which
      better describe what is needed in erspan_fb_xmit() and
      ip6erspan_tunnel_xmit()
      
      syzbot reported:
      WARNING: CPU: 0 PID: 5083 at include/linux/skbuff.h:2873 skb_mac_header include/linux/skbuff.h:2873 [inline]
      WARNING: CPU: 0 PID: 5083 at include/linux/skbuff.h:2873 ip6erspan_tunnel_xmit+0x1d9c/0x2d90 net/ipv6/ip6_gre.c:962
      Modules linked in:
      CPU: 0 PID: 5083 Comm: syz-executor406 Not tainted 6.3.0-rc2-syzkaller-00866-gd4671cb9 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
      RIP: 0010:skb_mac_header include/linux/skbuff.h:2873 [inline]
      RIP: 0010:ip6erspan_tunnel_xmit+0x1d9c/0x2d90 net/ipv6/ip6_gre.c:962
      Code: 04 02 41 01 de 84 c0 74 08 3c 03 0f 8e 1c 0a 00 00 45 89 b4 24 c8 00 00 00 c6 85 77 fe ff ff 01 e9 33 e7 ff ff e8 b4 27 a1 f8 <0f> 0b e9 b6 e7 ff ff e8 a8 27 a1 f8 49 8d bf f0 0c 00 00 48 b8 00
      RSP: 0018:ffffc90003b2f830 EFLAGS: 00010293
      RAX: 0000000000000000 RBX: 000000000000ffff RCX: 0000000000000000
      RDX: ffff888021273a80 RSI: ffffffff88e1bd4c RDI: 0000000000000003
      RBP: ffffc90003b2f9d8 R08: 0000000000000003 R09: 000000000000ffff
      R10: 000000000000ffff R11: 0000000000000000 R12: ffff88802b28da00
      R13: 00000000000000d0 R14: ffff88807e25b6d0 R15: ffff888023408000
      FS: 0000555556a61300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
      CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 000055e5b11eb6e8 CR3: 0000000027c1b000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
      <TASK>
      __netdev_start_xmit include/linux/netdevice.h:4900 [inline]
      netdev_start_xmit include/linux/netdevice.h:4914 [inline]
      __dev_direct_xmit+0x504/0x730 net/core/dev.c:4300
      dev_direct_xmit include/linux/netdevice.h:3088 [inline]
      packet_xmit+0x20a/0x390 net/packet/af_packet.c:285
      packet_snd net/packet/af_packet.c:3075 [inline]
      packet_sendmsg+0x31a0/0x5150 net/packet/af_packet.c:3107
      sock_sendmsg_nosec net/socket.c:724 [inline]
      sock_sendmsg+0xde/0x190 net/socket.c:747
      __sys_sendto+0x23a/0x340 net/socket.c:2142
      __do_sys_sendto net/socket.c:2154 [inline]
      __se_sys_sendto net/socket.c:2150 [inline]
      __x64_sys_sendto+0xe1/0x1b0 net/socket.c:2150
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f123aaa1039
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 14 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 c0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffc15d12058 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f123aaa1039
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
      RBP: 0000000000000000 R08: 0000000020000040 R09: 0000000000000014
      R10: 0000000000000000 R11: 0000000000000246 R12: 00007f123aa648c0
      R13: 431bde82d7b634db R14: 0000000000000000 R15: 0000000000000000
      
      Fixes: 1baf5ebf ("erspan: auto detect truncated packets.")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20230320163427.8096-1-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8e50ed77
    • Li Zetao's avatar
      atm: idt77252: fix kmemleak when rmmod idt77252 · 4fe3c885
      Li Zetao authored
      There are memory leaks reported by kmemleak:
      
        unreferenced object 0xffff888106500800 (size 128):
          comm "modprobe", pid 1017, jiffies 4297787785 (age 67.152s)
          hex dump (first 32 bytes):
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          backtrace:
            [<00000000970ce626>] __kmem_cache_alloc_node+0x20c/0x380
            [<00000000fb5f78d9>] kmalloc_trace+0x2f/0xb0
            [<000000000e947e2a>] idt77252_init_one+0x2847/0x3c90 [idt77252]
            [<000000006efb048e>] local_pci_probe+0xeb/0x1a0
          ...
      
        unreferenced object 0xffff888106500b00 (size 128):
          comm "modprobe", pid 1017, jiffies 4297787785 (age 67.152s)
          hex dump (first 32 bytes):
            00 20 3d 01 80 88 ff ff 00 20 3d 01 80 88 ff ff  . =...... =.....
            f0 23 3d 01 80 88 ff ff 00 20 3d 01 00 00 00 00  .#=...... =.....
          backtrace:
            [<00000000970ce626>] __kmem_cache_alloc_node+0x20c/0x380
            [<00000000fb5f78d9>] kmalloc_trace+0x2f/0xb0
            [<00000000f451c5be>] alloc_scq.constprop.0+0x4a/0x400 [idt77252]
            [<00000000e6313849>] idt77252_init_one+0x28cf/0x3c90 [idt77252]
      
      The root cause is traced to the vc_maps which alloced in open_card_oam()
      are not freed in close_card_oam(). The vc_maps are used to record
      open connections, so when close a vc_map in close_card_oam(), the memory
      should be freed. Moreover, the ubr0 is not closed when close a idt77252
      device, leading to the memory leak of vc_map and scq_info.
      
      Fix them by adding kfree in close_card_oam() and implementing new
      close_card_ubr0() to close ubr0.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarLi Zetao <lizetao1@huawei.com>
      Reviewed-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
      Link: https://lore.kernel.org/r/20230320143318.2644630-1-lizetao1@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4fe3c885