1. 09 May, 2024 10 commits
    • Peiyang Wang's avatar
      net: hns3: use appropriate barrier function after setting a bit value · 094c2812
      Peiyang Wang authored
      There is a memory barrier in followed case. When set the port down,
      hclgevf_set_timmer will set DOWN in state. Meanwhile, the service task has
      different behaviour based on whether the state is DOWN. Thus, to make sure
      service task see DOWN, use smp_mb__after_atomic after calling set_bit().
      
                CPU0                        CPU1
      ========================== ===================================
      hclgevf_set_timer_task()    hclgevf_periodic_service_task()
        set_bit(DOWN,state)         test_bit(DOWN,state)
      
      pf also has this issue.
      
      Fixes: ff200099 ("net: hns3: remove unnecessary work in hclgevf_main")
      Fixes: 1c6dfe6f ("net: hns3: remove mailbox and reset work in hclge_main")
      Signed-off-by: default avatarPeiyang Wang <wangpeiyang1@huawei.com>
      Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      094c2812
    • Peiyang Wang's avatar
      net: hns3: release PTP resources if pf initialization failed · 950aa423
      Peiyang Wang authored
      During the PF initialization process, hclge_update_port_info may return an
      error code for some reason. At this point,  the ptp initialization has been
      completed. To void memory leaks, the resources that are applied by ptp
      should be released. Therefore, when hclge_update_port_info returns an error
      code, hclge_ptp_uninit is called to release the corresponding resources.
      
      Fixes: eaf83ae5 ("net: hns3: add querying fec ability from firmware")
      Signed-off-by: default avatarPeiyang Wang <wangpeiyang1@huawei.com>
      Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
      Reviewed-by: default avatarHariprasad Kelam <hkelam@marvell.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      950aa423
    • Peiyang Wang's avatar
      net: hns3: change type of numa_node_mask as nodemask_t · 6639a7b9
      Peiyang Wang authored
      It provides nodemask_t to describe the numa node mask in kernel. To
      improve transportability, change the type of numa_node_mask as nodemask_t.
      
      Fixes: 38caee9d ("net: hns3: Add support of the HNAE3 framework")
      Signed-off-by: default avatarPeiyang Wang <wangpeiyang1@huawei.com>
      Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      6639a7b9
    • Jian Shen's avatar
      net: hns3: direct return when receive a unknown mailbox message · 669554c5
      Jian Shen authored
      Currently, the driver didn't return when receive a unknown
      mailbox message, and continue checking whether need to
      generate a response. It's unnecessary and may be incorrect.
      
      Fixes: bb5790b7 ("net: hns3: refactor mailbox response scheme between PF and VF")
      Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
      Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      669554c5
    • Peiyang Wang's avatar
      net: hns3: using user configure after hardware reset · 05eb60e9
      Peiyang Wang authored
      When a reset occurring, it's supposed to recover user's configuration.
      Currently, the port info(speed, duplex and autoneg) is stored in hclge_mac
      and will be scheduled updated. Consider the case that reset was happened
      consecutively. During the first reset, the port info is configured with
      a temporary value cause the PHY is reset and looking for best link config.
      Second reset start and use pervious configuration which is not the user's.
      The specific process is as follows:
      
      +------+               +----+                +----+
      | USER |               | PF |                | HW |
      +---+--+               +-+--+                +-+--+
          |  ethtool --reset   |                     |
          +------------------->|    reset command    |
          |  ethtool --reset   +-------------------->|
          +------------------->|                     +---+
          |                    +---+                 |   |
          |                    |   |reset currently  |   | HW RESET
          |                    |   |and wait to do   |   |
          |                    |<--+                 |   |
          |                    | send pervious cfg   |<--+
          |                    | (1000M FULL AN_ON)  |
          |                    +-------------------->|
          |                    | read cfg(time task) |
          |                    | (10M HALF AN_OFF)   +---+
          |                    |<--------------------+   | cfg take effect
          |                    |    reset command    |<--+
          |                    +-------------------->|
          |                    |                     +---+
          |                    | send pervious cfg   |   | HW RESET
          |                    | (10M HALF AN_OFF)   |<--+
          |                    +-------------------->|
          |                    | read cfg(time task) |
          |                    |  (10M HALF AN_OFF)  +---+
          |                    |<--------------------+   | cfg take effect
          |                    |                     |   |
          |                    | read cfg(time task) |<--+
          |                    |  (10M HALF AN_OFF)  |
          |                    |<--------------------+
          |                    |                     |
          v                    v                     v
      
      To avoid aboved situation, this patch introduced req_speed, req_duplex,
      req_autoneg to store user's configuration and it only be used after
      hardware reset and to recover user's configuration
      
      Fixes: f5f2b3e4 ("net: hns3: add support for imp-controlled PHYs")
      Signed-off-by: default avatarPeiyang Wang <wangpeiyang1@huawei.com>
      Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
      Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      05eb60e9
    • Wen Gu's avatar
      net/smc: fix neighbour and rtable leak in smc_ib_find_route() · 2ddc0dd7
      Wen Gu authored
      In smc_ib_find_route(), the neighbour found by neigh_lookup() and rtable
      resolved by ip_route_output_flow() are not released or put before return.
      It may cause the refcount leak, so fix it.
      
      Link: https://lore.kernel.org/r/20240506015439.108739-1-guwen@linux.alibaba.com
      Fixes: e5c4744c ("net/smc: add SMC-Rv2 connection establishment")
      Signed-off-by: default avatarWen Gu <guwen@linux.alibaba.com>
      Link: https://lore.kernel.org/r/20240507125331.2808-1-guwen@linux.alibaba.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      2ddc0dd7
    • Eric Dumazet's avatar
      ipv6: prevent NULL dereference in ip6_output() · 4db783d6
      Eric Dumazet authored
      According to syzbot, there is a chance that ip6_dst_idev()
      returns NULL in ip6_output(). Most places in IPv6 stack
      deal with a NULL idev just fine, but not here.
      
      syzbot reported:
      
      general protection fault, probably for non-canonical address 0xdffffc00000000bc: 0000 [#1] PREEMPT SMP KASAN PTI
      KASAN: null-ptr-deref in range [0x00000000000005e0-0x00000000000005e7]
      CPU: 0 PID: 9775 Comm: syz-executor.4 Not tainted 6.9.0-rc5-syzkaller-00157-g6a30653b #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
       RIP: 0010:ip6_output+0x231/0x3f0 net/ipv6/ip6_output.c:237
      Code: 3c 1e 00 49 89 df 74 08 4c 89 ef e8 19 58 db f7 48 8b 44 24 20 49 89 45 00 49 89 c5 48 8d 9d e0 05 00 00 48 89 d8 48 c1 e8 03 <42> 0f b6 04 38 84 c0 4c 8b 74 24 28 0f 85 61 01 00 00 8b 1b 31 ff
      RSP: 0018:ffffc9000927f0d8 EFLAGS: 00010202
      RAX: 00000000000000bc RBX: 00000000000005e0 RCX: 0000000000040000
      RDX: ffffc900131f9000 RSI: 0000000000004f47 RDI: 0000000000004f48
      RBP: 0000000000000000 R08: ffffffff8a1f0b9a R09: 1ffffffff1f51fad
      R10: dffffc0000000000 R11: fffffbfff1f51fae R12: ffff8880293ec8c0
      R13: ffff88805d7fc000 R14: 1ffff1100527d91a R15: dffffc0000000000
      FS:  00007f135c6856c0(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000020000080 CR3: 0000000064096000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
        NF_HOOK include/linux/netfilter.h:314 [inline]
        ip6_xmit+0xefe/0x17f0 net/ipv6/ip6_output.c:358
        sctp_v6_xmit+0x9f2/0x13f0 net/sctp/ipv6.c:248
        sctp_packet_transmit+0x26ad/0x2ca0 net/sctp/output.c:653
        sctp_packet_singleton+0x22c/0x320 net/sctp/outqueue.c:783
        sctp_outq_flush_ctrl net/sctp/outqueue.c:914 [inline]
        sctp_outq_flush+0x6d5/0x3e20 net/sctp/outqueue.c:1212
        sctp_side_effects net/sctp/sm_sideeffect.c:1198 [inline]
        sctp_do_sm+0x59cc/0x60c0 net/sctp/sm_sideeffect.c:1169
        sctp_primitive_ASSOCIATE+0x95/0xc0 net/sctp/primitive.c:73
        __sctp_connect+0x9cd/0xe30 net/sctp/socket.c:1234
        sctp_connect net/sctp/socket.c:4819 [inline]
        sctp_inet_connect+0x149/0x1f0 net/sctp/socket.c:4834
        __sys_connect_file net/socket.c:2048 [inline]
        __sys_connect+0x2df/0x310 net/socket.c:2065
        __do_sys_connect net/socket.c:2075 [inline]
        __se_sys_connect net/socket.c:2072 [inline]
        __x64_sys_connect+0x7a/0x90 net/socket.c:2072
        do_syscall_x64 arch/x86/entry/common.c:52 [inline]
        do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f
      
      Fixes: 778d80be ("ipv6: Add disable_ipv6 sysctl to disable IPv6 operaion on specific interface.")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarLarysa Zaremba <larysa.zaremba@intel.com>
      Link: https://lore.kernel.org/r/20240507161842.773961-1-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4db783d6
    • Lukasz Majewski's avatar
      hsr: Simplify code for announcing HSR nodes timer setup · 4893b8b3
      Lukasz Majewski authored
      Up till now the code to start HSR announce timer, which triggers sending
      supervisory frames, was assuming that hsr_netdev_notify() would be called
      at least twice for hsrX interface. This was required to have different
      values for old and current values of network device's operstate.
      
      This is problematic for a case where hsrX interface is already in the
      operational state when hsr_netdev_notify() is called, so timer is not
      configured to trigger and as a result the hsrX is not sending supervisory
      frames to HSR ring.
      
      This error has been discovered when hsr_ping.sh script was run. To be
      more specific - for the hsr1 and hsr2 the hsr_netdev_notify() was
      called at least twice with different IF_OPER_{LOWERDOWN|DOWN|UP} states
      assigned in hsr_check_carrier_and_operstate(hsr). As a result there was
      no issue with sending supervisory frames.
      However, with hsr3, the notify function was called only once with
      operstate set to IF_OPER_UP and timer responsible for triggering
      supervisory frames was not fired.
      
      The solution is to use netif_oper_up() and netif_running() helper
      functions to assess if network hsrX device is up.
      Only then, when the timer is not already pending, it is started.
      Otherwise it is deactivated.
      
      Fixes: f421436a ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarLukasz Majewski <lukma@denx.de>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20240507111214.3519800-1-lukma@denx.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4893b8b3
    • Eric Dumazet's avatar
      ipv6: fib6_rules: avoid possible NULL dereference in fib6_rule_action() · d101291b
      Eric Dumazet authored
      syzbot is able to trigger the following crash [1],
      caused by unsafe ip6_dst_idev() use.
      
      Indeed ip6_dst_idev() can return NULL, and must always be checked.
      
      [1]
      
      Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN PTI
      KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
      CPU: 0 PID: 31648 Comm: syz-executor.0 Not tainted 6.9.0-rc4-next-20240417-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
       RIP: 0010:__fib6_rule_action net/ipv6/fib6_rules.c:237 [inline]
       RIP: 0010:fib6_rule_action+0x241/0x7b0 net/ipv6/fib6_rules.c:267
      Code: 02 00 00 49 8d 9f d8 00 00 00 48 89 d8 48 c1 e8 03 42 80 3c 20 00 74 08 48 89 df e8 f9 32 bf f7 48 8b 1b 48 89 d8 48 c1 e8 03 <42> 80 3c 20 00 74 08 48 89 df e8 e0 32 bf f7 4c 8b 03 48 89 ef 4c
      RSP: 0018:ffffc9000fc1f2f0 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: 0000000000000000 RCX: 1a772f98c8186700
      RDX: 0000000000000003 RSI: ffffffff8bcac4e0 RDI: ffffffff8c1f9760
      RBP: ffff8880673fb980 R08: ffffffff8fac15ef R09: 1ffffffff1f582bd
      R10: dffffc0000000000 R11: fffffbfff1f582be R12: dffffc0000000000
      R13: 0000000000000080 R14: ffff888076509000 R15: ffff88807a029a00
      FS:  00007f55e82ca6c0(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000001b31d23000 CR3: 0000000022b66000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
        fib_rules_lookup+0x62c/0xdb0 net/core/fib_rules.c:317
        fib6_rule_lookup+0x1fd/0x790 net/ipv6/fib6_rules.c:108
        ip6_route_output_flags_noref net/ipv6/route.c:2637 [inline]
        ip6_route_output_flags+0x38e/0x610 net/ipv6/route.c:2649
        ip6_route_output include/net/ip6_route.h:93 [inline]
        ip6_dst_lookup_tail+0x189/0x11a0 net/ipv6/ip6_output.c:1120
        ip6_dst_lookup_flow+0xb9/0x180 net/ipv6/ip6_output.c:1250
        sctp_v6_get_dst+0x792/0x1e20 net/sctp/ipv6.c:326
        sctp_transport_route+0x12c/0x2e0 net/sctp/transport.c:455
        sctp_assoc_add_peer+0x614/0x15c0 net/sctp/associola.c:662
        sctp_connect_new_asoc+0x31d/0x6c0 net/sctp/socket.c:1099
        __sctp_connect+0x66d/0xe30 net/sctp/socket.c:1197
        sctp_connect net/sctp/socket.c:4819 [inline]
        sctp_inet_connect+0x149/0x1f0 net/sctp/socket.c:4834
        __sys_connect_file net/socket.c:2048 [inline]
        __sys_connect+0x2df/0x310 net/socket.c:2065
        __do_sys_connect net/socket.c:2075 [inline]
        __se_sys_connect net/socket.c:2072 [inline]
        __x64_sys_connect+0x7a/0x90 net/socket.c:2072
        do_syscall_x64 arch/x86/entry/common.c:52 [inline]
        do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f
      
      Fixes: 5e5f3f0f ("[IPV6] ADDRCONF: Convert ipv6_get_saddr() to ipv6_dev_get_saddr().")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20240507163145.835254-1-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d101291b
    • Daniel Golle's avatar
      dt-bindings: net: mediatek: remove wrongly added clocks and SerDes · cc349b07
      Daniel Golle authored
      Several clocks as well as both sgmiisys phandles were added by mistake
      to the Ethernet bindings for MT7988. Also, the total number of clocks
      didn't match with the actual number of items listed.
      
      This happened because the vendor driver which served as a reference uses
      a high number of syscon phandles to access various parts of the SoC
      which wasn't acceptable upstream. Hence several parts which have never
      previously been supported (such SerDes PHY and USXGMII PCS) are going to
      be implemented by separate drivers. As a result the device tree will
      look much more sane.
      
      Quickly align the bindings with the upcoming reality of the drivers
      actually adding support for the remaining Ethernet-related features of
      the MT7988 SoC.
      
      Fixes: c94a9aab ("dt-bindings: net: mediatek,net: add mt7988-eth binding")
      Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Acked-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Link: https://lore.kernel.org/r/1569290b21cc787a424469ed74456a7e976b102d.1715084326.git.daniel@makrotopia.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      cc349b07
  2. 08 May, 2024 9 commits
  3. 07 May, 2024 3 commits
  4. 06 May, 2024 1 commit
  5. 03 May, 2024 17 commits
    • Potnuri Bharat Teja's avatar
      MAINTAINERS: update cxgb4 and cxgb3 network drivers maintainer · fa870b45
      Potnuri Bharat Teja authored
      Add myself(Bharat) as maintainer for cxgb4 and cxgb3 network drivers.
      Signed-off-by: default avatarPotnuri Bharat Teja <bharat@chelsio.com>
      Link: https://lore.kernel.org/r/20240502184209.2723379-1-bharat@chelsio.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      fa870b45
    • Roded Zats's avatar
      rtnetlink: Correct nested IFLA_VF_VLAN_LIST attribute validation · 1aec77b2
      Roded Zats authored
      Each attribute inside a nested IFLA_VF_VLAN_LIST is assumed to be a
      struct ifla_vf_vlan_info so the size of such attribute needs to be at least
      of sizeof(struct ifla_vf_vlan_info) which is 14 bytes.
      The current size validation in do_setvfinfo is against NLA_HDRLEN (4 bytes)
      which is less than sizeof(struct ifla_vf_vlan_info) so this validation
      is not enough and a too small attribute might be cast to a
      struct ifla_vf_vlan_info, this might result in an out of bands
      read access when accessing the saved (casted) entry in ivvl.
      
      Fixes: 79aab093 ("net: Update API for VF vlan protocol 802.1ad support")
      Signed-off-by: default avatarRoded Zats <rzats@paloaltonetworks.com>
      Reviewed-by: default avatarDonald Hunter <donald.hunter@gmail.com>
      Link: https://lore.kernel.org/r/20240502155751.75705-1-rzats@paloaltonetworks.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      1aec77b2
    • Jakub Kicinski's avatar
      Merge tag 'ipsec-2024-05-02' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec · d0de6167
      Jakub Kicinski authored
      Steffen Klassert says:
      
      ====================
      pull request (net): ipsec 2024-05-02
      
      1) Fix an error pointer dereference in xfrm_in_fwd_icmp.
         From Antony Antony.
      
      2) Preserve vlan tags for ESP transport mode software GRO.
         From Paul Davey.
      
      3) Fix a spelling mistake in an uapi xfrm.h comment.
         From Anotny Antony.
      
      * tag 'ipsec-2024-05-02' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec:
        xfrm: Correct spelling mistake in xfrm.h comment
        xfrm: Preserve vlan tags for transport mode software GRO
        xfrm: fix possible derferencing in error path
      ====================
      
      Link: https://lore.kernel.org/r/20240502084838.2269355-1-steffen.klassert@secunet.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d0de6167
    • Jakub Kicinski's avatar
      Merge tag 'for-net-2024-05-03' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth · f2d85904
      Jakub Kicinski authored
      Luiz Augusto von Dentz says:
      
      ====================
      bluetooth pull request for net:
      
       - mediatek: mt8183-pico6: Fix bluetooth node
       - sco: Fix use-after-free bugs caused by sco_sock_timeout
       - l2cap: fix null-ptr-deref in l2cap_chan_timeout
       - qca: Various fixes
       - l2cap: Fix slab-use-after-free in l2cap_connect()
       - msft: fix slab-use-after-free in msft_do_close()
       - HCI: Fix potential null-ptr-deref
      
      * tag 'for-net-2024-05-03' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth:
        Bluetooth: qca: fix firmware check error path
        Bluetooth: l2cap: fix null-ptr-deref in l2cap_chan_timeout
        Bluetooth: HCI: Fix potential null-ptr-deref
        arm64: dts: mediatek: mt8183-pico6: Fix bluetooth node
        Bluetooth: qca: fix info leak when fetching board id
        Bluetooth: qca: fix info leak when fetching fw build id
        Bluetooth: qca: generalise device address check
        Bluetooth: qca: fix NVM configuration parsing
        Bluetooth: qca: add missing firmware sanity checks
        Bluetooth: msft: fix slab-use-after-free in msft_do_close()
        Bluetooth: L2CAP: Fix slab-use-after-free in l2cap_connect()
        Bluetooth: qca: fix wcn3991 device address check
        Bluetooth: Fix use-after-free bugs caused by sco_sock_timeout
      ====================
      
      Link: https://lore.kernel.org/r/20240503171933.3851244-1-luiz.dentz@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f2d85904
    • Marek Vasut's avatar
      net: ks8851: Queue RX packets in IRQ handler instead of disabling BHs · e0863634
      Marek Vasut authored
      Currently the driver uses local_bh_disable()/local_bh_enable() in its
      IRQ handler to avoid triggering net_rx_action() softirq on exit from
      netif_rx(). The net_rx_action() could trigger this driver .start_xmit
      callback, which is protected by the same lock as the IRQ handler, so
      calling the .start_xmit from netif_rx() from the IRQ handler critical
      section protected by the lock could lead to an attempt to claim the
      already claimed lock, and a hang.
      
      The local_bh_disable()/local_bh_enable() approach works only in case
      the IRQ handler is protected by a spinlock, but does not work if the
      IRQ handler is protected by mutex, i.e. this works for KS8851 with
      Parallel bus interface, but not for KS8851 with SPI bus interface.
      
      Remove the BH manipulation and instead of calling netif_rx() inside
      the IRQ handler code protected by the lock, queue all the received
      SKBs in the IRQ handler into a queue first, and once the IRQ handler
      exits the critical section protected by the lock, dequeue all the
      queued SKBs and push them all into netif_rx(). At this point, it is
      safe to trigger the net_rx_action() softirq, since the netif_rx()
      call is outside of the lock that protects the IRQ handler.
      
      Fixes: be0384bf ("net: ks8851: Handle softirqs at the end of IRQ thread to fix hang")
      Tested-by: Ronald Wahl <ronald.wahl@raritan.com> # KS8851 SPI
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20240502183436.117117-1-marex@denx.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e0863634
    • Johan Hovold's avatar
      Bluetooth: qca: fix firmware check error path · 40d442f9
      Johan Hovold authored
      A recent commit fixed the code that parses the firmware files before
      downloading them to the controller but introduced a memory leak in case
      the sanity checks ever fail.
      
      Make sure to free the firmware buffer before returning on errors.
      
      Fixes: f905ae0be4b7 ("Bluetooth: qca: add missing firmware sanity checks")
      Cc: stable@vger.kernel.org      # 4.19
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      40d442f9
    • Duoming Zhou's avatar
      Bluetooth: l2cap: fix null-ptr-deref in l2cap_chan_timeout · adf0398c
      Duoming Zhou authored
      There is a race condition between l2cap_chan_timeout() and
      l2cap_chan_del(). When we use l2cap_chan_del() to delete the
      channel, the chan->conn will be set to null. But the conn could
      be dereferenced again in the mutex_lock() of l2cap_chan_timeout().
      As a result the null pointer dereference bug will happen. The
      KASAN report triggered by POC is shown below:
      
      [  472.074580] ==================================================================
      [  472.075284] BUG: KASAN: null-ptr-deref in mutex_lock+0x68/0xc0
      [  472.075308] Write of size 8 at addr 0000000000000158 by task kworker/0:0/7
      [  472.075308]
      [  472.075308] CPU: 0 PID: 7 Comm: kworker/0:0 Not tainted 6.9.0-rc5-00356-g78c0094a146b #36
      [  472.075308] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu4
      [  472.075308] Workqueue: events l2cap_chan_timeout
      [  472.075308] Call Trace:
      [  472.075308]  <TASK>
      [  472.075308]  dump_stack_lvl+0x137/0x1a0
      [  472.075308]  print_report+0x101/0x250
      [  472.075308]  ? __virt_addr_valid+0x77/0x160
      [  472.075308]  ? mutex_lock+0x68/0xc0
      [  472.075308]  kasan_report+0x139/0x170
      [  472.075308]  ? mutex_lock+0x68/0xc0
      [  472.075308]  kasan_check_range+0x2c3/0x2e0
      [  472.075308]  mutex_lock+0x68/0xc0
      [  472.075308]  l2cap_chan_timeout+0x181/0x300
      [  472.075308]  process_one_work+0x5d2/0xe00
      [  472.075308]  worker_thread+0xe1d/0x1660
      [  472.075308]  ? pr_cont_work+0x5e0/0x5e0
      [  472.075308]  kthread+0x2b7/0x350
      [  472.075308]  ? pr_cont_work+0x5e0/0x5e0
      [  472.075308]  ? kthread_blkcg+0xd0/0xd0
      [  472.075308]  ret_from_fork+0x4d/0x80
      [  472.075308]  ? kthread_blkcg+0xd0/0xd0
      [  472.075308]  ret_from_fork_asm+0x11/0x20
      [  472.075308]  </TASK>
      [  472.075308] ==================================================================
      [  472.094860] Disabling lock debugging due to kernel taint
      [  472.096136] BUG: kernel NULL pointer dereference, address: 0000000000000158
      [  472.096136] #PF: supervisor write access in kernel mode
      [  472.096136] #PF: error_code(0x0002) - not-present page
      [  472.096136] PGD 0 P4D 0
      [  472.096136] Oops: 0002 [#1] PREEMPT SMP KASAN NOPTI
      [  472.096136] CPU: 0 PID: 7 Comm: kworker/0:0 Tainted: G    B              6.9.0-rc5-00356-g78c0094a146b #36
      [  472.096136] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu4
      [  472.096136] Workqueue: events l2cap_chan_timeout
      [  472.096136] RIP: 0010:mutex_lock+0x88/0xc0
      [  472.096136] Code: be 08 00 00 00 e8 f8 23 1f fd 4c 89 f7 be 08 00 00 00 e8 eb 23 1f fd 42 80 3c 23 00 74 08 48 88
      [  472.096136] RSP: 0018:ffff88800744fc78 EFLAGS: 00000246
      [  472.096136] RAX: 0000000000000000 RBX: 1ffff11000e89f8f RCX: ffffffff8457c865
      [  472.096136] RDX: 0000000000000001 RSI: 0000000000000008 RDI: ffff88800744fc78
      [  472.096136] RBP: 0000000000000158 R08: ffff88800744fc7f R09: 1ffff11000e89f8f
      [  472.096136] R10: dffffc0000000000 R11: ffffed1000e89f90 R12: dffffc0000000000
      [  472.096136] R13: 0000000000000158 R14: ffff88800744fc78 R15: ffff888007405a00
      [  472.096136] FS:  0000000000000000(0000) GS:ffff88806d200000(0000) knlGS:0000000000000000
      [  472.096136] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  472.096136] CR2: 0000000000000158 CR3: 000000000da32000 CR4: 00000000000006f0
      [  472.096136] Call Trace:
      [  472.096136]  <TASK>
      [  472.096136]  ? __die_body+0x8d/0xe0
      [  472.096136]  ? page_fault_oops+0x6b8/0x9a0
      [  472.096136]  ? kernelmode_fixup_or_oops+0x20c/0x2a0
      [  472.096136]  ? do_user_addr_fault+0x1027/0x1340
      [  472.096136]  ? _printk+0x7a/0xa0
      [  472.096136]  ? mutex_lock+0x68/0xc0
      [  472.096136]  ? add_taint+0x42/0xd0
      [  472.096136]  ? exc_page_fault+0x6a/0x1b0
      [  472.096136]  ? asm_exc_page_fault+0x26/0x30
      [  472.096136]  ? mutex_lock+0x75/0xc0
      [  472.096136]  ? mutex_lock+0x88/0xc0
      [  472.096136]  ? mutex_lock+0x75/0xc0
      [  472.096136]  l2cap_chan_timeout+0x181/0x300
      [  472.096136]  process_one_work+0x5d2/0xe00
      [  472.096136]  worker_thread+0xe1d/0x1660
      [  472.096136]  ? pr_cont_work+0x5e0/0x5e0
      [  472.096136]  kthread+0x2b7/0x350
      [  472.096136]  ? pr_cont_work+0x5e0/0x5e0
      [  472.096136]  ? kthread_blkcg+0xd0/0xd0
      [  472.096136]  ret_from_fork+0x4d/0x80
      [  472.096136]  ? kthread_blkcg+0xd0/0xd0
      [  472.096136]  ret_from_fork_asm+0x11/0x20
      [  472.096136]  </TASK>
      [  472.096136] Modules linked in:
      [  472.096136] CR2: 0000000000000158
      [  472.096136] ---[ end trace 0000000000000000 ]---
      [  472.096136] RIP: 0010:mutex_lock+0x88/0xc0
      [  472.096136] Code: be 08 00 00 00 e8 f8 23 1f fd 4c 89 f7 be 08 00 00 00 e8 eb 23 1f fd 42 80 3c 23 00 74 08 48 88
      [  472.096136] RSP: 0018:ffff88800744fc78 EFLAGS: 00000246
      [  472.096136] RAX: 0000000000000000 RBX: 1ffff11000e89f8f RCX: ffffffff8457c865
      [  472.096136] RDX: 0000000000000001 RSI: 0000000000000008 RDI: ffff88800744fc78
      [  472.096136] RBP: 0000000000000158 R08: ffff88800744fc7f R09: 1ffff11000e89f8f
      [  472.132932] R10: dffffc0000000000 R11: ffffed1000e89f90 R12: dffffc0000000000
      [  472.132932] R13: 0000000000000158 R14: ffff88800744fc78 R15: ffff888007405a00
      [  472.132932] FS:  0000000000000000(0000) GS:ffff88806d200000(0000) knlGS:0000000000000000
      [  472.132932] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  472.132932] CR2: 0000000000000158 CR3: 000000000da32000 CR4: 00000000000006f0
      [  472.132932] Kernel panic - not syncing: Fatal exception
      [  472.132932] Kernel Offset: disabled
      [  472.132932] ---[ end Kernel panic - not syncing: Fatal exception ]---
      
      Add a check to judge whether the conn is null in l2cap_chan_timeout()
      in order to mitigate the bug.
      
      Fixes: 3df91ea2 ("Bluetooth: Revert to mutexes from RCU list")
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      adf0398c
    • Sungwoo Kim's avatar
      Bluetooth: HCI: Fix potential null-ptr-deref · d2706004
      Sungwoo Kim authored
      Fix potential null-ptr-deref in hci_le_big_sync_established_evt().
      
      Fixes: f777d882 (Bluetooth: ISO: Notify user space about failed bis connections)
      Signed-off-by: default avatarSungwoo Kim <iam@sung-woo.kim>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      d2706004
    • Chen-Yu Tsai's avatar
      arm64: dts: mediatek: mt8183-pico6: Fix bluetooth node · cd17bcbd
      Chen-Yu Tsai authored
      Bluetooth is not a random device connected to the MMC/SD controller. It
      is function 2 of the SDIO device.
      
      Fix the address of the bluetooth node. Also fix the node name and drop
      the label.
      
      Fixes: 055ef10c ("arm64: dts: mt8183: Add jacuzzi pico/pico6 board")
      Signed-off-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      cd17bcbd
    • Johan Hovold's avatar
      Bluetooth: qca: fix info leak when fetching board id · 0adcf6be
      Johan Hovold authored
      Add the missing sanity check when fetching the board id to avoid leaking
      slab data when later requesting the firmware.
      
      Fixes: a7f8dedb ("Bluetooth: qca: add support for QCA2066")
      Cc: stable@vger.kernel.org	# 6.7
      Cc: Tim Jiang <quic_tjiang@quicinc.com>
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      0adcf6be
    • Johan Hovold's avatar
      Bluetooth: qca: fix info leak when fetching fw build id · cda0d6a1
      Johan Hovold authored
      Add the missing sanity checks and move the 255-byte build-id buffer off
      the stack to avoid leaking stack data through debugfs in case the
      build-info reply is malformed.
      
      Fixes: c0187b0b ("Bluetooth: btqca: Add support to read FW build version for WCN3991 BTSoC")
      Cc: stable@vger.kernel.org	# 5.12
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      cda0d6a1
    • Johan Hovold's avatar
      Bluetooth: qca: generalise device address check · dd336649
      Johan Hovold authored
      The default device address apparently comes from the NVM configuration
      file and can differ quite a bit between controllers.
      
      Store the default address when parsing the configuration file and use it
      to determine whether the controller has been provisioned with an
      address.
      
      This makes sure that devices without a unique address start as
      unconfigured unless a valid address has been provided in the devicetree.
      
      Fixes: 32868e12 ("Bluetooth: qca: fix invalid device address check")
      Cc: stable@vger.kernel.org      # 6.5
      Cc: Doug Anderson <dianders@chromium.org>
      Cc: Janaki Ramaiah Thota <quic_janathot@quicinc.com>
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Tested-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      dd336649
    • Johan Hovold's avatar
      Bluetooth: qca: fix NVM configuration parsing · a112d3c7
      Johan Hovold authored
      The NVM configuration files used by WCN3988 and WCN3990/1/8 have two
      sets of configuration tags that are enclosed by a type-length header of
      type four which the current parser fails to account for.
      
      Instead the driver happily parses random data as if it were valid tags,
      something which can lead to the configuration data being corrupted if it
      ever encounters the words 0x0011 or 0x001b.
      
      As is clear from commit b6388254 ("Bluetooth: btqca: Fix the NVM
      baudrate tag offcet for wcn3991") the intention has always been to
      process the configuration data also for WCN3991 and WCN3998 which
      encodes the baud rate at a different offset.
      
      Fix the parser so that it can handle the WCN3xxx configuration files,
      which has an enclosing type-length header of type four and two sets of
      TLV tags enclosed by a type-length header of type two and three,
      respectively.
      
      Note that only the first set, which contains the tags the driver is
      currently looking for, will be parsed for now.
      
      With the parser fixed, the software in-band sleep bit will now be set
      for WCN3991 and WCN3998 (as it is for later controllers) and the default
      baud rate 3200000 may be updated by the driver also for WCN3xxx
      controllers.
      
      Notably the deep-sleep feature bit is already set by default in all
      configuration files in linux-firmware.
      
      Fixes: 4219d468 ("Bluetooth: btqca: Add wcn3990 firmware download support.")
      Cc: stable@vger.kernel.org	# 4.19
      Cc: Matthias Kaehlcke <mka@chromium.org>
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      a112d3c7
    • Johan Hovold's avatar
      Bluetooth: qca: add missing firmware sanity checks · 2e4edfa1
      Johan Hovold authored
      Add the missing sanity checks when parsing the firmware files before
      downloading them to avoid accessing and corrupting memory beyond the
      vmalloced buffer.
      
      Fixes: 83e81961 ("Bluetooth: btqca: Introduce generic QCA ROME support")
      Cc: stable@vger.kernel.org	# 4.10
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      2e4edfa1
    • Sungwoo Kim's avatar
      Bluetooth: msft: fix slab-use-after-free in msft_do_close() · 10f9f426
      Sungwoo Kim authored
      Tying the msft->data lifetime to hdev by freeing it in
      hci_release_dev() to fix the following case:
      
      [use]
      msft_do_close()
        msft = hdev->msft_data;
        if (!msft)                      ...(1) <- passed.
          return;
        mutex_lock(&msft->filter_lock); ...(4) <- used after freed.
      
      [free]
      msft_unregister()
        msft = hdev->msft_data;
        hdev->msft_data = NULL;         ...(2)
        kfree(msft);                    ...(3) <- msft is freed.
      
      ==================================================================
      BUG: KASAN: slab-use-after-free in __mutex_lock_common
      kernel/locking/mutex.c:587 [inline]
      BUG: KASAN: slab-use-after-free in __mutex_lock+0x8f/0xc30
      kernel/locking/mutex.c:752
      Read of size 8 at addr ffff888106cbbca8 by task kworker/u5:2/309
      
      Fixes: bf6a4e30 ("Bluetooth: disable advertisement filters during suspend")
      Signed-off-by: default avatarSungwoo Kim <iam@sung-woo.kim>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      10f9f426
    • Sungwoo Kim's avatar
      Bluetooth: L2CAP: Fix slab-use-after-free in l2cap_connect() · 4d7b41c0
      Sungwoo Kim authored
      Extend a critical section to prevent chan from early freeing.
      Also make the l2cap_connect() return type void. Nothing is using the
      returned value but it is ugly to return a potentially freed pointer.
      Making it void will help with backports because earlier kernels did use
      the return value. Now the compile will break for kernels where this
      patch is not a complete fix.
      
      Call stack summary:
      
      [use]
      l2cap_bredr_sig_cmd
        l2cap_connect
        ┌ mutex_lock(&conn->chan_lock);
        │ chan = pchan->ops->new_connection(pchan); <- alloc chan
        │ __l2cap_chan_add(conn, chan);
        │   l2cap_chan_hold(chan);
        │   list_add(&chan->list, &conn->chan_l);   ... (1)
        └ mutex_unlock(&conn->chan_lock);
          chan->conf_state              ... (4) <- use after free
      
      [free]
      l2cap_conn_del
      ┌ mutex_lock(&conn->chan_lock);
      │ foreach chan in conn->chan_l:            ... (2)
      │   l2cap_chan_put(chan);
      │     l2cap_chan_destroy
      │       kfree(chan)               ... (3) <- chan freed
      └ mutex_unlock(&conn->chan_lock);
      
      ==================================================================
      BUG: KASAN: slab-use-after-free in instrument_atomic_read
      include/linux/instrumented.h:68 [inline]
      BUG: KASAN: slab-use-after-free in _test_bit
      include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline]
      BUG: KASAN: slab-use-after-free in l2cap_connect+0xa67/0x11a0
      net/bluetooth/l2cap_core.c:4260
      Read of size 8 at addr ffff88810bf040a0 by task kworker/u3:1/311
      
      Fixes: 73ffa904 ("Bluetooth: Move conf_{req,rsp} stuff to struct l2cap_chan")
      Signed-off-by: default avatarSungwoo Kim <iam@sung-woo.kim>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      4d7b41c0
    • Johan Hovold's avatar
      Bluetooth: qca: fix wcn3991 device address check · 66c39332
      Johan Hovold authored
      Qualcomm Bluetooth controllers may not have been provisioned with a
      valid device address and instead end up using the default address
      00:00:00:00:5a:ad.
      
      This address is now used to determine if a controller has a valid
      address or if one needs to be provided through devicetree or by user
      space before the controller can be used.
      
      It turns out that the WCN3991 controllers used in Chromium Trogdor
      machines use a different default address, 39:98:00:00:5a:ad, which also
      needs to be marked as invalid so that the correct address is fetched
      from the devicetree.
      
      Qualcomm has unfortunately not yet provided any answers as to whether
      the 39:98 encodes a hardware id and if there are other variants of the
      default address that needs to be handled by the driver.
      
      For now, add the Trogdor WCN3991 default address to the device address
      check to avoid having these controllers start with the default address
      instead of their assigned addresses.
      
      Fixes: 32868e12 ("Bluetooth: qca: fix invalid device address check")
      Cc: stable@vger.kernel.org      # 6.5
      Cc: Doug Anderson <dianders@chromium.org>
      Cc: Janaki Ramaiah Thota <quic_janathot@quicinc.com>
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Tested-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      66c39332