Skip to content
  1. Oct 11, 2023
    • Leon Hwang's avatar
      bpf: Fix tr dereferencing · 163042a0
      Leon Hwang authored
      [ Upstream commit b724a641 ]
      
      Fix 'tr' dereferencing bug when CONFIG_BPF_JIT is turned off.
      
      When CONFIG_BPF_JIT is turned off, 'bpf_trampoline_get()' returns NULL,
      which is same as the cases when CONFIG_BPF_JIT is turned on.
      
      Closes: https://lore.kernel.org/r/202309131936.5Nc8eUD0-lkp@intel.com/
      Fixes: f7b12b6f
      
       ("bpf: verifier: refactor check_attach_btf_id()")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Signed-off-by: default avatarLeon Hwang <hffilwlqm@gmail.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20230917153846.88732-1-hffilwlqm@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      163042a0
    • Marek Behún's avatar
      leds: Drop BUG_ON check for LED_COLOR_ID_MULTI · c14c7214
      Marek Behún authored
      [ Upstream commit 9dc1664f ]
      
      Commit c3f85318 ("leds: Fix BUG_ON check for LED_COLOR_ID_MULTI that
      is always false") fixed a no-op BUG_ON. This turned out to cause a
      regression, since some in-tree device-tree files already use
      LED_COLOR_ID_MULTI.
      
      Drop the BUG_ON altogether.
      
      Fixes: c3f85318
      
       ("leds: Fix BUG_ON check for LED_COLOR_ID_MULTI that is always false")
      Reported-by: default avatarDa Xue <da@libre.computer>
      Closes: https://lore.kernel.org/linux-leds/ZQLelWcNjjp2xndY@duo.ucw.cz/T/
      Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
      Link: https://lore.kernel.org/r/20230918140724.18634-1-kabel@kernel.org
      Signed-off-by: default avatarLee Jones <lee@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c14c7214
    • Pin-yen Lin's avatar
      wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet · 6b706286
      Pin-yen Lin authored
      [ Upstream commit aef7a030 ]
      
      Only skip the code path trying to access the rfc1042 headers when the
      buffer is too small, so the driver can still process packets without
      rfc1042 headers.
      
      Fixes: 11958528
      
       ("wifi: mwifiex: Fix OOB and integer underflow when rx packets")
      Signed-off-by: default avatarPin-yen Lin <treapking@chromium.org>
      Acked-by: default avatarBrian Norris <briannorris@chromium.org>
      Reviewed-by: default avatarMatthew Wang <matthewmwang@chromium.org>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20230908104308.1546501-1-treapking@chromium.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6b706286
    • Johannes Berg's avatar
      wifi: cfg80211: add missing kernel-doc for cqm_rssi_work · 42970d32
      Johannes Berg authored
      [ Upstream commit d1383077
      
       ]
      
      As reported by Stephen, I neglected to add the kernel-doc
      for the new struct member. Fix that.
      
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Fixes: 37c20b2e
      
       ("wifi: cfg80211: fix cqm_config access race")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      42970d32
    • Johannes Berg's avatar
      wifi: cfg80211: fix cqm_config access race · c797498e
      Johannes Berg authored
      [ Upstream commit 37c20b2e
      
       ]
      
      Max Schulze reports crashes with brcmfmac. The reason seems
      to be a race between userspace removing the CQM config and
      the driver calling cfg80211_cqm_rssi_notify(), where if the
      data is freed while cfg80211_cqm_rssi_notify() runs it will
      crash since it assumes wdev->cqm_config is set. This can't
      be fixed with a simple non-NULL check since there's nothing
      we can do for locking easily, so use RCU instead to protect
      the pointer, but that requires pulling the updates out into
      an asynchronous worker so they can sleep and call back into
      the driver.
      
      Since we need to change the free anyway, also change it to
      go back to the old settings if changing the settings fails.
      
      Reported-and-tested-by: default avatarMax Schulze <max.schulze@online.de>
      Closes: https://lore.kernel.org/r/ac96309a-8d8d-4435-36e6-6d152eb31876@online.de
      Fixes: 4a4b8169
      
       ("cfg80211: Accept multiple RSSI thresholds for CQM")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c797498e
    • Johannes Berg's avatar
      wifi: cfg80211: add a work abstraction with special semantics · 3fcc6d7d
      Johannes Berg authored
      [ Upstream commit a3ee4dc8
      
       ]
      
      Add a work abstraction at the cfg80211 level that will always
      hold the wiphy_lock() for any work executed and therefore also
      can be canceled safely (without waiting) while holding that.
      This improves on what we do now as with the new wiphy works we
      don't have to worry about locking while cancelling them safely.
      
      Also, don't let such works run while the device is suspended,
      since they'll likely need to interact with the device. Flush
      them before suspend though.
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Stable-dep-of: 37c20b2e
      
       ("wifi: cfg80211: fix cqm_config access race")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3fcc6d7d
    • Johannes Berg's avatar
      wifi: cfg80211: move wowlan disable under locks · 2ae4585f
      Johannes Berg authored
      [ Upstream commit a993df0f
      
       ]
      
      This is a driver callback, and the driver should be able
      to assume that it's called with the wiphy lock held. Move
      the call up so that's true, it has no other effect since
      the device is already unregistering and we cannot reach
      this function through other paths.
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Stable-dep-of: 37c20b2e
      
       ("wifi: cfg80211: fix cqm_config access race")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ae4585f
    • Johannes Berg's avatar
      wifi: cfg80211: hold wiphy lock in auto-disconnect · fb195ff4
      Johannes Berg authored
      [ Upstream commit e9da6df7
      
       ]
      
      Most code paths in cfg80211 already hold the wiphy lock,
      mostly by virtue of being called from nl80211, so make
      the auto-disconnect worker also hold it, aligning the
      locking promises between different parts of cfg80211.
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Stable-dep-of: 37c20b2e
      
       ("wifi: cfg80211: fix cqm_config access race")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb195ff4
    • Christophe JAILLET's avatar
      wifi: iwlwifi: mvm: Fix a memory corruption issue · 6b322344
      Christophe JAILLET authored
      [ Upstream commit 8ba438ef ]
      
      A few lines above, space is kzalloc()'ed for:
      	sizeof(struct iwl_nvm_data) +
      	sizeof(struct ieee80211_channel) +
      	sizeof(struct ieee80211_rate)
      
      'mvm->nvm_data' is a 'struct iwl_nvm_data', so it is fine.
      
      At the end of this structure, there is the 'channels' flex array.
      Each element is of type 'struct ieee80211_channel'.
      So only 1 element is allocated in this array.
      
      When doing:
        mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels;
      We point at the first element of the 'channels' flex array.
      So this is fine.
      
      However, when doing:
        mvm->nvm_data->bands[0].bitrates =
      			(void *)((u8 *)mvm->nvm_data->channels + 1);
      because of the "(u8 *)" cast, we add only 1 to the address of the beginning
      of the flex array.
      
      It is likely that we want point at the 'struct ieee80211_rate' allocated
      just after.
      
      Remove the spurious casting so that the pointer arithmetic works as
      expected.
      
      Fixes: 8ca151b5
      
       ("iwlwifi: add the MVM driver")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Acked-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Link: https://lore.kernel.org/r/23f0ec986ef1529055f4f93dcb3940a6cf8d9a94.1690143750.git.christophe.jaillet@wanadoo.fr
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6b322344
    • Arnd Bergmann's avatar
      wifi: iwlwifi: dbg_ini: fix structure packing · 78b5c62e
      Arnd Bergmann authored
      [ Upstream commit 424c82e8 ]
      
      The iwl_fw_ini_error_dump_range structure has conflicting alignment
      requirements for the inner union and the outer struct:
      
      In file included from drivers/net/wireless/intel/iwlwifi/fw/dbg.c:9:
      drivers/net/wireless/intel/iwlwifi/fw/error-dump.h:312:2: error: field  within 'struct iwl_fw_ini_error_dump_range' is less aligned than 'union iwl_fw_ini_error_dump_range::(anonymous at drivers/net/wireless/intel/iwlwifi/fw/error-dump.h:312:2)' and is usually due to 'struct iwl_fw_ini_error_dump_range' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
              union {
      
      As the original intention was apparently to make the entire structure
      unaligned, mark the innermost members the same way so the union
      becomes packed as well.
      
      Fixes: 97319355
      
       ("iwlwifi: dbg_ini: dump headers cleanup")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Link: https://lore.kernel.org/r/20230616090343.2454061-1-arnd@kernel.org
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      78b5c62e
    • Gao Xiang's avatar
      erofs: fix memory leak of LZMA global compressed deduplication · 6a5a8f0a
      Gao Xiang authored
      [ Upstream commit 75a52216 ]
      
      When stressing microLZMA EROFS images with the new global compressed
      deduplication feature enabled (`-Ededupe`), I found some short-lived
      temporary pages weren't properly released, which could slowly cause
      unexpected OOMs hours later.
      
      Let's fix it now (LZ4 and DEFLATE don't have this issue.)
      
      Fixes: 5c2a6425
      
       ("erofs: introduce partial-referenced pclusters")
      Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
      Link: https://lore.kernel.org/r/20230907050542.97152-1-hsiangkao@linux.alibaba.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6a5a8f0a
    • Zhihao Cheng's avatar
      ubi: Refuse attaching if mtd's erasesize is 0 · 91aeb418
      Zhihao Cheng authored
      [ Upstream commit 017c73a3 ]
      
      There exists mtd devices with zero erasesize, which will trigger a
      divide-by-zero exception while attaching ubi device.
      Fix it by refusing attaching if mtd's erasesize is 0.
      
      Fixes: 801c135c
      
       ("UBI: Unsorted Block Images")
      Reported-by: default avatarYu Hao <yhao016@ucr.edu>
      Link: https://lore.kernel.org/lkml/977347543.226888.1682011999468.JavaMail.zimbra@nod.at/T/
      Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
      Reviewed-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      91aeb418
    • Christophe JAILLET's avatar
      HID: sony: Fix a potential memory leak in sony_probe() · f237b176
      Christophe JAILLET authored
      [ Upstream commit e1cd4004 ]
      
      If an error occurs after a successful usb_alloc_urb() call, usb_free_urb()
      should be called.
      
      Fixes: fb1a79a6
      
       ("HID: sony: fix freeze when inserting ghlive ps3/wii dongles")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f237b176
    • Rob Herring's avatar
      arm64: errata: Add Cortex-A520 speculative unprivileged load workaround · 6e3ae292
      Rob Herring authored
      commit 471470bc
      
       upstream.
      
      Implement the workaround for ARM Cortex-A520 erratum 2966298. On an
      affected Cortex-A520 core, a speculatively executed unprivileged load
      might leak data from a privileged load via a cache side channel. The
      issue only exists for loads within a translation regime with the same
      translation (e.g. same ASID and VMID). Therefore, the issue only affects
      the return to EL0.
      
      The workaround is to execute a TLBI before returning to EL0 after all
      loads of privileged data. A non-shareable TLBI to any address is
      sufficient.
      
      The workaround isn't necessary if page table isolation (KPTI) is
      enabled, but for simplicity it will be. Page table isolation should
      normally be disabled for Cortex-A520 as it supports the CSV3 feature
      and the E0PD feature (used when KASLR is enabled).
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230921194156.1050055-2-robh@kernel.org
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6e3ae292
    • Rob Herring's avatar
      arm64: Add Cortex-A520 CPU part definition · 0a4ae263
      Rob Herring authored
      commit a654a69b
      
       upstream.
      
      Add the CPU Part number for the new Arm design.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230921194156.1050055-1-robh@kernel.org
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a4ae263
    • Mario Limonciello's avatar
      drm/amd: Fix logic error in sienna_cichlid_update_pcie_parameters() · d2894c4f
      Mario Limonciello authored
      commit 2a1fe39a
      
       upstream.
      
      While aligning SMU11 with SMU13 implementation an assumption was made that
      `dpm_context->dpm_tables.pcie_table` was populated in dpm table initialization
      like in SMU13 but it isn't.
      
      So restore some of the original logic and instead just check for
      amdgpu_device_pcie_dynamic_switching_supported() to decide whether to hardcode
      values; erring on the side of performance.
      
      Cc: stable@vger.kernel.org # 6.1+
      Reported-and-tested-by: default avatarUmio Yasuno <coelacanth_dream@protonmail.com>
      Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/1447#note_2101382
      Fixes: e701156c
      
       ("drm/amd: Align SMU11 SMU_MSG_OverridePcieParameters implementation with SMU13")
      Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2894c4f
    • Mario Limonciello's avatar
      drm/amd: Fix detection of _PR3 on the PCIe root port · c8bd3e12
      Mario Limonciello authored
      commit 134b8c5d
      
       upstream.
      
      On some systems with Navi3x dGPU will attempt to use BACO for runtime
      PM but fails to resume properly.  This is because on these systems
      the root port goes into D3cold which is incompatible with BACO.
      
      This happens because in this case dGPU is connected to a bridge between
      root port which causes BOCO detection logic to fail.  Fix the intent of
      the logic by looking at root port, not the immediate upstream bridge for
      _PR3.
      
      Cc: stable@vger.kernel.org
      Suggested-by: default avatarJun Ma <Jun.Ma2@amd.com>
      Tested-by: default avatarDavid Perry <David.Perry@amd.com>
      Fixes: b10c1c5b
      
       ("drm/amdgpu: add check for ACPI power resources")
      Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c8bd3e12
    • Jordan Rife's avatar
      net: prevent rewrite of msg_name in sock_sendmsg() · fc8d9630
      Jordan Rife authored
      commit 86a7e0b6 upstream.
      
      Callers of sock_sendmsg(), and similarly kernel_sendmsg(), in kernel
      space may observe their value of msg_name change in cases where BPF
      sendmsg hooks rewrite the send address. This has been confirmed to break
      NFS mounts running in UDP mode and has the potential to break other
      systems.
      
      This patch:
      
      1) Creates a new function called __sock_sendmsg() with same logic as the
         old sock_sendmsg() function.
      2) Replaces calls to sock_sendmsg() made by __sys_sendto() and
         __sys_sendmsg() with __sock_sendmsg() to avoid an unnecessary copy,
         as these system calls are already protected.
      3) Modifies sock_sendmsg() so that it makes a copy of msg_name if
         present before passing it down the stack to insulate callers from
         changes to the send address.
      
      Link: https://lore.kernel.org/netdev/20230912013332.2048422-1-jrife@google.com/
      Fixes: 1cedee13
      
       ("bpf: Hooks for sys_sendmsg")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarJordan Rife <jrife@google.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fc8d9630
    • Jordan Rife's avatar
      net: replace calls to sock->ops->connect() with kernel_connect() · 34f9370a
      Jordan Rife authored
      commit 26297b4c upstream.
      
      commit 0bdf3993 ("net: Avoid address overwrite in kernel_connect")
      ensured that kernel_connect() will not overwrite the address parameter
      in cases where BPF connect hooks perform an address rewrite. This change
      replaces direct calls to sock->ops->connect() in net with kernel_connect()
      to make these call safe.
      
      Link: https://lore.kernel.org/netdev/20230912013332.2048422-1-jrife@google.com/
      Fixes: d74bad4e
      
       ("bpf: Hooks for sys_connect")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarJordan Rife <jrife@google.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34f9370a
    • Sricharan Ramabadhran's avatar
      PCI: qcom: Fix IPQ8074 enumeration · 2dfb5f32
      Sricharan Ramabadhran authored
      commit 6a878a54 upstream.
      
      PARF_SLV_ADDR_SPACE_SIZE_2_3_3 is used by qcom_pcie_post_init_2_3_3().
      This PCIe slave address space size register offset is 0x358 but was
      incorrectly changed to 0x16c by 39171b33 ("PCI: qcom: Remove PCIE20_
      prefix from register definitions").
      
      This prevented access to slave address space registers like iATU, etc.,
      so the IPQ8074 PCIe controller was not enumerated.
      
      Revert back to the correct 0x358 offset and remove the unused
      PARF_SLV_ADDR_SPACE_SIZE_2_3_3.
      
      Fixes: 39171b33
      
       ("PCI: qcom: Remove PCIE20_ prefix from register definitions")
      Link: https://lore.kernel.org/r/20230919102948.1844909-1-quic_srichara@quicinc.com
      Tested-by: default avatarRobert Marko <robimarko@gmail.com>
      Signed-off-by: default avatarSricharan Ramabadhran <quic_srichara@quicinc.com>
      [bhelgaas: commit log]
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarManivannan Sadhasivam <mani@kernel.org>
      Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Cc: stable@vger.kernel.org	# v6.4+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2dfb5f32
    • David Jeffery's avatar
      md/raid5: release batch_last before waiting for another stripe_head · ebf2d9a7
      David Jeffery authored
      commit 2fd7b0f6 upstream.
      
      When raid5_get_active_stripe is called with a ctx containing a stripe_head in
      its batch_last pointer, it can cause a deadlock if the task sleeps waiting on
      another stripe_head to become available. The stripe_head held by batch_last
      can be blocking the advancement of other stripe_heads, leading to no
      stripe_heads being released so raid5_get_active_stripe waits forever.
      
      Like with the quiesce state handling earlier in the function, batch_last
      needs to be released by raid5_get_active_stripe before it waits for another
      stripe_head.
      
      Fixes: 3312e6c8
      
       ("md/raid5: Keep a reference to last stripe_head for batch")
      Cc: stable@vger.kernel.org # v6.0+
      Signed-off-by: default avatarDavid Jeffery <djeffery@redhat.com>
      Reviewed-by: default avatarLogan Gunthorpe <logang@deltatee.com>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Link: https://lore.kernel.org/r/20231002183422.13047-1-djeffery@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ebf2d9a7
    • Gustavo A. R. Silva's avatar
      wifi: mwifiex: Fix tlv_buf_left calculation · c404d39e
      Gustavo A. R. Silva authored
      commit eec679e4 upstream.
      
      In a TLV encoding scheme, the Length part represents the length after
      the header containing the values for type and length. In this case,
      `tlv_len` should be:
      
      tlv_len == (sizeof(*tlv_rxba) - 1) - sizeof(tlv_rxba->header) + tlv_bitmap_len
      
      Notice that the `- 1` accounts for the one-element array `bitmap`, which
      1-byte size is already included in `sizeof(*tlv_rxba)`.
      
      So, if the above is correct, there is a double-counting of some members
      in `struct mwifiex_ie_types_rxba_sync`, when `tlv_buf_left` and `tmp`
      are calculated:
      
      968                 tlv_buf_left -= (sizeof(*tlv_rxba) + tlv_len);
      969                 tmp = (u8 *)tlv_rxba + tlv_len + sizeof(*tlv_rxba);
      
      in specific, members:
      
      drivers/net/wireless/marvell/mwifiex/fw.h:777
       777         u8 mac[ETH_ALEN];
       778         u8 tid;
       779         u8 reserved;
       780         __le16 seq_num;
       781         __le16 bitmap_len;
      
      This is clearly wrong, and affects the subsequent decoding of data in
      `event_buf` through `tlv_rxba`:
      
      970                 tlv_rxba = (struct mwifiex_ie_types_rxba_sync *)tmp;
      
      Fix this by using `sizeof(tlv_rxba->header)` instead of `sizeof(*tlv_rxba)`
      in the calculation of `tlv_buf_left` and `tmp`.
      
      This results in the following binary differences before/after changes:
      
      | drivers/net/wireless/marvell/mwifiex/11n_rxreorder.o
      | @@ -4698,11 +4698,11 @@
      |  drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c:968
      |                 tlv_buf_left -= (sizeof(tlv_rxba->header) + tlv_len);
      | -    1da7:      lea    -0x11(%rbx),%edx
      | +    1da7:      lea    -0x4(%rbx),%edx
      |      1daa:      movzwl %bp,%eax
      |  drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c:969
      |                 tmp = (u8 *)tlv_rxba  + sizeof(tlv_rxba->header) + tlv_len;
      | -    1dad:      lea    0x11(%r15,%rbp,1),%r15
      | +    1dad:      lea    0x4(%r15,%rbp,1),%r15
      
      The above reflects the desired change: avoid counting 13 too many bytes;
      which is the total size of the double-counted members in
      `struct mwifiex_ie_types_rxba_sync`:
      
      $ pahole -C mwifiex_ie_types_rxba_sync drivers/net/wireless/marvell/mwifiex/11n_rxreorder.o
      struct mwifiex_ie_types_rxba_sync {
      	struct mwifiex_ie_types_header header;           /*     0     4 */
      
           |-----------------------------------------------------------------------
           |  u8                         mac[6];               /*     4     6 */  |
           |	u8                         tid;                  /*    10     1 */  |
           |  u8                         reserved;             /*    11     1 */  |
           | 	__le16                     seq_num;              /*    12     2 */  |
           | 	__le16                     bitmap_len;           /*    14     2 */  |
           |  u8                         bitmap[1];            /*    16     1 */  |
           |----------------------------------------------------------------------|
      								  | 13 bytes|
      								  -----------
      
      	/* size: 17, cachelines: 1, members: 7 */
      	/* last cacheline: 17 bytes */
      } __attribute__((__packed__));
      
      Fixes: 99ffe72c
      
       ("mwifiex: process rxba_sync event")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/06668edd68e7a26bbfeebd1201ae077a2a7a8bce.1692931954.git.gustavoars@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c404d39e
    • Luiz Augusto von Dentz's avatar
      Bluetooth: hci_sync: Fix handling of HCI_QUIRK_STRICT_DUPLICATE_FILTER · 794ae3a9
      Luiz Augusto von Dentz authored
      commit 941c998b upstream.
      
      When HCI_QUIRK_STRICT_DUPLICATE_FILTER is set LE scanning requires
      periodic restarts of the scanning procedure as the controller would
      consider device previously found as duplicated despite of RSSI changes,
      but in order to set the scan timeout properly set le_scan_restart needs
      to be synchronous so it shall not use hci_cmd_sync_queue which defers
      the command processing to cmd_sync_work.
      
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/linux-bluetooth/578e6d7afd676129decafba846a933f5@agner.ch/#t
      Fixes: 27d54b77
      
       ("Bluetooth: Rework le_scan_restart for hci_sync")
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      794ae3a9
    • Luiz Augusto von Dentz's avatar
      Bluetooth: hci_codec: Fix leaking content of local_codecs · 62653507
      Luiz Augusto von Dentz authored
      commit b938790e upstream.
      
      The following memory leak can be observed when the controller supports
      codecs which are stored in local_codecs list but the elements are never
      freed:
      
      unreferenced object 0xffff88800221d840 (size 32):
        comm "kworker/u3:0", pid 36, jiffies 4294898739 (age 127.060s)
        hex dump (first 32 bytes):
          f8 d3 02 03 80 88 ff ff 80 d8 21 02 80 88 ff ff  ..........!.....
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffffffffb324f557>] __kmalloc+0x47/0x120
          [<ffffffffb39ef37d>] hci_codec_list_add.isra.0+0x2d/0x160
          [<ffffffffb39ef643>] hci_read_codec_capabilities+0x183/0x270
          [<ffffffffb39ef9ab>] hci_read_supported_codecs+0x1bb/0x2d0
          [<ffffffffb39f162e>] hci_read_local_codecs_sync+0x3e/0x60
          [<ffffffffb39ff1b3>] hci_dev_open_sync+0x943/0x11e0
          [<ffffffffb396d55d>] hci_power_on+0x10d/0x3f0
          [<ffffffffb30c99b4>] process_one_work+0x404/0x800
          [<ffffffffb30ca134>] worker_thread+0x374/0x670
          [<ffffffffb30d9108>] kthread+0x188/0x1c0
          [<ffffffffb304db6b>] ret_from_fork+0x2b/0x50
          [<ffffffffb300206a>] ret_from_fork_asm+0x1a/0x30
      
      Cc: stable@vger.kernel.org
      Fixes: 8961987f
      
       ("Bluetooth: Enumerate local supported codec and cache details")
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      62653507
    • Gustavo A. R. Silva's avatar
      qed/red_ll2: Fix undefined behavior bug in struct qed_ll2_info · 01afbfb3
      Gustavo A. R. Silva authored
      commit eea03d18 upstream.
      
      The flexible structure (a structure that contains a flexible-array member
      at the end) `qed_ll2_tx_packet` is nested within the second layer of
      `struct qed_ll2_info`:
      
      struct qed_ll2_tx_packet {
      	...
              /* Flexible Array of bds_set determined by max_bds_per_packet */
              struct {
                      struct core_tx_bd *txq_bd;
                      dma_addr_t tx_frag;
                      u16 frag_len;
              } bds_set[];
      };
      
      struct qed_ll2_tx_queue {
      	...
      	struct qed_ll2_tx_packet cur_completing_packet;
      };
      
      struct qed_ll2_info {
      	...
      	struct qed_ll2_tx_queue tx_queue;
              struct qed_ll2_cbs cbs;
      };
      
      The problem is that member `cbs` in `struct qed_ll2_info` is placed just
      after an object of type `struct qed_ll2_tx_queue`, which is in itself
      an implicit flexible structure, which by definition ends in a flexible
      array member, in this case `bds_set`. This causes an undefined behavior
      bug at run-time when dynamic memory is allocated for `bds_set`, which
      could lead to a serious issue if `cbs` in `struct qed_ll2_info` is
      overwritten by the contents of `bds_set`. Notice that the type of `cbs`
      is a structure full of function pointers (and a cookie :) ):
      
      include/linux/qed/qed_ll2_if.h:
      107 typedef
      108 void (*qed_ll2_complete_rx_packet_cb)(void *cxt,
      109                                       struct qed_ll2_comp_rx_data *data);
      110
      111 typedef
      112 void (*qed_ll2_release_rx_packet_cb)(void *cxt,
      113                                      u8 connection_handle,
      114                                      void *cookie,
      115                                      dma_addr_t rx_buf_addr,
      116                                      bool b_last_packet);
      117
      118 typedef
      119 void (*qed_ll2_complete_tx_packet_cb)(void *cxt,
      120                                       u8 connection_handle,
      121                                       void *cookie,
      122                                       dma_addr_t first_frag_addr,
      123                                       bool b_last_fragment,
      124                                       bool b_last_packet);
      125
      126 typedef
      127 void (*qed_ll2_release_tx_packet_cb)(void *cxt,
      128                                      u8 connection_handle,
      129                                      void *cookie,
      130                                      dma_addr_t first_frag_addr,
      131                                      bool b_last_fragment, bool b_last_packet);
      132
      133 typedef
      134 void (*qed_ll2_slowpath_cb)(void *cxt, u8 connection_handle,
      135                             u32 opaque_data_0, u32 opaque_data_1);
      136
      137 struct qed_ll2_cbs {
      138         qed_ll2_complete_rx_packet_cb rx_comp_cb;
      139         qed_ll2_release_rx_packet_cb rx_release_cb;
      140         qed_ll2_complete_tx_packet_cb tx_comp_cb;
      141         qed_ll2_release_tx_packet_cb tx_release_cb;
      142         qed_ll2_slowpath_cb slowpath_cb;
      143         void *cookie;
      144 };
      
      Fix this by moving the declaration of `cbs` to the  middle of its
      containing structure `qed_ll2_info`, preventing it from being
      overwritten by the contents of `bds_set` at run-time.
      
      This bug was introduced in 2017, when `bds_set` was converted to a
      one-element array, and started to be used as a Variable Length Object
      (VLO) at run-time.
      
      Fixes: f5823fe6
      
       ("qed: Add ll2 option to limit the number of bds per packet")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/ZQ+Nz8DfPg56pIzr@work
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      01afbfb3
    • Geliang Tang's avatar
      mptcp: userspace pm allow creating id 0 subflow · 454bb54b
      Geliang Tang authored
      commit e5ed101a upstream.
      
      This patch drops id 0 limitation in mptcp_nl_cmd_sf_create() to allow
      creating additional subflows with the local addr ID 0.
      
      There is no reason not to allow additional subflows from this local
      address: we should be able to create new subflows from the initial
      endpoint. This limitation was breaking fullmesh support from userspace.
      
      Fixes: 702c2f64
      
       ("mptcp: netlink: allow userspace-driven subflow establishment")
      Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/391
      Cc: stable@vger.kernel.org
      Suggested-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
      Reviewed-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
      Signed-off-by: default avatarGeliang Tang <geliang.tang@suse.com>
      Signed-off-by: default avatarMat Martineau <martineau@kernel.org>
      Link: https://lore.kernel.org/r/20231004-send-net-20231004-v1-2-28de4ac663ae@kernel.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      454bb54b
    • Christian Marangi's avatar
      net: ethernet: mediatek: disable irq before schedule napi · 4674e962
      Christian Marangi authored
      commit fcdfc462 upstream.
      
      While searching for possible refactor of napi_schedule_prep and
      __napi_schedule it was notice that the mtk eth driver disable the
      interrupt for rx and tx AFTER napi is scheduled.
      
      While this is a very hard to repro case it might happen to have
      situation where the interrupt is disabled and never enabled again as the
      napi completes and the interrupt is enabled before.
      
      This is caused by the fact that a napi driven by interrupt expect a
      logic with:
      1. interrupt received. napi prepared -> interrupt disabled -> napi
         scheduled
      2. napi triggered. ring cleared -> interrupt enabled -> wait for new
         interrupt
      
      To prevent this case, disable the interrupt BEFORE the napi is
      scheduled.
      
      Fixes: 656e7052
      
       ("net-next: mediatek: add support for MT7623 ethernet")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
      Link: https://lore.kernel.org/r/20231002140805.568-1-ansuelsmth@gmail.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4674e962
    • Stefano Garzarella's avatar
      vringh: don't use vringh_kiov_advance() in vringh_iov_xfer() · 3a72decd
      Stefano Garzarella authored
      commit 7aed44ba upstream.
      
      In the while loop of vringh_iov_xfer(), `partlen` could be 0 if one of
      the `iov` has 0 lenght.
      In this case, we should skip the iov and go to the next one.
      But calling vringh_kiov_advance() with 0 lenght does not cause the
      advancement, since it returns immediately if asked to advance by 0 bytes.
      
      Let's restore the code that was there before commit b8c06ad4
      ("vringh: implement vringh_kiov_advance()"), avoiding using
      vringh_kiov_advance().
      
      Fixes: b8c06ad4
      
       ("vringh: implement vringh_kiov_advance()")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3a72decd
    • Zhang Rui's avatar
      iommu/vt-d: Avoid memory allocation in iommu_suspend() · c12ef025
      Zhang Rui authored
      commit 59df44bf upstream.
      
      The iommu_suspend() syscore suspend callback is invoked with IRQ disabled.
      Allocating memory with the GFP_KERNEL flag may re-enable IRQs during
      the suspend callback, which can cause intermittent suspend/hibernation
      problems with the following kernel traces:
      
      Calling iommu_suspend+0x0/0x1d0
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 15 at kernel/time/timekeeping.c:868 ktime_get+0x9b/0xb0
      ...
      CPU: 0 PID: 15 Comm: rcu_preempt Tainted: G     U      E      6.3-intel #r1
      RIP: 0010:ktime_get+0x9b/0xb0
      ...
      Call Trace:
       <IRQ>
       tick_sched_timer+0x22/0x90
       ? __pfx_tick_sched_timer+0x10/0x10
       __hrtimer_run_queues+0x111/0x2b0
       hrtimer_interrupt+0xfa/0x230
       __sysvec_apic_timer_interrupt+0x63/0x140
       sysvec_apic_timer_interrupt+0x7b/0xa0
       </IRQ>
       <TASK>
       asm_sysvec_apic_timer_interrupt+0x1f/0x30
      ...
      ------------[ cut here ]------------
      Interrupts enabled after iommu_suspend+0x0/0x1d0
      WARNING: CPU: 0 PID: 27420 at drivers/base/syscore.c:68 syscore_suspend+0x147/0x270
      CPU: 0 PID: 27420 Comm: rtcwake Tainted: G     U  W   E      6.3-intel #r1
      RIP: 0010:syscore_suspend+0x147/0x270
      ...
      Call Trace:
       <TASK>
       hibernation_snapshot+0x25b/0x670
       hibernate+0xcd/0x390
       state_store+0xcf/0xe0
       kobj_attr_store+0x13/0x30
       sysfs_kf_write+0x3f/0x50
       kernfs_fop_write_iter+0x128/0x200
       vfs_write+0x1fd/0x3c0
       ksys_write+0x6f/0xf0
       __x64_sys_write+0x1d/0x30
       do_syscall_64+0x3b/0x90
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Given that only 4 words memory is needed, avoid the memory allocation in
      iommu_suspend().
      
      CC: stable@kernel.org
      Fixes: 33e07157
      
       ("iommu/vt-d: Avoid GFP_ATOMIC where it is not needed")
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Tested-by: default avatarOoi, Chin Hao <chin.hao.ooi@intel.com>
      Link: https://lore.kernel.org/r/20230921093956.234692-1-rui.zhang@intel.com
      Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Link: https://lore.kernel.org/r/20230925120417.55977-2-baolu.lu@linux.intel.com
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c12ef025
    • Dinghao Liu's avatar
      scsi: zfcp: Fix a double put in zfcp_port_enqueue() · cdf18e75
      Dinghao Liu authored
      commit b481f644 upstream.
      
      When device_register() fails, zfcp_port_release() will be called after
      put_device(). As a result, zfcp_ccw_adapter_put() will be called twice: one
      in zfcp_port_release() and one in the error path after device_register().
      So the reference on the adapter object is doubly put, which may lead to a
      premature free. Fix this by adjusting the error tag after
      device_register().
      
      Fixes: f3450c7b
      
       ("[SCSI] zfcp: Replace local reference counting with common kref")
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Link: https://lore.kernel.org/r/20230923103723.10320-1-dinghao.liu@zju.edu.cn
      Acked-by: default avatarBenjamin Block <bblock@linux.ibm.com>
      Cc: stable@vger.kernel.org # v2.6.33+
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cdf18e75
    • Yajun Deng's avatar
      i40e: fix the wrong PTP frequency calculation · ef167cc1
      Yajun Deng authored
      The new adjustment should be based on the base frequency, not the
      I40E_PTP_40GB_INCVAL in i40e_ptp_adjfine().
      
      This issue was introduced in commit 3626a690 ("i40e: use
      mul_u64_u64_div_u64 for PTP frequency calculation"), frequency is left
      just as base I40E_PTP_40GB_INCVAL before the commit. After the commit,
      frequency is the I40E_PTP_40GB_INCVAL times the ptp_adj_mult value.
      But then the diff is applied on the wrong value, and no multiplication
      is done afterwards.
      
      It was accidentally fixed in commit 1060707e ("ptp: introduce helpers
      to adjust by scaled parts per million"). It uses adjust_by_scaled_ppm
      correctly performs the calculation and uses the base adjustment, so
      there's no error here. But it is a new feature and doesn't need to
      backported to the stable releases.
      
      This issue affects both v6.0 and v6.1, and the v6.1 version is an LTS
      release. Therefore, the patch only needs to be applied to v6.1 stable.
      
      Fixes: 3626a690
      
       ("i40e: use mul_u64_u64_div_u64 for PTP frequency calculation")
      Cc: <stable@vger.kernel.org> # 6.1
      Cc: Tony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarYajun Deng <yajun.deng@linux.dev>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef167cc1
    • Aleksandr Mezin's avatar
      hwmon: (nzxt-smart2) add another USB ID · a0829d9c
      Aleksandr Mezin authored
      commit 4a148e9b
      
       upstream.
      
      This seems to be a new revision of the device. RGB controls have changed,
      but this driver doesn't touch them anyway.
      
      Fan speed control reported to be working with existing userspace (hidraw)
      software, so I assume it's compatible. Fan channel count is the same.
      
      Recently added (0x1e71, 0x2019) seems to be the same device.
      
      Discovered in liquidctl project:
      
      https://github.com/liquidctl/liquidctl/issues/541
      
      Signed-off-by: default avatarAleksandr Mezin <mezin.alexander@gmail.com>
      Link: https://lore.kernel.org/r/20230219105924.333007-1-mezin.alexander@gmail.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a0829d9c
    • Herman Fries's avatar
      hwmon: (nzxt-smart2) Add device id · 6ddb9e6b
      Herman Fries authored
      commit e247510e
      
       upstream.
      
      Adding support for new device id
      1e71:2019 NZXT NZXT RGB & Fan Controller
      
      Signed-off-by: default avatarHerman Fries <baracoder@googlemail.com>
      Link: https://lore.kernel.org/r/20221214194627.135692-1-baracoder@googlemail.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ddb9e6b
    • Ming Lei's avatar
      block: fix use-after-free of q->q_usage_counter · 752ec2d9
      Ming Lei authored
      commit d36a9ea5
      
       upstream.
      
      For blk-mq, queue release handler is usually called after
      blk_mq_freeze_queue_wait() returns. However, the
      q_usage_counter->release() handler may not be run yet at that time, so
      this can cause a use-after-free.
      
      Fix the issue by moving percpu_ref_exit() into blk_free_queue_rcu().
      Since ->release() is called with rcu read lock held, it is agreed that
      the race should be covered in caller per discussion from the two links.
      
      Reported-by: default avatarZhang Wensheng <zhangwensheng@huaweicloud.com>
      Reported-by: default avatarZhong Jinghua <zhongjinghua@huawei.com>
      Link: https://lore.kernel.org/linux-block/Y5prfOjyyjQKUrtH@T590/T/#u
      Link: https://lore.kernel.org/lkml/Y4%2FmzMd4evRg9yDi@fedora/
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Yu Kuai <yukuai3@huawei.com>
      Cc: Dennis Zhou <dennis@kernel.org>
      Fixes: 2b0d3d3e
      
       ("percpu_ref: reduce memory footprint of percpu_ref in fast path")
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20221215021629.74870-1-ming.lei@redhat.com
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSaranya Muruganandam <saranyamohan@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      752ec2d9
    • Ilya Dryomov's avatar
      rbd: take header_rwsem in rbd_dev_refresh() only when updating · 77d0e7e8
      Ilya Dryomov authored
      commit 0b207d02 upstream.
      
      rbd_dev_refresh() has been holding header_rwsem across header and
      parent info read-in unnecessarily for ages.  With commit 870611e4
      ("rbd: get snapshot context after exclusive lock is ensured to be
      held"), the potential for deadlocks became much more real owning to
      a) header_rwsem now nesting inside lock_rwsem and b) rw_semaphores
      not allowing new readers after a writer is registered.
      
      For example, assuming that I/O request 1, I/O request 2 and header
      read-in request all target the same OSD:
      
      1. I/O request 1 comes in and gets submitted
      2. watch error occurs
      3. rbd_watch_errcb() takes lock_rwsem for write, clears owner_cid and
         releases lock_rwsem
      4. after reestablishing the watch, rbd_reregister_watch() calls
         rbd_dev_refresh() which takes header_rwsem for write and submits
         a header read-in request
      5. I/O request 2 comes in: after taking lock_rwsem for read in
         __rbd_img_handle_request(), it blocks trying to take header_rwsem
         for read in rbd_img_object_requests()
      6. another watch error occurs
      7. rbd_watch_errcb() blocks trying to take lock_rwsem for write
      8. I/O request 1 completion is received by the messenger but can't be
         processed because lock_rwsem won't be granted anymore
      9. header read-in request completion can't be received, let alone
         processed, because the messenger is stranded
      
      Change rbd_dev_refresh() to take header_rwsem only for actually
      updating rbd_dev->header.  Header and parent info read-in don't need
      any locking.
      
      Cc: stable@vger.kernel.org # 0b035401: rbd: move rbd_dev_refresh() definition
      Cc: stable@vger.kernel.org # 510a7330: rbd: decouple header read-in from updating rbd_dev->header
      Cc: stable@vger.kernel.org # c1031177: rbd: decouple parent info read-in from updating rbd_dev
      Cc: stable@vger.kernel.org
      Fixes: 870611e4
      
       ("rbd: get snapshot context after exclusive lock is ensured to be held")
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: default avatarDongsheng Yang <dongsheng.yang@easystack.cn>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      77d0e7e8
    • Ilya Dryomov's avatar
      rbd: decouple parent info read-in from updating rbd_dev · 698039a4
      Ilya Dryomov authored
      commit c1031177
      
       upstream.
      
      Unlike header read-in, parent info read-in is already decoupled in
      get_parent_info(), but it's buried in rbd_dev_v2_parent_info() along
      with the processing logic.
      
      Separate the initial read-in and update read-in logic into
      rbd_dev_setup_parent() and rbd_dev_update_parent() respectively and
      have rbd_dev_v2_parent_info() just populate struct parent_image_info
      (i.e. what get_parent_info() did).  Some existing QoI issues, like
      flatten of a standalone clone being disregarded on refresh, remain.
      
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: default avatarDongsheng Yang <dongsheng.yang@easystack.cn>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      698039a4
    • Ilya Dryomov's avatar
      rbd: decouple header read-in from updating rbd_dev->header · 377d2617
      Ilya Dryomov authored
      commit 510a7330
      
       upstream.
      
      Make rbd_dev_header_info() populate a passed struct rbd_image_header
      instead of rbd_dev->header and introduce rbd_dev_update_header() for
      updating mutable fields in rbd_dev->header upon refresh.  The initial
      read-in of both mutable and immutable fields in rbd_dev_image_probe()
      passes in rbd_dev->header so no update step is required there.
      
      rbd_init_layout() is now called directly from rbd_dev_image_probe()
      instead of individually in format 1 and format 2 implementations.
      
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: default avatarDongsheng Yang <dongsheng.yang@easystack.cn>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      377d2617
    • Ilya Dryomov's avatar
      rbd: move rbd_dev_refresh() definition · 33ecf5f5
      Ilya Dryomov authored
      commit 0b035401
      
       upstream.
      
      Move rbd_dev_refresh() definition further down to avoid having to
      move struct parent_image_info definition in the next commit.  This
      spares some forward declarations too.
      
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: default avatarDongsheng Yang <dongsheng.yang@easystack.cn>
      [idryomov@gmail.com: backport to 5.10-6.1: context]
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      33ecf5f5
    • Robin Murphy's avatar
      iommu/arm-smmu-v3: Avoid constructing invalid range commands · ff09fa5f
      Robin Murphy authored
      [ Upstream commit eb6c9764 ]
      
      Although io-pgtable's non-leaf invalidations are always for full tables,
      I missed that SVA also uses non-leaf invalidations, while being at the
      mercy of whatever range the MMU notifier throws at it. This means it
      definitely wants the previous TTL fix as well, since it also doesn't
      know exactly which leaf level(s) may need invalidating, but it can also
      give us less-aligned ranges wherein certain corners may lead to building
      an invalid command where TTL, Num and Scale are all 0. It should be fine
      to handle this by over-invalidating an extra page, since falling back to
      a non-range command opens up a whole can of errata-flavoured worms.
      
      Fixes: 6833b8f2
      
       ("iommu/arm-smmu-v3: Set TTL invalidation hint better")
      Reported-by: default avatarRui Zhu <zhurui3@huawei.com>
      Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Link: https://lore.kernel.org/r/b99cfe71af2bd93a8a2930f20967fb2a4f7748dd.1694432734.git.robin.murphy@arm.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff09fa5f
    • Robin Murphy's avatar
      iommu/arm-smmu-v3: Set TTL invalidation hint better · 357ba59b
      Robin Murphy authored
      [ Upstream commit 6833b8f2
      
       ]
      
      When io-pgtable unmaps a whole table, rather than waste time walking it
      to find the leaf entries to invalidate exactly, it simply expects
      .tlb_flush_walk with nominal last-level granularity to invalidate any
      leaf entries at higher intermediate levels as well. This works fine with
      page-based invalidation, but with range commands we need to be careful
      with the TTL hint - unconditionally setting it based on the given level
      3 granule means that an invalidation for a level 1 table would strictly
      not be required to affect level 2 block entries. It's easy to comply
      with the expected behaviour by simply not setting the TTL hint for
      non-leaf invalidations, so let's do that.
      
      Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Link: https://lore.kernel.org/r/b409d9a17c52dc0db51faee91d92737bb7975f5b.1685637456.git.robin.murphy@arm.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      357ba59b