Skip to content
  1. Nov 16, 2022
    • Lu Wei's avatar
      tcp: prohibit TCP_REPAIR_OPTIONS if data was already sent · 13ecaa68
      Lu Wei authored
      [ Upstream commit 0c175da7 ]
      
      If setsockopt with option name of TCP_REPAIR_OPTIONS and opt_code
      of TCPOPT_SACK_PERM is called to enable sack after data is sent
      and dupacks are received , it will trigger a warning in function
      tcp_verify_left_out() as follows:
      
      ============================================
      WARNING: CPU: 8 PID: 0 at net/ipv4/tcp_input.c:2132
      tcp_timeout_mark_lost+0x154/0x160
      tcp_enter_loss+0x2b/0x290
      tcp_retransmit_timer+0x50b/0x640
      tcp_write_timer_handler+0x1c8/0x340
      tcp_write_timer+0xe5/0x140
      call_timer_fn+0x3a/0x1b0
      __run_timers.part.0+0x1bf/0x2d0
      run_timer_softirq+0x43/0xb0
      __do_softirq+0xfd/0x373
      __irq_exit_rcu+0xf6/0x140
      
      The warning is caused in the following steps:
      1. a socket named socketA is created
      2. socketA enters repair mode without build a connection
      3. socketA calls connect() and its state is changed to TCP_ESTABLISHED
         directly
      4. socketA leaves repair mode
      5. socketA calls sendmsg() to send data, packets_out and sack_outs(dup
         ack receives) increase
      6. socketA enters repair mode again
      7. socketA calls setsockopt with TCPOPT_SACK_PERM to enable sack
      8. retransmit timer expires, it calls tcp_timeout_mark_lost(), lost_out
         increases
      9. sack_outs + lost_out > packets_out triggers since lost_out and
         sack_outs increase repeatly
      
      In function tcp_timeout_mark_lost(), tp->sacked_out will be cleared if
      Step7 not happen and the warning will not be triggered. As suggested by
      Denis and Eric, TCP_REPAIR_OPTIONS should be prohibited if data was
      already sent.
      
      socket-tcp tests in CRIU has been tested as follows:
      $ sudo ./test/zdtm.py run -t zdtm/static/socket-tcp*  --keep-going \
             --ignore-taint
      
      socket-tcp* represent all socket-tcp tests in test/zdtm/static/.
      
      Fixes: b139ba4e
      
       ("tcp: Repair connection-time negotiated parameters")
      Signed-off-by: default avatarLu Wei <luwei32@huawei.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      13ecaa68
    • Yuan Can's avatar
      drm/vc4: Fix missing platform_unregister_drivers() call in vc4_drm_register() · bc79cb9f
      Yuan Can authored
      [ Upstream commit cf53db76 ]
      
      A problem about modprobe vc4 failed is triggered with the following log
      given:
      
       [  420.327987] Error: Driver 'vc4_hvs' is already registered, aborting...
       [  420.333904] failed to register platform driver vc4_hvs_driver [vc4]: -16
       modprobe: ERROR: could not insert 'vc4': Device or resource busy
      
      The reason is that vc4_drm_register() returns platform_driver_register()
      directly without checking its return value, if platform_driver_register()
      fails, it returns without unregistering all the vc4 drivers, resulting the
      vc4 can never be installed later.
      A simple call graph is shown as below:
      
       vc4_drm_register()
         platform_register_drivers() # all vc4 drivers are registered
         platform_driver_register()
           driver_register()
             bus_add_driver()
               priv = kzalloc(...) # OOM happened
         # return without unregister drivers
      
      Fixing this problem by checking the return value of
      platform_driver_register() and do platform_unregister_drivers() if
      error happened.
      
      Fixes: c8b75bca
      
       ("drm/vc4: Add KMS support for Raspberry Pi.")
      Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221103014705.109322-1-yuancan@huawei.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bc79cb9f
    • HW He's avatar
      net: wwan: mhi: fix memory leak in mhi_mbim_dellink · 2845bc90
      HW He authored
      [ Upstream commit 668205b9 ]
      
      MHI driver registers network device without setting the
      needs_free_netdev flag, and does NOT call free_netdev() when
      unregisters network device, which causes a memory leak.
      
      This patch sets needs_free_netdev to true when registers
      network device, which makes netdev subsystem call free_netdev()
      automatically after unregister_netdevice().
      
      Fixes: aa730a99
      
       ("net: wwan: Add MHI MBIM network driver")
      Signed-off-by: default avatarHW He <hw.he@mediatek.com>
      Signed-off-by: default avatarZhaoping Shu <zhaoping.shu@mediatek.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2845bc90
    • HW He's avatar
      net: wwan: iosm: fix memory leak in ipc_wwan_dellink · 2ce2348c
      HW He authored
      [ Upstream commit f25caaca ]
      
      IOSM driver registers network device without setting the
      needs_free_netdev flag, and does NOT call free_netdev() when
      unregisters network device, which causes a memory leak.
      
      This patch sets needs_free_netdev to true when registers
      network device, which makes netdev subsystem call free_netdev()
      automatically after unregister_netdevice().
      
      Fixes: 2a54f2c7
      
       ("net: iosm: net driver")
      Signed-off-by: default avatarHW He <hw.he@mediatek.com>
      Reviewed-by: default avatarLoic Poulain <loic.poulain@linaro.org>
      Signed-off-by: default avatarZhaoping Shu <zhaoping.shu@mediatek.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ce2348c
    • Zhengchao Shao's avatar
      hamradio: fix issue of dev reference count leakage in bpq_device_event() · 7b6bc50f
      Zhengchao Shao authored
      [ Upstream commit 85cbaf03 ]
      
      When following tests are performed, it will cause dev reference counting
      leakage.
      a)ip link add bond2 type bond mode balance-rr
      b)ip link set bond2 up
      c)ifenslave -f bond2 rose1
      d)ip link del bond2
      
      When new bond device is created, the default type of the bond device is
      ether. And the bond device is up, bpq_device_event() receives the message
      and creates a new bpq device. In this case, the reference count value of
      dev is hold once. But after "ifenslave -f bond2 rose1" command is
      executed, the type of the bond device is changed to rose. When the bond
      device is unregistered, bpq_device_event() will not put the dev reference
      count.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7b6bc50f
    • Zhengchao Shao's avatar
      net: lapbether: fix issue of dev reference count leakage in lapbeth_device_event() · f59adebb
      Zhengchao Shao authored
      [ Upstream commit 531705a7 ]
      
      When following tests are performed, it will cause dev reference counting
      leakage.
      a)ip link add bond2 type bond mode balance-rr
      b)ip link set bond2 up
      c)ifenslave -f bond2 rose1
      d)ip link del bond2
      
      When new bond device is created, the default type of the bond device is
      ether. And the bond device is up, lapbeth_device_event() receives the
      message and creates a new lapbeth device. In this case, the reference
      count value of dev is hold once. But after "ifenslave -f bond2 rose1"
      command is executed, the type of the bond device is changed to rose. When
      the bond device is unregistered, lapbeth_device_event() will not put the
      dev reference count.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f59adebb
    • Nico Boehr's avatar
      KVM: s390: pv: don't allow userspace to set the clock under PV · 119407dc
      Nico Boehr authored
      [ Upstream commit 6973091d ]
      
      When running under PV, the guest's TOD clock is under control of the
      ultravisor and the hypervisor isn't allowed to change it. Hence, don't
      allow userspace to change the guest's TOD clock by returning
      -EOPNOTSUPP.
      
      When userspace changes the guest's TOD clock, KVM updates its
      kvm.arch.epoch field and, in addition, the epoch field in all state
      descriptions of all VCPUs.
      
      But, under PV, the ultravisor will ignore the epoch field in the state
      description and simply overwrite it on next SIE exit with the actual
      guest epoch. This leads to KVM having an incorrect view of the guest's
      TOD clock: it has updated its internal kvm.arch.epoch field, but the
      ultravisor ignores the field in the state description.
      
      Whenever a guest is now waiting for a clock comparator, KVM will
      incorrectly calculate the time when the guest should wake up, possibly
      causing the guest to sleep for much longer than expected.
      
      With this change, kvm_s390_set_tod() will now take the kvm->lock to be
      able to call kvm_s390_pv_is_protected(). Since kvm_s390_set_tod_clock()
      also takes kvm->lock, use __kvm_s390_set_tod_clock() instead.
      
      The function kvm_s390_set_tod_clock is now unused, hence remove it.
      Update the documentation to indicate the TOD clock attr calls can now
      return -EOPNOTSUPP.
      
      Fixes: 0f303504
      
       ("KVM: s390: protvirt: Do only reset registers that are accessible")
      Reported-by: default avatarMarc Hartmayer <mhartmay@linux.ibm.com>
      Signed-off-by: default avatarNico Boehr <nrb@linux.ibm.com>
      Reviewed-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
      Reviewed-by: default avatarJanosch Frank <frankja@linux.ibm.com>
      Link: https://lore.kernel.org/r/20221011160712.928239-2-nrb@linux.ibm.com
      Message-Id: <20221011160712.928239-2-nrb@linux.ibm.com>
      Signed-off-by: default avatarJanosch Frank <frankja@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      119407dc
    • John Thomson's avatar
      phy: ralink: mt7621-pci: add sentinel to quirks table · 500bcd3a
      John Thomson authored
      [ Upstream commit 819b885c ]
      
      With mt7621 soc_dev_attr fixed to register the soc as a device,
      kernel will experience an oops in soc_device_match_attr
      
      This quirk test was introduced in the staging driver in
      commit 9445ccb3 ("staging: mt7621-pci-phy: add quirks for 'E2'
      revision using 'soc_device_attribute'"). The staging driver was removed,
      and later re-added in commit d87da323 ("phy: ralink: Add PHY driver
      for MT7621 PCIe PHY") for kernel 5.11
      
      Link: https://lore.kernel.org/lkml/26ebbed1-0fe9-4af9-8466-65f841d0b382@app.fastmail.com
      Fixes: d87da323
      
       ("phy: ralink: Add PHY driver for MT7621 PCIe PHY")
      Signed-off-by: default avatarJohn Thomson <git@johnthomson.fastmail.com.au>
      Acked-by: default avatarSergio Paracuellos <sergio.paracuellos@gmail.com>
      Link: https://lore.kernel.org/r/20221104205242.3440388-2-git@johnthomson.fastmail.com.au
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      500bcd3a
    • Gaosheng Cui's avatar
      capabilities: fix undefined behavior in bit shift for CAP_TO_MASK · 151dc808
      Gaosheng Cui authored
      [ Upstream commit 46653972 ]
      
      Shifting signed 32-bit value by 31 bits is undefined, so changing
      significant bit to unsigned. The UBSAN warning calltrace like below:
      
      UBSAN: shift-out-of-bounds in security/commoncap.c:1252:2
      left shift of 1 by 31 places cannot be represented in type 'int'
      Call Trace:
       <TASK>
       dump_stack_lvl+0x7d/0xa5
       dump_stack+0x15/0x1b
       ubsan_epilogue+0xe/0x4e
       __ubsan_handle_shift_out_of_bounds+0x1e7/0x20c
       cap_task_prctl+0x561/0x6f0
       security_task_prctl+0x5a/0xb0
       __x64_sys_prctl+0x61/0x8f0
       do_syscall_64+0x58/0x80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
       </TASK>
      
      Fixes: e338d263
      
       ("Add 64-bit capability support to the kernel")
      Signed-off-by: default avatarGaosheng Cui <cuigaosheng1@huawei.com>
      Acked-by: default avatarAndrew G. Morgan <morgan@kernel.org>
      Reviewed-by: default avatarSerge Hallyn <serge@hallyn.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      151dc808
    • Sean Anderson's avatar
      net: fman: Unregister ethernet device on removal · 435c7ddf
      Sean Anderson authored
      [ Upstream commit b7cbc674 ]
      
      When the mac device gets removed, it leaves behind the ethernet device.
      This will result in a segfault next time the ethernet device accesses
      mac_dev. Remove the ethernet device when we get removed to prevent
      this. This is not completely reversible, since some resources aren't
      cleaned up properly, but that can be addressed later.
      
      Fixes: 39339616
      
       ("fsl/fman: Add FMan MAC driver")
      Signed-off-by: default avatarSean Anderson <sean.anderson@seco.com>
      Link: https://lore.kernel.org/r/20221103182831.2248833-1-sean.anderson@seco.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      435c7ddf
    • Alex Barba's avatar
      bnxt_en: fix potentially incorrect return value for ndo_rx_flow_steer · 3a504d6d
      Alex Barba authored
      [ Upstream commit 02597d39 ]
      
      In the bnxt_en driver ndo_rx_flow_steer returns '0' whenever an entry
      that we are attempting to steer is already found.  This is not the
      correct behavior.  The return code should be the value/index that
      corresponds to the entry.  Returning zero all the time causes the
      RFS records to be incorrect unless entry '0' is the correct one.  As
      flows migrate to different cores this can create entries that are not
      correct.
      
      Fixes: c0c050c5
      
       ("bnxt_en: New Broadcom ethernet driver.")
      Reported-by: default avatarAkshay Navgire <anavgire@purestorage.com>
      Signed-off-by: default avatarAlex Barba <alex.barba@broadcom.com>
      Signed-off-by: default avatarAndy Gospodarek <gospo@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3a504d6d
    • Michael Chan's avatar
      bnxt_en: Fix possible crash in bnxt_hwrm_set_coal() · ac257c43
      Michael Chan authored
      [ Upstream commit 6d81ea37 ]
      
      During the error recovery sequence, the rtnl_lock is not held for the
      entire duration and some datastructures may be freed during the sequence.
      Check for the BNXT_STATE_OPEN flag instead of netif_running() to ensure
      that the device is fully operational before proceeding to reconfigure
      the coalescing settings.
      
      This will fix a possible crash like this:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
      PGD 0 P4D 0
      Oops: 0000 [#1] SMP NOPTI
      CPU: 10 PID: 181276 Comm: ethtool Kdump: loaded Tainted: G          IOE    --------- -  - 4.18.0-348.el8.x86_64 #1
      Hardware name: Dell Inc. PowerEdge R740/0F9N89, BIOS 2.3.10 08/15/2019
      RIP: 0010:bnxt_hwrm_set_coal+0x1fb/0x2a0 [bnxt_en]
      Code: c2 66 83 4e 22 08 66 89 46 1c e8 10 cb 00 00 41 83 c6 01 44 39 b3 68 01 00 00 0f 8e a3 00 00 00 48 8b 93 c8 00 00 00 49 63 c6 <48> 8b 2c c2 48 8b 85 b8 02 00 00 48 85 c0 74 2e 48 8b 74 24 08 f6
      RSP: 0018:ffffb11c8dcaba50 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: ffff8d168a8b0ac0 RCX: 00000000000000c5
      RDX: 0000000000000000 RSI: ffff8d162f72c000 RDI: ffff8d168a8b0b28
      RBP: 0000000000000000 R08: b6e1f68a12e9a7eb R09: 0000000000000000
      R10: 0000000000000001 R11: 0000000000000037 R12: ffff8d168a8b109c
      R13: ffff8d168a8b10aa R14: 0000000000000000 R15: ffffffffc01ac4e0
      FS:  00007f3852e4c740(0000) GS:ffff8d24c0080000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000000 CR3: 000000041b3ee003 CR4: 00000000007706e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      PKRU: 55555554
      Call Trace:
       ethnl_set_coalesce+0x3ce/0x4c0
       genl_family_rcv_msg_doit.isra.15+0x10f/0x150
       genl_family_rcv_msg+0xb3/0x160
       ? coalesce_fill_reply+0x480/0x480
       genl_rcv_msg+0x47/0x90
       ? genl_family_rcv_msg+0x160/0x160
       netlink_rcv_skb+0x4c/0x120
       genl_rcv+0x24/0x40
       netlink_unicast+0x196/0x230
       netlink_sendmsg+0x204/0x3d0
       sock_sendmsg+0x4c/0x50
       __sys_sendto+0xee/0x160
       ? syscall_trace_enter+0x1d3/0x2c0
       ? __audit_syscall_exit+0x249/0x2a0
       __x64_sys_sendto+0x24/0x30
       do_syscall_64+0x5b/0x1a0
       entry_SYSCALL_64_after_hwframe+0x65/0xca
      RIP: 0033:0x7f38524163bb
      
      Fixes: 2151fe08
      
       ("bnxt_en: Handle RESET_NOTIFY async event from firmware.")
      Reviewed-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ac257c43
    • Wang Yufen's avatar
      net: tun: Fix memory leaks of napi_get_frags · d7569302
      Wang Yufen authored
      [ Upstream commit 1118b204 ]
      
      kmemleak reports after running test_progs:
      
      unreferenced object 0xffff8881b1672dc0 (size 232):
        comm "test_progs", pid 394388, jiffies 4354712116 (age 841.975s)
        hex dump (first 32 bytes):
          e0 84 d7 a8 81 88 ff ff 80 2c 67 b1 81 88 ff ff  .........,g.....
          00 40 c5 9b 81 88 ff ff 00 00 00 00 00 00 00 00  .@..............
        backtrace:
          [<00000000c8f01748>] napi_skb_cache_get+0xd4/0x150
          [<0000000041c7fc09>] __napi_build_skb+0x15/0x50
          [<00000000431c7079>] __napi_alloc_skb+0x26e/0x540
          [<000000003ecfa30e>] napi_get_frags+0x59/0x140
          [<0000000099b2199e>] tun_get_user+0x183d/0x3bb0 [tun]
          [<000000008a5adef0>] tun_chr_write_iter+0xc0/0x1b1 [tun]
          [<0000000049993ff4>] do_iter_readv_writev+0x19f/0x320
          [<000000008f338ea2>] do_iter_write+0x135/0x630
          [<000000008a3377a4>] vfs_writev+0x12e/0x440
          [<00000000a6b5639a>] do_writev+0x104/0x280
          [<00000000ccf065d8>] do_syscall_64+0x3b/0x90
          [<00000000d776e329>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      The issue occurs in the following scenarios:
      tun_get_user()
        napi_gro_frags()
          napi_frags_finish()
            case GRO_NORMAL:
              gro_normal_one()
                list_add_tail(&skb->list, &napi->rx_list);
                <-- While napi->rx_count < READ_ONCE(gro_normal_batch),
                <-- gro_normal_list() is not called, napi->rx_list is not empty
        <-- not ask to complete the gro work, will cause memory leaks in
        <-- following tun_napi_del()
      ...
      tun_napi_del()
        netif_napi_del()
          __netif_napi_del()
          <-- &napi->rx_list is not empty, which caused memory leaks
      
      To fix, add napi_complete() after napi_gro_frags().
      
      Fixes: 90e33d45
      
       ("tun: enable napi_gro_frags() for TUN/TAP driver")
      Signed-off-by: default avatarWang Yufen <wangyufen@huawei.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d7569302
    • Ratheesh Kannoth's avatar
      octeontx2-pf: NIX TX overwrites SQ_CTX_HW_S[SQ_INT] · 430d1f49
      Ratheesh Kannoth authored
      [ Upstream commit 51afe902 ]
      
      In scenarios where multiple errors have occurred
      for a SQ before SW starts handling error interrupt,
      SQ_CTX[OP_INT] may get overwritten leading to
      NIX_LF_SQ_OP_INT returning incorrect value.
      To workaround this read LMT, MNQ and SQ individual
      error status registers to determine the cause of error.
      
      Fixes: 4ff7d148
      
       ("octeontx2-pf: Error handling support")
      Signed-off-by: default avatarRatheesh Kannoth <rkannoth@marvell.com>
      Reviewed-by: default avatarSunil Kovvuri Goutham <sgoutham@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      430d1f49
    • Geetha sowjanya's avatar
      octeontx2-pf: Use hardware register for CQE count · ec0db818
      Geetha sowjanya authored
      [ Upstream commit af3826db
      
       ]
      
      Current driver uses software CQ head pointer to poll on CQE
      header in memory to determine if CQE is valid. Software needs
      to make sure, that the reads of the CQE do not get re-ordered
      so much that it ends up with an inconsistent view of the CQE.
      To ensure that DMB barrier after read to first CQE cacheline
      and before reading of the rest of the CQE is needed.
      But having barrier for every CQE read will impact the performance,
      instead use hardware CQ head and tail pointers to find the
      valid number of CQEs.
      
      Signed-off-by: default avatarGeetha sowjanya <gakula@marvell.com>
      Signed-off-by: default avatarSunil Kovvuri Goutham <sgoutham@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: 51afe902
      
       ("octeontx2-pf: NIX TX overwrites SQ_CTX_HW_S[SQ_INT]")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ec0db818
    • Sabrina Dubroca's avatar
      macsec: clear encryption keys from the stack after setting up offload · b89a0d88
      Sabrina Dubroca authored
      [ Upstream commit aaab73f8 ]
      
      macsec_add_rxsa and macsec_add_txsa copy the key to an on-stack
      offloading context to pass it to the drivers, but leaves it there when
      it's done. Clear it with memzero_explicit as soon as it's not needed
      anymore.
      
      Fixes: 3cf3227a
      
       ("net: macsec: hardware offloading infrastructure")
      Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Reviewed-by: default avatarAntoine Tenart <atenart@kernel.org>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b89a0d88
    • Sabrina Dubroca's avatar
      macsec: fix detection of RXSCs when toggling offloading · eeba7f07
      Sabrina Dubroca authored
      [ Upstream commit 80df4706 ]
      
      macsec_is_configured incorrectly uses secy->n_rx_sc to check if some
      RXSCs exist. secy->n_rx_sc only counts the number of active RXSCs, but
      there can also be inactive SCs as well, which may be stored in the
      driver (in case we're disabling offloading), or would have to be
      pushed to the device (in case we're trying to enable offloading).
      
      As long as RXSCs active on creation and never turned off, the issue is
      not visible.
      
      Fixes: dcb780fb
      
       ("net: macsec: add nla support for changing the offloading selection")
      Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Reviewed-by: default avatarAntoine Tenart <atenart@kernel.org>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eeba7f07
    • Sabrina Dubroca's avatar
      macsec: fix secy->n_rx_sc accounting · 3070a880
      Sabrina Dubroca authored
      [ Upstream commit 73a4b31c ]
      
      secy->n_rx_sc is supposed to be the number of _active_ rxsc's within a
      secy. This is then used by macsec_send_sci to help decide if we should
      add the SCI to the header or not.
      
      This logic is currently broken when we create a new RXSC and turn it
      off at creation, as create_rx_sc always sets ->active to true (and
      immediately uses that to increment n_rx_sc), and only later
      macsec_add_rxsc sets rx_sc->active.
      
      Fixes: c09440f7
      
       ("macsec: introduce IEEE 802.1AE driver")
      Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Reviewed-by: default avatarAntoine Tenart <atenart@kernel.org>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3070a880
    • Sabrina Dubroca's avatar
      macsec: delete new rxsc when offload fails · e957555a
      Sabrina Dubroca authored
      [ Upstream commit 93a30947 ]
      
      Currently we get an inconsistent state:
       - netlink returns the error to userspace
       - the RXSC is installed but not offloaded
      
      Then the device could get confused when we try to add an RXSA, because
      the RXSC isn't supposed to exist.
      
      Fixes: 3cf3227a
      
       ("net: macsec: hardware offloading infrastructure")
      Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Reviewed-by: default avatarAntoine Tenart <atenart@kernel.org>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e957555a
    • Jiri Benc's avatar
      net: gso: fix panic on frag_list with mixed head alloc types · ad25a115
      Jiri Benc authored
      [ Upstream commit 9e4b7a99 ]
      
      Since commit 3dcbdb13 ("net: gso: Fix skb_segment splat when
      splitting gso_size mangled skb having linear-headed frag_list"), it is
      allowed to change gso_size of a GRO packet. However, that commit assumes
      that "checking the first list_skb member suffices; i.e if either of the
      list_skb members have non head_frag head, then the first one has too".
      
      It turns out this assumption does not hold. We've seen BUG_ON being hit
      in skb_segment when skbs on the frag_list had differing head_frag with
      the vmxnet3 driver. This happens because __netdev_alloc_skb and
      __napi_alloc_skb can return a skb that is page backed or kmalloced
      depending on the requested size. As the result, the last small skb in
      the GRO packet can be kmalloced.
      
      There are three different locations where this can be fixed:
      
      (1) We could check head_frag in GRO and not allow GROing skbs with
          different head_frag. However, that would lead to performance
          regression on normal forward paths with unmodified gso_size, where
          !head_frag in the last packet is not a problem.
      
      (2) Set a flag in bpf_skb_net_grow and bpf_skb_net_shrink indicating
          that NETIF_F_SG is undesirable. That would need to eat a bit in
          sk_buff. Furthermore, that flag can be unset when all skbs on the
          frag_list are page backed. To retain good performance,
          bpf_skb_net_grow/shrink would have to walk the frag_list.
      
      (3) Walk the frag_list in skb_segment when determining whether
          NETIF_F_SG should be cleared. This of course slows things down.
      
      This patch implements (3). To limit the performance impact in
      skb_segment, the list is walked only for skbs with SKB_GSO_DODGY set
      that have gso_size changed. Normal paths thus will not hit it.
      
      We could check only the last skb but since we need to walk the whole
      list anyway, let's stay on the safe side.
      
      Fixes: 3dcbdb13
      
       ("net: gso: Fix skb_segment splat when splitting gso_size mangled skb having linear-headed frag_list")
      Signed-off-by: default avatarJiri Benc <jbenc@redhat.com>
      Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
      Link: https://lore.kernel.org/r/e04426a6a91baf4d1081e1b478c82b5de25fdf21.1667407944.git.jbenc@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad25a115
    • Youlin Li's avatar
      bpf: Fix wrong reg type conversion in release_reference() · 466ce46f
      Youlin Li authored
      [ Upstream commit f1db2081 ]
      
      Some helper functions will allocate memory. To avoid memory leaks, the
      verifier requires the eBPF program to release these memories by calling
      the corresponding helper functions.
      
      When a resource is released, all pointer registers corresponding to the
      resource should be invalidated. The verifier use release_references() to
      do this job, by apply  __mark_reg_unknown() to each relevant register.
      
      It will give these registers the type of SCALAR_VALUE. A register that
      will contain a pointer value at runtime, but of type SCALAR_VALUE, which
      may allow the unprivileged user to get a kernel pointer by storing this
      register into a map.
      
      Using __mark_reg_not_init() while NOT allow_ptr_leaks can mitigate this
      problem.
      
      Fixes: fd978bf7
      
       ("bpf: Add reference tracking to verifier")
      Signed-off-by: default avatarYoulin Li <liulin063@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20221103093440.3161-1-liulin063@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      466ce46f
    • Kumar Kartikeya Dwivedi's avatar
      bpf: Add helper macro bpf_for_each_reg_in_vstate · 35d8130f
      Kumar Kartikeya Dwivedi authored
      [ Upstream commit b239da34
      
       ]
      
      For a lot of use cases in future patches, we will want to modify the
      state of registers part of some same 'group' (e.g. same ref_obj_id). It
      won't just be limited to releasing reference state, but setting a type
      flag dynamically based on certain actions, etc.
      
      Hence, we need a way to easily pass a callback to the function that
      iterates over all registers in current bpf_verifier_state in all frames
      upto (and including) the curframe.
      
      While in C++ we would be able to easily use a lambda to pass state and
      the callback together, sadly we aren't using C++ in the kernel. The next
      best thing to avoid defining a function for each case seems like
      statement expressions in GNU C. The kernel already uses them heavily,
      hence they can passed to the macro in the style of a lambda. The
      statement expression will then be substituted in the for loop bodies.
      
      Variables __state and __reg are set to current bpf_func_state and reg
      for each invocation of the expression inside the passed in verifier
      state.
      
      Then, convert mark_ptr_or_null_regs, clear_all_pkt_pointers,
      release_reference, find_good_pkt_pointers, find_equal_scalars to
      use bpf_for_each_reg_in_vstate.
      
      Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Link: https://lore.kernel.org/r/20220904204145.3089-16-memxor@gmail.com
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Stable-dep-of: f1db2081
      
       ("bpf: Fix wrong reg type conversion in release_reference()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      35d8130f
    • Cong Wang's avatar
      bpf, sock_map: Move cancel_work_sync() out of sock lock · 61274498
      Cong Wang authored
      [ Upstream commit 8bbabb3f ]
      
      Stanislav reported a lockdep warning, which is caused by the
      cancel_work_sync() called inside sock_map_close(), as analyzed
      below by Jakub:
      
      psock->work.func = sk_psock_backlog()
        ACQUIRE psock->work_mutex
          sk_psock_handle_skb()
            skb_send_sock()
              __skb_send_sock()
                sendpage_unlocked()
                  kernel_sendpage()
                    sock->ops->sendpage = inet_sendpage()
                      sk->sk_prot->sendpage = tcp_sendpage()
                        ACQUIRE sk->sk_lock
                          tcp_sendpage_locked()
                        RELEASE sk->sk_lock
        RELEASE psock->work_mutex
      
      sock_map_close()
        ACQUIRE sk->sk_lock
        sk_psock_stop()
          sk_psock_clear_state(psock, SK_PSOCK_TX_ENABLED)
          cancel_work_sync()
            __cancel_work_timer()
              __flush_work()
                // wait for psock->work to finish
        RELEASE sk->sk_lock
      
      We can move the cancel_work_sync() out of the sock lock protection,
      but still before saved_close() was called.
      
      Fixes: 799aa7f9
      
       ("skmsg: Avoid lock_sock() in sk_psock_backlog()")
      Reported-by: default avatarStanislav Fomichev <sdf@google.com>
      Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20221102043417.279409-1-xiyou.wangcong@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      61274498
    • John Fastabend's avatar
      bpf: Fix sockmap calling sleepable function in teardown path · 32b5dd03
      John Fastabend authored
      [ Upstream commit 697fb80a ]
      
      syzbot reproduced the bug ...
      
       BUG: sleeping function called from invalid context at kernel/workqueue.c:3010
      
      ... with the following stack trace fragment ...
      
       start_flush_work kernel/workqueue.c:3010 [inline]
       __flush_work+0x109/0xb10 kernel/workqueue.c:3074
       __cancel_work_timer+0x3f9/0x570 kernel/workqueue.c:3162
       sk_psock_stop+0x4cb/0x630 net/core/skmsg.c:802
       sock_map_destroy+0x333/0x760 net/core/sock_map.c:1581
       inet_csk_destroy_sock+0x196/0x440 net/ipv4/inet_connection_sock.c:1130
       __tcp_close+0xd5b/0x12b0 net/ipv4/tcp.c:2897
       tcp_close+0x29/0xc0 net/ipv4/tcp.c:2909
      
      ... introduced by d8616ee2. Do a quick trace of the code path and the
      bug is obvious:
      
         inet_csk_destroy_sock(sk)
           sk_prot->destroy(sk);      <--- sock_map_destroy
              sk_psock_stop(, true);   <--- true so cancel workqueue
                cancel_work_sync()     <--- splat, because *_bh_disable()
      
      We can not call cancel_work_sync() from inside destroy path. So mark
      the sk_psock_stop call to skip this cancel_work_sync(). This will avoid
      the BUG, but means we may run sk_psock_backlog after or during the
      destroy op. We zapped the ingress_skb queue in sk_psock_stop (safe to
      do with local_bh_disable) so its empty and the sk_psock_backlog work
      item will not find any pkts to process here. However, because we are
      not going to wait for it or clear its ->state its possible it kicks off
      or is already running. This should be 'safe' up until psock drops its
      refcnt to psock->sk. The sock_put() that drops this reference is only
      done at psock destroy time from sk_psock_destroy(). This is done through
      workqueue when sk_psock_drop() is called on psock refnt reaches 0.
      And importantly sk_psock_destroy() does a cancel_work_sync(). So trivial
      fix works.
      
      I've had hit or miss luck reproducing this caught it once or twice with
      the provided reproducer when running with many runners. However, syzkaller
      is very good at reproducing so relying on syzkaller to verify fix.
      
      Fixes: d8616ee2
      
       ("bpf, sockmap: Fix sk->sk_forward_alloc warn_on in sk_stream_kill_queues")
      Reported-by: default avatar <syzbot+140186ceba0c496183bc@syzkaller.appspotmail.com>
      Suggested-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: Wang Yufen <wangyufen@huawei.com>
      Link: https://lore.kernel.org/bpf/20220628035803.317876-1-john.fastabend@gmail.com
      Stable-dep-of: 8bbabb3f
      
       ("bpf, sock_map: Move cancel_work_sync() out of sock lock")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      32b5dd03
    • Wang Yufen's avatar
      bpf, sockmap: Fix sk->sk_forward_alloc warn_on in sk_stream_kill_queues · e9915581
      Wang Yufen authored
      [ Upstream commit d8616ee2
      
       ]
      
      During TCP sockmap redirect pressure test, the following warning is triggered:
      
      WARNING: CPU: 3 PID: 2145 at net/core/stream.c:205 sk_stream_kill_queues+0xbc/0xd0
      CPU: 3 PID: 2145 Comm: iperf Kdump: loaded Tainted: G        W         5.10.0+ #9
      Call Trace:
       inet_csk_destroy_sock+0x55/0x110
       inet_csk_listen_stop+0xbb/0x380
       tcp_close+0x41b/0x480
       inet_release+0x42/0x80
       __sock_release+0x3d/0xa0
       sock_close+0x11/0x20
       __fput+0x9d/0x240
       task_work_run+0x62/0x90
       exit_to_user_mode_prepare+0x110/0x120
       syscall_exit_to_user_mode+0x27/0x190
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      The reason we observed is that:
      
      When the listener is closing, a connection may have completed the three-way
      handshake but not accepted, and the client has sent some packets. The child
      sks in accept queue release by inet_child_forget()->inet_csk_destroy_sock(),
      but psocks of child sks have not released.
      
      To fix, add sock_map_destroy to release psocks.
      
      Signed-off-by: default avatarWang Yufen <wangyufen@huawei.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/bpf/20220524075311.649153-1-wangyufen@huawei.com
      Stable-dep-of: 8bbabb3f
      
       ("bpf, sock_map: Move cancel_work_sync() out of sock lock")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e9915581
    • Yang Yingliang's avatar
      HID: hyperv: fix possible memory leak in mousevsc_probe() · 5ad95d71
      Yang Yingliang authored
      [ Upstream commit b5bcb94b ]
      
      If hid_add_device() returns error, it should call hid_destroy_device()
      to free hid_dev which is allocated in hid_allocate_device().
      
      Fixes: 74c4fb05
      
       ("HID: hv_mouse: Properly add the hid device")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarWei Liu <wei.liu@kernel.org>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5ad95d71
    • Pu Lehui's avatar
      bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE · 6dcdd1b6
      Pu Lehui authored
      [ Upstream commit 34de8e6e ]
      
      When using bpftool to pin {PROG, MAP, LINK} without FILE,
      segmentation fault will occur. The reson is that the lack
      of FILE will cause strlen to trigger NULL pointer dereference.
      The corresponding stacktrace is shown below:
      
      do_pin
        do_pin_any
          do_pin_fd
            mount_bpffs_for_pin
              strlen(name) <- NULL pointer dereference
      
      Fix it by adding validation to the common process.
      
      Fixes: 75a1e792
      
       ("tools: bpftool: Allow all prog/map handles for pinning objects")
      Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
      Link: https://lore.kernel.org/bpf/20221102084034.3342995-1-pulehui@huaweicloud.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6dcdd1b6
    • Howard Hsu's avatar
      wifi: mac80211: Set TWT Information Frame Disabled bit as 1 · 2fc90224
      Howard Hsu authored
      [ Upstream commit 30ac96f7 ]
      
      The TWT Information Frame Disabled bit of control field of TWT Setup
      frame shall be set to 1 since handling TWT Information frame is not
      supported by current mac80211 implementation.
      
      Fixes: f5a4c24e
      
       ("mac80211: introduce individual TWT support in AP mode")
      Signed-off-by: default avatarHoward Hsu <howard-yh.hsu@mediatek.com>
      Link: https://lore.kernel.org/r/20221027015653.1448-1-howard-yh.hsu@mediatek.com
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2fc90224
    • Wang Yufen's avatar
      bpf, sockmap: Fix the sk->sk_forward_alloc warning of sk_stream_kill_queues · 95adbd2a
      Wang Yufen authored
      [ Upstream commit 8ec95b94 ]
      
      When running `test_sockmap` selftests, the following warning appears:
      
        WARNING: CPU: 2 PID: 197 at net/core/stream.c:205 sk_stream_kill_queues+0xd3/0xf0
        Call Trace:
        <TASK>
        inet_csk_destroy_sock+0x55/0x110
        tcp_rcv_state_process+0xd28/0x1380
        ? tcp_v4_do_rcv+0x77/0x2c0
        tcp_v4_do_rcv+0x77/0x2c0
        __release_sock+0x106/0x130
        __tcp_close+0x1a7/0x4e0
        tcp_close+0x20/0x70
        inet_release+0x3c/0x80
        __sock_release+0x3a/0xb0
        sock_close+0x14/0x20
        __fput+0xa3/0x260
        task_work_run+0x59/0xb0
        exit_to_user_mode_prepare+0x1b3/0x1c0
        syscall_exit_to_user_mode+0x19/0x50
        do_syscall_64+0x48/0x90
        entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      The root case is in commit 84472b43 ("bpf, sockmap: Fix more uncharged
      while msg has more_data"), where I used msg->sg.size to replace the tosend,
      causing breakage:
      
        if (msg->apply_bytes && msg->apply_bytes < tosend)
          tosend = psock->apply_bytes;
      
      Fixes: 84472b43
      
       ("bpf, sockmap: Fix more uncharged while msg has more_data")
      Reported-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarWang Yufen <wangyufen@huawei.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/1667266296-8794-1-git-send-email-wangyufen@huawei.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      95adbd2a
    • Kees Cook's avatar
      bpf, verifier: Fix memory leak in array reallocation for stack state · 06615967
      Kees Cook authored
      [ Upstream commit 42378a9c ]
      
      If an error (NULL) is returned by krealloc(), callers of realloc_array()
      were setting their allocation pointers to NULL, but on error krealloc()
      does not touch the original allocation. This would result in a memory
      resource leak. Instead, free the old allocation on the error handling
      path.
      
      The memory leak information is as follows as also reported by Zhengchao:
      
        unreferenced object 0xffff888019801800 (size 256):
        comm "bpf_repo", pid 6490, jiffies 4294959200 (age 17.170s)
        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:
          [<00000000b211474b>] __kmalloc_node_track_caller+0x45/0xc0
          [<0000000086712a0b>] krealloc+0x83/0xd0
          [<00000000139aab02>] realloc_array+0x82/0xe2
          [<00000000b1ca41d1>] grow_stack_state+0xfb/0x186
          [<00000000cd6f36d2>] check_mem_access.cold+0x141/0x1341
          [<0000000081780455>] do_check_common+0x5358/0xb350
          [<0000000015f6b091>] bpf_check.cold+0xc3/0x29d
          [<000000002973c690>] bpf_prog_load+0x13db/0x2240
          [<00000000028d1644>] __sys_bpf+0x1605/0x4ce0
          [<00000000053f29bd>] __x64_sys_bpf+0x75/0xb0
          [<0000000056fedaf5>] do_syscall_64+0x35/0x80
          [<000000002bd58261>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Fixes: c69431aa
      
       ("bpf: verifier: Improve function state reallocation")
      Reported-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
      Reported-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarBill Wendling <morbo@google.com>
      Cc: Lorenz Bauer <oss@lmb.io>
      Link: https://lore.kernel.org/bpf/20221029025433.2533810-1-keescook@chromium.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      06615967
    • Srinivas Kandagatla's avatar
      soundwire: qcom: check for outanding writes before doing a read · 4335a82c
      Srinivas Kandagatla authored
      [ Upstream commit 49a46731 ]
      
      Reading will increase the fifo count, so check for outstanding cmd wrt.
      write fifo depth to avoid overflow as read will also increase
      write fifo cnt.
      
      Fixes: a661308c
      
       ("soundwire: qcom: wait for fifo space to be available before read/write")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20221026110210.6575-3-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4335a82c
    • Srinivas Kandagatla's avatar
      soundwire: qcom: reinit broadcast completion · ae4dad2e
      Srinivas Kandagatla authored
      [ Upstream commit f936fa7a ]
      
      For some reason we never reinit the broadcast completion, there is a
      danger that broadcast commands could be treated as completed by driver
      from previous complete status.
      Fix this by reinitializing the completion before sending a broadcast command.
      
      Fixes: ddea6cf7
      
       ("soundwire: qcom: update register read/write routine")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20221026110210.6575-2-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ae4dad2e
    • Arend van Spriel's avatar
      wifi: cfg80211: fix memory leak in query_regdb_file() · 38c9fa2c
      Arend van Spriel authored
      [ Upstream commit 57b962e6 ]
      
      In the function query_regdb_file() the alpha2 parameter is duplicated
      using kmemdup() and subsequently freed in regdb_fw_cb(). However,
      request_firmware_nowait() can fail without calling regdb_fw_cb() and
      thus leak memory.
      
      Fixes: 007f6c5e
      
       ("cfg80211: support loading regulatory database as firmware file")
      Signed-off-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      38c9fa2c
    • Johannes Berg's avatar
      wifi: cfg80211: silence a sparse RCU warning · 2c6ba0a7
      Johannes Berg authored
      [ Upstream commit 03c0ad4b ]
      
      All we're going to do with this pointer is assign it to
      another __rcu pointer, but sparse can't see that, so
      use rcu_access_pointer() to silence the warning here.
      
      Fixes: c90b93b5
      
       ("wifi: cfg80211: update hidden BSSes to avoid WARN_ON")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2c6ba0a7
    • Dan Carpenter's avatar
      phy: stm32: fix an error code in probe · 921738c2
      Dan Carpenter authored
      [ Upstream commit ca1c7362 ]
      
      If "index > usbphyc->nphys" is true then this returns success but it
      should return -EINVAL.
      
      Fixes: 94c358da
      
       ("phy: stm32: add support for STM32 USB PHY Controller (USBPHYC)")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
      Link: https://lore.kernel.org/r/Y0kq8j6S+5nDdMpr@kili
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      921738c2
    • Krzysztof Kozlowski's avatar
      hwspinlock: qcom: correct MMIO max register for newer SoCs · fa722006
      Krzysztof Kozlowski authored
      [ Upstream commit 90cb380f ]
      
      Newer ARMv8 Qualcomm SoCs using 0x1000 register stride have maximum
      register 0x20000 (32 mutexes * 0x1000).
      
      Fixes: 7a1e6fb1
      
       ("hwspinlock: qcom: Allow mmio usage in addition to syscon")
      Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@somainline.org>
      Signed-off-by: default avatarBjorn Andersson <andersson@kernel.org>
      Link: https://lore.kernel.org/r/20220909092035.223915-4-krzysztof.kozlowski@linaro.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fa722006
    • Yang Li's avatar
      drm/amdkfd: Fix NULL pointer dereference in svm_migrate_to_ram() · 3c1bb618
      Yang Li authored
      [ Upstream commit 5b994354
      
       ]
      
      ./drivers/gpu/drm/amd/amdkfd/kfd_migrate.c:985:58-62: ERROR: p is NULL but dereferenced.
      
      Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2549
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
      Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3c1bb618
    • Philip Yang's avatar
      drm/amdkfd: handle CPU fault on COW mapping · b1f85227
      Philip Yang authored
      [ Upstream commit e1f84eef
      
       ]
      
      If CPU page fault in a page with zone_device_data svm_bo from another
      process, that means it is COW mapping in the child process and the
      range is migrated to VRAM by parent process. Migrate the parent
      process range back to system memory to recover the CPU page fault.
      
      Signed-off-by: default avatarPhilip Yang <Philip.Yang@amd.com>
      Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Stable-dep-of: 5b994354
      
       ("drm/amdkfd: Fix NULL pointer dereference in svm_migrate_to_ram()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b1f85227
    • Alex Sierra's avatar
      drm/amdkfd: avoid recursive lock in migrations back to RAM · 36770c04
      Alex Sierra authored
      [ Upstream commit a6283010
      
       ]
      
      [Why]:
      When we call hmm_range_fault to map memory after a migration, we don't
      expect memory to be migrated again as a result of hmm_range_fault. The
      driver ensures that all memory is in GPU-accessible locations so that
      no migration should be needed. However, there is one corner case where
      hmm_range_fault can unexpectedly cause a migration from DEVICE_PRIVATE
      back to system memory due to a write-fault when a system memory page in
      the same range was mapped read-only (e.g. COW). Ranges with individual
      pages in different locations are usually the result of failed page
      migrations (e.g. page lock contention). The unexpected migration back
      to system memory causes a deadlock from recursive locking in our
      driver.
      
      [How]:
      Creating a task reference new member under svm_range_list struct.
      Setting this with "current" reference, right before the hmm_range_fault
      is called. This member is checked against "current" reference at
      svm_migrate_to_ram callback function. If equal, the migration will be
      ignored.
      
      Signed-off-by: default avatarAlex Sierra <alex.sierra@amd.com>
      Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Stable-dep-of: 5b994354
      
       ("drm/amdkfd: Fix NULL pointer dereference in svm_migrate_to_ram()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      36770c04
    • Miklos Szeredi's avatar
      fuse: fix readdir cache race · 93a5de7e
      Miklos Szeredi authored
      [ Upstream commit 9fa248c6
      
       ]
      
      There's a race in fuse's readdir cache that can result in an uninitilized
      page being read.  The page lock is supposed to prevent this from happening
      but in the following case it doesn't:
      
      Two fuse_add_dirent_to_cache() start out and get the same parameters
      (size=0,offset=0).  One of them wins the race to create and lock the page,
      after which it fills in data, sets rdc.size and unlocks the page.
      
      In the meantime the page gets evicted from the cache before the other
      instance gets to run.  That one also creates the page, but finds the
      size to be mismatched, bails out and leaves the uninitialized page in the
      cache.
      
      Fix by marking a filled page uptodate and ignoring non-uptodate pages.
      
      Reported-by: default avatarFrank Sorenson <fsorenso@redhat.com>
      Fixes: 5d7bc7e8
      
       ("fuse: allow using readdir cache")
      Cc: <stable@vger.kernel.org> # v4.20
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      93a5de7e