Linux 6.1.39

 
Linux: Add MODULE_FIRMWARE() for FIRMWARE_TG357766. [+ + +]
Author: Tobias Heider <me@tobhe.de>
Date:   Wed Jun 28 02:13:32 2023 +0200

    Add MODULE_FIRMWARE() for FIRMWARE_TG357766.
    
    [ Upstream commit 046f753da6143ee16452966915087ec8b0de3c70 ]
    
    Fixes a bug where on the M1 mac mini initramfs-tools fails to
    include the necessary firmware into the initrd.
    
    Fixes: c4dab50697ff ("tg3: Download 57766 EEE service patch firmware")
    Signed-off-by: Tobias Heider <me@tobhe.de>
    Reviewed-by: Michael Chan <michael.chan@broadcom.com>
    Link: https://lore.kernel.org/r/ZJt7LKzjdz8+dClx@tobhe.de
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
afs: Fix accidental truncation when storing data [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Tue Jul 4 20:22:15 2023 +0100

    afs: Fix accidental truncation when storing data
    
    [ Upstream commit 03275585cabd0240944f19f33d7584a1b099a3a8 ]
    
    When an AFS FS.StoreData RPC call is made, amongst other things it is
    given the resultant file size to be.  On the server, this is processed
    by truncating the file to new size and then writing the data.
    
    Now, kafs has a lock (vnode->io_lock) that serves to serialise
    operations against a specific vnode (ie.  inode), but the parameters for
    the op are set before the lock is taken.  This allows two writebacks
    (say sync and kswapd) to race - and if writes are ongoing the writeback
    for a later write could occur before the writeback for an earlier one if
    the latter gets interrupted.
    
    Note that afs_writepages() cannot take i_mutex and only takes a shared
    lock on vnode->validate_lock.
    
    Also note that the server does the truncation and the write inside a
    lock, so there's no problem at that end.
    
    Fix this by moving the calculation for the proposed new i_size inside
    the vnode->io_lock.  Also reset the iterator (which we might have read
    from) and update the mtime setting there.
    
    Fixes: bd80d8a80e12 ("afs: Use ITER_XARRAY for writing")
    Reported-by: Marc Dionne <marc.dionne@auristor.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
    Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
    cc: linux-afs@lists.infradead.org
    cc: linux-fsdevel@vger.kernel.org
    Link: https://lore.kernel.org/r/3526895.1687960024@warthog.procyon.org.uk/
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ALSA: ac97: Fix possible NULL dereference in snd_ac97_mixer [+ + +]
Author: Su Hui <suhui@nfschina.com>
Date:   Thu Jun 15 10:17:32 2023 +0800

    ALSA: ac97: Fix possible NULL dereference in snd_ac97_mixer
    
    [ Upstream commit 79597c8bf64ca99eab385115743131d260339da5 ]
    
    smatch error:
    sound/pci/ac97/ac97_codec.c:2354 snd_ac97_mixer() error:
    we previously assumed 'rac97' could be null (see line 2072)
    
    remove redundant assignment, return error if rac97 is NULL.
    
    Fixes: da3cec35dd3c ("ALSA: Kill snd_assert() in sound/pci/*")
    Signed-off-by: Su Hui <suhui@nfschina.com>
    Link: https://lore.kernel.org/r/20230615021732.1972194-1-suhui@nfschina.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ALSA: hda/realtek: Add quirk for Clevo NPx0SNx [+ + +]
Author: Werner Sembach <wse@tuxedocomputers.com>
Date:   Wed Jun 28 17:54:34 2023 +0200

    ALSA: hda/realtek: Add quirk for Clevo NPx0SNx
    
    commit 22065e4214c1196b54fc164892c2e193a743caf3 upstream.
    
    This applies a SND_PCI_QUIRK(...) to the Clevo NPx0SNx barebones fixing the
    microphone not being detected on the headset combo port.
    
    Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20230628155434.584159-1-wse@tuxedocomputers.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: hda/realtek: Enable mute/micmute LEDs and limit mic boost on EliteBook [+ + +]
Author: Andy Chi <andy.chi@canonical.com>
Date:   Mon Jun 26 21:03:00 2023 +0800

    ALSA: hda/realtek: Enable mute/micmute LEDs and limit mic boost on EliteBook
    
    commit e94f1f96f108ba96c0ed8bf3fbdd8ee6a6703880 upstream.
    
    On HP EliteBook 835/845/845W G10, the audio LEDs can be enabled by
    ALC285_FIXUP_HP_MUTE_LED. So use it accordingly.
    
    Signed-off-by: Andy Chi <andy.chi@canonical.com>
    Cc: <stable@vger.kernel.org>
    Fixes: 3e10f6ca76c4 ("ALSA: hda/realtek: Add quirk for HP EliteBook G10 laptops")
    Link: https://lore.kernel.org/r/20230626130301.301712-1-andy.chi@canonical.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: jack: Fix mutex call in snd_jack_report() [+ + +]
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Jul 6 17:53:57 2023 +0200

    ALSA: jack: Fix mutex call in snd_jack_report()
    
    commit 89dbb335cb6a627a4067bc42caa09c8bc3326d40 upstream.
    
    snd_jack_report() is supposed to be callable from an IRQ context, too,
    and it's indeed used in that way from virtsnd driver.  The fix for
    input_dev race in commit 1b6a6fc5280e ("ALSA: jack: Access input_dev
    under mutex"), however, introduced a mutex lock in snd_jack_report(),
    and this resulted in a potential sleep-in-atomic.
    
    For addressing that problem, this patch changes the relevant code to
    use the object get/put and removes the mutex usage.  That is,
    snd_jack_report(), it takes input_get_device() and leaves with
    input_put_device() for assuring the input_dev being assigned.
    
    Although the whole mutex could be reduced, we keep it because it can
    be still a protection for potential races between creation and
    deletion.
    
    Fixes: 1b6a6fc5280e ("ALSA: jack: Access input_dev under mutex")
    Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
    Closes: https://lore.kernel.org/r/cf95f7fe-a748-4990-8378-000491b40329@moroto.mountain
    Tested-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20230706155357.3470-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: pcm: Fix potential data race at PCM memory allocation helpers [+ + +]
Author: Takashi Iwai <tiwai@suse.de>
Date:   Mon Jul 3 13:24:30 2023 +0200

    ALSA: pcm: Fix potential data race at PCM memory allocation helpers
    
    commit bd55842ed998a622ba6611fe59b3358c9f76773d upstream.
    
    The PCM memory allocation helpers have a sanity check against too many
    buffer allocations.  However, the check is performed without a proper
    lock and the allocation isn't serialized; this allows user to allocate
    more memories than predefined max size.
    
    Practically seen, this isn't really a big problem, as it's more or
    less some "soft limit" as a sanity check, and it's not possible to
    allocate unlimitedly.  But it's still better to address this for more
    consistent behavior.
    
    The patch covers the size check in do_alloc_pages() with the
    card->memory_mutex, and increases the allocated size there for
    preventing the further overflow.  When the actual allocation fails,
    the size is decreased accordingly.
    
    Reported-by: BassCheck <bass@buaa.edu.cn>
    Reported-by: Tuo Li <islituo@gmail.com>
    Link: https://lore.kernel.org/r/CADm8Tek6t0WedK+3Y6rbE5YEt19tML8BUL45N2ji4ZAz1KcN_A@mail.gmail.com
    Reviewed-by: Jaroslav Kysela <perex@perex.cz>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20230703112430.30634-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
amdgpu: validate offset_in_bo of drm_amdgpu_gem_va [+ + +]
Author: Chia-I Wu <olvaffe@gmail.com>
Date:   Thu Jun 1 15:44:12 2023 -0700

    amdgpu: validate offset_in_bo of drm_amdgpu_gem_va
    
    [ Upstream commit 9f0bcf49e9895cb005d78b33a5eebfa11711b425 ]
    
    This is motivated by OOB access in amdgpu_vm_update_range when
    offset_in_bo+map_size overflows.
    
    v2: keep the validations in amdgpu_vm_bo_map
    v3: add the validations to amdgpu_vm_bo_map/amdgpu_vm_bo_replace_map
        rather than to amdgpu_gem_va_ioctl
    
    Fixes: 9f7eb5367d00 ("drm/amdgpu: actually use the VM map parameters")
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
apparmor: fix missing error check for rhashtable_insert_fast [+ + +]
Author: Danila Chernetsov <listdansp@mail.ru>
Date:   Tue Apr 4 19:05:49 2023 +0000

    apparmor: fix missing error check for rhashtable_insert_fast
    
    [ Upstream commit 000518bc5aef25d3f703592a0296d578c98b1517 ]
    
     rhashtable_insert_fast() could return err value when memory allocation is
     failed. but unpack_profile() do not check values and this always returns
     success value. This patch just adds error check code.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Fixes: e025be0f26d5 ("apparmor: support querying extended trusted helper extra data")
    
    Signed-off-by: Danila Chernetsov <listdansp@mail.ru>
    Signed-off-by: John Johansen <john.johansen@canonical.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Mon Jun 12 00:50:50 2023 +0900

    ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard
    
    [ Upstream commit 92e2921eeafdfca9acd9b83f07d2b7ca099bac24 ]
    
    ASM_NL is useful not only in *.S files but also in .c files for using
    inline assembler in C code.
    
    On ARC, however, ASM_NL is evaluated inconsistently. It is expanded to
    a backquote (`) in *.S files, but a semicolon (;) in *.c files because
    arch/arc/include/asm/linkage.h defines it inside #ifdef __ASSEMBLY__,
    so the definition for C code falls back to the default value defined in
    include/linux/linkage.h.
    
    If ASM_NL is used in inline assembler in .c files, it will result in
    wrong assembly code because a semicolon is not an instruction separator,
    but the start of a comment for ARC.
    
    Move ASM_NL (also __ALIGN and __ALIGN_STR) out of the #ifdef.
    
    Fixes: 9df62f054406 ("arch: use ASM_NL instead of ';' for assembler new line character in the macro")
    Fixes: 8d92e992a785 ("ARC: define __ALIGN_STR and __ALIGN symbols for ARC")
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
arm64: dts: mediatek: Add cpufreq nodes for MT8192 [+ + +]
Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
Date:   Fri Mar 17 14:19:44 2023 +0800

    arm64: dts: mediatek: Add cpufreq nodes for MT8192
    
    [ Upstream commit 9d498cce9298a71e3896e2d1aee24a1a4c531d81 ]
    
    Add the cpufreq nodes for MT8192 SoC.
    
    Signed-off-by: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
    Tested-by: Chen-Yu Tsai <wenst@chromium.org>
    Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
    Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20230317061944.15434-1-allen-kh.cheng@mediatek.com
    Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
    Stable-dep-of: a4366b5695c9 ("arm64: dts: mediatek: mt8192: Fix CPUs capacity-dmips-mhz")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: mediatek: mt8183: Add mediatek,broken-save-restore-fw to kukui [+ + +]
Author: Douglas Anderson <dianders@chromium.org>
Date:   Mon May 15 13:13:52 2023 -0700

    arm64: dts: mediatek: mt8183: Add mediatek,broken-save-restore-fw to kukui
    
    [ Upstream commit 42127f578ebde652d1373e0233356fbd351675c4 ]
    
    Firmware shipped on mt8183 Chromebooks is affected by the GICR
    save/restore issue as described by the patch ("dt-bindings:
    interrupt-controller: arm,gic-v3: Add quirk for Mediatek SoCs w/
    broken FW"). Add the quirk property.
    
    Fixes: cd894e274b74 ("arm64: dts: mt8183: Add krane-sku176 board")
    Reviewed-by: Julius Werner <jwerner@chromium.org>
    Signed-off-by: Douglas Anderson <dianders@chromium.org>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20230515131353.v2.3.I525a2ed4260046d43c885ee1275e91707743df1c@changeid
    Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: mediatek: mt8192: Fix CPUs capacity-dmips-mhz [+ + +]
Author: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Date:   Fri Jun 2 14:35:15 2023 -0400

    arm64: dts: mediatek: mt8192: Fix CPUs capacity-dmips-mhz
    
    [ Upstream commit a4366b5695c984b8a3fc8b31de9e758c8f6d1aed ]
    
    The capacity-dmips-mhz parameter was miscalculated: this SoC runs
    the first (Cortex-A55) cluster at a maximum of 2000MHz and the
    second (Cortex-A76) cluster at a maximum of 2200MHz.
    
    In order to calculate the right capacity-dmips-mhz, the following
    test was performed:
    1. CPUFREQ governor was set to 'performance' on both clusters
    2. Ran dhrystone with 500000000 iterations for 10 times on each cluster
    3. Calculated the mean result for each cluster
    4. Calculated DMIPS/MHz: dmips_mhz = dmips_per_second / cpu_mhz
    5. Scaled results to 1024:
       result_c0 = dmips_mhz_c0 / dmips_mhz_c1 * 1024
    
    The mean results for this SoC are:
    Cluster 0 (LITTLE): 12016411 Dhry/s
    Cluster 1 (BIG): 31702034 Dhry/s
    
    The calculated scaled results are:
    Cluster 0: 426.953226899238 (rounded to 427)
    Cluster 1: 1024
    
    Fixes: 48489980e27e ("arm64: dts: Add Mediatek SoC MT8192 and evaluation board dts and Makefile")
    Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20230602183515.3778780-1-nfraprado@collabora.com
    Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: microchip: sparx5: do not use PSCI on reference boards [+ + +]
Author: Robert Marko <robert.marko@sartura.hr>
Date:   Tue Feb 21 11:50:37 2023 +0100

    arm64: dts: microchip: sparx5: do not use PSCI on reference boards
    
    [ Upstream commit 70be83708c925b3f72c508e4756e48ad2330c830 ]
    
    PSCI is not implemented on SparX-5 at all, there is no ATF and U-boot that
    is shipped does not implement it as well.
    
    I have tried flashing the latest BSP 2022.12 U-boot which did not work.
    After contacting Microchip, they confirmed that there is no ATF for the
    SoC nor PSCI implementation which is unfortunate in 2023.
    
    So, disable PSCI as otherwise kernel crashes as soon as it tries probing
    PSCI with, and the crash is only visible if earlycon is used.
    
    Since PSCI is not implemented, switch core bringup to use spin-tables
    which are implemented in the vendor U-boot and actually work.
    
    Tested on PCB134 with eMMC (VSC5640EV).
    
    Fixes: 6694aee00a4b ("arm64: dts: sparx5: Add basic cpu support")
    Signed-off-by: Robert Marko <robert.marko@sartura.hr>
    Acked-by: Steen Hegelund <Steen.Hegelund@microchip.com>
    Link: https://lore.kernel.org/r/20230221105039.316819-1-robert.marko@sartura.hr
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: apq8016-sbc: Fix 1.8V power rail on LS expansion [+ + +]
Author: Stephan Gerhold <stephan@gerhold.net>
Date:   Wed May 17 20:48:41 2023 +0200

    arm64: dts: qcom: apq8016-sbc: Fix 1.8V power rail on LS expansion
    
    [ Upstream commit 5500f823db38db073d30557af159b77fb1f2bf26 ]
    
    The 96Boards specification expects a 1.8V power rail on the low-speed
    expansion connector that is able to provide at least 0.18W / 100 mA.
    According to the DB410c hardware user manual this is done by connecting
    both L15 and L16 in parallel with up to 55mA each (for 110 mA total) [1].
    
    Unfortunately the current regulator setup in the DB410c device tree
    does not implement the specification correctly and only provides 5 mA:
    
      - Only L15 is marked always-on, so L16 is never enabled.
      - Without specifying a load the regulator is put into LPM where
        it can only provide 5 mA.
    
    Fix this by:
    
      - Adding proper voltage constraints for L16.
      - Making L16 always-on.
      - Adding regulator-system-load for both L15 and L16. 100 mA should be
        available in total, so specify 50 mA for each. (The regulator
        hardware can only be in normal (55 mA) or low-power mode (5 mA) so
        this will actually result in the expected 110 mA total...)
    
    [1]: https://www.96boards.org/documentation/consumer/dragonboard/dragonboard410c/hardware-docs/hardware-user-manual.md.html#power-supplies
    
    Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Fixes: 828dd5d66f0f ("arm64: dts: apq8016-sbc: make 1.8v available on LS expansion")
    Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230510-msm8916-regulators-v1-2-54d4960a05fc@gerhold.net
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: apq8016-sbc: Fix regulator constraints [+ + +]
Author: Stephan Gerhold <stephan@gerhold.net>
Date:   Wed May 17 20:48:40 2023 +0200

    arm64: dts: qcom: apq8016-sbc: Fix regulator constraints
    
    [ Upstream commit e27654df20d77ad7549a3cf6739ebaa3aa59a088 ]
    
    For some reason DB410c has completely bogus regulator constraints that
    actually just correspond to the programmable voltages which are already
    provided by the regulator driver. Some of them are not just outside the
    recommended operating conditions of the APQ8016E SoC but even exceed
    the absolute maximum ratings, potentially risking permanent device
    damage.
    
    In practice it's not quite as dangerous thanks to the RPM firmware:
    It turns out that it has its own voltage constraints and silently
    clamps all regulator requests. For example, requesting 3.3V for L5
    (allowed by the current regulator constraints!) still results in 1.8V
    being programmed in the actual regulator hardware.
    
    Experimentation with various voltages shows that the internal RPM
    voltage constraints roughly correspond to the safe "specified range"
    in the PM8916 Device Specification (rather than the "programmable
    range" used inside apq8016-sbc.dtsi right now).
    
    Combine those together with some fixed voltages used in the old
    msm-3.10 device tree from Qualcomm to give DB410c some actually valid
    voltage constraints.
    
    Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Fixes: 4c7d53d16d77 ("arm64: dts: apq8016-sbc: add regulators support")
    Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230510-msm8916-regulators-v1-1-54d4960a05fc@gerhold.net
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: apq8096: fix fixed regulator name property [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Sun May 7 19:45:16 2023 +0200

    arm64: dts: qcom: apq8096: fix fixed regulator name property
    
    [ Upstream commit c77612a07d18d4425fd8ddd532a8a9b8e1970c53 ]
    
    Correct the typo in 'regulator-name' property.
    
      apq8096-ifc6640.dtb: v1p05-regulator: 'regulator-name' is a required property
      apq8096-ifc6640.dtb: v1p05-regulator: Unevaluated properties are not allowed ('reglator-name' was unexpected)
    
    Fixes: 6cbdec2d3ca6 ("arm64: dts: qcom: msm8996: Introduce IFC6640")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230507174516.264936-3-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: msm8916: correct camss unit address [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Apr 19 23:18:40 2023 +0200

    arm64: dts: qcom: msm8916: correct camss unit address
    
    [ Upstream commit 48798d992ce276cf0d57bf75318daf8eabd02aa4 ]
    
    Match unit-address to reg entry to fix dtbs W=1 warnings:
    
      Warning (simple_bus_reg): /soc@0/camss@1b00000: simple-bus unit address format error, expected "1b0ac00"
    
    Fixes: 58f479f90a7c ("arm64: dts: qcom: msm8916: Add CAMSS support")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230419211856.79332-2-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: msm8916: correct MMC unit address [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Apr 19 23:18:41 2023 +0200

    arm64: dts: qcom: msm8916: correct MMC unit address
    
    [ Upstream commit 72644bc76d5145c098c268829554a0b98fab1de1 ]
    
    Match unit-address to reg entry to fix dtbs W=1 warnings:
    
      Warning (simple_bus_reg): /soc@0/mmc@7824000: simple-bus unit address format error, expected "7824900"
      Warning (simple_bus_reg): /soc@0/mmc@7864000: simple-bus unit address format error, expected "7864900"
    
    Fixes: c4da5a561627 ("arm64: dts: qcom: Add msm8916 sdhci configuration nodes")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230419211856.79332-3-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: msm8994: correct SPMI unit address [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Apr 19 23:18:46 2023 +0200

    arm64: dts: qcom: msm8994: correct SPMI unit address
    
    [ Upstream commit 24f0f6a8059c7108d4ee3476c95db1e7ff4feb79 ]
    
    Match unit-address to reg entry to fix dtbs W=1 warnings:
    
      Warning (simple_bus_reg): /soc/spmi@fc4c0000: simple-bus unit address format error, expected "fc4cf000"
    
    Fixes: b0ad598f8ec0 ("arm64: dts: qcom: msm8994: Add SPMI PMIC arbiter device")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230419211856.79332-8-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: msm8996: correct camss unit address [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Apr 19 23:18:47 2023 +0200

    arm64: dts: qcom: msm8996: correct camss unit address
    
    [ Upstream commit e959ced1d0e5ef0b1f66a0c2d0e1ae80790e5ca5 ]
    
    Match unit-address to reg entry to fix dtbs W=1 warnings:
    
      Warning (simple_bus_reg): /soc/camss@a00000: simple-bus unit address format error, expected "a34000"
    
    Fixes: e0531312e78f ("arm64: dts: qcom: msm8996: Add CAMSS support")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230419211856.79332-9-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: pm7250b: add missing spmi-vadc include [+ + +]
Author: Luca Weiss <luca.weiss@fairphone.com>
Date:   Fri Apr 7 09:45:44 2023 +0200

    arm64: dts: qcom: pm7250b: add missing spmi-vadc include
    
    [ Upstream commit 83022f6484b11a60dbf9a95a88c7ef8e59c4b19c ]
    
    This file is using definitions from the spmi-vadc header, so we need to
    include it.
    
    Fixes: 11975b9b8135 ("arm64: dts: qcom: Add pm7250b PMIC")
    Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230407-pm7250b-sid-v1-1-fc648478cc25@fairphone.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: sdm630: correct camss unit address [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Apr 19 23:18:48 2023 +0200

    arm64: dts: qcom: sdm630: correct camss unit address
    
    [ Upstream commit c8b7faa7e9913a94444b3f00b6480e53a174fcfd ]
    
    Match unit-address to reg entry to fix dtbs W=1 warnings:
    
      Warning (simple_bus_reg): /soc/camss@ca00000: simple-bus unit address format error, expected "ca00020"
    
    Fixes: f3d5d3cc6971 ("arm64: dts: qcom: sdm630: Configure the camera subsystem")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230419211856.79332-10-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: sdm845-polaris: add missing touchscreen child node reg [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Apr 19 23:18:56 2023 +0200

    arm64: dts: qcom: sdm845-polaris: add missing touchscreen child node reg
    
    [ Upstream commit 4a0156b8862665a3e31c8280607388e3001ace3d ]
    
    Add missing reg property to touchscreen child node to fix dtbs W=1 warnings:
    
      Warning (unit_address_vs_reg): /soc@0/geniqup@ac0000/i2c@a98000/touchscreen@20/rmi4-f12@12: node has a unit name, but no reg or ranges property
    
    Fixes: be497abe19bf ("arm64: dts: qcom: Add support for Xiaomi Mi Mix2s")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Reviewed-by: Molly Sophia <mollysophia379@gmail.com>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230419211856.79332-18-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: sdm845: correct camss unit address [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Apr 19 23:18:49 2023 +0200

    arm64: dts: qcom: sdm845: correct camss unit address
    
    [ Upstream commit a05b913a27e46926ba60ba2bcacc7ec7a8403e4c ]
    
    Match unit-address to reg entry to fix dtbs W=1 warnings:
    
      Warning (simple_bus_reg): /soc@0/camss@a00000: simple-bus unit address format error, expected "acb3000"
    
    Fixes: d48a6698a6b7 ("arm64: dts: qcom: sdm845: Add CAMSS ISP node")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230419211856.79332-11-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: sdm845: Flush RSC sleep & wake votes [+ + +]
Author: Konrad Dybcio <konrad.dybcio@linaro.org>
Date:   Wed May 31 15:22:40 2023 +0200

    arm64: dts: qcom: sdm845: Flush RSC sleep & wake votes
    
    [ Upstream commit 91e83140b5dd5598fbcfada3ee1f8b2b410c3731 ]
    
    The rpmh driver will cache sleep and wake votes until the cluster
    power-domain is about to enter idle, to avoid unnecessary writes. So
    associate the apps_rsc with the cluster pd, so that it can be notified
    about this event.
    
    Without this, only AMC votes are being commited.
    
    Fixes: c83545d95376 ("arm64: dts: sdm845: Add rpmh-rsc node")
    Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230531-topic-rsc-v1-6-b4a985f57b8b@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: sm8250-edo: Panel framebuffer is 2.5k instead of 4k [+ + +]
Author: Marijn Suijten <marijn.suijten@somainline.org>
Date:   Tue Jun 6 23:14:18 2023 +0200

    arm64: dts: qcom: sm8250-edo: Panel framebuffer is 2.5k instead of 4k
    
    [ Upstream commit 223ce29c8b7e5b00f01a68387aabeefd77d97f06 ]
    
    The framebuffer configuration for edo pdx203, written in edo dtsi (which
    is overwritten in pdx206 dts for its smaller panel) has to use a
    1096x2560 configuration as this is what the panel (and framebuffer area)
    has been initialized to.  Downstream userspace also has access to (and
    uses) this 2.5k mode by default, and only switches the panel to 4k when
    requested.
    
    This is similar to commit be8de06dc397 ("arm64: dts: qcom:
    sm8150-kumano: Panel framebuffer is 2.5k instead of 4k") which fixed the
    same for the previous generation Sony platform.
    
    Fixes: 69cdb97ef652 ("arm64: dts: qcom: sm8250: Add support for SONY Xperia 1 II / 5 II (Edo platform)")
    Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230606211418.587676-1-marijn.suijten@somainline.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: sm8350: Add GPI DMA compatible fallback [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Tue Oct 18 19:03:51 2022 -0400

    arm64: dts: qcom: sm8350: Add GPI DMA compatible fallback
    
    [ Upstream commit b561e225dee5412609fd98340ca71ba0ab2e4b36 ]
    
    Use SM6350 as fallback for GPI DMA, to indicate devices are compatible
    and that drivers can bind with only one compatible.
    
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20221018230352.1238479-5-krzysztof.kozlowski@linaro.org
    Stable-dep-of: 41d6bca799b3 ("arm64: dts: qcom: sm8350: correct DMA controller unit address")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: sm8350: correct DMA controller unit address [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Apr 19 23:18:51 2023 +0200

    arm64: dts: qcom: sm8350: correct DMA controller unit address
    
    [ Upstream commit 41d6bca799b3f40d4d3c22dd4545aeac7c210e33 ]
    
    Match unit-address to reg entry to fix dtbs W=1 warnings:
    
      Warning (simple_bus_reg): /soc@0/dma-controller@900000: simple-bus unit address format error, expected "9800000"
    
    Fixes: bc08fbf49bc8 ("arm64: dts: qcom: sm8350: Define GPI DMA engines")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230419211856.79332-13-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: renesas: ulcb-kf: Remove flow control for SCIF1 [+ + +]
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Thu May 25 10:48:22 2023 +0200

    arm64: dts: renesas: ulcb-kf: Remove flow control for SCIF1
    
    [ Upstream commit 1a2c4e5635177939a088d22fa35c6a7032725663 ]
    
    The schematics are misleading, the flow control is for HSCIF1. We need
    SCIF1 for GNSS/GPS which does not use flow control.
    
    Fixes: c6c816e22bc8 ("arm64: dts: ulcb-kf: enable SCIF1")
    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Link: https://lore.kernel.org/r/20230525084823.4195-2-wsa+renesas@sang-engineering.com
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: ti: k3-j7200: Fix physical address of pin [+ + +]
Author: Keerthy <j-keerthy@ti.com>
Date:   Wed Apr 19 09:30:06 2023 +0530

    arm64: dts: ti: k3-j7200: Fix physical address of pin
    
    [ Upstream commit 3d011933000ed9054c649952d83162d24f020a93 ]
    
    wkup_pmx splits into multiple regions. Like
    
        wkup_pmx0 -> 13 pins (WKUP_PADCONFIG 0 - 12)
        wkup_pmx1 -> 2 pins (WKUP_PADCONFIG 14 - 15)
        wkup_pmx2 -> 59 pins (WKUP_PADCONFIG 26 - 84)
        wkup_pmx3 -> 8 pins (WKUP_PADCONFIG 93 - 100)
    
    With this split, pin offset needs to be adjusted to
    match with new pmx for all pins above wkup_pmx0.
    
    Example a pin under wkup_pmx1 should start from 0 instead of
    old offset(0x38 WKUP_PADCONFIG 14 offset)
    
    J7200 Datasheet (Table 6-106, Section 6.4 Pin Multiplexing) :
    https://www.ti.com/lit/ds/symlink/dra821u.pdf
    
    Fixes: 9ae21ac445e9 ("arm64: dts: ti: k3-j7200: Fix wakeup pinmux range")
    
    Signed-off-by: Keerthy <j-keerthy@ti.com>
    Signed-off-by: Udit Kumar <u-kumar1@ti.com>
    Link: https://lore.kernel.org/r/20230419040007.3022780-2-u-kumar1@ti.com
    Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: sme: Use STR P to clear FFR context field in streaming SVE mode [+ + +]
Author: Will Deacon <will@kernel.org>
Date:   Wed Jun 28 16:56:05 2023 +0100

    arm64: sme: Use STR P to clear FFR context field in streaming SVE mode
    
    [ Upstream commit 893b24181b4c4bf1fa2841b1ed192e5413a97cb1 ]
    
    The FFR is a predicate register which can vary between 16 and 256 bits
    in size depending upon the configured vector length. When saving the
    SVE state in streaming SVE mode, the FFR register is inaccessible and
    so commit 9f5848665788 ("arm64/sve: Make access to FFR optional") simply
    clears the FFR field of the in-memory context structure. Unfortunately,
    it achieves this using an unconditional 8-byte store and so if the SME
    vector length is anything other than 64 bytes in size we will either
    fail to clear the entire field or, worse, we will corrupt memory
    immediately following the structure. This has led to intermittent kfence
    splats in CI [1] and can trigger kmalloc Redzone corruption messages
    when running the 'fp-stress' kselftest:
    
     | =============================================================================
     | BUG kmalloc-1k (Not tainted): kmalloc Redzone overwritten
     | -----------------------------------------------------------------------------
     |
     | 0xffff000809bf1e22-0xffff000809bf1e27 @offset=7714. First byte 0x0 instead of 0xcc
     | Allocated in do_sme_acc+0x9c/0x220 age=2613 cpu=1 pid=531
     |  __kmalloc+0x8c/0xcc
     |  do_sme_acc+0x9c/0x220
     |  ...
    
    Replace the 8-byte store with a store of a predicate register which has
    been zero-initialised with PFALSE, ensuring that the entire field is
    cleared in memory.
    
    [1] https://lore.kernel.org/r/CA+G9fYtU7HsV0R0dp4XEH5xXHSJFw8KyDf5VQrLLfMxWfxQkag@mail.gmail.com
    
    Cc: Mark Brown <broonie@kernel.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
    Fixes: 9f5848665788 ("arm64/sve: Make access to FFR optional")
    Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Signed-off-by: Will Deacon <will@kernel.org>
    Reviewed-by: Mark Brown <broonie@kernel.org>
    Tested-by: Anders Roxell <anders.roxell@linaro.org>
    Link: https://lore.kernel.org/r/20230628155605.22296-1-will@kernel.org
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ARM: 9303/1: kprobes: avoid missing-declaration warnings [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Fri Jun 2 19:28:42 2023 +0100

    ARM: 9303/1: kprobes: avoid missing-declaration warnings
    
    [ Upstream commit 1b9c3ddcec6a55e15d3e38e7405e2d078db02020 ]
    
    checker_stack_use_t32strd() and kprobe_handler() can be made static since
    they are not used from other files, while coverage_start_registers()
    and __kprobes_test_case() are used from assembler code, and just need
    a declaration to avoid a warning with the global definition.
    
    arch/arm/probes/kprobes/checkers-common.c:43:18: error: no previous prototype for 'checker_stack_use_t32strd'
    arch/arm/probes/kprobes/core.c:236:16: error: no previous prototype for 'kprobe_handler'
    arch/arm/probes/kprobes/test-core.c:723:10: error: no previous prototype for 'coverage_start_registers'
    arch/arm/probes/kprobes/test-core.c:918:14: error: no previous prototype for '__kprobes_test_case_start'
    arch/arm/probes/kprobes/test-core.c:952:14: error: no previous prototype for '__kprobes_test_case_end_16'
    arch/arm/probes/kprobes/test-core.c:967:14: error: no previous prototype for '__kprobes_test_case_end_32'
    
    Fixes: 6624cf651f1a ("ARM: kprobes: collects stack consumption for store instructions")
    Fixes: 454f3e132d05 ("ARM/kprobes: Remove jprobe arm implementation")
    Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: BCM5301X: Drop "clock-names" from the SPI node [+ + +]
Author: Rafał Miłecki <rafal@milecki.pl>
Date:   Wed May 3 14:28:30 2023 +0200

    ARM: dts: BCM5301X: Drop "clock-names" from the SPI node
    
    [ Upstream commit d3c8e2c5757153bbfad70019ec1decbca86f3def ]
    
    There is no such property in the SPI controller binding documentation.
    Also Linux driver doesn't look for it.
    
    This fixes:
    arch/arm/boot/dts/bcm4708-asus-rt-ac56u.dtb: spi@18029200: Unevaluated properties are not allowed ('clock-names' was unexpected)
            From schema: Documentation/devicetree/bindings/spi/brcm,spi-bcm-qspi.yaml
    
    Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
    Link: https://lore.kernel.org/r/20230503122830.3200-1-zajec5@gmail.com
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: BCM5301X: fix duplex-full => full-duplex [+ + +]
Author: Christian Lamparter <chunkeey@gmail.com>
Date:   Thu Jun 8 17:36:29 2023 +0200

    ARM: dts: BCM5301X: fix duplex-full => full-duplex
    
    [ Upstream commit fd274b733bfdde3ca72f0fa2a37f032f3a8c402c ]
    
    this typo was found by the dtbs_check
    | ports:port@5:fixed-link: 'oneOf' conditional failed,
    |  {'speed': [[1000]], 'duplex-full': True} is not of type 'array'
    | 'duplex-full' does not match any of the regexes: 'pinctrl-[0-]..."
    
    this should have been full-duplex;
    
    Fixes: 935327a73553 ("ARM: dts: BCM5301X: Add DT for Meraki MR26")
    Fixes: ec88a9c344d9 ("ARM: BCM5301X: Add DT for Meraki MR32")
    Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
    Link: https://lore.kernel.org/r/50522f45566951a9eabd22820647924cc6b4a264.1686238550.git.chunkeey@gmail.com
    Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: gta04: Move model property out of pinctrl node [+ + +]
Author: Tony Lindgren <tony@atomide.com>
Date:   Wed May 17 13:32:25 2023 +0300

    ARM: dts: gta04: Move model property out of pinctrl node
    
    [ Upstream commit 4ffec92e70ac5097b9f67ec154065305b16a3b46 ]
    
    The model property should be at the top level, let's move it out
    of the pinctrl node.
    
    Fixes: d2eaf949d2c3 ("ARM: dts: omap3-gta04a5one: define GTA04A5 variant with OneNAND")
    Cc: Andreas Kemnade <andreas@kemnade.info>
    Cc: H. Nikolaus Schaller <hns@goldelico.com>
    Signed-off-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: iwg20d-q7-common: Fix backlight pwm specifier [+ + +]
Author: Geert Uytterhoeven <geert+renesas@glider.be>
Date:   Tue May 23 17:35:16 2023 +0200

    ARM: dts: iwg20d-q7-common: Fix backlight pwm specifier
    
    [ Upstream commit 0501fdec106a291c43b3c1b525cf22ab4c24b2d8 ]
    
    make dtbs_check:
    
        arch/arm/boot/dts/renesas/r8a7743-iwg20d-q7.dtb: backlight: pwms: [[58, 0, 5000000], [0]] is too long
                From schema: Documentation/devicetree/bindings/leds/backlight/pwm-backlight.yaml
        arch/arm/boot/dts/renesas/r8a7743-iwg20d-q7-dbcm-ca.dtb: backlight: pwms: [[67, 0, 5000000], [0]] is too long
                From schema: Documentation/devicetree/bindings/leds/backlight/pwm-backlight.yaml
        arch/arm/boot/dts/renesas/r8a7744-iwg20d-q7-dbcm-ca.dtb: backlight: pwms: [[67, 0, 5000000], [0]] is too long
                From schema: Documentation/devicetree/bindings/leds/backlight/pwm-backlight.yaml
        arch/arm/boot/dts/renesas/r8a7744-iwg20d-q7.dtb: backlight: pwms: [[58, 0, 5000000], [0]] is too long
                From schema: Documentation/devicetree/bindings/leds/backlight/pwm-backlight.yaml
    
    PWM specifiers referring to R-Car PWM Timer Controllers should contain
    only two cells.
    
    Fix this by dropping the bogus third cell.
    
    Fixes: 6f89dd9e9325d05b ("ARM: dts: iwg20d-q7-common: Add LCD support")
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Link: https://lore.kernel.org/r/6e5c3167424a43faf8c1fa68d9667b3d87dc86d8.1684855911.git.geert+renesas@glider.be
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: lan966x: kontron-d10: fix board reset [+ + +]
Author: Michael Walle <mwalle@kernel.org>
Date:   Fri Jun 16 15:18:39 2023 +0200

    ARM: dts: lan966x: kontron-d10: fix board reset
    
    [ Upstream commit bfcd5714f6424c03e385e0e9296dcd69855cfea7 ]
    
    The pinctrl node was missing which change the pin mux to GPIO mode. Add
    it.
    
    Fixes: 79d83b3a458e ("ARM: dts: lan966x: add basic Kontron KSwitch D10 support")
    Signed-off-by: Michael Walle <mwalle@kernel.org>
    [claudiu.beznea: moved pinctrl-* bindings after compatible]
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230616-feature-d10-dt-cleanups-v1-1-50dd0452b8fe@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: lan966x: kontron-d10: fix SPI CS [+ + +]
Author: Michael Walle <mwalle@kernel.org>
Date:   Fri Jun 16 15:18:40 2023 +0200

    ARM: dts: lan966x: kontron-d10: fix SPI CS
    
    [ Upstream commit fcb79ee3f0b15ed15f35eca5f24e952fdced9c61 ]
    
    The pinctrl node was missing which change the pin mux to GPIO mode.
    Add it so we don't have to rely on the bootloader to set the correct
    mode.
    
    Fixes: 79d83b3a458e ("ARM: dts: lan966x: add basic Kontron KSwitch D10 support")
    Signed-off-by: Michael Walle <mwalle@kernel.org>
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230616-feature-d10-dt-cleanups-v1-2-50dd0452b8fe@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: meson8: correct uart_B and uart_C clock references [+ + +]
Author: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Date:   Tue May 16 22:30:29 2023 +0200

    ARM: dts: meson8: correct uart_B and uart_C clock references
    
    [ Upstream commit 98b503c7fb13a17a47d8ebf15fa8f7c10118e75c ]
    
    On Meson8 uart_B and uart_C do not work, because they are relying on
    incorrect clocks. Change the references of pclk to the correct CLKID
    (UART1 for uart_B and UART2 for uart_C), to allow use of the two uarts.
    
    This was originally reported by Hans-Frieder Vogt for Meson8b [0], but
    the same bug is also present in meson8.dtsi
    
    [0] https://lore.kernel.org/linux-amlogic/trinity-bf20bcb9-790b-4ab9-99e3-0831ef8257f4-1680878185420@3c-app-gmx-bap55/
    
    Fixes: 57007bfb5469 ("ARM: dts: meson8: Fix the UART device-tree schema validation")
    Reported-by: Hans-Frieder Vogt <hfdevel@gmx.net> # for meson8b.dtsi
    Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
    Link: https://lore.kernel.org/r/20230516203029.1031174-1-martin.blumenstingl@googlemail.com
    Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: meson8b: correct uart_B and uart_C clock references [+ + +]
Author: hfdevel@gmx.net <hfdevel@gmx.net>
Date:   Fri Apr 7 16:36:25 2023 +0200

    ARM: dts: meson8b: correct uart_B and uart_C clock references
    
    [ Upstream commit d542ce8d4769cdef6a7bc3437e59cfed9c68f0e4 ]
    
    With the current device tree for meson8b, uarts B (e.g. available on pins
    8/10 on Odroid-C1) and C (pins 3/5 on Odroid-C1) do not work, because they
    are relying on incorrect clocks. Change the references of pclk to the
    correct CLKID, to allow use of the two uarts.
    
    Fixes: 3375aa77135f ("ARM: dts: meson8b: Fix the UART device-tree schema validation")
    Signed-off-by: Hans-Frieder Vogt <hfdevel@gmx.net>
    Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
    Link: https://lore.kernel.org/r/trinity-bf20bcb9-790b-4ab9-99e3-0831ef8257f4-1680878185420@3c-app-gmx-bap55
    Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: qcom: apq8074-dragonboard: Set DMA as remotely controlled [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Sun May 7 22:07:33 2023 +0300

    ARM: dts: qcom: apq8074-dragonboard: Set DMA as remotely controlled
    
    [ Upstream commit e60c230588d88036f974cec7e93361e2c4f62226 ]
    
    Add the qcom,controlled-remotely property for the blsp2_bam
    controller node. This board requires this, otherwise the board stalls
    during the boot for some reason (most probably because TZ mishandles the
    protection error and keeps on looping somewhere inside).
    
    Fixes: 62bc81792223 dts: msm8974: Add blsp2_bam dma node
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230507190735.2333145-3-dmitry.baryshkov@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: qcom: ipq4019: fix broken NAND controller properties override [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Thu Apr 20 09:28:11 2023 +0200

    ARM: dts: qcom: ipq4019: fix broken NAND controller properties override
    
    commit edcbdd57de499305e2a3737d4a73fe387f71d84c upstream.
    
    After renaming NAND controller node name from "qpic-nand" to
    "nand-controller", the board DTS/DTSI also have to be updated:
    
      Warning (unit_address_vs_reg): /soc/qpic-nand@79b0000: node has a unit name, but no reg or ranges property
    
    Cc: <stable@vger.kernel.org>
    Fixes: 9e1e00f18afc ("ARM: dts: qcom: Fix node name for NAND controller node")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230420072811.36947-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ARM: dts: qcom: msm8974: do not use underscore in node name (again) [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Mon Apr 10 19:52:32 2023 +0200

    ARM: dts: qcom: msm8974: do not use underscore in node name (again)
    
    [ Upstream commit 311bbc884b2edcf584b67d331be85ce43b27586f ]
    
    Align RPM requests node with DT schema by using hyphen instead of
    underscore.
    
    Fixes: f300826d27be ("ARM: dts: qcom-msm8974: Sort and clean up nodes")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230410175232.22317-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: stm32: Fix audio routing on STM32MP15xx DHCOM PDK2 [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Tue Jun 6 20:01:12 2023 +0200

    ARM: dts: stm32: Fix audio routing on STM32MP15xx DHCOM PDK2
    
    [ Upstream commit e3f2778b1b6ced649bffdc7cbb05b80bb92f2108 ]
    
    The audio routing flow is not correct, the flow should be from source
    (second element in the pair) to sink (first element in the pair). The
    flow now is from "HP_OUT" to "Playback", where "Playback" is source
    and "HP_OUT" is sink, i.e. the direction is swapped and there is no
    direct link between the two either.
    
    Fill in the correct routing, where "HP_OUT" supplies the "Headphone Jack",
    "Line In Jack" supplies "LINE_IN" input, "Microphone Jack" supplies "MIC_IN"
    input and "Mic Bias" supplies "Microphone Jack".
    
    Fixes: 34e0c7847dcf ("ARM: dts: stm32: Add DH Electronics DHCOM STM32MP1 SoM and PDK2 board")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: stm32: fix i2s endpoint format property for stm32mp15xx-dkx [+ + +]
Author: Olivier Moysan <olivier.moysan@foss.st.com>
Date:   Tue Jun 6 13:56:04 2023 +0200

    ARM: dts: stm32: fix i2s endpoint format property for stm32mp15xx-dkx
    
    [ Upstream commit 076c74c592cabe4a47537fe5205b5b678bed010d ]
    
    Use "dai-format" to configure DAI audio format as specified in
    audio-graph-port.yaml bindings.
    
    Fixes: 144d1ba70548 ("ARM: dts: stm32: Adapt STM32MP157 DK boards to stm32 DT diversity")
    Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
    Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: stm32: Move ethernet MAC EEPROM from SoM to carrier boards [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Fri May 5 23:37:29 2023 +0200

    ARM: dts: stm32: Move ethernet MAC EEPROM from SoM to carrier boards
    
    [ Upstream commit 9660efc2af37f3c12dc6e6a5511ad99e0addc297 ]
    
    The ethernet MAC EEPROM is not populated on the SoM itself, it has to be
    populated on each carrier board. Move the EEPROM into the correct place
    in DTs, i.e. the carrier board DTs. Add label to the EEPROM too.
    
    Fixes: 7e76f82acd9e1 ("ARM: dts: stm32: Split Avenger96 into DHCOR SoM and Avenger96 board")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: stm32: Shorten the AV96 HDMI sound card name [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Thu May 18 02:42:32 2023 +0200

    ARM: dts: stm32: Shorten the AV96 HDMI sound card name
    
    [ Upstream commit 0cf765e598712addec34d0208cc1418c151fefb2 ]
    
    Fix the following error in kernel log due to too long sound card name:
    "
    asoc-audio-graph-card sound: ASoC: driver name too long 'STM32MP1-AV96-HDMI' -> 'STM32MP1-AV96-H'
    "
    
    Fixes: e027da342772 ("ARM: dts: stm32: Add bindings for audio on AV96")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: ep93xx: fix missing-prototype warnings [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 16 17:30:58 2023 +0200

    ARM: ep93xx: fix missing-prototype warnings
    
    [ Upstream commit 419013740ea1e4343d8ade535d999f59fa28e460 ]
    
    ep93xx_clocksource_read() is only called from the file it is declared in,
    while ep93xx_timer_init() is declared in a header that is not included here.
    
    arch/arm/mach-ep93xx/timer-ep93xx.c:120:13: error: no previous prototype for 'ep93xx_timer_init'
    arch/arm/mach-ep93xx/timer-ep93xx.c:63:5: error: no previous prototype for 'ep93xx_clocksource_read'
    
    Fixes: 000bc17817bf ("ARM: ep93xx: switch to GENERIC_CLOCKEVENTS")
    Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
    Link: https://lore.kernel.org/r/20230516153109.514251-3-arnd@kernel.org
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: omap2: fix missing tick_broadcast() prototype [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 16 17:31:04 2023 +0200

    ARM: omap2: fix missing tick_broadcast() prototype
    
    [ Upstream commit 861bc1d2886d47bd57a2cbf2cda87fdbe3eb9d08 ]
    
    omap2 contains a hack to define tick_broadcast() on non-SMP
    configurations in place of the normal SMP definition. This one
    causes a warning because of a missing prototype:
    
    arch/arm/mach-omap2/board-generic.c:44:6: error: no previous prototype for 'tick_broadcast'
    
    Make sure to always include the header with the declaration.
    
    Fixes: d86ad463d670 ("ARM: OMAP2+: Fix regression for using local timer on non-SMP SoCs")
    Acked-by: Aaro Koskinen <aaro.koskinen@iki.fi>
    Link: https://lore.kernel.org/r/20230516153109.514251-9-arnd@kernel.org
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: orion5x: fix d2net gpio initialization [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 16 17:31:05 2023 +0200

    ARM: orion5x: fix d2net gpio initialization
    
    commit f8ef1233939495c405a9faa4bd1ae7d3f581bae4 upstream.
    
    The DT version of this board has a custom file with the gpio
    device. However, it does nothing because the d2net_init()
    has no caller or prototype:
    
    arch/arm/mach-orion5x/board-d2net.c:101:13: error: no previous prototype for 'd2net_init'
    
    Call it from the board-dt file as intended.
    
    Fixes: 94b0bd366e36 ("ARM: orion5x: convert d2net to Device Tree")
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20230516153109.514251-10-arnd@kernel.org
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ASoC: amd: acp: clear pdm dma interrupt mask [+ + +]
Author: Syed Saba Kareem <Syed.SabaKareem@amd.com>
Date:   Thu Jun 22 20:53:38 2023 +0530

    ASoC: amd: acp: clear pdm dma interrupt mask
    
    [ Upstream commit ad60672394bd1f95c58d3d9336902f47e05126fc ]
    
    Clear pdm dma interrupt mask in acp_dmic_shutdown().
    
    'Fixes: c32bd332ce5c9 ("ASoC: amd: acp: Add generic support for
    PDM controller on ACP")'
    
    Signed-off-by: Syed Saba Kareem <Syed.SabaKareem@amd.com>
    Link: https://lore.kernel.org/r/Message-Id: <20230622152406.3709231-1-Syed.SabaKareem@amd.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: es8316: Do not set rate constraints for unsupported MCLKs [+ + +]
Author: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Date:   Tue May 30 21:11:39 2023 +0300

    ASoC: es8316: Do not set rate constraints for unsupported MCLKs
    
    [ Upstream commit 60413129ee2b38a80347489270af7f6e1c1de4d0 ]
    
    When using the codec through the generic audio graph card, there are at
    least two calls of es8316_set_dai_sysclk(), with the effect of limiting
    the allowed sample rates according to the MCLK/LRCK ratios supported by
    the codec:
    
    1. During audio card setup, to set the initial MCLK - see
       asoc_simple_init_dai().
    
    2. Before opening a stream, to update MCLK, according to the stream
       sample rate and the multiplication factor - see
       asoc_simple_hw_params().
    
    In some cases the initial MCLK might be set to a frequency that doesn't
    match any of the supported ratios, e.g. 12287999 instead of 12288000,
    which is only 1 Hz below the supported clock, as that is what the
    hardware reports. This creates an empty list of rate constraints, which
    is further passed to snd_pcm_hw_constraint_list() via
    es8316_pcm_startup(), and causes the following error on the very first
    access of the sound card:
    
      $ speaker-test -D hw:Analog,0 -F S16_LE -c 2 -t wav
      Broken configuration for playback: no configurations available: Invalid argument
      Setting of hwparams failed: Invalid argument
    
    Note that all subsequent retries succeed thanks to the updated MCLK set
    at point 2 above, which uses a computed frequency value instead of a
    reading from the hardware registers. Normally this would have mitigated
    the issue, but es8316_pcm_startup() executes before the 2nd call to
    es8316_set_dai_sysclk(), hence it cannot make use of the updated
    constraints.
    
    Since es8316_pcm_hw_params() performs anyway a final validation of MCLK
    against the stream sample rate and the supported MCLK/LRCK ratios, fix
    the issue by ensuring that sysclk_constraints list is only set when at
    least one supported sample rate is autodetected by the codec.
    
    Fixes: b8b88b70875a ("ASoC: add es8316 codec driver")
    Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
    Link: https://lore.kernel.org/r/20230530181140.483936-3-cristian.ciocaltea@collabora.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: es8316: Increment max value for ALC Capture Target Volume control [+ + +]
Author: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Date:   Tue May 30 21:11:38 2023 +0300

    ASoC: es8316: Increment max value for ALC Capture Target Volume control
    
    [ Upstream commit 6f073429037cd79d7311cd8236311c53f5ea8f01 ]
    
    The following error occurs when trying to restore a previously saved
    ALSA mixer state (tested on a Rock 5B board):
    
      $ alsactl --no-ucm -f /tmp/asound.state store hw:Analog
      $ alsactl --no-ucm -I -f /tmp/asound.state restore hw:Analog
      alsactl: set_control:1475: Cannot write control '2:0:0:ALC Capture Target Volume:0' : Invalid argument
    
    According to ES8316 datasheet, the register at address 0x2B, which is
    related to the above mixer control, contains by default the value 0xB0.
    Considering the corresponding ALC target bits (ALCLVL) are 7:4, the
    control is initialized with 11, which is one step above the maximum
    value allowed by the driver:
    
     ALCLVL | dB gain
     -------+--------
      0000  |  -16.5
      0001  |  -15.0
      0010  |  -13.5
      ....  |  .....
      0111  |   -6.0
      1000  |   -4.5
      1001  |   -3.0
      1010  |   -1.5
      ....  |  .....
      1111  |   -1.5
    
    The tests performed using the VU meter feature (--vumeter=TYPE) of
    arecord/aplay confirm the specs are correct and there is no measured
    gain if the 1011-1111 range would have been mapped to 0 dB:
    
     dB gain | VU meter %
     --------+-----------
       -6.0  |  30-31
       -4.5  |  35-36
       -3.0  |  42-43
       -1.5  |  50-51
        0.0  |  50-51
    
    Increment the max value allowed for ALC Capture Target Volume control,
    so that it matches the hardware default.  Additionally, update the
    related TLV to prevent an artificial extension of the dB gain range.
    
    Fixes: b8b88b70875a ("ASoC: add es8316 codec driver")
    Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
    Link: https://lore.kernel.org/r/20230530181140.483936-2-cristian.ciocaltea@collabora.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: imx-audmix: check return value of devm_kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Wed Jun 14 15:15:09 2023 +0300

    ASoC: imx-audmix: check return value of devm_kasprintf()
    
    [ Upstream commit 2f76e1d6ca524a888d29aafe29f2ad2003857971 ]
    
    devm_kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230614121509.443926-1-claudiu.beznea@microchip.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: Intel: sof_sdw: remove SOF_SDW_TGL_HDMI for MeteorLake devices [+ + +]
Author: Bard Liao <yung-chuan.liao@linux.intel.com>
Date:   Fri May 12 12:32:59 2023 -0500

    ASoC: Intel: sof_sdw: remove SOF_SDW_TGL_HDMI for MeteorLake devices
    
    [ Upstream commit 0db94947c9d3da16aa31d152b7d26fab78b02cb9 ]
    
    Topologies support three HDMI links on MeteorLake devices only.
    
    Fixes: 18489174e4fb ("ASoC: intel: sof_sdw: add RT711 SDCA card for MTL platform")
    Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com
    Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
    Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
    Link: https://lore.kernel.org/r/20230512173305.65399-3-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Mark Brown <broonie@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: mediatek: mt8173: Fix irq error path [+ + +]
Author: Ricardo Ribalda Delgado <ribalda@chromium.org>
Date:   Mon Jun 12 11:05:32 2023 +0200

    ASoC: mediatek: mt8173: Fix irq error path
    
    commit f9c058d14f4fe23ef523a7ff73734d51c151683c upstream.
    
    After reordering the irq probe, the error path was not properly done.
    Lets fix it.
    
    Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
    Cc: stable@kernel.org
    Fixes: 4cbb264d4e91 ("ASoC: mediatek: mt8173: Enable IRQ when pdata is ready")
    Signed-off-by: Ricardo Ribalda Delgado <ribalda@chromium.org>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20230612-mt8173-fixup-v2-2-432aa99ce24d@chromium.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ASoC: mediatek: mt8173: Fix snd_soc_component_initialize error path [+ + +]
Author: Ricardo Ribalda Delgado <ribalda@chromium.org>
Date:   Mon Jun 12 11:05:31 2023 +0200

    ASoC: mediatek: mt8173: Fix snd_soc_component_initialize error path
    
    commit a46d37012a5be1737393b8f82fd35665e4556eee upstream.
    
    If the second component fails to initialize, cleanup the first on.
    
    Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
    Cc: stable@kernel.org
    Fixes: f1b5bf07365d ("ASoC: mt2701/mt8173: replace platform to component")
    Signed-off-by: Ricardo Ribalda Delgado <ribalda@chromium.org>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20230612-mt8173-fixup-v2-1-432aa99ce24d@chromium.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
autofs: use flexible array in ioctl structure [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 23 10:19:35 2023 +0200

    autofs: use flexible array in ioctl structure
    
    commit e910c8e3aa02dc456e2f4c32cb479523c326b534 upstream.
    
    Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") introduced a warning
    for the autofs_dev_ioctl structure:
    
    In function 'check_name',
        inlined from 'validate_dev_ioctl' at fs/autofs/dev-ioctl.c:131:9,
        inlined from '_autofs_dev_ioctl' at fs/autofs/dev-ioctl.c:624:8:
    fs/autofs/dev-ioctl.c:33:14: error: 'strchr' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
       33 |         if (!strchr(name, '/'))
          |              ^~~~~~~~~~~~~~~~~
    In file included from include/linux/auto_dev-ioctl.h:10,
                     from fs/autofs/autofs_i.h:10,
                     from fs/autofs/dev-ioctl.c:14:
    include/uapi/linux/auto_dev-ioctl.h: In function '_autofs_dev_ioctl':
    include/uapi/linux/auto_dev-ioctl.h:112:14: note: source object 'path' of size 0
      112 |         char path[0];
          |              ^~~~
    
    This is easily fixed by changing the gnu 0-length array into a c99
    flexible array. Since this is a uapi structure, we have to be careful
    about possible regressions but this one should be fine as they are
    equivalent here. While it would break building with ancient gcc versions
    that predate c99, it helps building with --std=c99 and -Wpedantic builds
    in user space, as well as non-gnu compilers. This means we probably
    also want it fixed in stable kernels.
    
    Cc: stable@vger.kernel.org
    Cc: Kees Cook <keescook@chromium.org>
    Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20230523081944.581710-1-arnd@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent [+ + +]
Author: Zheng Wang <zyytlz.wz@163.com>
Date:   Thu Jun 15 20:12:22 2023 +0800

    bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent
    
    commit 80fca8a10b604afad6c14213fdfd816c4eda3ee4 upstream.
    
    In some specific situations, the return value of __bch_btree_node_alloc
    may be NULL. This may lead to a potential NULL pointer dereference in
    caller function like a calling chain :
    btree_split->bch_btree_node_alloc->__bch_btree_node_alloc.
    
    Fix it by initializing the return value in __bch_btree_node_alloc.
    
    Fixes: cafe56359144 ("bcache: A block layer cache")
    Cc: stable@vger.kernel.org
    Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
    Signed-off-by: Coly Li <colyli@suse.de>
    Link: https://lore.kernel.org/r/20230615121223.22502-6-colyli@suse.de
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bcache: fixup btree_cache_wait list damage [+ + +]
Author: Mingzhe Zou <mingzhe.zou@easystack.cn>
Date:   Thu Jun 15 20:12:23 2023 +0800

    bcache: fixup btree_cache_wait list damage
    
    commit f0854489fc07d2456f7cc71a63f4faf9c716ffbe upstream.
    
    We get a kernel crash about "list_add corruption. next->prev should be
    prev (ffff9c801bc01210), but was ffff9c77b688237c.
    (next=ffffae586d8afe68)."
    
    crash> struct list_head 0xffff9c801bc01210
    struct list_head {
      next = 0xffffae586d8afe68,
      prev = 0xffffae586d8afe68
    }
    crash> struct list_head 0xffff9c77b688237c
    struct list_head {
      next = 0x0,
      prev = 0x0
    }
    crash> struct list_head 0xffffae586d8afe68
    struct list_head struct: invalid kernel virtual address: ffffae586d8afe68  type: "gdb_readmem_callback"
    Cannot access memory at address 0xffffae586d8afe68
    
    [230469.019492] Call Trace:
    [230469.032041]  prepare_to_wait+0x8a/0xb0
    [230469.044363]  ? bch_btree_keys_free+0x6c/0xc0 [escache]
    [230469.056533]  mca_cannibalize_lock+0x72/0x90 [escache]
    [230469.068788]  mca_alloc+0x2ae/0x450 [escache]
    [230469.080790]  bch_btree_node_get+0x136/0x2d0 [escache]
    [230469.092681]  bch_btree_check_thread+0x1e1/0x260 [escache]
    [230469.104382]  ? finish_wait+0x80/0x80
    [230469.115884]  ? bch_btree_check_recurse+0x1a0/0x1a0 [escache]
    [230469.127259]  kthread+0x112/0x130
    [230469.138448]  ? kthread_flush_work_fn+0x10/0x10
    [230469.149477]  ret_from_fork+0x35/0x40
    
    bch_btree_check_thread() and bch_dirty_init_thread() may call
    mca_cannibalize() to cannibalize other cached btree nodes. Only one thread
    can do it at a time, so the op of other threads will be added to the
    btree_cache_wait list.
    
    We must call finish_wait() to remove op from btree_cache_wait before free
    it's memory address. Otherwise, the list will be damaged. Also should call
    bch_cannibalize_unlock() to release the btree_cache_alloc_lock and wake_up
    other waiters.
    
    Fixes: 8e7102273f59 ("bcache: make bch_btree_check() to be multithreaded")
    Fixes: b144e45fc576 ("bcache: make bch_sectors_dirty_init() to be multithreaded")
    Cc: stable@vger.kernel.org
    Signed-off-by: Mingzhe Zou <mingzhe.zou@easystack.cn>
    Signed-off-by: Coly Li <colyli@suse.de>
    Link: https://lore.kernel.org/r/20230615121223.22502-7-colyli@suse.de
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bcache: Remove unnecessary NULL point check in node allocations [+ + +]
Author: Zheng Wang <zyytlz.wz@163.com>
Date:   Thu Jun 15 20:12:21 2023 +0800

    bcache: Remove unnecessary NULL point check in node allocations
    
    commit 028ddcac477b691dd9205c92f991cc15259d033e upstream.
    
    Due to the previous fix of __bch_btree_node_alloc, the return value will
    never be a NULL pointer. So IS_ERR is enough to handle the failure
    situation. Fix it by replacing IS_ERR_OR_NULL check by an IS_ERR check.
    
    Fixes: cafe56359144 ("bcache: A block layer cache")
    Cc: stable@vger.kernel.org
    Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
    Signed-off-by: Coly Li <colyli@suse.de>
    Link: https://lore.kernel.org/r/20230615121223.22502-5-colyli@suse.de
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
blk-iocost: use spin_lock_irqsave in adjust_inuse_and_calc_cost [+ + +]
Author: Li Nan <linan122@huawei.com>
Date:   Sat May 27 17:19:04 2023 +0800

    blk-iocost: use spin_lock_irqsave in adjust_inuse_and_calc_cost
    
    [ Upstream commit 8d211554679d0b23702bd32ba04aeac0c1c4f660 ]
    
    adjust_inuse_and_calc_cost() use spin_lock_irq() and IRQ will be enabled
    when unlock. DEADLOCK might happen if we have held other locks and disabled
    IRQ before invoking it.
    
    Fix it by using spin_lock_irqsave() instead, which can keep IRQ state
    consistent with before when unlock.
    
      ================================
      WARNING: inconsistent lock state
      5.10.0-02758-g8e5f91fd772f #26 Not tainted
      --------------------------------
      inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
      kworker/2:3/388 [HC0[0]:SC0[0]:HE0:SE1] takes:
      ffff888118c00c28 (&bfqd->lock){?.-.}-{2:2}, at: spin_lock_irq
      ffff888118c00c28 (&bfqd->lock){?.-.}-{2:2}, at: bfq_bio_merge+0x141/0x390
      {IN-HARDIRQ-W} state was registered at:
        __lock_acquire+0x3d7/0x1070
        lock_acquire+0x197/0x4a0
        __raw_spin_lock_irqsave
        _raw_spin_lock_irqsave+0x3b/0x60
        bfq_idle_slice_timer_body
        bfq_idle_slice_timer+0x53/0x1d0
        __run_hrtimer+0x477/0xa70
        __hrtimer_run_queues+0x1c6/0x2d0
        hrtimer_interrupt+0x302/0x9e0
        local_apic_timer_interrupt
        __sysvec_apic_timer_interrupt+0xfd/0x420
        run_sysvec_on_irqstack_cond
        sysvec_apic_timer_interrupt+0x46/0xa0
        asm_sysvec_apic_timer_interrupt+0x12/0x20
      irq event stamp: 837522
      hardirqs last  enabled at (837521): [<ffffffff84b9419d>] __raw_spin_unlock_irqrestore
      hardirqs last  enabled at (837521): [<ffffffff84b9419d>] _raw_spin_unlock_irqrestore+0x3d/0x40
      hardirqs last disabled at (837522): [<ffffffff84b93fa3>] __raw_spin_lock_irq
      hardirqs last disabled at (837522): [<ffffffff84b93fa3>] _raw_spin_lock_irq+0x43/0x50
      softirqs last  enabled at (835852): [<ffffffff84e00558>] __do_softirq+0x558/0x8ec
      softirqs last disabled at (835845): [<ffffffff84c010ff>] asm_call_irq_on_stack+0xf/0x20
    
      other info that might help us debug this:
       Possible unsafe locking scenario:
    
             CPU0
             ----
        lock(&bfqd->lock);
        <Interrupt>
          lock(&bfqd->lock);
    
       *** DEADLOCK ***
    
      3 locks held by kworker/2:3/388:
       #0: ffff888107af0f38 ((wq_completion)kthrotld){+.+.}-{0:0}, at: process_one_work+0x742/0x13f0
       #1: ffff8881176bfdd8 ((work_completion)(&td->dispatch_work)){+.+.}-{0:0}, at: process_one_work+0x777/0x13f0
       #2: ffff888118c00c28 (&bfqd->lock){?.-.}-{2:2}, at: spin_lock_irq
       #2: ffff888118c00c28 (&bfqd->lock){?.-.}-{2:2}, at: bfq_bio_merge+0x141/0x390
    
      stack backtrace:
      CPU: 2 PID: 388 Comm: kworker/2:3 Not tainted 5.10.0-02758-g8e5f91fd772f #26
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
      Workqueue: kthrotld blk_throtl_dispatch_work_fn
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x107/0x167
       print_usage_bug
       valid_state
       mark_lock_irq.cold+0x32/0x3a
       mark_lock+0x693/0xbc0
       mark_held_locks+0x9e/0xe0
       __trace_hardirqs_on_caller
       lockdep_hardirqs_on_prepare.part.0+0x151/0x360
       trace_hardirqs_on+0x5b/0x180
       __raw_spin_unlock_irq
       _raw_spin_unlock_irq+0x24/0x40
       spin_unlock_irq
       adjust_inuse_and_calc_cost+0x4fb/0x970
       ioc_rqos_merge+0x277/0x740
       __rq_qos_merge+0x62/0xb0
       rq_qos_merge
       bio_attempt_back_merge+0x12c/0x4a0
       blk_mq_sched_try_merge+0x1b6/0x4d0
       bfq_bio_merge+0x24a/0x390
       __blk_mq_sched_bio_merge+0xa6/0x460
       blk_mq_sched_bio_merge
       blk_mq_submit_bio+0x2e7/0x1ee0
       __submit_bio_noacct_mq+0x175/0x3b0
       submit_bio_noacct+0x1fb/0x270
       blk_throtl_dispatch_work_fn+0x1ef/0x2b0
       process_one_work+0x83e/0x13f0
       process_scheduled_works
       worker_thread+0x7e3/0xd80
       kthread+0x353/0x470
       ret_from_fork+0x1f/0x30
    
    Fixes: b0853ab4a238 ("blk-iocost: revamp in-period donation snapbacks")
    Signed-off-by: Li Nan <linan122@huawei.com>
    Acked-by: Tejun Heo <tj@kernel.org>
    Reviewed-by: Yu Kuai <yukuai3@huawei.com>
    Link: https://lore.kernel.org/r/20230527091904.3001833-1-linan666@huaweicloud.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
blk-mq: fix potential io hang by wrong 'wake_batch' [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Sat Jun 10 10:30:43 2023 +0800

    blk-mq: fix potential io hang by wrong 'wake_batch'
    
    [ Upstream commit 4f1731df60f9033669f024d06ae26a6301260b55 ]
    
    In __blk_mq_tag_busy/idle(), updating 'active_queues' and calculating
    'wake_batch' is not atomic:
    
    t1:                     t2:
    _blk_mq_tag_busy        blk_mq_tag_busy
    inc active_queues
    // assume 1->2
                            inc active_queues
                            // 2 -> 3
                            blk_mq_update_wake_batch
                            // calculate based on 3
    blk_mq_update_wake_batch
    /* calculate based on 2, while active_queues is actually 3. */
    
    Fix this problem by protecting them wih 'tags->lock', this is not a hot
    path, so performance should not be concerned. And now that all writers
    are inside the lock, switch 'actives_queues' from atomic to unsigned
    int.
    
    Fixes: 180dccb0dba4 ("blk-mq: fix tag_get wait task can't be awakened")
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20230610023043.2559121-1-yukuai1@huaweicloud.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
blktrace: use inline function for blk_trace_remove() while blktrace is disabled [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Sat Jun 10 10:20:01 2023 +0800

    blktrace: use inline function for blk_trace_remove() while blktrace is disabled
    
    commit cbe7cff4a76bc749dd70264ca5cf924e2adf9296 upstream.
    
    If config is disabled, call blk_trace_remove() directly will trigger
    build warning, hence use inline function instead, prepare to fix
    blktrace debugfs entries leakage.
    
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20230610022003.2557284-2-yukuai1@huaweicloud.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
block/partition: fix signedness issue for Amiga partitions [+ + +]
Author: Michael Schmitz <schmitzmic@gmail.com>
Date:   Wed Jul 5 11:38:08 2023 +1200

    block/partition: fix signedness issue for Amiga partitions
    
    commit 7eb1e47696aa231b1a567846bbe3a1e1befe1854 upstream.
    
    Making 'blk' sector_t (i.e. 64 bit if LBD support is active) fails the
    'blk>0' test in the partition block loop if a value of (signed int) -1 is
    used to mark the end of the partition block list.
    
    Explicitly cast 'blk' to signed int to allow use of -1 to terminate the
    partition block linked list.
    
    Fixes: b6f3f28f604b ("block: add overflow checks for Amiga partition support")
    Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
    Link: https://lore.kernel.org/r/024ce4fa-cc6d-50a2-9aae-3701d0ebf668@xenosoft.de
    Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
    Reviewed-by: Martin Steigerwald <martin@lichtvoll.de>
    Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
block: add overflow checks for Amiga partition support [+ + +]
Author: Michael Schmitz <schmitzmic@gmail.com>
Date:   Wed Jun 21 08:17:25 2023 +1200

    block: add overflow checks for Amiga partition support
    
    commit b6f3f28f604ba3de4724ad82bea6adb1300c0b5f upstream.
    
    The Amiga partition parser module uses signed int for partition sector
    address and count, which will overflow for disks larger than 1 TB.
    
    Use u64 as type for sector address and size to allow using disks up to
    2 TB without LBD support, and disks larger than 2 TB with LBD. The RBD
    format allows to specify disk sizes up to 2^128 bytes (though native
    OS limitations reduce this somewhat, to max 2^68 bytes), so check for
    u64 overflow carefully to protect against overflowing sector_t.
    
    Bail out if sector addresses overflow 32 bits on kernels without LBD
    support.
    
    This bug was reported originally in 2012, and the fix was created by
    the RDB author, Joanne Dow <jdow@earthlink.net>. A patch had been
    discussed and reviewed on linux-m68k at that time but never officially
    submitted (now resubmitted as patch 1 in this series).
    This patch adds additional error checking and warning messages.
    
    Reported-by: Martin Steigerwald <Martin@lichtvoll.de>
    Closes: https://bugzilla.kernel.org/show_bug.cgi?id=43511
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Message-ID: <201206192146.09327.Martin@lichtvoll.de>
    Cc: <stable@vger.kernel.org> # 5.2
    Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
    Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Reviewed-by: Christoph Hellwig <hch@infradead.org>
    Link: https://lore.kernel.org/r/20230620201725.7020-4-schmitzmic@gmail.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

block: change all __u32 annotations to __be32 in affs_hardblocks.h [+ + +]
Author: Michael Schmitz <schmitzmic@gmail.com>
Date:   Wed Jun 21 08:17:24 2023 +1200

    block: change all __u32 annotations to __be32 in affs_hardblocks.h
    
    commit 95a55437dc49fb3342c82e61f5472a71c63d9ed0 upstream.
    
    The Amiga partition parser module uses signed int for partition sector
    address and count, which will overflow for disks larger than 1 TB.
    
    Use u64 as type for sector address and size to allow using disks up to
    2 TB without LBD support, and disks larger than 2 TB with LBD. The RBD
    format allows to specify disk sizes up to 2^128 bytes (though native
    OS limitations reduce this somewhat, to max 2^68 bytes), so check for
    u64 overflow carefully to protect against overflowing sector_t.
    
    This bug was reported originally in 2012, and the fix was created by
    the RDB author, Joanne Dow <jdow@earthlink.net>. A patch had been
    discussed and reviewed on linux-m68k at that time but never officially
    submitted (now resubmitted as patch 1 of this series).
    
    Patch 3 (this series) adds additional error checking and warning
    messages. One of the error checks now makes use of the previously
    unused rdb_CylBlocks field, which causes a 'sparse' warning
    (cast to restricted __be32).
    
    Annotate all 32 bit fields in affs_hardblocks.h as __be32, as the
    on-disk format of RDB and partition blocks is always big endian.
    
    Reported-by: Martin Steigerwald <Martin@lichtvoll.de>
    Closes: https://bugzilla.kernel.org/show_bug.cgi?id=43511
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Message-ID: <201206192146.09327.Martin@lichtvoll.de>
    Cc: <stable@vger.kernel.org> # 5.2
    Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Link: https://lore.kernel.org/r/20230620201725.7020-3-schmitzmic@gmail.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

block: fix blktrace debugfs entries leakage [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Sat Jun 10 10:20:03 2023 +0800

    block: fix blktrace debugfs entries leakage
    
    [ Upstream commit dd7de3704af9989b780693d51eaea49a665bd9c2 ]
    
    Commit 99d055b4fd4b ("block: remove per-disk debugfs files in
    blk_unregister_queue") moves blk_trace_shutdown() from
    blk_release_queue() to blk_unregister_queue(), this is safe if blktrace
    is created through sysfs, however, there is a regression in corner
    case.
    
    blktrace can still be enabled after del_gendisk() through ioctl if
    the disk is opened before del_gendisk(), and if blktrace is not shutdown
    through ioctl before closing the disk, debugfs entries will be leaked.
    
    Fix this problem by shutdown blktrace in disk_release(), this is safe
    because blk_trace_remove() is reentrant.
    
    Fixes: 99d055b4fd4b ("block: remove per-disk debugfs files in blk_unregister_queue")
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20230610022003.2557284-4-yukuai1@huaweicloud.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

block: fix signed int overflow in Amiga partition support [+ + +]
Author: Michael Schmitz <schmitzmic@gmail.com>
Date:   Wed Jun 21 08:17:23 2023 +1200

    block: fix signed int overflow in Amiga partition support
    
    commit fc3d092c6bb48d5865fec15ed5b333c12f36288c upstream.
    
    The Amiga partition parser module uses signed int for partition sector
    address and count, which will overflow for disks larger than 1 TB.
    
    Use sector_t as type for sector address and size to allow using disks
    up to 2 TB without LBD support, and disks larger than 2 TB with LBD.
    
    This bug was reported originally in 2012, and the fix was created by
    the RDB author, Joanne Dow <jdow@earthlink.net>. A patch had been
    discussed and reviewed on linux-m68k at that time but never officially
    submitted. This patch differs from Joanne's patch only in its use of
    sector_t instead of unsigned int. No checking for overflows is done
    (see patch 3 of this series for that).
    
    Reported-by: Martin Steigerwald <Martin@lichtvoll.de>
    Closes: https://bugzilla.kernel.org/show_bug.cgi?id=43511
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Message-ID: <201206192146.09327.Martin@lichtvoll.de>
    Cc: <stable@vger.kernel.org> # 5.2
    Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
    Tested-by: Martin Steigerwald <Martin@lichtvoll.de>
    Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20230620201725.7020-2-schmitzmic@gmail.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

block: Fix the type of the second bdev_op_is_zoned_write() argument [+ + +]
Author: Bart Van Assche <bvanassche@acm.org>
Date:   Wed May 17 10:42:21 2023 -0700

    block: Fix the type of the second bdev_op_is_zoned_write() argument
    
    [ Upstream commit 3ddbe2a7e0d4a155a805f69c906c9beed30d4cc4 ]
    
    Change the type of the second argument of bdev_op_is_zoned_write() from
    blk_opf_t into enum req_op because this function expects an operation
    without flags as second argument.
    
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Cc: Ming Lei <ming.lei@redhat.com>
    Fixes: 8cafdb5ab94c ("block: adapt blk_mq_plug() to not plug for writes that require a zone lock")
    Signed-off-by: Bart Van Assche <bvanassche@acm.org>
    Link: https://lore.kernel.org/r/20230517174230.897144-4-bvanassche@acm.org
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

block: increment diskseq on all media change events [+ + +]
Author: Demi Marie Obenour <demi@invisiblethingslab.com>
Date:   Wed Jun 7 13:08:37 2023 -0400

    block: increment diskseq on all media change events
    
    commit b90ecc0379eb7bbe79337b0c7289390a98752646 upstream.
    
    Currently, associating a loop device with a different file descriptor
    does not increment its diskseq.  This allows the following race
    condition:
    
    1. Program X opens a loop device
    2. Program X gets the diskseq of the loop device.
    3. Program X associates a file with the loop device.
    4. Program X passes the loop device major, minor, and diskseq to
       something.
    5. Program X exits.
    6. Program Y detaches the file from the loop device.
    7. Program Y attaches a different file to the loop device.
    8. The opener finally gets around to opening the loop device and checks
       that the diskseq is what it expects it to be.  Even though the
       diskseq is the expected value, the result is that the opener is
       accessing the wrong file.
    
    From discussions with Christoph Hellwig, it appears that
    disk_force_media_change() was supposed to call inc_diskseq(), but in
    fact it does not.  Adding a Fixes: tag to indicate this.  Christoph's
    Reported-by is because he stated that disk_force_media_change()
    calls inc_diskseq(), which is what led me to discover that it should but
    does not.
    
    Reported-by: Christoph Hellwig <hch@infradead.org>
    Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
    Fixes: e6138dc12de9 ("block: add a helper to raise a media changed event")
    Cc: stable@vger.kernel.org # 5.15+
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20230607170837.1559-1-demi@invisiblethingslab.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Bluetooth: fix invalid-bdaddr quirk for non-persistent setup [+ + +]
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Wed May 31 11:04:23 2023 +0200

    Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
    
    [ Upstream commit 0cb7365850bacb8c2a9975cae672d65714d8daa1 ]
    
    Devices that lack persistent storage for the device address can indicate
    this by setting the HCI_QUIRK_INVALID_BDADDR which causes the controller
    to be marked as unconfigured until user space has set a valid address.
    
    Once configured, the device address must be set on every setup for
    controllers with HCI_QUIRK_NON_PERSISTENT_SETUP to avoid marking the
    controller as unconfigured and requiring the address to be set again.
    
    Fixes: 740011cfe948 ("Bluetooth: Add new quirk for non-persistent setup settings")
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Bluetooth: ISO: use hci_sync for setting CIG parameters [+ + +]
Author: Pauli Virtanen <pav@iki.fi>
Date:   Thu Jun 1 09:34:43 2023 +0300

    Bluetooth: ISO: use hci_sync for setting CIG parameters
    
    [ Upstream commit 6b9545dc9f8ff01d8bc1229103960d9cd265343f ]
    
    When reconfiguring CIG after disconnection of the last CIS, LE Remove
    CIG shall be sent before LE Set CIG Parameters.  Otherwise, it fails
    because CIG is in the inactive state and not configurable (Core v5.3
    Vol 6 Part B Sec. 4.5.14.3). This ordering is currently wrong under
    suitable timing conditions, because LE Remove CIG is sent via the
    hci_sync queue and may be delayed, but Set CIG Parameters is via
    hci_send_cmd.
    
    Make the ordering well-defined by sending also Set CIG Parameters via
    hci_sync.
    
    Fixes: 26afbd826ee3 ("Bluetooth: Add initial implementation of CIS connections")
    Signed-off-by: Pauli Virtanen <pav@iki.fi>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Bluetooth: MGMT: add CIS feature bits to controller information [+ + +]
Author: Pauli Virtanen <pav@iki.fi>
Date:   Mon Jan 30 20:37:01 2023 +0200

    Bluetooth: MGMT: add CIS feature bits to controller information
    
    [ Upstream commit 2394186a2cefb9a45a029281a55749804dd8c556 ]
    
    Userspace needs to know whether the adapter has feature support for
    Connected Isochronous Stream - Central/Peripheral, so it can set up
    LE Audio features accordingly.
    
    Expose these feature bits as settings in MGMT controller info.
    
    Signed-off-by: Pauli Virtanen <pav@iki.fi>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Stable-dep-of: 73f55453ea52 ("Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable [+ + +]
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Wed Jun 7 12:33:47 2023 -0700

    Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable
    
    [ Upstream commit 73f55453ea5236a586a7f1b3d5e2ee051d655351 ]
    
    When receiving a scan response there is no way to know if the remote
    device is connectable or not, so when it cannot be merged don't
    make any assumption and instead just mark it with a new flag defined as
    MGMT_DEV_FOUND_SCAN_RSP so userspace can tell it is a standalone
    SCAN_RSP.
    
    Link: https://lore.kernel.org/linux-bluetooth/CABBYNZ+CYMsDSPTxBn09Js3BcdC-x7vZFfyLJ3ppZGGwJKmUTw@mail.gmail.com/
    Fixes: c70a7e4cc8d2 ("Bluetooth: Add support for Not Connectable flag for Device Found events")
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Bluetooth: MGMT: Use BIT macro when defining bitfields [+ + +]
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Mon Feb 13 14:28:55 2023 -0800

    Bluetooth: MGMT: Use BIT macro when defining bitfields
    
    [ Upstream commit a80d2c545ded86d0350b9a870735565d8b749786 ]
    
    This makes use of BIT macro when defining bitfields which makes it
    clearer what bit it is toggling.
    
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Stable-dep-of: 73f55453ea52 ("Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
bonding: do not assume skb mac_header is set [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Jun 22 15:23:04 2023 +0000

    bonding: do not assume skb mac_header is set
    
    [ Upstream commit 6a940abdef3162e5723f1495b8a49859d1708f79 ]
    
    Drivers must not assume in their ndo_start_xmit() that
    skbs have their mac_header set. skb->data is all what is needed.
    
    bonding seems to be one of the last offender as caught by syzbot:
    
    WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 skb_mac_offset include/linux/skbuff.h:2913 [inline]
    WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 bond_xmit_hash drivers/net/bonding/bond_main.c:4170 [inline]
    WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 bond_xmit_3ad_xor_slave_get drivers/net/bonding/bond_main.c:5149 [inline]
    WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 bond_3ad_xor_xmit drivers/net/bonding/bond_main.c:5186 [inline]
    WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 __bond_start_xmit drivers/net/bonding/bond_main.c:5442 [inline]
    WARNING: CPU: 1 PID: 12155 at include/linux/skbuff.h:2907 bond_start_xmit+0x14ab/0x19d0 drivers/net/bonding/bond_main.c:5470
    Modules linked in:
    CPU: 1 PID: 12155 Comm: syz-executor.3 Not tainted 6.1.30-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023
    RIP: 0010:skb_mac_header include/linux/skbuff.h:2907 [inline]
    RIP: 0010:skb_mac_offset include/linux/skbuff.h:2913 [inline]
    RIP: 0010:bond_xmit_hash drivers/net/bonding/bond_main.c:4170 [inline]
    RIP: 0010:bond_xmit_3ad_xor_slave_get drivers/net/bonding/bond_main.c:5149 [inline]
    RIP: 0010:bond_3ad_xor_xmit drivers/net/bonding/bond_main.c:5186 [inline]
    RIP: 0010:__bond_start_xmit drivers/net/bonding/bond_main.c:5442 [inline]
    RIP: 0010:bond_start_xmit+0x14ab/0x19d0 drivers/net/bonding/bond_main.c:5470
    Code: 8b 7c 24 30 e8 76 dd 1a 01 48 85 c0 74 0d 48 89 c3 e8 29 67 2e fe e9 15 ef ff ff e8 1f 67 2e fe e9 10 ef ff ff e8 15 67 2e fe <0f> 0b e9 45 f8 ff ff e8 09 67 2e fe e9 dc fa ff ff e8 ff 66 2e fe
    RSP: 0018:ffffc90002fff6e0 EFLAGS: 00010283
    RAX: ffffffff835874db RBX: 000000000000ffff RCX: 0000000000040000
    RDX: ffffc90004dcf000 RSI: 00000000000000b5 RDI: 00000000000000b6
    RBP: ffffc90002fff8b8 R08: ffffffff83586d16 R09: ffffffff83586584
    R10: 0000000000000007 R11: ffff8881599fc780 R12: ffff88811b6a7b7e
    R13: 1ffff110236d4f6f R14: ffff88811b6a7ac0 R15: 1ffff110236d4f76
    FS: 00007f2e9eb47700(0000) GS:ffff8881f6b00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000001b2e421000 CR3: 000000010e6d4000 CR4: 00000000003526e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
    <TASK>
    [<ffffffff8471a49f>] netdev_start_xmit include/linux/netdevice.h:4925 [inline]
    [<ffffffff8471a49f>] __dev_direct_xmit+0x4ef/0x850 net/core/dev.c:4380
    [<ffffffff851d845b>] dev_direct_xmit include/linux/netdevice.h:3043 [inline]
    [<ffffffff851d845b>] packet_direct_xmit+0x18b/0x300 net/packet/af_packet.c:284
    [<ffffffff851c7472>] packet_snd net/packet/af_packet.c:3112 [inline]
    [<ffffffff851c7472>] packet_sendmsg+0x4a22/0x64d0 net/packet/af_packet.c:3143
    [<ffffffff8467a4b2>] sock_sendmsg_nosec net/socket.c:716 [inline]
    [<ffffffff8467a4b2>] sock_sendmsg net/socket.c:736 [inline]
    [<ffffffff8467a4b2>] __sys_sendto+0x472/0x5f0 net/socket.c:2139
    [<ffffffff8467a715>] __do_sys_sendto net/socket.c:2151 [inline]
    [<ffffffff8467a715>] __se_sys_sendto net/socket.c:2147 [inline]
    [<ffffffff8467a715>] __x64_sys_sendto+0xe5/0x100 net/socket.c:2147
    [<ffffffff8553071f>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [<ffffffff8553071f>] do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80
    [<ffffffff85600087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    Fixes: 7b8fc0103bb5 ("bonding: add a vlan+srcmac tx hashing option")
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Jarod Wilson <jarod@redhat.com>
    Cc: Moshe Tal <moshet@nvidia.com>
    Cc: Jussi Maki <joamaki@gmail.com>
    Cc: Jay Vosburgh <j.vosburgh@gmail.com>
    Cc: Andy Gospodarek <andy@greyhouse.net>
    Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
    Link: https://lore.kernel.org/r/20230622152304.2137482-1-edumazet@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
bootmem: remove the vmemmap pages from kmemleak in free_bootmem_page [+ + +]
Author: Liu Shixin <liushixin2@huawei.com>
Date:   Tue Jul 4 18:19:42 2023 +0800

    bootmem: remove the vmemmap pages from kmemleak in free_bootmem_page
    
    commit 028725e73375a1ff080bbdf9fb503306d0116f28 upstream.
    
    commit dd0ff4d12dd2 ("bootmem: remove the vmemmap pages from kmemleak in
    put_page_bootmem") fix an overlaps existing problem of kmemleak.  But the
    problem still existed when HAVE_BOOTMEM_INFO_NODE is disabled, because in
    this case, free_bootmem_page() will call free_reserved_page() directly.
    
    Fix the problem by adding kmemleak_free_part() in free_bootmem_page() when
    HAVE_BOOTMEM_INFO_NODE is disabled.
    
    Link: https://lkml.kernel.org/r/20230704101942.2819426-1-liushixin2@huawei.com
    Fixes: f41f2ed43ca5 ("mm: hugetlb: free the vmemmap pages associated with each HugeTLB page")
    Signed-off-by: Liu Shixin <liushixin2@huawei.com>
    Acked-by: Muchun Song <songmuchun@bytedance.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Oscar Salvador <osalvador@suse.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
bpf, btf: Warn but return no error for NULL btf from __register_btf_kfunc_id_set() [+ + +]
Author: SeongJae Park <sj@kernel.org>
Date:   Sat Jul 1 17:14:47 2023 +0000

    bpf, btf: Warn but return no error for NULL btf from __register_btf_kfunc_id_set()
    
    [ Upstream commit 3de4d22cc9ac7c9f38e10edcf54f9a8891a9c2aa ]
    
    __register_btf_kfunc_id_set() assumes .BTF to be part of the module's .ko
    file if CONFIG_DEBUG_INFO_BTF is enabled. If that's not the case, the
    function prints an error message and return an error. As a result, such
    modules cannot be loaded.
    
    However, the section could be stripped out during a build process. It would
    be better to let the modules loaded, because their basic functionalities
    have no problem [0], though the BTF functionalities will not be supported.
    Make the function to lower the level of the message from error to warn, and
    return no error.
    
      [0] https://lore.kernel.org/bpf/20220219082037.ow2kbq5brktf4f2u@apollo.legion
    
    Fixes: c446fdacb10d ("bpf: fix register_btf_kfunc_id_set for !CONFIG_DEBUG_INFO_BTF")
    Reported-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
    Suggested-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Jiri Olsa <jolsa@kernel.org>
    Link: https://lore.kernel.org/bpf/87y228q66f.fsf@oc8242746057.ibm.com
    Link: https://lore.kernel.org/bpf/20220219082037.ow2kbq5brktf4f2u@apollo.legion
    Link: https://lore.kernel.org/bpf/20230701171447.56464-1-sj@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
bpf: Call __bpf_sk_lookup()/__bpf_skc_lookup() directly via TC hookpoint [+ + +]
Author: Gilad Sever <gilad9366@gmail.com>
Date:   Wed Jun 21 13:42:09 2023 +0300

    bpf: Call __bpf_sk_lookup()/__bpf_skc_lookup() directly via TC hookpoint
    
    [ Upstream commit 97fbfeb86917bdbe9c41d5143e335a929147f405 ]
    
    skb->dev always exists in the tc flow. There is no need to use
    bpf_skc_lookup(), bpf_sk_lookup() from this code path.
    
    This change facilitates fixing the tc flow to be VRF aware.
    
    Signed-off-by: Gilad Sever <gilad9366@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
    Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
    Acked-by: Stanislav Fomichev <sdf@google.com>
    Link: https://lore.kernel.org/bpf/20230621104211.301902-3-gilad9366@gmail.com
    Stable-dep-of: 9a5cb79762e0 ("bpf: Fix bpf socket lookup from tc/xdp to respect socket VRF bindings")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

bpf: Don't EFAULT for {g,s}setsockopt with wrong optlen [+ + +]
Author: Stanislav Fomichev <sdf@google.com>
Date:   Thu May 11 10:04:53 2023 -0700

    bpf: Don't EFAULT for {g,s}setsockopt with wrong optlen
    
    [ Upstream commit 29ebbba7d46136cba324264e513a1e964ca16c0a ]
    
    With the way the hooks implemented right now, we have a special
    condition: optval larger than PAGE_SIZE will expose only first 4k into
    BPF; any modifications to the optval are ignored. If the BPF program
    doesn't handle this condition by resetting optlen to 0,
    the userspace will get EFAULT.
    
    The intention of the EFAULT was to make it apparent to the
    developers that the program is doing something wrong.
    However, this inadvertently might affect production workloads
    with the BPF programs that are not too careful (i.e., returning EFAULT
    for perfectly valid setsockopt/getsockopt calls).
    
    Let's try to minimize the chance of BPF program screwing up userspace
    by ignoring the output of those BPF programs (instead of returning
    EFAULT to the userspace). pr_info_once those cases to
    the dmesg to help with figuring out what's going wrong.
    
    Fixes: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks")
    Suggested-by: Martin KaFai Lau <martin.lau@kernel.org>
    Signed-off-by: Stanislav Fomichev <sdf@google.com>
    Link: https://lore.kernel.org/r/20230511170456.1759459-2-sdf@google.com
    Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

bpf: Factor out socket lookup functions for the TC hookpoint. [+ + +]
Author: Gilad Sever <gilad9366@gmail.com>
Date:   Wed Jun 21 13:42:08 2023 +0300

    bpf: Factor out socket lookup functions for the TC hookpoint.
    
    [ Upstream commit 6e98730bc0b44acaf86eccc75f823128aa9c9e79 ]
    
    Change BPF helper socket lookup functions to use TC specific variants:
    bpf_tc_sk_lookup_tcp() / bpf_tc_sk_lookup_udp() / bpf_tc_skc_lookup_tcp()
    instead of sharing implementation with the cg / sk_skb hooking points.
    This allows introducing a separate logic for the TC flow.
    
    The tc functions are identical to the original code.
    
    Signed-off-by: Gilad Sever <gilad9366@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
    Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
    Acked-by: Stanislav Fomichev <sdf@google.com>
    Link: https://lore.kernel.org/bpf/20230621104211.301902-2-gilad9366@gmail.com
    Stable-dep-of: 9a5cb79762e0 ("bpf: Fix bpf socket lookup from tc/xdp to respect socket VRF bindings")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

bpf: Fix bpf socket lookup from tc/xdp to respect socket VRF bindings [+ + +]
Author: Gilad Sever <gilad9366@gmail.com>
Date:   Wed Jun 21 13:42:10 2023 +0300

    bpf: Fix bpf socket lookup from tc/xdp to respect socket VRF bindings
    
    [ Upstream commit 9a5cb79762e0eda17ca15c2a6eaca4622383c21c ]
    
    When calling bpf_sk_lookup_tcp(), bpf_sk_lookup_udp() or
    bpf_skc_lookup_tcp() from tc/xdp ingress, VRF socket bindings aren't
    respoected, i.e. unbound sockets are returned, and bound sockets aren't
    found.
    
    VRF binding is determined by the sdif argument to sk_lookup(), however
    when called from tc the IP SKB control block isn't initialized and thus
    inet{,6}_sdif() always returns 0.
    
    Fix by calculating sdif for the tc/xdp flows by observing the device's
    l3 enslaved state.
    
    The cg/sk_skb hooking points which are expected to support
    inet{,6}_sdif() pass sdif=-1 which makes __bpf_skc_lookup() use the
    existing logic.
    
    Fixes: 6acc9b432e67 ("bpf: Add helper to retrieve socket in BPF")
    Signed-off-by: Gilad Sever <gilad9366@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
    Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
    Acked-by: Stanislav Fomichev <sdf@google.com>
    Cc: David Ahern <dsahern@kernel.org>
    Link: https://lore.kernel.org/bpf/20230621104211.301902-4-gilad9366@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

bpf: Fix memleak due to fentry attach failure [+ + +]
Author: Yafang Shao <laoar.shao@gmail.com>
Date:   Mon May 15 13:08:47 2023 +0000

    bpf: Fix memleak due to fentry attach failure
    
    [ Upstream commit 108598c39eefbedc9882273ac0df96127a629220 ]
    
    If it fails to attach fentry, the allocated bpf trampoline image will be
    left in the system. That can be verified by checking /proc/kallsyms.
    
    This meamleak can be verified by a simple bpf program as follows:
    
      SEC("fentry/trap_init")
      int fentry_run()
      {
          return 0;
      }
    
    It will fail to attach trap_init because this function is freed after
    kernel init, and then we can find the trampoline image is left in the
    system by checking /proc/kallsyms.
    
      $ tail /proc/kallsyms
      ffffffffc0613000 t bpf_trampoline_6442453466_1  [bpf]
      ffffffffc06c3000 t bpf_trampoline_6442453466_1  [bpf]
    
      $ bpftool btf dump file /sys/kernel/btf/vmlinux | grep "FUNC 'trap_init'"
      [2522] FUNC 'trap_init' type_id=119 linkage=static
    
      $ echo $((6442453466 & 0x7fffffff))
      2522
    
    Note that there are two left bpf trampoline images, that is because the
    libbpf will fallback to raw tracepoint if -EINVAL is returned.
    
    Fixes: e21aa341785c ("bpf: Fix fexit trampoline.")
    Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Song Liu <song@kernel.org>
    Cc: Jiri Olsa <olsajiri@gmail.com>
    Link: https://lore.kernel.org/bpf/20230515130849.57502-2-laoar.shao@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

bpf: Remove bpf trampoline selector [+ + +]
Author: Yafang Shao <laoar.shao@gmail.com>
Date:   Mon May 15 13:08:48 2023 +0000

    bpf: Remove bpf trampoline selector
    
    [ Upstream commit 47e79cbeea4b3891ad476047f4c68543eb51c8e0 ]
    
    After commit e21aa341785c ("bpf: Fix fexit trampoline."), the selector is only
    used to indicate how many times the bpf trampoline image are updated and been
    displayed in the trampoline ksym name. After the trampoline is freed, the
    selector will start from 0 again. So the selector is a useless value to the
    user. We can remove it.
    
    If the user want to check whether the bpf trampoline image has been updated
    or not, the user can compare the address. Each time the trampoline image is
    updated, the address will change consequently. Jiri also pointed out another
    issue that perf is still using the old name "bpf_trampoline_%lu", so this
    change can fix the issue in perf.
    
    Fixes: e21aa341785c ("bpf: Fix fexit trampoline.")
    Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Song Liu <song@kernel.org>
    Cc: Jiri Olsa <olsajiri@gmail.com>
    Link: https://lore.kernel.org/bpf/ZFvOOlrmHiY9AgXE@krava
    Link: https://lore.kernel.org/bpf/20230515130849.57502-3-laoar.shao@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
bpftool: JIT limited misreported as negative value on aarch64 [+ + +]
Author: Alan Maguire <alan.maguire@oracle.com>
Date:   Fri May 12 12:31:34 2023 +0100

    bpftool: JIT limited misreported as negative value on aarch64
    
    [ Upstream commit 04cb8453a91c7c22f60ddadb6cef0d19abb33bb5 ]
    
    On aarch64, "bpftool feature" reports an incorrect BPF JIT limit:
    
    $ sudo /sbin/bpftool feature
    Scanning system configuration...
    bpf() syscall restricted to privileged users
    JIT compiler is enabled
    JIT compiler hardening is disabled
    JIT compiler kallsyms exports are enabled for root
    skipping kernel config, can't open file: No such file or directory
    Global memory limit for JIT compiler for unprivileged users is -201326592 bytes
    
    This is because /proc/sys/net/core/bpf_jit_limit reports
    
    $ sudo cat /proc/sys/net/core/bpf_jit_limit
    68169519595520
    
    ...and an int is assumed in read_procfs().  Change read_procfs()
    to return a long to avoid negative value reporting.
    
    Fixes: 7a4522bbef0c ("tools: bpftool: add probes for /proc/ eBPF parameters")
    Reported-by: Nicky Veitch <nicky.veitch@oracle.com>
    Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Jiri Olsa <jolsa@kernel.org>
    Acked-by: Quentin Monnet <quentin@isovalent.com>
    Link: https://lore.kernel.org/bpf/20230512113134.58996-1-alan.maguire@oracle.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
btrfs: add block-group tree to lockdep classes [+ + +]
Author: David Sterba <dsterba@suse.com>
Date:   Thu Jun 1 00:33:01 2023 +0200

    btrfs: add block-group tree to lockdep classes
    
    commit 1a1b0e729d227f9f758f7b5f1c997e874e94156e upstream.
    
    The block group tree was not present among the lockdep classes. We could
    get potentially lockdep warnings but so far none has been seen, also
    because block-group-tree is a relatively new feature.
    
    CC: stable@vger.kernel.org # 6.1+
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: add handling for RAID1C23/DUP to btrfs_reduce_alloc_profile [+ + +]
Author: Matt Corallo <blnxfsl@bluematt.me>
Date:   Mon Jun 5 16:49:45 2023 -0700

    btrfs: add handling for RAID1C23/DUP to btrfs_reduce_alloc_profile
    
    commit 160fe8f6fdb13da6111677be6263e5d65e875987 upstream.
    
    Callers of `btrfs_reduce_alloc_profile` expect it to return exactly
    one allocation profile flag, and failing to do so may ultimately
    result in a WARN_ON and remount-ro when allocating new blocks, like
    the below transaction abort on 6.1.
    
    `btrfs_reduce_alloc_profile` has two ways of determining the profile,
    first it checks if a conversion balance is currently running and
    uses the profile we're converting to. If no balance is currently
    running, it returns the max-redundancy profile which at least one
    block in the selected block group has.
    
    This works by simply checking each known allocation profile bit in
    redundancy order. However, `btrfs_reduce_alloc_profile` has not been
    updated as new flags have been added - first with the `DUP` profile
    and later with the RAID1C34 profiles.
    
    Because of the way it checks, if we have blocks with different
    profiles and at least one is known, that profile will be selected.
    However, if none are known we may return a flag set with multiple
    allocation profiles set.
    
    This is currently only possible when a balance from one of the three
    unhandled profiles to another of the unhandled profiles is canceled
    after allocating at least one block using the new profile.
    
    In that case, a transaction abort like the below will occur and the
    filesystem will need to be mounted with -o skip_balance to get it
    mounted rw again (but the balance cannot be resumed without a
    similar abort).
    
      [770.648] ------------[ cut here ]------------
      [770.648] BTRFS: Transaction aborted (error -22)
      [770.648] WARNING: CPU: 43 PID: 1159593 at fs/btrfs/extent-tree.c:4122 find_free_extent+0x1d94/0x1e00 [btrfs]
      [770.648] CPU: 43 PID: 1159593 Comm: btrfs Tainted: G        W 6.1.0-0.deb11.7-powerpc64le #1  Debian 6.1.20-2~bpo11+1a~test
      [770.648] Hardware name: T2P9D01 REV 1.00 POWER9 0x4e1202 opal:skiboot-bc106a0 PowerNV
      [770.648] NIP:  c00800000f6784fc LR: c00800000f6784f8 CTR: c000000000d746c0
      [770.648] REGS: c000200089afe9a0 TRAP: 0700   Tainted: G        W (6.1.0-0.deb11.7-powerpc64le Debian 6.1.20-2~bpo11+1a~test)
      [770.648] MSR:  9000000002029033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE>  CR: 28848282  XER: 20040000
      [770.648] CFAR: c000000000135110 IRQMASK: 0
                GPR00: c00800000f6784f8 c000200089afec40 c00800000f7ea800 0000000000000026
                GPR04: 00000001004820c2 c000200089afea00 c000200089afe9f8 0000000000000027
                GPR08: c000200ffbfe7f98 c000000002127f90 ffffffffffffffd8 0000000026d6a6e8
                GPR12: 0000000028848282 c000200fff7f3800 5deadbeef0000122 c00000002269d000
                GPR16: c0002008c7797c40 c000200089afef17 0000000000000000 0000000000000000
                GPR20: 0000000000000000 0000000000000001 c000200008bc5a98 0000000000000001
                GPR24: 0000000000000000 c0000003c73088d0 c000200089afef17 c000000016d3a800
                GPR28: c0000003c7308800 c00000002269d000 ffffffffffffffea 0000000000000001
      [770.648] NIP [c00800000f6784fc] find_free_extent+0x1d94/0x1e00 [btrfs]
      [770.648] LR [c00800000f6784f8] find_free_extent+0x1d90/0x1e00 [btrfs]
      [770.648] Call Trace:
      [770.648] [c000200089afec40] [c00800000f6784f8] find_free_extent+0x1d90/0x1e00 [btrfs] (unreliable)
      [770.648] [c000200089afed30] [c00800000f681398] btrfs_reserve_extent+0x1a0/0x2f0 [btrfs]
      [770.648] [c000200089afeea0] [c00800000f681bf0] btrfs_alloc_tree_block+0x108/0x670 [btrfs]
      [770.648] [c000200089afeff0] [c00800000f66bd68] __btrfs_cow_block+0x170/0x850 [btrfs]
      [770.648] [c000200089aff100] [c00800000f66c58c] btrfs_cow_block+0x144/0x288 [btrfs]
      [770.648] [c000200089aff1b0] [c00800000f67113c] btrfs_search_slot+0x6b4/0xcb0 [btrfs]
      [770.648] [c000200089aff2a0] [c00800000f679f60] lookup_inline_extent_backref+0x128/0x7c0 [btrfs]
      [770.648] [c000200089aff3b0] [c00800000f67b338] lookup_extent_backref+0x70/0x190 [btrfs]
      [770.648] [c000200089aff470] [c00800000f67b54c] __btrfs_free_extent+0xf4/0x1490 [btrfs]
      [770.648] [c000200089aff5a0] [c00800000f67d770] __btrfs_run_delayed_refs+0x328/0x1530 [btrfs]
      [770.648] [c000200089aff740] [c00800000f67ea2c] btrfs_run_delayed_refs+0xb4/0x3e0 [btrfs]
      [770.648] [c000200089aff800] [c00800000f699aa4] btrfs_commit_transaction+0x8c/0x12b0 [btrfs]
      [770.648] [c000200089aff8f0] [c00800000f6dc628] reset_balance_state+0x1c0/0x290 [btrfs]
      [770.648] [c000200089aff9a0] [c00800000f6e2f7c] btrfs_balance+0x1164/0x1500 [btrfs]
      [770.648] [c000200089affb40] [c00800000f6f8e4c] btrfs_ioctl+0x2b54/0x3100 [btrfs]
      [770.648] [c000200089affc80] [c00000000053be14] sys_ioctl+0x794/0x1310
      [770.648] [c000200089affd70] [c00000000002af98] system_call_exception+0x138/0x250
      [770.648] [c000200089affe10] [c00000000000c654] system_call_common+0xf4/0x258
      [770.648] --- interrupt: c00 at 0x7fff94126800
      [770.648] NIP:  00007fff94126800 LR: 0000000107e0b594 CTR: 0000000000000000
      [770.648] REGS: c000200089affe80 TRAP: 0c00   Tainted: G        W (6.1.0-0.deb11.7-powerpc64le Debian 6.1.20-2~bpo11+1a~test)
      [770.648] MSR:  900000000000d033 <SF,HV,EE,PR,ME,IR,DR,RI,LE>  CR: 24002848  XER: 00000000
      [770.648] IRQMASK: 0
                GPR00: 0000000000000036 00007fffc9439da0 00007fff94217100 0000000000000003
                GPR04: 00000000c4009420 00007fffc9439ee8 0000000000000000 0000000000000000
                GPR08: 00000000803c7416 0000000000000000 0000000000000000 0000000000000000
                GPR12: 0000000000000000 00007fff9467d120 0000000107e64c9c 0000000107e64d0a
                GPR16: 0000000107e64d06 0000000107e64cf1 0000000107e64cc4 0000000107e64c73
                GPR20: 0000000107e64c31 0000000107e64bf1 0000000107e64be7 0000000000000000
                GPR24: 0000000000000000 00007fffc9439ee0 0000000000000003 0000000000000001
                GPR28: 00007fffc943f713 0000000000000000 00007fffc9439ee8 0000000000000000
      [770.648] NIP [00007fff94126800] 0x7fff94126800
      [770.648] LR [0000000107e0b594] 0x107e0b594
      [770.648] --- interrupt: c00
      [770.648] Instruction dump:
      [770.648] 3b00ffe4 e8898828 481175f5 60000000 4bfff4fc 3be00000 4bfff570 3d220000
      [770.648] 7fc4f378 e8698830 4811cd95 e8410018 <0fe00000> f9c10060 f9e10068 fa010070
      [770.648] ---[ end trace 0000000000000000 ]---
      [770.648] BTRFS: error (device dm-2: state A) in find_free_extent_update_loop:4122: errno=-22 unknown
      [770.648] BTRFS info (device dm-2: state EA): forced readonly
      [770.648] BTRFS: error (device dm-2: state EA) in __btrfs_free_extent:3070: errno=-22 unknown
      [770.648] BTRFS error (device dm-2: state EA): failed to run delayed ref for logical 17838685708288 num_bytes 24576 type 184 action 2 ref_mod 1: -22
      [770.648] BTRFS: error (device dm-2: state EA) in btrfs_run_delayed_refs:2144: errno=-22 unknown
      [770.648] BTRFS: error (device dm-2: state EA) in reset_balance_state:3599: errno=-22 unknown
    
    Fixes: 47e6f7423b91 ("btrfs: add support for 3-copy replication (raid1c3)")
    Fixes: 8d6fac0087e5 ("btrfs: add support for 4-copy replication (raid1c4)")
    CC: stable@vger.kernel.org # 5.10+
    Signed-off-by: Matt Corallo <blnxfsl@bluematt.me>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: bail out reclaim process if filesystem is read-only [+ + +]
Author: Naohiro Aota <naota@elisp.net>
Date:   Tue Jun 6 14:36:35 2023 +0900

    btrfs: bail out reclaim process if filesystem is read-only
    
    commit 93463ff7b54626f8276c0bd3d3f968fbf8d5d380 upstream.
    
    When a filesystem is read-only, we cannot reclaim a block group as it
    cannot rewrite the data. Just bail out in that case.
    
    Note that it can drop block groups in this case. As we did
    sb_start_write(), read-only filesystem means we got a fatal error and
    forced read-only. There is no chance to reclaim them again.
    
    Fixes: 18bb8bbf13c1 ("btrfs: zoned: automatically reclaim zones")
    CC: stable@vger.kernel.org # 5.15+
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: delete unused BGs while reclaiming BGs [+ + +]
Author: Naohiro Aota <naota@elisp.net>
Date:   Tue Jun 6 14:36:33 2023 +0900

    btrfs: delete unused BGs while reclaiming BGs
    
    commit 3ed01616bad6c7e3de196676b542ae3df8058592 upstream.
    
    The reclaiming process only starts after the filesystem volumes are
    allocated to a certain level (75% by default). Thus, the list of
    reclaiming target block groups can build up so huge at the time the
    reclaim process kicks in. On a test run, there were over 1000 BGs in the
    reclaim list.
    
    As the reclaim involves rewriting the data, it takes really long time to
    reclaim the BGs. While the reclaim is running, btrfs_delete_unused_bgs()
    won't proceed because the reclaim side is holding
    fs_info->reclaim_bgs_lock. As a result, we will have a large number of
    unused BGs kept in the unused list. On my test run, I got 1057 unused BGs.
    
    Since deleting a block group is relatively easy and fast work, we can call
    btrfs_delete_unused_bgs() while it reclaims BGs, to avoid building up
    unused BGs.
    
    Fixes: 18bb8bbf13c1 ("btrfs: zoned: automatically reclaim zones")
    CC: stable@vger.kernel.org # 5.15+
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: do not BUG_ON() on tree mod log failure at __btrfs_cow_block() [+ + +]
Author: Filipe Manana <fdmanana@suse.com>
Date:   Thu Jun 8 11:27:40 2023 +0100

    btrfs: do not BUG_ON() on tree mod log failure at __btrfs_cow_block()
    
    commit 40b0a749388517de244643c09bdbb98f7dcb6ef1 upstream.
    
    At __btrfs_cow_block(), instead of doing a BUG_ON() in case we fail to
    record a tree mod log root insertion operation, do a transaction abort
    instead. There's really no need for the BUG_ON(), we can properly
    release all resources in this context and turn the filesystem to RO mode
    and in an error state instead.
    
    CC: stable@vger.kernel.org # 5.4+
    Reviewed-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: do not BUG_ON() on tree mod log failure at balance_level() [+ + +]
Author: Filipe Manana <fdmanana@suse.com>
Date:   Thu Jun 8 11:27:41 2023 +0100

    btrfs: do not BUG_ON() on tree mod log failure at balance_level()
    
    [ Upstream commit 39020d8abc7ec62c4de9b260e3d10d4a1c2478ce ]
    
    At balance_level(), instead of doing a BUG_ON() in case we fail to record
    tree mod log operations, do a transaction abort and return the error to
    the callers. There's really no need for the BUG_ON() as we can release
    all resources in this context, and we have to abort because other future
    tree searches that use the tree mod log (btrfs_search_old_slot()) may get
    inconsistent results if other operations modify the tree after that
    failure and before the tree mod log based search.
    
    CC: stable@vger.kernel.org # 5.4+
    Reviewed-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

btrfs: fix extent buffer leak after tree mod log failure at split_node() [+ + +]
Author: Filipe Manana <fdmanana@suse.com>
Date:   Thu Jun 8 11:27:38 2023 +0100

    btrfs: fix extent buffer leak after tree mod log failure at split_node()
    
    commit ede600e497b1461d06d22a7d17703d9096868bc3 upstream.
    
    At split_node(), if we fail to log the tree mod log copy operation, we
    return without unlocking the split extent buffer we just allocated and
    without decrementing the reference we own on it. Fix this by unlocking
    it and decrementing the ref count before returning.
    
    Fixes: 5de865eebb83 ("Btrfs: fix tree mod logging")
    CC: stable@vger.kernel.org # 5.4+
    Reviewed-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: fix race when deleting free space root from the dirty cow roots list [+ + +]
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Jun 19 17:21:48 2023 +0100

    btrfs: fix race when deleting free space root from the dirty cow roots list
    
    commit babebf023e661b90b1c78b2baa384fb03a226879 upstream.
    
    When deleting the free space tree we are deleting the free space root
    from the list fs_info->dirty_cowonly_roots without taking the lock that
    protects it, which is struct btrfs_fs_info::trans_lock.
    This unsynchronized list manipulation may cause chaos if there's another
    concurrent manipulation of this list, such as when adding a root to it
    with ctree.c:add_root_to_dirty_list().
    
    This can result in all sorts of weird failures caused by a race, such as
    the following crash:
    
      [337571.278245] general protection fault, probably for non-canonical address 0xdead000000000108: 0000 [#1] PREEMPT SMP PTI
      [337571.278933] CPU: 1 PID: 115447 Comm: btrfs Tainted: G        W          6.4.0-rc6-btrfs-next-134+ #1
      [337571.279153] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
      [337571.279572] RIP: 0010:commit_cowonly_roots+0x11f/0x250 [btrfs]
      [337571.279928] Code: 85 38 06 00 (...)
      [337571.280363] RSP: 0018:ffff9f63446efba0 EFLAGS: 00010206
      [337571.280582] RAX: ffff942d98ec2638 RBX: ffff9430b82b4c30 RCX: 0000000449e1c000
      [337571.280798] RDX: dead000000000100 RSI: ffff9430021e4900 RDI: 0000000000036070
      [337571.281015] RBP: ffff942d98ec2000 R08: ffff942d98ec2000 R09: 000000000000015b
      [337571.281254] R10: 0000000000000009 R11: 0000000000000001 R12: ffff942fe8fbf600
      [337571.281476] R13: ffff942dabe23040 R14: ffff942dabe20800 R15: ffff942d92cf3b48
      [337571.281723] FS:  00007f478adb7340(0000) GS:ffff94349fa40000(0000) knlGS:0000000000000000
      [337571.281950] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [337571.282184] CR2: 00007f478ab9a3d5 CR3: 000000001e02c001 CR4: 0000000000370ee0
      [337571.282416] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [337571.282647] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [337571.282874] Call Trace:
      [337571.283101]  <TASK>
      [337571.283327]  ? __die_body+0x1b/0x60
      [337571.283570]  ? die_addr+0x39/0x60
      [337571.283796]  ? exc_general_protection+0x22e/0x430
      [337571.284022]  ? asm_exc_general_protection+0x22/0x30
      [337571.284251]  ? commit_cowonly_roots+0x11f/0x250 [btrfs]
      [337571.284531]  btrfs_commit_transaction+0x42e/0xf90 [btrfs]
      [337571.284803]  ? _raw_spin_unlock+0x15/0x30
      [337571.285031]  ? release_extent_buffer+0x103/0x130 [btrfs]
      [337571.285305]  reset_balance_state+0x152/0x1b0 [btrfs]
      [337571.285578]  btrfs_balance+0xa50/0x11e0 [btrfs]
      [337571.285864]  ? __kmem_cache_alloc_node+0x14a/0x410
      [337571.286086]  btrfs_ioctl+0x249a/0x3320 [btrfs]
      [337571.286358]  ? mod_objcg_state+0xd2/0x360
      [337571.286577]  ? refill_obj_stock+0xb0/0x160
      [337571.286798]  ? seq_release+0x25/0x30
      [337571.287016]  ? __rseq_handle_notify_resume+0x3ba/0x4b0
      [337571.287235]  ? percpu_counter_add_batch+0x2e/0xa0
      [337571.287455]  ? __x64_sys_ioctl+0x88/0xc0
      [337571.287675]  __x64_sys_ioctl+0x88/0xc0
      [337571.287901]  do_syscall_64+0x38/0x90
      [337571.288126]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
      [337571.288352] RIP: 0033:0x7f478aaffe9b
    
    So fix this by locking struct btrfs_fs_info::trans_lock before deleting
    the free space root from that list.
    
    Fixes: a5ed91828518 ("Btrfs: implement the free space B-tree")
    CC: stable@vger.kernel.org # 4.14+
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: fix race when deleting quota root from the dirty cow roots list [+ + +]
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Jun 19 17:21:47 2023 +0100

    btrfs: fix race when deleting quota root from the dirty cow roots list
    
    commit b31cb5a6eb7a48b0a7bfdf06832b1fd5088d8c79 upstream.
    
    When disabling quotas we are deleting the quota root from the list
    fs_info->dirty_cowonly_roots without taking the lock that protects it,
    which is struct btrfs_fs_info::trans_lock. This unsynchronized list
    manipulation may cause chaos if there's another concurrent manipulation
    of this list, such as when adding a root to it with
    ctree.c:add_root_to_dirty_list().
    
    This can result in all sorts of weird failures caused by a race, such as
    the following crash:
    
      [337571.278245] general protection fault, probably for non-canonical address 0xdead000000000108: 0000 [#1] PREEMPT SMP PTI
      [337571.278933] CPU: 1 PID: 115447 Comm: btrfs Tainted: G        W          6.4.0-rc6-btrfs-next-134+ #1
      [337571.279153] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
      [337571.279572] RIP: 0010:commit_cowonly_roots+0x11f/0x250 [btrfs]
      [337571.279928] Code: 85 38 06 00 (...)
      [337571.280363] RSP: 0018:ffff9f63446efba0 EFLAGS: 00010206
      [337571.280582] RAX: ffff942d98ec2638 RBX: ffff9430b82b4c30 RCX: 0000000449e1c000
      [337571.280798] RDX: dead000000000100 RSI: ffff9430021e4900 RDI: 0000000000036070
      [337571.281015] RBP: ffff942d98ec2000 R08: ffff942d98ec2000 R09: 000000000000015b
      [337571.281254] R10: 0000000000000009 R11: 0000000000000001 R12: ffff942fe8fbf600
      [337571.281476] R13: ffff942dabe23040 R14: ffff942dabe20800 R15: ffff942d92cf3b48
      [337571.281723] FS:  00007f478adb7340(0000) GS:ffff94349fa40000(0000) knlGS:0000000000000000
      [337571.281950] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [337571.282184] CR2: 00007f478ab9a3d5 CR3: 000000001e02c001 CR4: 0000000000370ee0
      [337571.282416] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [337571.282647] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [337571.282874] Call Trace:
      [337571.283101]  <TASK>
      [337571.283327]  ? __die_body+0x1b/0x60
      [337571.283570]  ? die_addr+0x39/0x60
      [337571.283796]  ? exc_general_protection+0x22e/0x430
      [337571.284022]  ? asm_exc_general_protection+0x22/0x30
      [337571.284251]  ? commit_cowonly_roots+0x11f/0x250 [btrfs]
      [337571.284531]  btrfs_commit_transaction+0x42e/0xf90 [btrfs]
      [337571.284803]  ? _raw_spin_unlock+0x15/0x30
      [337571.285031]  ? release_extent_buffer+0x103/0x130 [btrfs]
      [337571.285305]  reset_balance_state+0x152/0x1b0 [btrfs]
      [337571.285578]  btrfs_balance+0xa50/0x11e0 [btrfs]
      [337571.285864]  ? __kmem_cache_alloc_node+0x14a/0x410
      [337571.286086]  btrfs_ioctl+0x249a/0x3320 [btrfs]
      [337571.286358]  ? mod_objcg_state+0xd2/0x360
      [337571.286577]  ? refill_obj_stock+0xb0/0x160
      [337571.286798]  ? seq_release+0x25/0x30
      [337571.287016]  ? __rseq_handle_notify_resume+0x3ba/0x4b0
      [337571.287235]  ? percpu_counter_add_batch+0x2e/0xa0
      [337571.287455]  ? __x64_sys_ioctl+0x88/0xc0
      [337571.287675]  __x64_sys_ioctl+0x88/0xc0
      [337571.287901]  do_syscall_64+0x38/0x90
      [337571.288126]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
      [337571.288352] RIP: 0033:0x7f478aaffe9b
    
    So fix this by locking struct btrfs_fs_info::trans_lock before deleting
    the quota root from that list.
    
    Fixes: bed92eae26cc ("Btrfs: qgroup implementation and prototypes")
    CC: stable@vger.kernel.org # 4.14+
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

btrfs: reinsert BGs failed to reclaim [+ + +]
Author: Naohiro Aota <naota@elisp.net>
Date:   Tue Jun 6 14:36:36 2023 +0900

    btrfs: reinsert BGs failed to reclaim
    
    commit 7e27180994383b7c741ad87749db01e4989a02ba upstream.
    
    The reclaim process can temporarily fail. For example, if the space is
    getting tight, it fails to make the block group read-only. If there are no
    further writes on that block group, the block group will never get back to
    the reclaim list, and the BG never gets reclaimed. In a certain workload,
    we can leave many such block groups never reclaimed.
    
    So, let's get it back to the list and give it a chance to be reclaimed.
    
    Fixes: 18bb8bbf13c1 ("btrfs: zoned: automatically reclaim zones")
    CC: stable@vger.kernel.org # 5.15+
    Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
bus: fsl-mc: don't assume child devices are all fsl-mc devices [+ + +]
Author: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Date:   Tue Jun 13 19:07:18 2023 +0300

    bus: fsl-mc: don't assume child devices are all fsl-mc devices
    
    [ Upstream commit 303c9c63abb9390e906052863f82bb4e9824e5c0 ]
    
    Changes in VFIO caused a pseudo-device to be created as child of
    fsl-mc devices causing a crash [1] when trying to bind a fsl-mc
    device to VFIO. Fix this by checking the device type when enumerating
    fsl-mc child devices.
    
    [1]
    Modules linked in:
    Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
    CPU: 6 PID: 1289 Comm: sh Not tainted 6.2.0-rc5-00047-g7c46948a6e9c #2
    Hardware name: NXP Layerscape LX2160ARDB (DT)
    pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    pc : mc_send_command+0x24/0x1f0
    lr : dprc_get_obj_region+0xfc/0x1c0
    sp : ffff80000a88b900
    x29: ffff80000a88b900 x28: ffff48a9429e1400 x27: 00000000000002b2
    x26: ffff48a9429e1718 x25: 0000000000000000 x24: 0000000000000000
    x23: ffffd59331ba3918 x22: ffffd59331ba3000 x21: 0000000000000000
    x20: ffff80000a88b9b8 x19: 0000000000000000 x18: 0000000000000001
    x17: 7270642f636d2d6c x16: 73662e3030303030 x15: ffffffffffffffff
    x14: ffffd59330f1d668 x13: ffff48a8727dc389 x12: ffff48a8727dc386
    x11: 0000000000000002 x10: 00008ceaf02f35d4 x9 : 0000000000000012
    x8 : 0000000000000000 x7 : 0000000000000006 x6 : ffff80000a88bab0
    x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff80000a88b9e8
    x2 : ffff80000a88b9e8 x1 : 0000000000000000 x0 : ffff48a945142b80
    Call trace:
     mc_send_command+0x24/0x1f0
     dprc_get_obj_region+0xfc/0x1c0
     fsl_mc_device_add+0x340/0x590
     fsl_mc_obj_device_add+0xd0/0xf8
     dprc_scan_objects+0x1c4/0x340
     dprc_scan_container+0x38/0x60
     vfio_fsl_mc_probe+0x9c/0xf8
     fsl_mc_driver_probe+0x24/0x70
     really_probe+0xbc/0x2a8
     __driver_probe_device+0x78/0xe0
     device_driver_attach+0x30/0x68
     bind_store+0xa8/0x130
     drv_attr_store+0x24/0x38
     sysfs_kf_write+0x44/0x60
     kernfs_fop_write_iter+0x128/0x1b8
     vfs_write+0x334/0x448
     ksys_write+0x68/0xf0
     __arm64_sys_write+0x1c/0x28
     invoke_syscall+0x44/0x108
     el0_svc_common.constprop.1+0x94/0xf8
     do_el0_svc+0x38/0xb0
     el0_svc+0x20/0x50
     el0t_64_sync_handler+0x98/0xc0
     el0t_64_sync+0x174/0x178
    Code: aa0103f4 a9025bf5 d5384100 b9400801 (79401260)
    ---[ end trace 0000000000000000 ]---
    
    Fixes: 3c28a76124b2 ("vfio: Add struct device to vfio_device")
    Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
    Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com>
    Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
    Message-ID: <20230613160718.29500-1-laurentiu.tudor@nxp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

bus: ti-sysc: Fix dispc quirk masking bool variables [+ + +]
Author: Tony Lindgren <tony@atomide.com>
Date:   Wed May 17 10:04:16 2023 +0300

    bus: ti-sysc: Fix dispc quirk masking bool variables
    
    [ Upstream commit f620596fa347170852da499e778a5736d79a4b79 ]
    
    Fix warning drivers/bus/ti-sysc.c:1806 sysc_quirk_dispc()
    warn: masking a bool.
    
    While at it let's add a comment for what were doing to make
    the code a bit easier to follow.
    
    Fixes: 7324a7a0d5e2 ("bus: ti-sysc: Implement display subsystem reset quirk")
    Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
    Closes: https://lore.kernel.org/linux-omap/a8ec8a68-9c2c-4076-bf47-09fccce7659f@kili.mountain/
    Signed-off-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
can: kvaser_pciefd: Add function to set skb hwtstamps [+ + +]
Author: Jimmy Assarsson <extja@kvaser.com>
Date:   Mon May 29 15:42:37 2023 +0200

    can: kvaser_pciefd: Add function to set skb hwtstamps
    
    [ Upstream commit 2d55e9f9b4427e1ad59b974f2267767aac3788d3 ]
    
    Add new function, kvaser_pciefd_set_skb_timestamp(), to set skb hwtstamps.
    
    Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
    Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Link: https://lore.kernel.org/all/20230529134248.752036-4-extja@kvaser.com
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Stable-dep-of: ec681b91befa ("can: kvaser_pciefd: Set hardware timestamp on transmitted packets")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

can: kvaser_pciefd: Set hardware timestamp on transmitted packets [+ + +]
Author: Jimmy Assarsson <extja@kvaser.com>
Date:   Mon May 29 15:42:38 2023 +0200

    can: kvaser_pciefd: Set hardware timestamp on transmitted packets
    
    [ Upstream commit ec681b91befa982477e24a150dd6452427fe6473 ]
    
    Set hardware timestamp on transmitted packets.
    
    Fixes: 26ad340e582d ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
    Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
    Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Link: https://lore.kernel.org/all/20230529134248.752036-5-extja@kvaser.com
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

can: length: fix bitstuffing count [+ + +]
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Sun Jun 11 11:57:26 2023 +0900

    can: length: fix bitstuffing count
    
    [ Upstream commit 9fde4c557f78ee2f3626e92b4089ce9d54a2573a ]
    
    The Stuff Bit Count is always coded on 4 bits [1]. Update the Stuff
    Bit Count size accordingly.
    
    In addition, the CRC fields of CAN FD Frames contain stuff bits at
    fixed positions called fixed stuff bits [2]. The CRC field starts with
    a fixed stuff bit and then has another fixed stuff bit after each
    fourth bit [2], which allows us to derive this formula:
    
      FSB count = 1 + round_down(len(CRC field)/4)
    
    The length of the CRC field is [1]:
    
      len(CRC field) = len(Stuff Bit Count) + len(CRC)
                     = 4 + len(CRC)
    
    with len(CRC) either 17 or 21 bits depending of the payload length.
    
    In conclusion, for CRC17:
    
      FSB count = 1 + round_down((4 + 17)/4)
                = 6
    
    and for CRC 21:
    
      FSB count = 1 + round_down((4 + 21)/4)
                = 7
    
    Add a Fixed Stuff bits (FSB) field with above values and update
    CANFD_FRAME_OVERHEAD_SFF and CANFD_FRAME_OVERHEAD_EFF accordingly.
    
    [1] ISO 11898-1:2015 section 10.4.2.6 "CRC field":
    
      The CRC field shall contain the CRC sequence followed by a recessive
      CRC delimiter. For FD Frames, the CRC field shall also contain the
      stuff count.
    
      Stuff count
    
      If FD Frames, the stuff count shall be at the beginning of the CRC
      field. It shall consist of the stuff bit count modulo 8 in a 3-bit
      gray code followed by a parity bit [...]
    
    [2] ISO 11898-1:2015 paragraph 10.5 "Frame coding":
    
      In the CRC field of FD Frames, the stuff bits shall be inserted at
      fixed positions; they are called fixed stuff bits. There shall be a
      fixed stuff bit before the first bit of the stuff count, even if the
      last bits of the preceding field are a sequence of five consecutive
      bits of identical value, there shall be only the fixed stuff bit,
      there shall not be two consecutive stuff bits. A further fixed stuff
      bit shall be inserted after each fourth bit of the CRC field [...]
    
    Fixes: 85d99c3e2a13 ("can: length: can_skb_get_frame_len(): introduce function to get data length of frame in data link layer")
    Suggested-by: Thomas Kopp <Thomas.Kopp@microchip.com>
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Reviewed-by: Thomas Kopp <Thomas.Kopp@microchip.com>
    Link: https://lore.kernel.org/all/20230611025728.450837-2-mailhol.vincent@wanadoo.fr
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
cifs: do all necessary checks for credits within or before locking [+ + +]
Author: Shyam Prasad N <sprasad@microsoft.com>
Date:   Thu Jun 22 18:16:04 2023 +0000

    cifs: do all necessary checks for credits within or before locking
    
    [ Upstream commit 326a8d04f147e2bf393f6f9cdb74126ee6900607 ]
    
    All the server credits and in-flight info is protected by req_lock.
    Once the req_lock is held, and we've determined that we have enough
    credits to continue, this lock cannot be dropped till we've made the
    changes to credits and in-flight count.
    
    However, we used to drop the lock in order to avoid deadlock with
    the recent srv_lock. This could cause the checks already made to be
    invalidated.
    
    Fixed it by moving the server status check to before locking req_lock.
    
    Fixes: d7d7a66aacd6 ("cifs: avoid use of global locks for high contention data")
    Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

cifs: prevent use-after-free by freeing the cfile later [+ + +]
Author: Shyam Prasad N <sprasad@microsoft.com>
Date:   Thu Jun 22 18:16:03 2023 +0000

    cifs: prevent use-after-free by freeing the cfile later
    
    [ Upstream commit 33f736187d08f6bc822117629f263b97d3df4165 ]
    
    In smb2_compound_op we have a possible use-after-free
    which can cause hard to debug problems later on.
    
    This was revealed during stress testing with KASAN enabled
    kernel. Fixing it by moving the cfile free call to
    a few lines below, after the usage.
    
    Fixes: 76894f3e2f71 ("cifs: improve symlink handling for smb2+")
    Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
    Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
clk: bcm: rpi: Fix off by one in raspberrypi_discover_clocks() [+ + +]
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Fri Apr 21 13:41:01 2023 +0300

    clk: bcm: rpi: Fix off by one in raspberrypi_discover_clocks()
    
    [ Upstream commit da2edb3e3c09fd1451b7f400ccd1070ef086619a ]
    
    Smatch detected an off by one in this code:
        drivers/clk/bcm/clk-raspberrypi.c:374 raspberrypi_discover_clocks()
        error: buffer overflow 'data->hws' 16 <= 16
    
    The data->hws[] array has RPI_FIRMWARE_NUM_CLK_ID elements so the >
    comparison needs to changed to >=.
    
    Fixes: 12c90f3f27bb ("clk: bcm: rpi: Add variant structure")
    Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
    Link: https://lore.kernel.org/r/5a850b08-d2f5-4794-aceb-a6b468965139@kili.mountain
    Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
    Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: cdce925: check return value of kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Tue May 30 12:39:07 2023 +0300

    clk: cdce925: check return value of kasprintf()
    
    [ Upstream commit bb7d09ddbf361d51eae46f38e7c8a2b85914ea2a ]
    
    kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: 19fbbbbcd3a3 ("Add TI CDCE925 I2C controlled clock synthesizer driver")
    Depends-on: e665f029a283 ("clk: Convert to using %pOFn instead of device_node.name")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230530093913.1656095-3-claudiu.beznea@microchip.com
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: clocking-wizard: Fix Oops in clk_wzrd_register_divider() [+ + +]
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Thu May 11 20:01:20 2023 +0300

    clk: clocking-wizard: Fix Oops in clk_wzrd_register_divider()
    
    [ Upstream commit 9c632a6396505a019ea6d12b5ab45e659a542a93 ]
    
    Smatch detected this potential error pointer dereference
    clk_wzrd_register_divider().  If devm_clk_hw_register() fails then
    it sets "hw" to an error pointer and then dereferences it on the
    next line.  Return the error directly instead.
    
    Fixes: 5a853722eb32 ("staging: clocking-wizard: Add support for dynamic reconfiguration")
    Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
    Link: https://lore.kernel.org/r/f0e39b5c-4554-41e0-80d9-54ca3fabd060@kili.mountain
    Reviewed-by: Michal Simek <michal.simek@amd.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: Export clk_hw_forward_rate_request() [+ + +]
Author: Maxime Ripard <mripard@kernel.org>
Date:   Fri May 5 13:25:03 2023 +0200

    clk: Export clk_hw_forward_rate_request()
    
    [ Upstream commit ed046ac74da0b5602566073023a1519b5ae657b7 ]
    
    Commit 262ca38f4b6e ("clk: Stop forwarding clk_rate_requests to the
    parent") introduced the public clk_hw_forward_rate_request() function,
    but didn't export the symbol. Make sure it's the case.
    
    Fixes: 262ca38f4b6e ("clk: Stop forwarding clk_rate_requests to the parent")
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Link: https://lore.kernel.org/r/20221018-clk-range-checks-fixes-v4-1-971d5077e7d2@cerno.tech
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: Fix memory leak in devm_clk_notifier_register() [+ + +]
Author: Fei Shao <fshao@chromium.org>
Date:   Mon Jun 19 11:22:53 2023 +0800

    clk: Fix memory leak in devm_clk_notifier_register()
    
    [ Upstream commit 7fb933e56f77a57ef7cfc59fc34cbbf1b1fa31ff ]
    
    devm_clk_notifier_register() allocates a devres resource for clk
    notifier but didn't register that to the device, so the notifier didn't
    get unregistered on device detach and the allocated resource was leaked.
    
    Fix the issue by registering the resource through devres_add().
    
    This issue was found with kmemleak on a Chromebook.
    
    Fixes: 6d30d50d037d ("clk: add devm variant of clk_notifier_register")
    Signed-off-by: Fei Shao <fshao@chromium.org>
    Link: https://lore.kernel.org/r/20230619112253.v2.1.I13f060c10549ef181603e921291bdea95f83033c@changeid
    Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: imx93: fix memory leak and missing unwind goto in imx93_clocks_probe [+ + +]
Author: Zhanhao Hu <zero12113@hust.edu.cn>
Date:   Thu Jun 1 03:38:25 2023 +0000

    clk: imx93: fix memory leak and missing unwind goto in imx93_clocks_probe
    
    [ Upstream commit e02ba11b457647050cb16e7cad16cec3c252fade ]
    
    In function probe(), it returns directly without unregistered hws
    when error occurs.
    
    Fix this by adding 'goto unregister_hws;' on line 295 and
    line 310.
    
    Use devm_kzalloc() instead of kzalloc() to automatically
    free the memory using devm_kfree() when error occurs.
    
    Replace of_iomap() with devm_of_iomap() to automatically
    handle the unused ioremap region and delete 'iounmap(anatop_base);'
    in unregister_hws.
    
    Fixes: 24defbe194b6 ("clk: imx: add i.MX93 clk")
    Signed-off-by: Zhanhao Hu <zero12113@hust.edu.cn>
    Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
    Link: https://lore.kernel.org/r/20230601033825.336558-1-zero12113@hust.edu.cn
    Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: imx: clk-imx8mn: fix memory leak in imx8mn_clocks_probe [+ + +]
Author: Hao Luo <m202171776@hust.edu.cn>
Date:   Tue Apr 11 09:51:07 2023 +0800

    clk: imx: clk-imx8mn: fix memory leak in imx8mn_clocks_probe
    
    [ Upstream commit 188d070de9132667956f5aadd98d2bd87d3eac89 ]
    
    Use devm_of_iomap() instead of of_iomap() to automatically handle
    the unused ioremap region.
    
    If any error occurs, regions allocated by kzalloc() will leak,
    but using devm_kzalloc() instead will automatically free the memory
    using devm_kfree().
    
    Fixes: daeb14545514 ("clk: imx: imx8mn: Switch to clk_hw based API")
    Fixes: 96d6392b54db ("clk: imx: Add support for i.MX8MN clock driver")
    Signed-off-by: Hao Luo <m202171776@hust.edu.cn>
    Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
    Reviewed-by: Peng Fan <peng.fan@nxp.com>
    Link: https://lore.kernel.org/r/20230411015107.2645-1-m202171776@hust.edu.cn
    Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: imx: clk-imx8mp: improve error handling in imx8mp_clocks_probe() [+ + +]
Author: Yuxing Liu <lyx2022@hust.edu.cn>
Date:   Wed May 3 07:06:07 2023 +0000

    clk: imx: clk-imx8mp: improve error handling in imx8mp_clocks_probe()
    
    [ Upstream commit 878b02d5f3b56cb090dbe2c70c89273be144087f ]
    
    Replace of_iomap() and kzalloc() with devm_of_iomap() and devm_kzalloc()
    which can automatically release the related memory when the device
    or driver is removed or unloaded to avoid potential memory leak.
    
    In this case, iounmap(anatop_base) in line 427,433 are removed
    as manual release is not required.
    
    Besides, referring to clk-imx8mq.c, check the return code of
    of_clk_add_hw_provider, if it returns negtive, print error info
    and unregister hws, which makes the program more robust.
    
    Fixes: 9c140d992676 ("clk: imx: Add support for i.MX8MP clock driver")
    Signed-off-by: Yuxing Liu <lyx2022@hust.edu.cn>
    Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
    Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
    Link: https://lore.kernel.org/r/20230503070607.2462-1-lyx2022@hust.edu.cn
    Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: imx: clk-imxrt1050: fix memory leak in imxrt1050_clocks_probe [+ + +]
Author: Kai Ma <kaima@hust.edu.cn>
Date:   Tue Apr 18 11:34:51 2023 +0000

    clk: imx: clk-imxrt1050: fix memory leak in imxrt1050_clocks_probe
    
    [ Upstream commit 1b280598ab3bd8a2dc8b96a12530d5b1ee7a8f4a ]
    
    Use devm_of_iomap() instead of of_iomap() to automatically
    handle the unused ioremap region. If any error occurs, regions allocated by
    kzalloc() will leak, but using devm_kzalloc() instead will automatically
    free the memory using devm_kfree().
    
    Also, fix error handling of hws by adding unregister_hws label, which
    unregisters remaining hws when iomap failed.
    
    Fixes: 7154b046d8f3 ("clk: imx: Add initial support for i.MXRT1050 clock driver")
    Signed-off-by: Kai Ma <kaima@hust.edu.cn>
    Reviewed-by: Peng Fan <peng.fan@nxp.com>
    Acked-by: Jesse Taube <Mr.Bossman075@gmail.com>
    Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
    Link: https://lore.kernel.org/r/20230418113451.151312-1-kaima@hust.edu.cn
    Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: imx: scu: use _safe list iterator to avoid a use after free [+ + +]
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Wed Apr 19 17:23:01 2023 +0300

    clk: imx: scu: use _safe list iterator to avoid a use after free
    
    [ Upstream commit 632c60ecd25dbacee54d5581fe3aeb834b57010a ]
    
    This loop is freeing "clk" so it needs to use list_for_each_entry_safe().
    Otherwise it dereferences a freed variable to get the next item on the
    loop.
    
    Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells binding support")
    Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
    Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
    Link: https://lore.kernel.org/r/0793fbd1-d2b5-4ec2-9403-3c39343a3e2d@kili.mountain
    Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: keystone: sci-clk: check return value of kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Tue May 30 12:39:11 2023 +0300

    clk: keystone: sci-clk: check return value of kasprintf()
    
    [ Upstream commit b73ed981da6d25c921aaefa7ca3df85bbd85b7fc ]
    
    kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: b745c0794e2f ("clk: keystone: Add sci-clk driver support")
    Depends-on: 96488c09b0f4 ("clk: keystone: sci-clk: cut down the clock name length")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230530093913.1656095-7-claudiu.beznea@microchip.com
    Reviewed-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: camcc-sc7180: Add parent dependency to all camera GDSCs [+ + +]
Author: Taniya Das <quic_tdas@quicinc.com>
Date:   Mon May 1 19:59:32 2023 +0530

    clk: qcom: camcc-sc7180: Add parent dependency to all camera GDSCs
    
    [ Upstream commit 3e4d179532423f299554cd0dedabdd9d2fdd238d ]
    
    Camera titan top GDSC is a parent supply to all other camera GDSCs. Titan
    top GDSC is required to be enabled before enabling any other camera GDSCs
    and it should be disabled only after all other camera GDSCs are disabled.
    Ensure this behavior by marking titan top GDSC as parent of all other
    camera GDSCs.
    
    Fixes: 15d09e830bbc ("clk: qcom: camcc: Add camera clock controller driver for SC7180")
    Signed-off-by: Taniya Das <quic_tdas@quicinc.com>
    Acked-by: Stephen Boyd <sboyd@kernel.org>
    Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230501142932.13049-1-quic_tdas@quicinc.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: dispcc-qcm2290: Fix BI_TCXO_AO handling [+ + +]
Author: Konrad Dybcio <konrad.dybcio@linaro.org>
Date:   Fri Apr 14 13:06:35 2023 +0200

    clk: qcom: dispcc-qcm2290: Fix BI_TCXO_AO handling
    
    [ Upstream commit 92dfee0fc889b5b00ffb6b1de87ce64c483bcb7b ]
    
    BI_TCXO_AO (.fw_name = "bi_tcxo_ao") was previously made to reuse the
    same parent enum entry as BI_TCXO (.fw_name = "bi_tcxo") in parent_map_2.
    
    Resolve it by introducing its own entry in the parent enum and
    correctly assigning it in disp_cc_parent_map_2[].
    
    Fixes: cc517ea3333f ("clk: qcom: Add display clock controller driver for QCM2290")
    Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230412-topic-qcm_dispcc-v2-1-bce7dd512fe4@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: dispcc-qcm2290: Fix GPLL0_OUT_DIV handling [+ + +]
Author: Konrad Dybcio <konrad.dybcio@linaro.org>
Date:   Fri Apr 14 13:06:36 2023 +0200

    clk: qcom: dispcc-qcm2290: Fix GPLL0_OUT_DIV handling
    
    [ Upstream commit 63d56adf04b5795e54440dc5b7afddecb2966863 ]
    
    GPLL0_OUT_DIV (.fw_name = "gcc_disp_gpll0_div_clk_src") was previously
    made to reuse the same parent enum entry as GPLL0_OUT_MAIN
    (.fw_name = "gcc_disp_gpll0_clk_src") in parent_map_2.
    
    Resolve it by introducing its own entry in the parent enum and
    correctly assigning it in disp_cc_parent_map_2[].
    
    Fixes: cc517ea3333f ("clk: qcom: Add display clock controller driver for QCM2290")
    Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230412-topic-qcm_dispcc-v2-2-bce7dd512fe4@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: gcc-ipq6018: Use floor ops for sdcc clocks [+ + +]
Author: Mantas Pucka <mantas@8devices.com>
Date:   Tue Apr 25 12:11:49 2023 +0300

    clk: qcom: gcc-ipq6018: Use floor ops for sdcc clocks
    
    [ Upstream commit 56e5ae0116aef87273cf1812d608645b076e4f02 ]
    
    SDCC clocks must be rounded down to avoid overclocking the controller.
    
    Fixes: d9db07f088af ("clk: qcom: Add ipq6018 Global Clock Controller support")
    Signed-off-by: Mantas Pucka <mantas@8devices.com>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/1682413909-24927-1-git-send-email-mantas@8devices.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: gcc-qcm2290: Mark RCGs shared where applicable [+ + +]
Author: Konrad Dybcio <konrad.dybcio@linaro.org>
Date:   Mon Apr 3 19:48:07 2023 +0200

    clk: qcom: gcc-qcm2290: Mark RCGs shared where applicable
    
    [ Upstream commit 7bf654a0d95e75b415f454e10627309d650762d0 ]
    
    The vast majority of shared RCGs were not marked as such. Fix it.
    
    Fixes: 496d1a13d405 ("clk: qcom: Add Global Clock Controller driver for QCM2290")
    Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Acked-by: Shawn Guo <shawn.guo@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230403174807.345185-1-konrad.dybcio@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: ipq6018: fix networking resets [+ + +]
Author: Robert Marko <robimarko@gmail.com>
Date:   Fri May 26 21:08:55 2023 +0200

    clk: qcom: ipq6018: fix networking resets
    
    [ Upstream commit 349b5bed539b491b7894a5186a895751fd8ba6c7 ]
    
    Networking resets in IPQ6018 all use bitmask as they require multiple
    bits to be set and cleared instead of a single bit.
    
    So, current networking resets have the same register and bit 0 set which
    is clearly incorrect.
    
    Fixes: d9db07f088af ("clk: qcom: Add ipq6018 Global Clock Controller support")
    Signed-off-by: Robert Marko <robimarko@gmail.com>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230526190855.2941291-2-robimarko@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: mmcc-msm8974: fix MDSS_GDSC power flags [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Sun May 7 20:53:35 2023 +0300

    clk: qcom: mmcc-msm8974: fix MDSS_GDSC power flags
    
    [ Upstream commit 4e13c7a55cf752887f2b8d8008711dbbc64ea796 ]
    
    Using PWRSTS_RET on msm8974's MDSS_GDSC causes display to stop working.
    The gdsc doesn't fully come out of retention mode. Change it's pwrsts
    flags to PWRSTS_OFF_ON.
    
    Fixes: d399723950c4 ("clk: qcom: gdsc: Fix the handling of PWRSTS_RET support")
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Rajendra Nayak <quic_rjendra@quicinc.com>
    Tested-by: Luca Weiss <luca@z3ntu.xyz>
    Link: https://lore.kernel.org/r/20230507175335.2321503-2-dmitry.baryshkov@linaro.org
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: mmcc-msm8974: remove oxili_ocmemgx_clk [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Mon May 8 18:33:19 2023 +0300

    clk: qcom: mmcc-msm8974: remove oxili_ocmemgx_clk
    
    [ Upstream commit 853c064b57491d739bfd0cc35ff75c5ea9c5e8f5 ]
    
    After the internal discussions, it looks like this clock is managed by
    RPM itself. Linux kernel should not touch it on its own, as this causes
    disagreement with RPM. Shutting down this clock causes the OCMEM<->GPU
    interface to stop working, resulting in GPU hangchecks/timeouts.
    
    Fixes: d8b212014e69 ("clk: qcom: Add support for MSM8974's multimedia clock controller (MMCC)")
    Suggested-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Tested-by: Luca Weiss <luca@z3ntu.xyz>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230508153319.2371645-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: mmcc-msm8974: use clk_rcg2_shared_ops for mdp_clk_src clock [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Sun May 7 20:53:34 2023 +0300

    clk: qcom: mmcc-msm8974: use clk_rcg2_shared_ops for mdp_clk_src clock
    
    [ Upstream commit 8fd492e77ff71f68f7311c22f7bc960182465cd7 ]
    
    The mdp_clk_src clock should not be turned off. Instead it should be
    'parked' to the XO, as most of other mdp_clk_src clocks. Fix that by
    using the clk_rcg2_shared_ops.
    
    Fixes: d8b212014e69 ("clk: qcom: Add support for MSM8974's multimedia clock controller (MMCC)")
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Tested-by: Luca Weiss <luca@z3ntu.xyz>
    Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20230507175335.2321503-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: qcom: reset: support resetting multiple bits [+ + +]
Author: Robert Marko <robimarko@gmail.com>
Date:   Mon Nov 7 14:28:59 2022 +0100

    clk: qcom: reset: support resetting multiple bits
    
    [ Upstream commit 4a5210893625f89723ea210d7c630b730abb37ad ]
    
    This patch adds the support for giving the complete bitmask
    in reset structure and reset operation will use this bitmask
    for all reset operations.
    
    Currently, reset structure only takes a single bit for each reset
    and then calculates the bitmask by using the BIT() macro.
    
    However, this is not sufficient anymore for newer SoC-s like IPQ8074,
    IPQ6018 and more, since their networking resets require multiple bits
    to be asserted in order to properly reset the HW block completely.
    
    So, in order to allow asserting multiple bits add "bitmask" field to
    qcom_reset_map, and then use that bitmask value if its populated in the
    driver, if its not populated, then we just default to existing behaviour
    and calculate the bitmask on the fly.
    
    Signed-off-by: Robert Marko <robimarko@gmail.com>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20221107132901.489240-1-robimarko@gmail.com
    Stable-dep-of: 349b5bed539b ("clk: qcom: ipq6018: fix networking resets")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: renesas: rzg2l: Fix CPG_SIPLL5_CLK1 register write [+ + +]
Author: Biju Das <biju.das.jz@bp.renesas.com>
Date:   Thu May 18 16:23:34 2023 +0100

    clk: renesas: rzg2l: Fix CPG_SIPLL5_CLK1 register write
    
    [ Upstream commit d1c20885d3b01e6a62e920af4b227abd294d22f3 ]
    
    As per the RZ/G2L HW(Rev.1.30 May2023) manual, there are no "write enable"
    bits in the CPG_SIPLL5_CLK1 register.  So fix the CPG_SIPLL5_CLK register
    write by removing the "write enable" bits.
    
    Fixes: 1561380ee72f ("clk: renesas: rzg2l: Add FOUTPOSTDIV clk support")
    Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Link: https://lore.kernel.org/r/20230518152334.514922-1-biju.das.jz@bp.renesas.com
    [geert: Remove CPG_SIPLL5_CLK1_*_WEN bit definitions]
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: rs9: Fix .driver_data content in i2c_device_id [+ + +]
Author: Marek Vasut <marek.vasut+renesas@mailbox.org>
Date:   Sun May 7 15:39:06 2023 +0200

    clk: rs9: Fix .driver_data content in i2c_device_id
    
    [ Upstream commit ad527ca87e4ea42d7baad2ce710b44069287931b ]
    
    The .driver_data content in i2c_device_id table must match the
    .data content in of_device_id table, else device_get_match_data()
    would return bogus value on i2c_device_id match. Align the two
    tables.
    
    The i2c_device_id table is now converted from of_device_id using
    's@.compatible = "renesas,\([^"]\+"\), .data = \(.*\)@"\1, .driver_data = (kernel_ulong_t)\2@'
    
    Fixes: 892e0ddea1aa ("clk: rs9: Add Renesas 9-series PCIe clock generator driver")
    Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
    Link: https://lore.kernel.org/r/20230507133906.15061-3-marek.vasut+renesas@mailbox.org
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: si5341: check return value of {devm_}kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Tue May 30 12:39:09 2023 +0300

    clk: si5341: check return value of {devm_}kasprintf()
    
    [ Upstream commit 36e4ef82016a2b785cf2317eade77e76699b7bff ]
    
    {devm_}kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: 3044a860fd09 ("clk: Add Si5341/Si5340 driver")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230530093913.1656095-5-claudiu.beznea@microchip.com
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: si5341: free unused memory on probe failure [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Tue May 30 12:39:10 2023 +0300

    clk: si5341: free unused memory on probe failure
    
    [ Upstream commit 267ad94b13c53d8c99a336f0841b1fa1595b1d0f ]
    
    Pointers from synth_clock_names[] should be freed at the end of probe
    either on probe success or failure path.
    
    Fixes: b7bbf6ec4940 ("clk: si5341: Allow different output VDD_SEL values")
    Fixes: 9b13ff4340df ("clk: si5341: Add sysfs properties to allow checking/resetting device faults")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230530093913.1656095-6-claudiu.beznea@microchip.com
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: si5341: return error if one synth clock registration fails [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Tue May 30 12:39:08 2023 +0300

    clk: si5341: return error if one synth clock registration fails
    
    [ Upstream commit 2560114c06d7a752b3f4639f28cece58fed11267 ]
    
    In case devm_clk_hw_register() fails for one of synth clocks the probe
    continues. Later on, when registering output clocks which have as parents
    all the synth clocks, in case there is registration failure for at least
    one synth clock the information passed to clk core for registering output
    clock is not right: init.num_parents is fixed but init.parents may contain
    an array with less parents.
    
    Fixes: 3044a860fd09 ("clk: Add Si5341/Si5340 driver")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230530093913.1656095-4-claudiu.beznea@microchip.com
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: tegra: tegra124-emc: Fix potential memory leak [+ + +]
Author: Yuan Can <yuancan@huawei.com>
Date:   Fri Dec 9 09:41:24 2022 +0000

    clk: tegra: tegra124-emc: Fix potential memory leak
    
    [ Upstream commit 53a06e5924c0d43c11379a08c5a78529c3e61595 ]
    
    The tegra and tegra needs to be freed in the error handling path, otherwise
    it will be leaked.
    
    Fixes: 2db04f16b589 ("clk: tegra: Add EMC clock driver")
    Signed-off-by: Yuan Can <yuancan@huawei.com>
    Link: https://lore.kernel.org/r/20221209094124.71043-1-yuancan@huawei.com
    Acked-by: Thierry Reding <treding@nvidia.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: ti: clkctrl: check return value of kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Tue May 30 12:39:12 2023 +0300

    clk: ti: clkctrl: check return value of kasprintf()
    
    [ Upstream commit bd46cd0b802d9c9576ca78007aa084ae3e74907b ]
    
    kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: 852049594b9a ("clk: ti: clkctrl: convert subclocks to use proper names also")
    Fixes: 6c3090520554 ("clk: ti: clkctrl: Fix hidden dependency to node name")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230530093913.1656095-8-claudiu.beznea@microchip.com
    Reviewed-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: vc5: check memory returned by kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Tue May 30 12:39:06 2023 +0300

    clk: vc5: check memory returned by kasprintf()
    
    [ Upstream commit 144601f6228de5598f03e693822b60a95c367a17 ]
    
    kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: f491276a5168 ("clk: vc5: Allow Versaclock driver to support multiple instances")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230530093913.1656095-2-claudiu.beznea@microchip.com
    Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: vc5: Fix .driver_data content in i2c_device_id [+ + +]
Author: Marek Vasut <marek.vasut+renesas@mailbox.org>
Date:   Sun May 7 15:39:04 2023 +0200

    clk: vc5: Fix .driver_data content in i2c_device_id
    
    [ Upstream commit be3471c5bd9b921c9adfab7948e8021611639164 ]
    
    The .driver_data content in i2c_device_id table must match the
    .data content in of_device_id table, else device_get_match_data()
    would return bogus value on i2c_device_id match. Align the two
    tables.
    
    The i2c_device_id table is now converted from of_device_id using
    's@.compatible = "idt,\([^"]\+"\), .data = \(.*\)@"\1, .driver_data = (kernel_ulong_t)\2@'
    
    Fixes: 9adddb01ce5f ("clk: vc5: Add structure to describe particular chip features")
    Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
    Link: https://lore.kernel.org/r/20230507133906.15061-1-marek.vasut+renesas@mailbox.org
    Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: vc5: Use `clamp()` to restrict PLL range [+ + +]
Author: Lars-Peter Clausen <lars@metafoo.de>
Date:   Sat Jan 14 15:34:58 2023 -0800

    clk: vc5: Use `clamp()` to restrict PLL range
    
    [ Upstream commit 3ed741db04f58e8df0d46cec7ecfc4bfd075f047 ]
    
    The VCO frequency needs to be within a certain range and the driver
    enforces this.
    
    Make use of the clamp macro to implement this instead of open-coding it.
    This makes the code a bit shorter and also semanticly stronger.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    Link: https://lore.kernel.org/r/20230114233500.3294789-1-lars@metafoo.de
    Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Stable-dep-of: be3471c5bd9b ("clk: vc5: Fix .driver_data content in i2c_device_id")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

clk: vc7: Fix .driver_data content in i2c_device_id [+ + +]
Author: Marek Vasut <marek.vasut+renesas@mailbox.org>
Date:   Sun May 7 15:39:05 2023 +0200

    clk: vc7: Fix .driver_data content in i2c_device_id
    
    [ Upstream commit b5e10beeafaa3266559c582dde7534ae3fe8cefb ]
    
    The .driver_data content in i2c_device_id table must match the
    .data content in of_device_id table, else device_get_match_data()
    would return bogus value on i2c_device_id match. Align the two
    tables.
    
    The i2c_device_id table is now converted from of_device_id using
    's@.compatible = "renesas,\([^"]\+"\), .data = \(.*\)@"\1, .driver_data = (kernel_ulong_t)\2@'
    
    Fixes: 48c5e98fedd9 ("clk: Renesas versaclock7 ccf device driver")
    Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
    Link: https://lore.kernel.org/r/20230507133906.15061-2-marek.vasut+renesas@mailbox.org
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
clocksource/drivers/cadence-ttc: Fix memory leak in ttc_timer_probe [+ + +]
Author: Feng Mingxi <m202271825@hust.edu.cn>
Date:   Tue Apr 25 06:56:11 2023 +0000

    clocksource/drivers/cadence-ttc: Fix memory leak in ttc_timer_probe
    
    [ Upstream commit 8b5bf64c89c7100c921bd807ba39b2eb003061ab ]
    
    Smatch reports:
    drivers/clocksource/timer-cadence-ttc.c:529 ttc_timer_probe()
    warn: 'timer_baseaddr' from of_iomap() not released on lines: 498,508,516.
    
    timer_baseaddr may have the problem of not being released after use,
    I replaced it with the devm_of_iomap() function and added the clk_put()
    function to cleanup the "clk_ce" and "clk_cs".
    
    Fixes: e932900a3279 ("arm: zynq: Use standard timer binding")
    Fixes: 70504f311d4b ("clocksource/drivers/cadence_ttc: Convert init function to return error")
    Signed-off-by: Feng Mingxi <m202271825@hust.edu.cn>
    Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
    Acked-by: Michal Simek <michal.simek@amd.com>
    Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Link: https://lore.kernel.org/r/20230425065611.702917-1-m202271825@hust.edu.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
coresight: Fix loss of connection info when a module is unloaded [+ + +]
Author: James Clark <james.clark@arm.com>
Date:   Tue Apr 25 15:35:28 2023 +0100

    coresight: Fix loss of connection info when a module is unloaded
    
    [ Upstream commit c45b2835e7b205783bdfe08cc98fa86a7c5eeb74 ]
    
    child_fwnode should be a read only property based on the DT or ACPI. If
    it's cleared on the parent device when a child is unloaded, then when
    the child is loaded again the connection won't be remade.
    
    child_dev should be cleared instead which signifies that the connection
    should be remade when the child_fwnode registers a new coresight_device.
    
    Similarly the reference count shouldn't be decremented as long as the
    parent device exists. The correct place to drop the reference is in
    coresight_release_platform_data() which is already done.
    
    Reproducible on Juno with the following steps:
    
      # load all coresight modules.
      $ cd /sys/bus/coresight/devices/
      $ echo 1 > tmc_etr0/enable_sink
      $ echo 1 > etm0/enable_source
      # Works fine ^
    
      $ echo 0 > etm0/enable_source
      $ rmmod coresight-funnel
      $ modprobe coresight-funnel
      $ echo 1 > etm0/enable_source
      -bash: echo: write error: Invalid argument
    
    Fixes: 37ea1ffddffa ("coresight: Use fwnode handle instead of device names")
    Fixes: 2af89ebacf29 ("coresight: Clear the connection field properly")
    Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Reviewed-by: Mike Leach <mike.leach@linaro.org>
    Signed-off-by: James Clark <james.clark@arm.com>
    Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Link: https://lore.kernel.org/r/20230425143542.2305069-2-james.clark@arm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
cpufreq: intel_pstate: Fix energy_performance_preference for passive [+ + +]
Author: Tero Kristo <tero.kristo@linux.intel.com>
Date:   Wed Jun 21 09:58:39 2023 +0300

    cpufreq: intel_pstate: Fix energy_performance_preference for passive
    
    [ Upstream commit 03f44ffb3d5be2fceda375d92c70ab6de4df7081 ]
    
    If the intel_pstate driver is set to passive mode, then writing the
    same value to the energy_performance_preference sysfs twice will fail.
    This is caused by the wrong return value used (index of the matched
    energy_perf_string), instead of the length of the passed in parameter.
    Fix by forcing the internal return value to zero when the same
    preference is passed in by user. This same issue is not present when
    active mode is used for the driver.
    
    Fixes: f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode with HWP enabled")
    Reported-by: Niklas Neronin <niklas.neronin@intel.com>
    Signed-off-by: Tero Kristo <tero.kristo@linux.intel.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

cpufreq: mediatek: correct voltages for MT7622 and MT7623 [+ + +]
Author: Daniel Golle <daniel@makrotopia.org>
Date:   Mon Jun 5 15:18:12 2023 +0100

    cpufreq: mediatek: correct voltages for MT7622 and MT7623
    
    [ Upstream commit f85534113f5ae90a52521cdb9e9977a43ee42626 ]
    
    The MT6380 regulator typically used together with MT7622 does not
    support the current maximum processor and SRAM voltage in the cpufreq
    driver (1360000uV).
    For MT7622 limit processor and SRAM supply voltages to 1350000uV to
    avoid having the tracking algorithm request unsupported voltages from
    the regulator.
    
    On MT7623 there is no separate SRAM supply and the maximum voltage used
    is 1300000uV. Create dedicated platform data for MT7623 to cover that
    case as well.
    
    Fixes: 0883426fd07e3 ("cpufreq: mediatek: Raise proc and sram max voltage for MT7622/7623")
    Suggested-by: Jia-wei Chang <Jia-wei.Chang@mediatek.com>
    Signed-off-by: Daniel Golle <daniel@makrotopia.org>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
crypto: jitter - correct health test during initialization [+ + +]
Author: Stephan Müller <smueller@chronox.de>
Date:   Thu May 25 19:00:05 2023 +0200

    crypto: jitter - correct health test during initialization
    
    [ Upstream commit d23659769ad1bf2cbafaa0efcbae20ef1a74f77e ]
    
    With the update of the permanent and intermittent health errors, the
    actual indicator for the health test indicates a potential error only
    for the one offending time stamp gathered in the current iteration
    round. The next iteration round will "overwrite" the health test result.
    
    Thus, the entropy collection loop in jent_gen_entropy checks for
    the health test failure upon each loop iteration. However, the
    initialization operation checked for the APT health test once for
    an APT window which implies it would not catch most errors.
    
    Thus, the check for all health errors is now invoked unconditionally
    during each loop iteration for the startup test.
    
    With the change, the error JENT_ERCT becomes unused as all health
    errors are only reported with the JENT_HEALTH return code. This
    allows the removal of the error indicator.
    
    Fixes: 3fde2fe99aa6 ("crypto: jitter - permanent and intermittent health errors"
    )
    Reported-by: Joachim Vandersmissen <git@jvdsn.com>
    Signed-off-by: Stephan Mueller <smueller@chronox.de>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

crypto: kpp - Add helper to set reqsize [+ + +]
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Tue Nov 22 17:24:01 2022 +0800

    crypto: kpp - Add helper to set reqsize
    
    [ Upstream commit 56861cbde1b9f3b34d300e6ba87f2c3de1a9c309 ]
    
    The value of reqsize should only be changed through a helper.
    To do so we need to first add a helper for this.
    
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Stable-dep-of: eb7713f5ca97 ("crypto: qat - unmap buffer before free for DH")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

crypto: marvell/cesa - Fix type mismatch warning [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 23 10:33:04 2023 +0200

    crypto: marvell/cesa - Fix type mismatch warning
    
    [ Upstream commit efbc7764c4446566edb76ca05e903b5905673d2e ]
    
    Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") uncovered
    a type mismatch in cesa 3des support that leads to a memcpy beyond the
    end of a structure:
    
    In function 'fortify_memcpy_chk',
        inlined from 'mv_cesa_des3_ede_setkey' at drivers/crypto/marvell/cesa/cipher.c:307:2:
    include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
      583 |                         __write_overflow_field(p_size_field, size);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    This is probably harmless as the actual data that is copied has the correct
    type, but clearly worth fixing nonetheless.
    
    Fixes: 4ada48397823 ("crypto: marvell/cesa - add Triple-DES support")
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

crypto: nx - fix build warnings when DEBUG_FS is not enabled [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Fri May 19 15:33:34 2023 -0700

    crypto: nx - fix build warnings when DEBUG_FS is not enabled
    
    [ Upstream commit b04b076fb56560b39d695ac3744db457e12278fd ]
    
    Fix build warnings when DEBUG_FS is not enabled by using an empty
    do-while loop instead of a value:
    
    In file included from ../drivers/crypto/nx/nx.c:27:
    ../drivers/crypto/nx/nx.c: In function 'nx_register_algs':
    ../drivers/crypto/nx/nx.h:173:33: warning: statement with no effect [-Wunused-value]
      173 | #define NX_DEBUGFS_INIT(drv)    (0)
    ../drivers/crypto/nx/nx.c:573:9: note: in expansion of macro 'NX_DEBUGFS_INIT'
      573 |         NX_DEBUGFS_INIT(&nx_driver);
    ../drivers/crypto/nx/nx.c: In function 'nx_remove':
    ../drivers/crypto/nx/nx.h:174:33: warning: statement with no effect [-Wunused-value]
      174 | #define NX_DEBUGFS_FINI(drv)    (0)
    ../drivers/crypto/nx/nx.c:793:17: note: in expansion of macro 'NX_DEBUGFS_FINI'
      793 |                 NX_DEBUGFS_FINI(&nx_driver);
    
    Also, there is no need to build nx_debugfs.o when DEBUG_FS is not
    enabled, so change the Makefile to accommodate that.
    
    Fixes: ae0222b7289d ("powerpc/crypto: nx driver code supporting nx encryption")
    Fixes: aef7b31c8833 ("powerpc/crypto: Build files for the nx device driver")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Cc: Breno Leitão <leitao@debian.org>
    Cc: Nayna Jain <nayna@linux.ibm.com>
    Cc: Paulo Flabiano Smorigo <pfsmorigo@gmail.com>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: linux-crypto@vger.kernel.org
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
    Cc: linuxppc-dev@lists.ozlabs.org
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

crypto: qat - unmap buffer before free for DH [+ + +]
Author: Hareshx Sankar Raj <hareshx.sankar.raj@intel.com>
Date:   Mon Jun 5 22:06:06 2023 +0100

    crypto: qat - unmap buffer before free for DH
    
    [ Upstream commit eb7713f5ca97697b92f225127440d1525119b8de ]
    
    The callback function for DH frees the memory allocated for the
    destination buffer before unmapping it.
    This sequence is wrong.
    
    Change the cleanup sequence to unmap the buffer before freeing it.
    
    Fixes: 029aa4624a7f ("crypto: qat - remove dma_free_coherent() for DH")
    Signed-off-by: Hareshx Sankar Raj <hareshx.sankar.raj@intel.com>
    Co-developed-by: Bolemx Sivanagaleela <bolemx.sivanagaleela@intel.com>
    Signed-off-by: Bolemx Sivanagaleela <bolemx.sivanagaleela@intel.com>
    Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

crypto: qat - unmap buffers before free for RSA [+ + +]
Author: Hareshx Sankar Raj <hareshx.sankar.raj@intel.com>
Date:   Mon Jun 5 22:06:07 2023 +0100

    crypto: qat - unmap buffers before free for RSA
    
    [ Upstream commit d776b25495f2c71b9dbf1f5e53b642215ba72f3c ]
    
    The callback function for RSA frees the memory allocated for the source
    and destination buffers before unmapping them.
    This sequence is wrong.
    
    Change the cleanup sequence to unmap the buffers before freeing them.
    
    Fixes: 3dfaf0071ed7 ("crypto: qat - remove dma_free_coherent() for RSA")
    Signed-off-by: Hareshx Sankar Raj <hareshx.sankar.raj@intel.com>
    Co-developed-by: Bolemx Sivanagaleela <bolemx.sivanagaleela@intel.com>
    Signed-off-by: Bolemx Sivanagaleela <bolemx.sivanagaleela@intel.com>
    Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

crypto: qat - Use helper to set reqsize [+ + +]
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Tue Nov 22 17:30:58 2022 +0800

    crypto: qat - Use helper to set reqsize
    
    [ Upstream commit 80e62ad58db084920d8cf23323b713391e09f374 ]
    
    The value of reqsize must only be changed through the helper.
    
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Stable-dep-of: eb7713f5ca97 ("crypto: qat - unmap buffer before free for DH")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dax/kmem: Pass valid argument to memory_group_register_static [+ + +]
Author: Tarun Sahu <tsahu@linux.ibm.com>
Date:   Wed Jun 21 21:20:25 2023 +0530

    dax/kmem: Pass valid argument to memory_group_register_static
    
    [ Upstream commit 46e66dab8565f742374e9cc4ff7d35f344d774e2 ]
    
    memory_group_register_static takes maximum number of pages as the argument
    while dev_dax_kmem_probe passes total_len (in bytes) as the argument.
    
    IIUC, I don't see any crash/panic impact as such. As,
    memory_group_register_static just set the max_pages limit which is used in
    auto_movable_zone_for_pfn to determine the zone.
    
    which might cause these condition to behave differently,
    
    This will be true always so jump will happen to kernel_zone
        ...
        if (!auto_movable_can_online_movable(NUMA_NO_NODE, group, nr_pages))
            goto kernel_zone;
    
        ...
        kernel_zone:
            return default_kernel_zone_for_pfn(nid, pfn, nr_pages);
    
    Here, In below, zone_intersects compare range will be larger as nr_pages
    will be higher (derived from total_len passed in dev_dax_kmem_probe).
    
        ...
        static struct zone *default_kernel_zone_for_pfn(int nid, unsigned long start_pfn,
                    unsigned long nr_pages)
        {
            struct pglist_data *pgdat = NODE_DATA(nid);
            int zid;
    
            for (zid = 0; zid < ZONE_NORMAL; zid++) {
                    struct zone *zone = &pgdat->node_zones[zid];
    
                    if (zone_intersects(zone, start_pfn, nr_pages))
                            return zone;
            }
    
            return &pgdat->node_zones[ZONE_NORMAL];
        }
    
    Incorrect zone will be returned here, which in later time might cause bigger
    problem.
    
    Fixes: eedf634aac3b ("dax/kmem: use a single static memory group for a single probed unit")
    Signed-off-by: Tarun Sahu <tsahu@linux.ibm.com>
    Link: https://lore.kernel.org/r/20230621155025.370672-1-tsahu@linux.ibm.com
    Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dax: Fix dax_mapping_release() use after free [+ + +]
Author: Dan Williams <dan.j.williams@intel.com>
Date:   Fri Jun 2 23:13:54 2023 -0700

    dax: Fix dax_mapping_release() use after free
    
    [ Upstream commit 6d24b170a9db0456f577b1ab01226a2254c016a8 ]
    
    A CONFIG_DEBUG_KOBJECT_RELEASE test of removing a device-dax region
    provider (like modprobe -r dax_hmem) yields:
    
     kobject: 'mapping0' (ffff93eb460e8800): kobject_release, parent 0000000000000000 (delayed 2000)
     [..]
     DEBUG_LOCKS_WARN_ON(1)
     WARNING: CPU: 23 PID: 282 at kernel/locking/lockdep.c:232 __lock_acquire+0x9fc/0x2260
     [..]
     RIP: 0010:__lock_acquire+0x9fc/0x2260
     [..]
     Call Trace:
      <TASK>
     [..]
      lock_acquire+0xd4/0x2c0
      ? ida_free+0x62/0x130
      _raw_spin_lock_irqsave+0x47/0x70
      ? ida_free+0x62/0x130
      ida_free+0x62/0x130
      dax_mapping_release+0x1f/0x30
      device_release+0x36/0x90
      kobject_delayed_cleanup+0x46/0x150
    
    Due to attempting ida_free() on an ida object that has already been
    freed. Devices typically only hold a reference on their parent while
    registered. If a child needs a parent object to complete its release it
    needs to hold a reference that it drops from its release callback.
    Arrange for a dax_mapping to pin its parent dev_dax instance until
    dax_mapping_release().
    
    Fixes: 0b07ce872a9e ("device-dax: introduce 'mapping' devices")
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Link: https://lore.kernel.org/r/168577283412.1672036.16111545266174261446.stgit@dwillia2-xfh.jf.intel.com
    Reviewed-by: Dave Jiang <dave.jiang@intel.com>
    Reviewed-by: Fan Ni <fan.ni@samsung.com>
    Reviewed-by: Ira Weiny <ira.weiny@intel.com>
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

dax: Introduce alloc_dev_dax_id() [+ + +]
Author: Dan Williams <dan.j.williams@intel.com>
Date:   Fri Jun 2 23:14:05 2023 -0700

    dax: Introduce alloc_dev_dax_id()
    
    [ Upstream commit 70aab281e18c68a1284bc387de127c2fc0bed3f8 ]
    
    The reference counting of dax_region objects is needlessly complicated,
    has lead to confusion [1], and has hidden a bug [2]. Towards cleaning up
    that mess introduce alloc_dev_dax_id() to minimize the holding of a
    dax_region reference to only what dev_dax_release() needs, the
    dax_region->ida.
    
    Part of the reason for the mess was the design to dereference a
    dax_region in all cases in free_dev_dax_id() even if the id was
    statically assigned by the upper level dax_region driver. Remove the
    need to call "is_static(dax_region)" by tracking whether the id is
    dynamic directly in the dev_dax instance itself.
    
    With that flag the dax_region pinning and release per dev_dax instance
    can move to alloc_dev_dax_id() and free_dev_dax_id() respectively.
    
    A follow-on cleanup address the unnecessary references in the dax_region
    setup and drivers.
    
    Fixes: 0f3da14a4f05 ("device-dax: introduce 'seed' devices")
    Link: http://lore.kernel.org/r/20221203095858.612027-1-liuyongqiang13@huawei.com [1]
    Link: http://lore.kernel.org/r/3cf0890b-4eb0-e70e-cd9c-2ecc3d496263@hpe.com [2]
    Reported-by: Yongqiang Liu <liuyongqiang13@huawei.com>
    Reported-by: Paul Cassella <cassella@hpe.com>
    Reported-by: Ira Weiny <ira.weiny@intel.com>
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Link: https://lore.kernel.org/r/168577284563.1672036.13493034988900989554.stgit@dwillia2-xfh.jf.intel.com
    Reviewed-by: Ira Weiny <ira.weiny@intel.com>
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
device property: Clarify description of returned value in some functions [+ + +]
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Fri Feb 17 15:33:44 2023 +0200

    device property: Clarify description of returned value in some functions
    
    [ Upstream commit 295209ca7b5b3aa6375d6190311b2ae804dbcf65 ]
    
    Some of the functions do not provide Return: section on absence of which
    kernel-doc complains. Besides that several functions return the fwnode
    handle with incremented reference count. Add a respective note to make sure
    that the caller decrements it when it's not needed anymore.
    
    While at it, unify the style of the Return: sections.
    
    Reported-by: Daniel Kaehn <kaehndan@gmail.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Acked-by: Rafael J. Wysocki <rafael@kernel.org>
    Link: https://lore.kernel.org/r/20230217133344.79278-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Stable-dep-of: 39d422555e43 ("drivers: fwnode: fix fwnode_irq_get[_byname]()")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

device property: Fix documentation for fwnode_get_next_parent() [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed Dec 7 15:22:18 2022 +0400

    device property: Fix documentation for fwnode_get_next_parent()
    
    [ Upstream commit f18caf261398a7f2de4fa3f600deb87072fe7b8d ]
    
    Use fwnode_handle_put() on the node pointer to release the refcount.
    Change fwnode_handle_node() to fwnode_handle_put().
    
    Fixes: 233872585de1 ("device property: Add fwnode_get_next_parent()")
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Daniel Scally <djrscally@gmail.com>
    Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20221207112219.2652411-1-linmq006@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Stable-dep-of: 39d422555e43 ("drivers: fwnode: fix fwnode_irq_get[_byname]()")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dm ioctl: Avoid double-fetch of version [+ + +]
Author: Demi Marie Obenour <demi@invisiblethingslab.com>
Date:   Sat Jun 3 10:52:42 2023 -0400

    dm ioctl: Avoid double-fetch of version
    
    [ Upstream commit 249bed821b4db6d95a99160f7d6d236ea5fe6362 ]
    
    The version is fetched once in check_version(), which then does some
    validation and then overwrites the version in userspace with the API
    version supported by the kernel.  copy_params() then fetches the version
    from userspace *again*, and this time no validation is done.  The result
    is that the kernel's version number is completely controllable by
    userspace, provided that userspace can win a race condition.
    
    Fix this flaw by not copying the version back to the kernel the second
    time.  This is not exploitable as the version is not further used in the
    kernel.  However, it could become a problem if future patches start
    relying on the version field.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
    Signed-off-by: Mike Snitzer <snitzer@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

dm ioctl: have constant on the right side of the test [+ + +]
Author: Heinz Mauelshagen <heinzm@redhat.com>
Date:   Tue Feb 7 21:47:45 2023 +0100

    dm ioctl: have constant on the right side of the test
    
    [ Upstream commit 5cae0aa77397015f530aeb34f3ced32db6ac2875 ]
    
    Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@kernel.org>
    Stable-dep-of: 249bed821b4d ("dm ioctl: Avoid double-fetch of version")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dm: avoid split of quoted strings where possible [+ + +]
Author: Heinz Mauelshagen <heinzm@redhat.com>
Date:   Fri Feb 3 18:55:47 2023 +0100

    dm: avoid split of quoted strings where possible
    
    [ Upstream commit 2e84fecf19e1694338deec8bf6c90ff84f8f31fb ]
    
    Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@kernel.org>
    Stable-dep-of: 249bed821b4d ("dm ioctl: Avoid double-fetch of version")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

dm: fix undue/missing spaces [+ + +]
Author: Heinz Mauelshagen <heinzm@redhat.com>
Date:   Mon Jan 30 21:43:57 2023 +0100

    dm: fix undue/missing spaces
    
    [ Upstream commit 43be9c743c2553519c2093d1798b542f28095a51 ]
    
    Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@kernel.org>
    Stable-dep-of: 249bed821b4d ("dm ioctl: Avoid double-fetch of version")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
driver: soc: xilinx: use _safe loop iterator to avoid a use after free [+ + +]
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Fri Apr 21 13:44:54 2023 +0300

    driver: soc: xilinx: use _safe loop iterator to avoid a use after free
    
    [ Upstream commit c58da0ba3e5c86e51e2c1557afaf6f71e00c4533 ]
    
    The hash_for_each_possible() loop dereferences "eve_data" to get the
    next item on the list.  However the loop frees eve_data so it leads to
    a use after free.  Use hash_for_each_possible_safe() instead.
    
    Fixes: c7fdb2404f66 ("drivers: soc: xilinx: add xilinx event management driver")
    Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
    Link: https://lore.kernel.org/r/761e0e4a-4caf-4a71-8f47-1c6ad908a848@kili.mountain
    Signed-off-by: Michal Simek <michal.simek@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drivers/perf: hisi: Don't migrate perf to the CPU going to teardown [+ + +]
Author: Junhao He <hejunhao3@huawei.com>
Date:   Thu Jun 8 19:43:26 2023 +0800

    drivers/perf: hisi: Don't migrate perf to the CPU going to teardown
    
    [ Upstream commit 7a6a9f1c5a0a875a421db798d4b2ee022dc1ee1a ]
    
    The driver needs to migrate the perf context if the current using CPU going
    to teardown. By the time calling the cpuhp::teardown() callback the
    cpu_online_mask() hasn't updated yet and still includes the CPU going to
    teardown. In current driver's implementation we may migrate the context
    to the teardown CPU and leads to the below calltrace:
    
    ...
    [  368.104662][  T932] task:cpuhp/0         state:D stack:    0 pid:   15 ppid:     2 flags:0x00000008
    [  368.113699][  T932] Call trace:
    [  368.116834][  T932]  __switch_to+0x7c/0xbc
    [  368.120924][  T932]  __schedule+0x338/0x6f0
    [  368.125098][  T932]  schedule+0x50/0xe0
    [  368.128926][  T932]  schedule_preempt_disabled+0x18/0x24
    [  368.134229][  T932]  __mutex_lock.constprop.0+0x1d4/0x5dc
    [  368.139617][  T932]  __mutex_lock_slowpath+0x1c/0x30
    [  368.144573][  T932]  mutex_lock+0x50/0x60
    [  368.148579][  T932]  perf_pmu_migrate_context+0x84/0x2b0
    [  368.153884][  T932]  hisi_pcie_pmu_offline_cpu+0x90/0xe0 [hisi_pcie_pmu]
    [  368.160579][  T932]  cpuhp_invoke_callback+0x2a0/0x650
    [  368.165707][  T932]  cpuhp_thread_fun+0xe4/0x190
    [  368.170316][  T932]  smpboot_thread_fn+0x15c/0x1a0
    [  368.175099][  T932]  kthread+0x108/0x13c
    [  368.179012][  T932]  ret_from_fork+0x10/0x18
    ...
    
    Use function cpumask_any_but() to find one correct active cpu to fixes
    this issue.
    
    Fixes: 8404b0fbc7fb ("drivers/perf: hisi: Add driver for HiSilicon PCIe PMU")
    Signed-off-by: Junhao He <hejunhao3@huawei.com>
    Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: Yicong Yang <yangyicong@hisilicon.com>
    Acked-by: Mark Rutland <mark.rutland@arm.com>
    Link: https://lore.kernel.org/r/20230608114326.27649-1-hejunhao3@huawei.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drivers: fwnode: fix fwnode_irq_get[_byname]() [+ + +]
Author: Matti Vaittinen <mazziesaccount@gmail.com>
Date:   Mon May 29 09:22:33 2023 +0300

    drivers: fwnode: fix fwnode_irq_get[_byname]()
    
    [ Upstream commit 39d422555e43379516d4d13f5b7162a3dee6e646 ]
    
    The fwnode_irq_get() and the fwnode_irq_get_byname() return 0 upon
    device-tree IRQ mapping failure. This is contradicting the
    fwnode_irq_get_byname() function documentation and can potentially be a
    source of errors like:
    
    int probe(...) {
            ...
    
            irq = fwnode_irq_get_byname();
            if (irq <= 0)
                    return irq;
    
            ...
    }
    
    Here we do correctly check the return value from fwnode_irq_get_byname()
    but the driver probe will now return success. (There was already one
    such user in-tree).
    
    Change the fwnode_irq_get_byname() to work as documented and make also the
    fwnode_irq_get() follow same common convention returning a negative errno
    upon failure.
    
    Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname")
    Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Suggested-by: Jonathan Cameron <jic23@kernel.org>
    Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    
    Message-ID: <3e64fe592dc99e27ef9a0b247fc49fa26b6b8a58.1685340157.git.mazziesaccount@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drivers: meson: secure-pwrc: always enable DMA domain [+ + +]
Author: Alexey Romanov <avromanov@sberdevices.ru>
Date:   Sat Jun 10 12:04:14 2023 +0300

    drivers: meson: secure-pwrc: always enable DMA domain
    
    [ Upstream commit 0bb4644d583789c97e74d3e3047189f0c59c4742 ]
    
    Starting from commit e45f243409db ("firmware: meson_sm:
    populate platform devices from sm device tree data") pwrc
    is probed successfully and disables unused pwr domains.
    By A1 SoC family design, any TEE requires DMA pwr domain
    always enabled.
    
    Fixes: b3dde5013e13 ("soc: amlogic: Add support for Secure power domains controller")
    Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
    Acked-by: Neil Armstrong <neil.armstrong@linaro.org>
    Link: https://lore.kernel.org/r/20230610090414.90529-1-avromanov@sberdevices.ru
    [narmstrong: added fixes tag]
    Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/amd/display: Add logging for display MALL refresh setting [+ + +]
Author: Wesley Chalmers <Wesley.Chalmers@amd.com>
Date:   Wed Jun 10 11:49:16 2020 -0400

    drm/amd/display: Add logging for display MALL refresh setting
    
    [ Upstream commit cd8f067a46d34dee3188da184912ae3d64d98444 ]
    
    [WHY]
    Add log entry for when display refresh from MALL
    settings are sent to SMU.
    
    Fixes: 1664641ea946 ("drm/amd/display: Add logger for SMU msg")
    Signed-off-by: Wesley Chalmers <Wesley.Chalmers@amd.com>
    Acked-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/amd/display: Explicitly specify update type per plane info change [+ + +]
Author: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Date:   Thu May 2 13:21:48 2019 -0400

    drm/amd/display: Explicitly specify update type per plane info change
    
    [ Upstream commit 710cc1e7cd461446a9325c9bd1e9a54daa462952 ]
    
    [Why]
    The bit for flip addr is being set causing the determination for
    FAST vs MEDIUM to always return MEDIUM when plane info is provided
    as a surface update. This causes extreme stuttering for the typical
    atomic update path on Linux.
    
    [How]
    Don't use update_flags->raw for determining FAST vs MEDIUM. It's too
    fragile to changes like this.
    
    Explicitly specify the update type per update flag instead. It's not
    as clever as checking the bits itself but at least it's correct.
    
    Fixes: aa5fdb1ab5b6 ("drm/amd/display: Explicitly specify update type per plane info change")
    Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/amd/display: Fix a test CalculatePrefetchSchedule() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Mon Apr 17 23:35:08 2023 +0200

    drm/amd/display: Fix a test CalculatePrefetchSchedule()
    
    [ Upstream commit 960e27a5741cd3001996ff6ddfb3eb0ed3a4909d ]
    
    It is likely Height was expected here, instead of Width.
    
    Test the correct variable.
    
    Fixes: 17529ea2acfa ("drm/amd/display: Optimizations for DML math")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/amd/display: Fix a test dml32_rq_dlg_get_rq_reg() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Mon Apr 17 23:41:11 2023 +0200

    drm/amd/display: Fix a test dml32_rq_dlg_get_rq_reg()
    
    [ Upstream commit bafc31166aa7df5fa26ae0ad8196d1717e6cdea9 ]
    
    It is likely p1_min_meta_chunk_bytes was expected here, instead of
    min_meta_chunk_bytes.
    
    Test the correct variable.
    
    Fixes: dda4fb85e433 ("drm/amd/display: DML changes for DCN32/321")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/amd/display: Fix artifacting on eDP panels when engaging freesync video mode [+ + +]
Author: Aurabindo Pillai <aurabindo.pillai@amd.com>
Date:   Wed May 17 14:39:46 2023 -0400

    drm/amd/display: Fix artifacting on eDP panels when engaging freesync video mode
    
    [ Upstream commit b18f05a0666aecd5cb19c26a8305bcfa4e9d6502 ]
    
    [Why]
    When freesync video mode is enabled, switching resolution from native
    mode to one of the freesync video compatible modes can trigger continous
    artifacts on some eDP panels when running under KDE. The articating can be seen in the
    attached bug report.
    
    [How]
    Fix this by restricting updates that require full commit by using the same checks
    for stream and scaling changes in the the enable pass of dm_update_crtc_state()
    along with the check for compatible timings for freesync vide mode.
    
    Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2162
    Fixes: da5e14909776 ("drm/amd/display: Fix hang when skipping modeset")
    Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
    Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/amd: Don't try to enable secure display TA multiple times [+ + +]
Author: Mario Limonciello <mario.limonciello@amd.com>
Date:   Thu Jun 22 22:18:39 2023 -0500

    drm/amd: Don't try to enable secure display TA multiple times
    
    [ Upstream commit 5c6d52ff4b61e5267b25be714eb5a9ba2a338199 ]
    
    If the securedisplay TA failed to load the first time, it's unlikely
    to work again after a suspend/resume cycle or reset cycle and it appears
    to be causing problems in futher attempts.
    
    Fixes: e42dfa66d592 ("drm/amdgpu: Add secure display TA load for Renoir")
    Reported-by: Filip Hejsek <filip.hejsek@gmail.com>
    Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/2633
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function. [+ + +]
Author: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Date:   Fri Jun 9 14:06:43 2023 +0530

    drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function.
    
    [ Upstream commit d50dc746ff72b9c48812dac3344fa87fbde940a3 ]
    
    Fixes the following gcc with W=1:
    
    In file included from ./include/linux/string.h:253,
                     from ./include/linux/bitmap.h:11,
                     from ./include/linux/cpumask.h:12,
                     from ./arch/x86/include/asm/cpumask.h:5,
                     from ./arch/x86/include/asm/msr.h:11,
                     from ./arch/x86/include/asm/processor.h:22,
                     from ./arch/x86/include/asm/cpufeature.h:5,
                     from ./arch/x86/include/asm/thread_info.h:53,
                     from ./include/linux/thread_info.h:60,
                     from ./arch/x86/include/asm/preempt.h:7,
                     from ./include/linux/preempt.h:78,
                     from ./include/linux/spinlock.h:56,
                     from ./include/linux/mmzone.h:8,
                     from ./include/linux/gfp.h:7,
                     from ./include/linux/firmware.h:7,
                     from drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:26:
    In function ‘fortify_memcpy_chk’,
        inlined from ‘sienna_cichlid_append_powerplay_table’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:444:2,
        inlined from ‘sienna_cichlid_setup_pptable’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:506:8,
        inlined from ‘sienna_cichlid_setup_pptable’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:494:12:
    ./include/linux/fortify-string.h:413:4: warning: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
      413 |    __read_overflow2_field(q_size_field, size);
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    the compiler complains about the size calculation in the memcpy() -
    "sizeof(*smc_dpm_table) - sizeof(smc_dpm_table->table_header)" is much
    larger than what fits into table_member.
    
    Hence, reuse 'smu_memcpy_trailing' for nv1x
    
    Fixes: 7077b19a38240 ("drm/amd/pm: use macro to get pptable members")
    Suggested-by: Evan Quan <Evan.Quan@amd.com>
    Cc: Evan Quan <Evan.Quan@amd.com>
    Cc: Chengming Gui <Jack.Gui@amd.com>
    Cc: Christian König <christian.koenig@amd.com>
    Cc: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
    Reviewed-by: Evan Quan <evan.quan@amd.com>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/amdgpu: fix number of fence calculations [+ + +]
Author: Christian König <christian.koenig@amd.com>
Date:   Tue Jun 20 13:18:13 2023 +0200

    drm/amdgpu: fix number of fence calculations
    
    [ Upstream commit 570b295248b00c3cf4cf59e397de5cb2361e10c2 ]
    
    Since adding gang submit we need to take the gang size into account
    while reserving fences.
    
    Signed-off-by: Christian König <christian.koenig@amd.com>
    Fixes: 4624459c84d7 ("drm/amdgpu: add gang submit frontend v6")
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/amdgpu: Fix usage of UMC fill record in RAS [+ + +]
Author: Luben Tuikov <luben.tuikov@amd.com>
Date:   Sat Jun 10 06:19:15 2023 -0400

    drm/amdgpu: Fix usage of UMC fill record in RAS
    
    [ Upstream commit 71344a718a9fda8c551cdc4381d354f9a9907f6f ]
    
    The fixed commit listed in the Fixes tag below, introduced a bug in
    amdgpu_ras.c::amdgpu_reserve_page_direct(), in that when introducing the new
    amdgpu_umc_fill_error_record() and internally in that new function the physical
    address (argument "uint64_t retired_page"--wrong name) is right-shifted by
    AMDGPU_GPU_PAGE_SHIFT. Thus, in amdgpu_reserve_page_direct() when we pass
    "address" to that new function, we should NOT right-shift it, since this
    results, erroneously, in the page address to be 0 for first
    2^(2*AMDGPU_GPU_PAGE_SHIFT) memory addresses.
    
    This commit fixes this bug.
    
    Cc: Tao Zhou <tao.zhou1@amd.com>
    Cc: Hawking Zhang <Hawking.Zhang@amd.com>
    Cc: Alex Deucher <Alexander.Deucher@amd.com>
    Fixes: 400013b268cb ("drm/amdgpu: add umc_fill_error_record to make code more simple")
    Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
    Link: https://lore.kernel.org/r/20230610113536.10621-1-luben.tuikov@amd.com
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/amdkfd: Fix potential deallocation of previously deallocated memory. [+ + +]
Author: Daniil Dulov <d.dulov@aladdin.ru>
Date:   Thu May 11 04:23:14 2023 -0700

    drm/amdkfd: Fix potential deallocation of previously deallocated memory.
    
    [ Upstream commit cabbdea1f1861098991768d7bbf5a49ed1608213 ]
    
    Pointer mqd_mem_obj can be deallocated in kfd_gtt_sa_allocate().
    The function then returns non-zero value, which causes the second deallocation.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Fixes: d1f8f0d17d40 ("drm/amdkfd: Move non-sdma mqd allocation out of init_mqd")
    Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
    Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/bridge: anx7625: Convert to i2c's .probe_new() [+ + +]
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Fri Nov 18 23:35:51 2022 +0100

    drm/bridge: anx7625: Convert to i2c's .probe_new()
    
    [ Upstream commit 71450f8c824f5571d4af9e6e021b733085c8e690 ]
    
    The probe function doesn't make use of the i2c_device_id * parameter so it
    can be trivially converted.
    
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
    Link: https://lore.kernel.org/r/20221118224540.619276-18-uwe@kleine-koenig.org
    Signed-off-by: Robert Foss <robert.foss@linaro.org>
    Stable-dep-of: 1464e48d69ab ("drm/bridge: anx7625: Prevent endless probe loop")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: anx7625: Prevent endless probe loop [+ + +]
Author: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Date:   Thu May 18 15:39:02 2023 -0400

    drm/bridge: anx7625: Prevent endless probe loop
    
    [ Upstream commit 1464e48d69ab7a50a377c9d39f5e5eb3cee2722e ]
    
    During probe, the driver registers i2c dummy devices and populates the
    aux bus, which registers a device for the panel. After doing that, the
    driver can still defer probe if needed. This ordering of operations is
    troublesome however, because the deferred probe work will retry probing
    all pending devices every time a new device is registered. Therefore, if
    modules need to be loaded in order to satisfy the dependencies for this
    driver to complete probe, the kernel will stall, since it'll keep trying
    to probe the anx7625 driver, but never succeed, given that modules would
    only be loaded after the deferred probe work completes.
    
    Two changes are required to avoid this issue:
    * Move of_find_mipi_dsi_host_by_node(), which can defer probe, to before
      anx7625_register_i2c_dummy_clients() and
      devm_of_dp_aux_populate_ep_devices(), which register devices.
    * Make use of the done_probing callback when populating the aux bus,
      so that the bridge registration is only done after the panel is
      probed. This is required because the panel might need to defer probe,
      but the aux bus population needs the i2c dummy devices working, so
      this call couldn't just be moved to an earlier point in probe.
      One caveat is that if the panel is described outside the aux bus, the
      probe loop issue can still happen, but we don't have a way to avoid
      it in that case since there's no callback available.
    
    With this patch applied, it's possible to boot on
    mt8192-asurada-spherion with
    
    CONFIG_DRM_ANALOGIX_ANX7625=y
    CONFIG_MTK_MMSYS=m
    CONFIG_BACKLIGHT_PWM=y
    
    and also with
    
    CONFIG_DRM_ANALOGIX_ANX7625=y
    CONFIG_MTK_MMSYS=y
    CONFIG_BACKLIGHT_PWM=m
    
    Fixes: adca62ec370c ("drm/bridge: anx7625: Support reading edid through aux channel")
    Fixes: 269332997a16 ("drm/bridge: anx7625: Return -EPROBE_DEFER if the dsi host was not found")
    Reported-by: "kernelci.org bot" <bot@kernelci.org>
    Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230518193902.891121-1-nfraprado@collabora.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: Introduce pre_enable_prev_first to alter bridge init order [+ + +]
Author: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date:   Mon Dec 5 17:33:26 2022 +0000

    drm/bridge: Introduce pre_enable_prev_first to alter bridge init order
    
    [ Upstream commit 4fb912e5e19075874379cfcf074d90bd51ebf8ea ]
    
    DSI sink devices typically want the DSI host powered up and configured
    before they are powered up. pre_enable is the place this would normally
    happen, but they are called in reverse order from panel/connector towards
    the encoder, which is the "wrong" order.
    
    Add a new flag pre_enable_prev_first that any bridge can set
    to swap the order of pre_enable (and post_disable) for that and the
    immediately previous bridge.
    Should the immediately previous bridge also set the
    pre_enable_prev_first flag, the previous bridge to that will be called
    before either of those which requested pre_enable_prev_first.
    
    eg:
    - Panel
    - Bridge 1
    - Bridge 2 pre_enable_prev_first
    - Bridge 3
    - Bridge 4 pre_enable_prev_first
    - Bridge 5 pre_enable_prev_first
    - Bridge 6
    - Encoder
    Would result in pre_enable's being called as Panel, Bridge 1, Bridge 3,
    Bridge 2, Bridge 6, Bridge 5, Bridge 4, Encoder.
    
    Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
    Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
    Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
    Link: https://lore.kernel.org/r/20221205173328.1395350-5-dave.stevenson@raspberrypi.com
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Stable-dep-of: dd9e329af723 ("drm/bridge: ti-sn65dsi83: Fix enable/disable flow to meet spec")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: it6505: Move a variable assignment behind a null pointer check in receive_timing_debugfs_show() [+ + +]
Author: Markus Elfring <elfring@users.sourceforge.net>
Date:   Sun Apr 16 17:30:46 2023 +0200

    drm/bridge: it6505: Move a variable assignment behind a null pointer check in receive_timing_debugfs_show()
    
    [ Upstream commit 0be05a75de2916421e88e0d64b001984f54df0bd ]
    
    The address of a data structure member was determined before
    a corresponding null pointer check in the implementation of
    the function “receive_timing_debugfs_show”.
    
    Thus avoid the risk for undefined behaviour by moving the assignment
    for the variable “vid” behind the null pointer check.
    
    This issue was detected by using the Coccinelle software.
    
    Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver")
    Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
    Link: https://patchwork.freedesktop.org/patch/msgid/fa69384f-1485-142b-c4ee-3df54ac68a89@web.de
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358767: Switch to devm MIPI-DSI helpers [+ + +]
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Wed May 17 14:21:06 2023 +0200

    drm/bridge: tc358767: Switch to devm MIPI-DSI helpers
    
    [ Upstream commit f47d6140b7a4c858d82d263e7577ff6fb5279a9c ]
    
    DSI device registering and attaching needs to be undone upon
    deregistration. This fixes module unload/load.
    
    Fixes: bbfd3190b656 ("drm/bridge: tc358767: Add DSI-to-DPI mode support")
    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230517122107.1766673-1-alexander.stein@ew.tq-group.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: Add atomic_get_input_bus_fmts() implementation [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Mar 30 11:59:41 2023 +0200

    drm/bridge: tc358768: Add atomic_get_input_bus_fmts() implementation
    
    [ Upstream commit cec5ccef85bd0128cf895612de54a9d21d2015d0 ]
    
    Add atomic_get_input_bus_fmts() implementation, tc358768 has a parallel
    RGB input interface with the actual bus format depending on the amount
    of parallel input data lines.
    
    Without this change when the tc358768 is used with less than 24bit the
    color mapping is completely wrong.
    
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230330095941.428122-7-francesco@dolcini.it
    Stable-dep-of: ee18698e212b ("drm/bridge: tc358768: fix TCLK_TRAILCNT computation")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: always enable HS video mode [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Apr 27 16:29:26 2023 +0200

    drm/bridge: tc358768: always enable HS video mode
    
    [ Upstream commit 75a8aeac2573ab258c53676eba9b3796ea691988 ]
    
    Always enable HS video mode setting the TXMD bit, without this change no
    video output is present with DSI sinks that are setting
    MIPI_DSI_MODE_LPM flag (tested with LT8912B DSI-HDMI bridge).
    
    Previously the driver was enabling HS mode only when the DSI sink was
    not explicitly setting the MIPI_DSI_MODE_LPM, however this is not
    correct.
    
    The MIPI_DSI_MODE_LPM is supposed to indicate that the sink is willing
    to receive data in low power mode, however clearing the
    TC358768_DSI_CONTROL_TXMD bit will make the TC358768 send video in
    LP mode that is not the intended behavior.
    
    Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-2-francesco@dolcini.it
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: fix PLL parameters computation [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Apr 27 16:29:27 2023 +0200

    drm/bridge: tc358768: fix PLL parameters computation
    
    [ Upstream commit 6a4020b4c63911977aaf8047f904a300d15de739 ]
    
    According to Toshiba documentation the PLL input clock after the divider
    should be not less than 4MHz, fix the PLL parameters computation
    accordingly.
    
    Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-3-francesco@dolcini.it
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: fix PLL target frequency [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Apr 27 16:29:28 2023 +0200

    drm/bridge: tc358768: fix PLL target frequency
    
    [ Upstream commit ffd2e4bbea626d565b9817312b0fcfb382fecb88 ]
    
    Correctly compute the PLL target frequency, the current formula works
    correctly only when the input bus width is 24bit, actually to properly
    compute the PLL target frequency what is relevant is the bits-per-pixel
    on the DSI link.
    
    No regression expected since the DSI format is currently hard-coded as
    MIPI_DSI_FMT_RGB888.
    
    Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-4-francesco@dolcini.it
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: fix TCLK_TRAILCNT computation [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Apr 27 16:29:30 2023 +0200

    drm/bridge: tc358768: fix TCLK_TRAILCNT computation
    
    [ Upstream commit ee18698e212b1659dd0850d7e2ae0f22e16ed3d3 ]
    
    Correct computation of TCLK_TRAILCNT register.
    
    The driver does not implement non-continuous clock mode, so the actual
    value doesn't make a practical difference yet. However this change also
    ensures that the value does not write to reserved registers bits in case
    of under/overflow.
    
    This register must be set to a value that ensures that
    
    TCLK-TRAIL > 60ns
     and
    TEOT <= (105 ns + 12 x UI)
    
    with the actual value of TCLK-TRAIL being
    
    (TCLK_TRAILCNT + (1 to 2)) xHSByteClkCycle +
     (2 + (1 to 2)) * HSBYTECLKCycle - (PHY output delay)
    
    with PHY output delay being about
    
    (2 to 3) x MIPIBitClk cycle in the BitClk conversion.
    
    Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-2-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-3-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-4-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-5-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-2-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-3-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-4-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-5-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-2-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-3-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-4-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-5-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-2-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-3-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-4-francesco@dolcini.it
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-5-francesco@dolcini.it
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: fix TCLK_ZEROCNT computation [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Apr 27 16:29:29 2023 +0200

    drm/bridge: tc358768: fix TCLK_ZEROCNT computation
    
    [ Upstream commit f9cf811374f42fca31ac34aaf59ee2ae72b89879 ]
    
    Correct computation of TCLK_ZEROCNT register.
    
    This register must be set to a value that ensure that
    (TCLK-PREPARECNT + TCLK-ZERO) > 300ns
    
    with the actual value of (TCLK-PREPARECNT + TCLK-ZERO) being
    
    (1 to 2) + (TCLK_ZEROCNT + 1)) x HSByteClkCycle + (PHY output delay)
    
    with PHY output delay being about
    
    (2 to 3) x MIPIBitClk cycle in the BitClk conversion.
    
    Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-5-francesco@dolcini.it
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: fix THS_TRAILCNT computation [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Apr 27 16:29:33 2023 +0200

    drm/bridge: tc358768: fix THS_TRAILCNT computation
    
    [ Upstream commit bac7842cd179572e8e0fc2d7b5254e40c6e9e057 ]
    
    Correct computation of THS_TRAILCNT register.
    
    This register must be set to a value that ensure that
    THS_TRAIL > 60 ns + 4 x UI
     and
    THS_TRAIL > 8 x UI
     and
    THS_TRAIL < TEOT
     with
    TEOT = 105 ns + (12 x UI)
    
    with the actual value of THS_TRAIL being
    
    (1 + THS_TRAILCNT) x ByteClk cycle + ((1 to 2) + 2) xHSBYTECLK cycle +
     - (PHY output delay)
    
    with PHY output delay being about
    
    (8 + (5 to 6)) x MIPIBitClk cycle in the BitClk conversion.
    
    Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-9-francesco@dolcini.it
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: fix THS_ZEROCNT computation [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Apr 27 16:29:31 2023 +0200

    drm/bridge: tc358768: fix THS_ZEROCNT computation
    
    [ Upstream commit 77a089328da791118af9692543a5eedc79eb5fd4 ]
    
    Correct computation of THS_ZEROCNT register.
    
    This register must be set to a value that ensure that
    THS_PREPARE + THS_ZERO > 145ns + 10*UI
    
    with the actual value of (THS_PREPARE + THS_ZERO) being
    
    ((1 to 2) + 1 + (TCLK_ZEROCNT + 1) + (3 to 4)) x ByteClk cycle +
      + HSByteClk x (2 + (1 to 2)) + (PHY delay)
    
    with PHY delay being about
    
    (8 + (5 to 6)) x MIPIBitClk cycle in the BitClk conversion.
    
    Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-7-francesco@dolcini.it
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: tc358768: fix TXTAGOCNT computation [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Thu Apr 27 16:29:32 2023 +0200

    drm/bridge: tc358768: fix TXTAGOCNT computation
    
    [ Upstream commit 3666aad8185af8d0ce164fd3c4974235417d6d0b ]
    
    Correct computation of TXTAGOCNT register.
    
    This register must be set to a value that ensure that the
    TTA-GO period = (4 x TLPX)
    
    with the actual value of TTA-GO being
    
    4 x (TXTAGOCNT + 1) x (HSByteClk cycle)
    
    Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Reviewed-by: Robert Foss <rfoss@kernel.org>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-8-francesco@dolcini.it
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: ti-sn65dsi83: Fix enable error path [+ + +]
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Thu May 4 08:53:16 2023 +0200

    drm/bridge: ti-sn65dsi83: Fix enable error path
    
    [ Upstream commit 8a91b29f1f50ce7742cdbe5cf11d17f128511f3f ]
    
    If PLL locking failed, the regulator needs to be disabled again.
    
    Fixes: 5664e3c907e2 ("drm/bridge: ti-sn65dsi83: Add vcc supply regulator support")
    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Robert Foss <rfoss@kernel.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230504065316.2640739-1-alexander.stein@ew.tq-group.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: ti-sn65dsi83: Fix enable/disable flow to meet spec [+ + +]
Author: Frieder Schrempf <frieder.schrempf@kontron.de>
Date:   Wed May 3 18:33:07 2023 +0200

    drm/bridge: ti-sn65dsi83: Fix enable/disable flow to meet spec
    
    [ Upstream commit dd9e329af7236e34c566d3705ea32a63069b9b13 ]
    
    The datasheet describes the following initialization flow including
    minimum delay times between each step:
    
    1. DSI data lanes need to be in LP-11 and the clock lane in HS mode
    2. toggle EN signal
    3. initialize registers
    4. enable PLL
    5. soft reset
    6. enable DSI stream
    7. check error status register
    
    To meet this requirement we need to make sure the host bridge's
    pre_enable() is called first by using the pre_enable_prev_first
    flag.
    
    Furthermore we need to split enable() into pre_enable() which covers
    steps 2-5 from above and enable() which covers step 7 and is called
    after the host bridge's enable().
    
    Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
    Fixes: ceb515ba29ba ("drm/bridge: ti-sn65dsi83: Add TI SN65DSI83 and SN65DSI84 driver")
    Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com> #TQMa8MxML/MBa8Mx
    Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
    Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230503163313.2640898-3-frieder@fris.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/i915/guc/slpc: Apply min softlimit correctly [+ + +]
Author: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Date:   Tue Jun 20 18:42:57 2023 -0700

    drm/i915/guc/slpc: Apply min softlimit correctly
    
    [ Upstream commit 3e49de73fb89272dea01ba420c7ccbcf6b96aed7 ]
    
    The scenario being fixed here is depicted in the following sequence-
    
    modprobe i915
    echo 1 > /sys/class/drm/card0/gt/gt0/slpc_ignore_eff_freq
    echo 300 > /sys/class/drm/card0/gt_min_freq_mhz (RPn)
    cat /sys/class/drm/card0/gt_cur_freq_mhz --> cur == RPn as expected
    echo 1 > /sys/kernel/debug/dri/0/gt0/reset --> reset
    cat /sys/class/drm/card0/gt_min_freq_mhz --> cached freq is RPn
    cat /sys/class/drm/card0/gt_cur_freq_mhz --> it's not RPn, but RPe!!
    
    When SLPC reinitializes, it sets SLPC min freq to efficient frequency.
    Even if we disable efficient freq post that, we should restore the cached
    min freq (via H2G) for it to take effect.
    
    v2: Clarify commit message (Ashutosh)
    
    Fixes: 95ccf312a1e4 ("drm/i915/guc/slpc: Allow SLPC to use efficient frequency")
    Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
    Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
    Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230621014257.1769564-1-vinay.belgaumkar@intel.com
    (cherry picked from commit da86b2b13f1d1ca26745b951ac94421f3137539a)
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/i915/psr: Use hw.adjusted mode when calculating io/fast wake times [+ + +]
Author: Jouni Högander <jouni.hogander@intel.com>
Date:   Tue Jun 20 14:17:45 2023 +0300

    drm/i915/psr: Use hw.adjusted mode when calculating io/fast wake times
    
    [ Upstream commit 5311892a0ad1d301aafd53ca0154091b3eb407ea ]
    
    Encoder compute config is changing hw.adjusted mode. Uapi.adjusted mode
    doesn't get updated before psr compute config gets called. This causes io
    and fast wake line calculation using adjusted mode containing values before
    encoder adjustments. Fix this by using hw.adjusted mode instead of
    uapi.adjusted mode.
    
    Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
    
    Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
    Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8475
    Fixes: cb42e8ede5b4 ("drm/i915/psr: Use calculated io and fast wake lines")
    Reviewed-by: Mika Kahola <mika.kahola@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230620111745.2870706-1-jouni.hogander@intel.com
    (cherry picked from commit ef0af9db2a21257885116949f471fe5565b2f0ab)
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/i915/tc: Fix system resume MST mode restore for DP-alt sinks [+ + +]
Author: Imre Deak <imre.deak@intel.com>
Date:   Thu Mar 16 15:17:14 2023 +0200

    drm/i915/tc: Fix system resume MST mode restore for DP-alt sinks
    
    commit 06f66261a1567d66b9d35c87393b6edfbea4c8f8 upstream.
    
    At least restoring the MST topology during system resume needs to use
    AUX before the display HW readout->sanitization sequence is complete,
    but on TC ports the PHY may be in the wrong mode for this, resulting in
    the AUX transfers to fail.
    
    The initial TC port mode is kept fixed as BIOS left it for the above HW
    readout sequence (to prevent changing the mode on an enabled port).  If
    the port is disabled this initial mode is TBT - as in any case the PHY
    ownership is not held - even if a DP-alt sink is connected. Thus, the
    AUX transfers during this time will use TBT mode instead of the expected
    DP-alt mode and so time out.
    
    Fix the above by connecting the PHY during port initialization if the
    port is disabled, which will switch to the expected mode (DP-alt in the
    above case).
    
    As the encoder/pipe HW state isn't read-out yet at this point, check if
    the port is enabled based on the DDI_BUF enabled flag. Save the read-out
    initial mode, so intel_tc_port_sanitize_mode() can check this wrt. the
    read-out encoder HW state.
    
    Signed-off-by: Imre Deak <imre.deak@intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230316131724.359612-5-imre.deak@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/i915/tc: Fix TC port link ref init for DP MST during HW readout [+ + +]
Author: Imre Deak <imre.deak@intel.com>
Date:   Thu Mar 16 15:17:12 2023 +0200

    drm/i915/tc: Fix TC port link ref init for DP MST during HW readout
    
    commit 67165722c27cc46de112a4e10b450170c8980a6f upstream.
    
    An enabled TC MST port holds one TC port link reference, regardless of
    the number of enabled streams on it, but the TC port HW readout takes
    one reference for each active MST stream.
    
    Fix the HW readout, taking only one reference for MST ports.
    
    This didn't cause an actual problem, since the encoder HW readout doesn't
    yet support reading out the MST HW state.
    
    Signed-off-by: Imre Deak <imre.deak@intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Reviewed-by: Mika Kahola <mika.kahola@intel.com>
    Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230316131724.359612-3-imre.deak@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/i915: Fix TypeC mode initialization during system resume [+ + +]
Author: Imre Deak <imre.deak@intel.com>
Date:   Thu Sep 22 20:21:48 2022 +0300

    drm/i915: Fix TypeC mode initialization during system resume
    
    commit a82796a2e332d108b2d3aff38509caad370f69b5 upstream.
    
    During system resume DP MST requires AUX to be working already before
    the HW state readout of the given encoder. Since AUX requires the
    encoder/PHY TypeC mode to be initialized, which atm only happens during
    HW state readout, these AUX transfers can change the TypeC mode
    incorrectly (disconnecting the PHY for an enabled encoder) and trigger
    the state check WARNs in intel_tc_port_sanitize().
    
    Fix this by initializing the TypeC mode earlier both during driver
    loading and system resume and making sure that the mode can't change
    until the encoder's state is read out. While at it add the missing
    DocBook comments and rename
    intel_tc_port_sanitize()->intel_tc_port_sanitize_mode() for consistency.
    
    Signed-off-by: Imre Deak <imre.deak@intel.com>
    Reviewed-by: Mika Kahola <mika.kahola@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220922172148.2913088-1-imre.deak@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/msm/a5xx: really check for A510 in a5xx_gpu_init [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Sun Apr 9 04:13:29 2023 +0300

    drm/msm/a5xx: really check for A510 in a5xx_gpu_init
    
    [ Upstream commit 736a9327365644b460e4498b1ce172ca411efcbc ]
    
    The commit 010c8bbad2cb ("drm: msm: adreno: Disable preemption on Adreno
    510") added special handling for a510 (this SKU doesn't seem to support
    preemption, so the driver should clamp nr_rings to 1). However the
    gpu->revn is not yet set (it is set later, in adreno_gpu_init()) and
    thus the condition is always false. Check config->rev instead.
    
    Fixes: 010c8bbad2cb ("drm: msm: adreno: Disable preemption on Adreno 510")
    Reported-by: Adam Skladowski <a39.skl@gmail.com>
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Tested-by: Adam Skladowski <a39.skl@gmail.com>
    Patchwork: https://patchwork.freedesktop.org/patch/531511/
    Signed-off-by: Rob Clark <robdclark@chromium.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/disp/dpu: get timing engine status from intf status register [+ + +]
Author: Vinod Polimera <quic_vpolimer@quicinc.com>
Date:   Thu Mar 2 22:03:08 2023 +0530

    drm/msm/disp/dpu: get timing engine status from intf status register
    
    [ Upstream commit e3969eadc8ee78a5bdca65b8ed0a421a359e4090 ]
    
    Recommended way of reading the interface timing gen status is via
    status register. Timing gen status register will give a reliable status
    of the interface especially during ON/OFF transitions. This support was
    added from DPU version 5.0.0.
    
    Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/524724/
    Link: https://lore.kernel.org/r/1677774797-31063-6-git-send-email-quic_vpolimer@quicinc.com
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Stable-dep-of: a7129231edf3 ("drm/msm/dpu: Set DPU_DATA_HCTL_EN for in INTF_SC7180_MASK")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/dp: Free resources after unregistering them [+ + +]
Author: Bjorn Andersson <quic_bjorande@quicinc.com>
Date:   Mon Jun 12 15:02:59 2023 -0700

    drm/msm/dp: Free resources after unregistering them
    
    [ Upstream commit fa0048a4b1fa7a50c8b0e514f5b428abdf69a6f8 ]
    
    The DP component's unbind operation walks through the submodules to
    unregister and clean things up. But if the unbind happens because the DP
    controller itself is being removed, all the memory for those submodules
    has just been freed.
    
    Change the order of these operations to avoid the many use-after-free
    that otherwise happens in this code path.
    
    Fixes: c943b4948b58 ("drm/msm/dp: add displayPort driver support")
    Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/542166/
    Link: https://lore.kernel.org/r/20230612220259.1884381-1-quic_bjorande@quicinc.com
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/dpu: correct MERGE_3D length [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Tue Jun 13 03:09:41 2023 +0300

    drm/msm/dpu: correct MERGE_3D length
    
    [ Upstream commit 9a6c13b847d61b0c3796820ca6e976789df59cd8 ]
    
    Each MERGE_3D block has just two registers. Correct the block length
    accordingly.
    
    Fixes: 4369c93cf36b ("drm/msm/dpu: initial support for merge3D hardware block")
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Patchwork: https://patchwork.freedesktop.org/patch/542177/
    Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
    Link: https://lore.kernel.org/r/20230613001004.3426676-3-dmitry.baryshkov@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/dpu: do not enable color-management if DSPPs are not available [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Mon Jun 12 21:25:33 2023 +0300

    drm/msm/dpu: do not enable color-management if DSPPs are not available
    
    [ Upstream commit 3bcfc7b90465efd337d39b91b43972162f0d1908 ]
    
    We can not support color management without DSPP blocks being provided
    in the HW catalog. Do not enable color management for CRTCs if num_dspps
    is 0.
    
    Fixes: 4259ff7ae509 ("drm/msm/dpu: add support for pcc color block in dpu driver")
    Reported-by: Yongqin Liu <yongqin.liu@linaro.org>
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
    Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org>
    Tested-by: Yongqin Liu <yongqin.liu@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/542141/
    Link: https://lore.kernel.org/r/20230612182534.3345805-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/dpu: Fix slice_last_group_size calculation [+ + +]
Author: Jessica Zhang <quic_jesszhan@quicinc.com>
Date:   Wed May 24 10:45:20 2023 -0700

    drm/msm/dpu: Fix slice_last_group_size calculation
    
    [ Upstream commit c223059e6f8340f7eac2319470984cbfc39c433b ]
    
    Correct the math for slice_last_group_size so that it matches the
    calculations downstream.
    
    Fixes: c110cfd1753e ("drm/msm/disp/dpu1: Add support for DSC")
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
    Signed-off-by: Jessica Zhang <quic_jesszhan@quicinc.com>
    Patchwork: https://patchwork.freedesktop.org/patch/539269/
    Link: https://lore.kernel.org/r/20230329-rfc-msm-dsc-helper-v14-7-bafc7be95691@quicinc.com
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/dpu: Set DPU_DATA_HCTL_EN for in INTF_SC7180_MASK [+ + +]
Author: Konrad Dybcio <konrad.dybcio@linaro.org>
Date:   Fri May 19 20:49:59 2023 +0200

    drm/msm/dpu: Set DPU_DATA_HCTL_EN for in INTF_SC7180_MASK
    
    [ Upstream commit a7129231edf329a00e92dbd2d741f6da728a4a06 ]
    
    DPU5 and newer targets enable this unconditionally. Move it from the
    SC7280 mask to the SC7180 one.
    
    Fixes: 7e6ee55320f0 ("drm/msm/disp/dpu1: enable DATA_HCTL_EN for sc7280 target")
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
    Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Patchwork: https://patchwork.freedesktop.org/patch/538159/
    Link: https://lore.kernel.org/r/20230508-topic-hctl_en-v2-1-e7bea9f1f5dd@linaro.org
    [DB: removed BIT(DPU_INTF_DATA_COMPRESS), which is not yet merged]
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/dpu: set DSC flush bit correctly at MDP CTL flush register [+ + +]
Author: Kuogee Hsieh <quic_khsieh@quicinc.com>
Date:   Thu May 25 10:40:49 2023 -0700

    drm/msm/dpu: set DSC flush bit correctly at MDP CTL flush register
    
    [ Upstream commit 12cef323c903bd8b13d1f6ff24a9695c2cdc360b ]
    
    The CTL_FLUSH register should be programmed with the 22th bit
    (DSC_IDX) to flush the DSC hardware blocks, not the literal value of
    22 (which corresponds to flushing VIG1, VIG2 and RGB1 instead).
    
    Changes in V12:
    -- split this patch out of "separate DSC flush update out of interface"
    
    Changes in V13:
    -- rewording the commit text
    
    Changes in V14:
    -- drop 'DSC" from "The DSC CTL_FLUSH register" at commit text
    
    Fixes: 77f6da90487c ("drm/msm/disp/dpu1: Add DSC support in hw_ctl")
    Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
    Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
    Patchwork: https://patchwork.freedesktop.org/patch/539496/
    Link: https://lore.kernel.org/r/1685036458-22683-2-git-send-email-quic_khsieh@quicinc.com
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/dsi: don't allow enabling 14nm VCO with unprogrammed rate [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Mon May 1 04:12:57 2023 +0300

    drm/msm/dsi: don't allow enabling 14nm VCO with unprogrammed rate
    
    [ Upstream commit 1e0a97f84d73ea1182740f62069690c7f3271abb ]
    
    If the dispcc uses CLK_OPS_PARENT_ENABLE (e.g. on QCM2290), CCF can try
    enabling VCO before the rate has been programmed. This can cause clock
    lockups and/or other boot issues. Program the VCO to the minimal PLL
    rate if the read rate is 0 Hz.
    
    Cc: Konrad Dybcio <konrad.dybcio@linaro.org>
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reported-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
    Reported-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Fixes: f079f6d999cb ("drm/msm/dsi: Add PHY/PLL for 8x96")
    Patchwork: https://patchwork.freedesktop.org/patch/534813/
    Link: https://lore.kernel.org/r/20230501011257.3460103-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/dsi: Flip greater-than check for slice_count and slice_per_intf [+ + +]
Author: Marijn Suijten <marijn.suijten@somainline.org>
Date:   Thu Dec 22 00:19:38 2022 +0100

    drm/msm/dsi: Flip greater-than check for slice_count and slice_per_intf
    
    [ Upstream commit 82e72fd22a8f9eff4e75c08be68319008ea90a29 ]
    
    According to downstream /and the comment copied from it/ this comparison
    should be the other way around.  In other words, when the panel driver
    requests to use more slices per packet than what could be sent over this
    interface, it is bumped down to only use a single slice per packet (and
    strangely not the number of slices that could fit on the interface).
    
    Fixes: 08802f515c3c ("drm/msm/dsi: Add support for DSC configuration")
    Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Patchwork: https://patchwork.freedesktop.org/patch/515686/
    Link: https://lore.kernel.org/r/20221221231943.1961117-4-marijn.suijten@somainline.org
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Stable-dep-of: 155fa3a91d64 ("drm/msm/dsi: Remove incorrect references to slice_count")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/dsi: Remove incorrect references to slice_count [+ + +]
Author: Jessica Zhang <quic_jesszhan@quicinc.com>
Date:   Fri Jun 9 15:57:17 2023 -0700

    drm/msm/dsi: Remove incorrect references to slice_count
    
    [ Upstream commit 155fa3a91d64221eb0885fd221cc8085dbef908f ]
    
    Currently, slice_count is being used to calculate word count and
    pkt_per_line. Instead, these values should be calculated using slice per
    packet, which is not the same as slice_count.
    
    Slice count represents the number of slices per interface, and its value
    will not always match that of slice per packet. For example, it is possible
    to have cases where there are multiple slices per interface but the panel
    specifies only one slice per packet.
    
    Thus, use the default value of one slice per packet and remove slice_count
    from the aforementioned calculations.
    
    Fixes: 08802f515c3c ("drm/msm/dsi: Add support for DSC configuration")
    Fixes: bc6b6ff8135c ("drm/msm/dsi: Use DSC slice(s) packet size to compute word count")
    Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
    Signed-off-by: Jessica Zhang <quic_jesszhan@quicinc.com>
    Patchwork: https://patchwork.freedesktop.org/patch/541965/
    Link: https://lore.kernel.org/r/20230405-add-dsc-support-v6-5-95eab864d1b6@quicinc.com
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/dsi: Use DSC slice(s) packet size to compute word count [+ + +]
Author: Marijn Suijten <marijn.suijten@somainline.org>
Date:   Thu Dec 22 00:19:37 2022 +0100

    drm/msm/dsi: Use DSC slice(s) packet size to compute word count
    
    [ Upstream commit bc6b6ff8135c4b96787eda88f3baf653939a75ce ]
    
    According to downstream the value to use for WORD_COUNT is
    bytes_per_pkt, which denotes the number of bytes in a packet based on
    how many slices have been configured by the panel driver times the
    width of a slice times the number of bytes per pixel.
    
    The DSC panels seen thus far use one byte per pixel, only one slice
    per packet, and a slice width of half the panel width leading to the
    desired bytes_per_pkt+1 value to be equal to hdisplay/2+1.  This however
    isn't the case anymore for panels that configure two slices per packet,
    where the value should now be hdisplay+1.
    
    Note that the aforementioned panel (on a Sony Xperia XZ3, sdm845) with
    slice_count=1 has also been tested to successfully accept slice_count=2,
    which would have shown corrupted output previously.
    
    Fixes: 08802f515c3c ("drm/msm/dsi: Add support for DSC configuration")
    Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Patchwork: https://patchwork.freedesktop.org/patch/515694/
    Link: https://lore.kernel.org/r/20221221231943.1961117-3-marijn.suijten@somainline.org
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Stable-dep-of: 155fa3a91d64 ("drm/msm/dsi: Remove incorrect references to slice_count")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/panel: sharp-ls043t1le01: adjust mode settings [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Sun May 7 20:26:38 2023 +0300

    drm/panel: sharp-ls043t1le01: adjust mode settings
    
    [ Upstream commit dee23b2c9e3ff46d59c5d45e1436eceb878e7c9a ]
    
    Using current settings causes panel flickering on APQ8074 dragonboard.
    Adjust panel settings to follow the vendor-provided mode. This also
    enables MIPI_DSI_MODE_VIDEO_SYNC_PULSE, which is also specified by the
    vendor dtsi for the mentioned dragonboard.
    
    Fixes: ee0172383190 ("drm/panel: Add Sharp LS043T1LE01 MIPI DSI panel")
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
    Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230507172639.2320934-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/panel: simple: fix active size for Ampire AM-480272H3TMQW-T01H [+ + +]
Author: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Date:   Tue May 16 10:50:39 2023 +0200

    drm/panel: simple: fix active size for Ampire AM-480272H3TMQW-T01H
    
    [ Upstream commit f24b49550814fdee4a98b9552e35e243ccafd4a8 ]
    
    The previous setting was related to the overall dimension and not to the
    active display area.
    In the "PHYSICAL SPECIFICATIONS" section, the datasheet shows the
    following parameters:
    
     ----------------------------------------------------------
    |       Item        |         Specifications        | unit |
     ----------------------------------------------------------
    | Display area      | 98.7 (W) x 57.5 (H)           |  mm  |
     ----------------------------------------------------------
    | Overall dimension | 105.5(W) x 67.2(H) x 4.96(D)  |  mm  |
     ----------------------------------------------------------
    
    Fixes: 966fea78adf2 ("drm/panel: simple: Add support for Ampire AM-480272H3TMQW-T01H")
    Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
    Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
    [narmstrong: fixed Fixes commit id length]
    Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230516085039.3797303-1-dario.binacchi@amarulasolutions.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/radeon: fix possible division-by-zero errors [+ + +]
Author: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Date:   Fri May 19 08:33:27 2023 -0700

    drm/radeon: fix possible division-by-zero errors
    
    [ Upstream commit 1becc57cd1a905e2aa0e1eca60d2a37744525c4a ]
    
    Function rv740_get_decoded_reference_divider() may return 0 due to
    unpredictable reference divider value calculated in
    radeon_atom_get_clock_dividers(). This will lead to
    division-by-zero error once that value is used as a divider
    in calculating 'clk_s'.
    While unlikely, this issue should nonetheless be prevented so add a
    sanity check for such cases by testing 'decoded_ref' value against 0.
    
    Found by Linux Verification Center (linuxtesting.org) with static
    analysis tool SVACE.
    
    v2: minor coding style fixes (Alex)
    In practice this should actually happen as the vbios should be
    properly populated.
    
    Fixes: 66229b200598 ("drm/radeon/kms: add dpm support for rv7xx (v4)")
    Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/vkms: Fix RGB565 pixel conversion [+ + +]
Author: Maíra Canal <mcanal@igalia.com>
Date:   Fri May 12 07:40:45 2023 -0300

    drm/vkms: Fix RGB565 pixel conversion
    
    [ Upstream commit ab87f558dcfb2562c3497e89600dec798a446665 ]
    
    Currently, the pixel conversion isn't rounding the fixed-point values
    before assigning it to the RGB coefficients, which is causing the IGT
    pixel-format tests to fail. So, use the drm_fixp2int_round() fixed-point
    helper to round the values when assigning it to the RGB coefficients.
    
    Tested with igt@kms_plane@pixel-format and igt@kms_plane@pixel-format-source-clamping.
    
    [v2]:
        * Use drm_fixp2int_round() to fix the pixel conversion instead of
          casting the values to s32 (Melissa Wen).
    
    Fixes: 89b03aeaef16 ("drm/vkms: fix 32bit compilation error by replacing macros")
    Signed-off-by: Maíra Canal <mcanal@igalia.com>
    Reviewed-by: Arthur Grillo <arthurgrillo@riseup.net>
    Signed-off-by: Maíra Canal <mairacanal@riseup.net>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230512104044.65034-2-mcanal@igalia.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/vkms: isolate pixel conversion functionality [+ + +]
Author: Maíra Canal <mcanal@igalia.com>
Date:   Tue Apr 18 10:05:21 2023 -0300

    drm/vkms: isolate pixel conversion functionality
    
    [ Upstream commit 322d716a3e8a74fb75cd0f657647be4df253fd2f ]
    
    Currently, the pixel conversion functions repeat the same loop to
    iterate the rows. Instead of repeating the same code for each pixel
    format, create a function to wrap the loop and isolate the pixel
    conversion functionality.
    
    Suggested-by: Arthur Grillo <arthurgrillo@riseup.net>
    Signed-off-by: Maíra Canal <mcanal@igalia.com>
    Reviewed-by: Arthur Grillo <arthurgrillo@riseup.net>
    Signed-off-by: Maíra Canal <mairacanal@riseup.net>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230418130525.128733-2-mcanal@igalia.com
    Stable-dep-of: ab87f558dcfb ("drm/vkms: Fix RGB565 pixel conversion")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/vram-helper: fix function names in vram helper doc [+ + +]
Author: Luc Ma <luc@sietium.com>
Date:   Mon May 8 08:09:16 2023 +0800

    drm/vram-helper: fix function names in vram helper doc
    
    [ Upstream commit b8e392245105b50706f18418054821e71e637288 ]
    
    Refer to drmm_vram_helper_init() instead of the non-existent
    drmm_vram_helper_alloc_mm().
    
    Fixes: a5f23a72355d ("drm/vram-helper: Managed vram helpers")
    Signed-off-by: Luc Ma <luc@sietium.com>
    Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
    Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/64583db2.630a0220.eb75d.8f51@mx.google.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm: Add fixed-point helper to get rounded integer values [+ + +]
Author: Maíra Canal <mcanal@igalia.com>
Date:   Fri May 12 07:40:44 2023 -0300

    drm: Add fixed-point helper to get rounded integer values
    
    [ Upstream commit 8b25320887d7feac98875546ea0f521628b745bb ]
    
    Create a new fixed-point helper to allow us to return the rounded value
    of our fixed point value.
    
    [v2]:
        * Create the function drm_fixp2int_round() (Melissa Wen).
    [v3]:
        * Use drm_fixp2int() instead of shifting manually (Arthur Grillo).
    
    Signed-off-by: Maíra Canal <mcanal@igalia.com>
    Reviewed-by: Arthur Grillo <arthurgrillo@riseup.net>
    Signed-off-by: Maíra Canal <mairacanal@riseup.net>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230512104044.65034-1-mcanal@igalia.com
    Stable-dep-of: ab87f558dcfb ("drm/vkms: Fix RGB565 pixel conversion")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm: sun4i_tcon: use devm_clk_get_enabled in `sun4i_tcon_init_clocks` [+ + +]
Author: XuDong Liu <m202071377@hust.edu.cn>
Date:   Sun Apr 30 19:23:46 2023 +0800

    drm: sun4i_tcon: use devm_clk_get_enabled in `sun4i_tcon_init_clocks`
    
    [ Upstream commit 123ee07ba5b7123e0ce0e0f9d64938026c16a2ce ]
    
    Smatch reports:
    drivers/gpu/drm/sun4i/sun4i_tcon.c:805 sun4i_tcon_init_clocks() warn:
    'tcon->clk' from clk_prepare_enable() not released on lines: 792,801.
    
    In the function sun4i_tcon_init_clocks(), tcon->clk and tcon->sclk0 are
    not disabled in the error handling, which affects the release of
    these variable. Although sun4i_tcon_bind(), which calls
    sun4i_tcon_init_clocks(), use sun4i_tcon_free_clocks to disable the
    variables mentioned, but the error handling branch of
    sun4i_tcon_init_clocks() ignores the required disable process.
    
    To fix this issue, use the devm_clk_get_enabled to automatically
    balance enable and disabled calls. As original implementation use
    sun4i_tcon_free_clocks() to disable clk explicitly, we delete the
    related calls and error handling that are no longer needed.
    
    Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
    Fixes: b14e945bda8a ("drm/sun4i: tcon: Prepare and enable TCON channel 0 clock at init")
    Fixes: 8e9240472522 ("drm/sun4i: support TCONs without channel 1")
    Fixes: 34d698f6e349 ("drm/sun4i: Add has_channel_0 TCON quirk")
    Signed-off-by: XuDong Liu <m202071377@hust.edu.cn>
    Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230430112347.4689-1-m202071377@hust.edu.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm: use mgr->dev in drm_dbg_kms in drm_dp_add_payload_part2 [+ + +]
Author: Jeff Layton <jlayton@kernel.org>
Date:   Wed Apr 19 07:24:46 2023 -0400

    drm: use mgr->dev in drm_dbg_kms in drm_dp_add_payload_part2
    
    commit 54d217406afe250d7a768783baaa79a035f21d38 upstream.
    
    I've been experiencing some intermittent crashes down in the display
    driver code. The symptoms are ususally a line like this in dmesg:
    
        amdgpu 0000:30:00.0: [drm] Failed to create MST payload for port 000000006d3a3885: -5
    
    ...followed by an Oops due to a NULL pointer dereference.
    
    Switch to using mgr->dev instead of state->dev since "state" can be
    NULL in some cases.
    
    Link: https://bugzilla.redhat.com/show_bug.cgi?id=2184855
    Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
    Signed-off-by: Jeff Layton <jlayton@kernel.org>
    Reviewed-by: Jani Nikula <jani.nikula@intel.com>
    Reviewed-by: Lyude Paul <lyude@redhat.com>
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230419112447.18471-1-jlayton@kernel.org
    Cc: "Limonciello, Mario" <mario.limonciello@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 
dt-bindings: power: reset: qcom-pon: Only allow reboot-mode pre-pmk8350 [+ + +]
Author: Konrad Dybcio <konrad.dybcio@linaro.org>
Date:   Wed Apr 19 12:41:06 2023 +0200

    dt-bindings: power: reset: qcom-pon: Only allow reboot-mode pre-pmk8350
    
    [ Upstream commit d41dab4c031edaa460a484113394327aa52dc0bd ]
    
    As pointed out by Shazad [1], PMICs using a separate HLOS+PBS scheme
    (so PMK8350 and newer) are expected to pass reboot mode data through SDAM,
    as the reboot mode registers are absent in the HLOS reg space.
    
    Limit the reboot-mode.yaml inclusion to PMICs without a separate PBS
    region.
    
    [1] https://lore.kernel.org/linux-arm-msm/12f13183-c381-25f7-459e-62e0c2b19498@quicinc.com/
    
    Fixes: 03fccdc76dce ("dt-bindings: power: reset: qcom-pon: Add new compatible "qcom,pmk8350-pon"")
    Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Acked-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
efi/libstub: Disable PCI DMA before grabbing the EFI memory map [+ + +]
Author: Ard Biesheuvel <ardb@kernel.org>
Date:   Tue Jun 27 09:33:09 2023 +0200

    efi/libstub: Disable PCI DMA before grabbing the EFI memory map
    
    [ Upstream commit 2e28a798c3092ea42b968fa16ac835969d124898 ]
    
    Currently, the EFI stub will disable PCI DMA as the very last thing it
    does before calling ExitBootServices(), to avoid interfering with the
    firmware's normal operation as much as possible.
    
    However, the stub will invoke DisconnectController() on all endpoints
    downstream of the PCI bridges it disables, and this may affect the
    layout of the EFI memory map, making it substantially more likely that
    ExitBootServices() will fail the first time around, and that the EFI
    memory map needs to be reloaded.
    
    This, in turn, increases the likelihood that the slack space we
    allocated is insufficient (and we can no longer allocate memory via boot
    services after having called ExitBootServices() once), causing the
    second call to GetMemoryMap (and therefore the boot) to fail. This makes
    the PCI DMA disable feature a bit more fragile than it already is, so
    let's make it more robust, by allocating the space for the EFI memory
    map after disabling PCI DMA.
    
    Fixes: 4444f8541dad16fe ("efi: Allow disabling PCI busmastering on bridges during boot")
    Reported-by: Glenn Washburn <development@efficientek.com>
    Acked-by: Matthew Garrett <mjg59@srcf.ucam.org>
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
erofs: avoid tagged pointers to mark sync decompression [+ + +]
Author: Gao Xiang <xiang@kernel.org>
Date:   Sat Feb 4 17:30:36 2023 +0800

    erofs: avoid tagged pointers to mark sync decompression
    
    [ Upstream commit cdba55067f2f9fdc7870ffcb6aef912d3468cff8 ]
    
    We could just use a boolean in z_erofs_decompressqueue for sync
    decompression to simplify the code.
    
    Reviewed-by: Yue Hu <huyue2@coolpad.com>
    Reviewed-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20230204093040.97967-2-hsiangkao@linux.alibaba.com
    Stable-dep-of: 967c28b23f6c ("erofs: kill hooked chains to avoid loops on deduplicated compressed images")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

erofs: clean up cached I/O strategies [+ + +]
Author: Gao Xiang <xiang@kernel.org>
Date:   Tue Dec 6 14:03:52 2022 +0800

    erofs: clean up cached I/O strategies
    
    [ Upstream commit 1282dea37b09087b8aec59f0774572c16b52276a ]
    
    After commit 4c7e42552b3a ("erofs: remove useless cache strategy of
    DELAYEDALLOC"), only one cached I/O allocation strategy is supported:
    
      When cached I/O is preferred, page allocation is applied without
      direct reclaim.  If allocation fails, fall back to inplace I/O.
    
    Let's get rid of z_erofs_cache_alloctype.  No logical changes.
    
    Reviewed-by: Yue Hu <huyue2@coolpad.com>
    Reviewed-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Yue Hu <huyue2@coolpad.com>
    Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20221206060352.152830-1-xiang@kernel.org
    Stable-dep-of: 967c28b23f6c ("erofs: kill hooked chains to avoid loops on deduplicated compressed images")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

erofs: fix compact 4B support for 16k block size [+ + +]
Author: Gao Xiang <xiang@kernel.org>
Date:   Thu Jun 1 19:23:41 2023 +0800

    erofs: fix compact 4B support for 16k block size
    
    [ Upstream commit 001b8ccd0650727e54ec16ef72bf1b8eeab7168e ]
    
    In compact 4B, two adjacent lclusters are packed together as a unit to
    form on-disk indexes for effective random access, as below:
    
    (amortized = 4, vcnt = 2)
           _____________________________________________
          |___@_____ encoded bits __________|_ blkaddr _|
          0        .                                    amortized * vcnt = 8
          .             .
          .                  .              amortized * vcnt - 4 = 4
          .                        .
          .____________________________.
          |_type (2 bits)_|_clusterofs_|
    
    Therefore, encoded bits for each pack are 32 bits (4 bytes). IOWs,
    since each lcluster can get 16 bits for its type and clusterofs, the
    maximum supported lclustersize for compact 4B format is 16k (14 bits).
    
    Fix this to enable compact 4B format for 16k lclusters (blocks), which
    is tested on an arm64 server with 16k page size.
    
    Fixes: 152a333a5895 ("staging: erofs: add compacted compression indexes support")
    Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20230601112341.56960-1-hsiangkao@linux.alibaba.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

erofs: kill hooked chains to avoid loops on deduplicated compressed images [+ + +]
Author: Gao Xiang <xiang@kernel.org>
Date:   Sat May 27 04:14:56 2023 +0800

    erofs: kill hooked chains to avoid loops on deduplicated compressed images
    
    [ Upstream commit 967c28b23f6c89bb8eef6a046ea88afe0d7c1029 ]
    
    After heavily stressing EROFS with several images which include a
    hand-crafted image of repeated patterns for more than 46 days, I found
    two chains could be linked with each other almost simultaneously and
    form a loop so that the entire loop won't be submitted.  As a
    consequence, the corresponding file pages will remain locked forever.
    
    It can be _only_ observed on data-deduplicated compressed images.
    For example, consider two chains with five pclusters in total:
            Chain 1:  2->3->4->5    -- The tail pcluster is 5;
            Chain 2:  5->1->2       -- The tail pcluster is 2.
    
    Chain 2 could link to Chain 1 with pcluster 5; and Chain 1 could link
    to Chain 2 at the same time with pcluster 2.
    
    Since hooked chains are all linked locklessly now, I have no idea how
    to simply avoid the race.  Instead, let's avoid hooked chains completely
    until I could work out a proper way to fix this and end users finally
    tell us that it's needed to add it back.
    
    Actually, this optimization can be found with multi-threaded workloads
    (especially even more often on deduplicated compressed images), yet I'm
    not sure about the overall system impacts of not having this compared
    with implementation complexity.
    
    Fixes: 267f2492c8f7 ("erofs: introduce multi-reference pclusters (fully-referenced)")
    Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
    Reviewed-by: Yue Hu <huyue2@coolpad.com>
    Link: https://lore.kernel.org/r/20230526201459.128169-4-hsiangkao@linux.alibaba.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

erofs: move zdata.h into zdata.c [+ + +]
Author: Gao Xiang <xiang@kernel.org>
Date:   Sat Feb 4 17:30:38 2023 +0800

    erofs: move zdata.h into zdata.c
    
    [ Upstream commit a9a94d9373349e1a53f149d2015eb6f03a8517cf ]
    
    Definitions in zdata.h are only used in zdata.c and for internal
    use only.  No logic changes.
    
    Reviewed-by: Yue Hu <huyue2@coolpad.com>
    Reviewed-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20230204093040.97967-4-hsiangkao@linux.alibaba.com
    Stable-dep-of: 967c28b23f6c ("erofs: kill hooked chains to avoid loops on deduplicated compressed images")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

erofs: remove tagged pointer helpers [+ + +]
Author: Gao Xiang <xiang@kernel.org>
Date:   Sat Feb 4 17:30:37 2023 +0800

    erofs: remove tagged pointer helpers
    
    [ Upstream commit b1ed220c6262bff63cdcb53692e492be0b05206c ]
    
    Just open-code the remaining one to simplify the code.
    
    Reviewed-by: Yue Hu <huyue2@coolpad.com>
    Reviewed-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20230204093040.97967-3-hsiangkao@linux.alibaba.com
    Stable-dep-of: 967c28b23f6c ("erofs: kill hooked chains to avoid loops on deduplicated compressed images")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

erofs: simplify iloc() [+ + +]
Author: Gao Xiang <xiang@kernel.org>
Date:   Sat Jan 14 23:08:23 2023 +0800

    erofs: simplify iloc()
    
    [ Upstream commit b780d3fc6107464dcc43631a6208c43b6421f1e6 ]
    
    Actually we could pass in inodes directly to clean up all callers.
    Also rename iloc() as erofs_iloc().
    
    Link: https://lore.kernel.org/r/20230114150823.432069-1-xiang@kernel.org
    Reviewed-by: Yue Hu <huyue2@coolpad.com>
    Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
    Reviewed-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
    Stable-dep-of: 001b8ccd0650 ("erofs: fix compact 4B support for 16k block size")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
evm: Complete description of evm_inode_setattr() [+ + +]
Author: Roberto Sassu <roberto.sassu@huawei.com>
Date:   Mon Mar 6 11:40:36 2023 +0100

    evm: Complete description of evm_inode_setattr()
    
    [ Upstream commit b1de86d4248b273cb12c4cd7d20c08d459519f7d ]
    
    Add the description for missing parameters of evm_inode_setattr() to
    avoid the warning arising with W=n compile option.
    
    Fixes: 817b54aa45db ("evm: add evm_inode_setattr to prevent updating an invalid security.evm") # v3.2+
    Fixes: c1632a0f1120 ("fs: port ->setattr() to pass mnt_idmap") # v6.3+
    Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
    Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
    Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

evm: Fix build warnings [+ + +]
Author: Roberto Sassu <roberto.sassu@huawei.com>
Date:   Tue Jun 6 09:41:12 2023 +0200

    evm: Fix build warnings
    
    [ Upstream commit 996e0a97ebd7b11cb785794e2a83c20c1add9d92 ]
    
    Fix build warnings (function parameters description) for
    evm_read_protected_xattrs(), evm_set_key() and evm_verifyxattr().
    
    Fixes: 7626676320f3 ("evm: provide a function to set the EVM key from the kernel") # v4.5+
    Fixes: 8314b6732ae4 ("ima: Define new template fields xattrnames, xattrlengths and xattrvalues") # v5.14+
    Fixes: 2960e6cb5f7c ("evm: additional parameter to pass integrity cache entry 'iint'") # v3.2+
    Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
    Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ext4: Remove ext4 locking of moved directory [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Thu Jun 1 12:58:21 2023 +0200

    ext4: Remove ext4 locking of moved directory
    
    commit 3658840cd363f2be094f5dfd2f0b174a9055dd0f upstream.
    
    Remove locking of moved directory in ext4_rename2(). We will take care
    of it in VFS instead. This effectively reverts commit 0813299c586b
    ("ext4: Fix possible corruption when moving a directory") and followup
    fixes.
    
    CC: Ted Tso <tytso@mit.edu>
    CC: stable@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Message-Id: <20230601105830.13168-1-jack@suse.cz>
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
extcon: Fix kernel doc of property capability fields to avoid warnings [+ + +]
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Wed Mar 22 16:39:53 2023 +0200

    extcon: Fix kernel doc of property capability fields to avoid warnings
    
    [ Upstream commit 73346b9965ebda2feb7fef8629e9b28baee820e3 ]
    
    Kernel documentation has to be synchronized with a code, otherwise
    the validator is not happy:
    
         Function parameter or member 'usb_bits' not described in 'extcon_cable'
         Function parameter or member 'chg_bits' not described in 'extcon_cable'
         Function parameter or member 'jack_bits' not described in 'extcon_cable'
         Function parameter or member 'disp_bits' not described in 'extcon_cable'
    
    Describe the fields added in the past.
    
    Fixes: ceaa98f442cf ("extcon: Add the support for the capability of each property")
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

extcon: Fix kernel doc of property fields to avoid warnings [+ + +]
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Wed Mar 22 16:39:52 2023 +0200

    extcon: Fix kernel doc of property fields to avoid warnings
    
    [ Upstream commit 7e77e0b7a9f4cdf91cb0950749b40c840ea63efc ]
    
    Kernel documentation has to be synchronized with a code, otherwise
    the validator is not happy:
    
         Function parameter or member 'usb_propval' not described in 'extcon_cable'
         Function parameter or member 'chg_propval' not described in 'extcon_cable'
         Function parameter or member 'jack_propval' not described in 'extcon_cable'
         Function parameter or member 'disp_propval' not described in 'extcon_cable'
    
    Describe the fields added in the past.
    
    Fixes: 067c1652e7a7 ("extcon: Add the support for extcon property according to extcon type")
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

extcon: usbc-tusb320: Convert to i2c's .probe_new() [+ + +]
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Fri Nov 18 23:35:44 2022 +0100

    extcon: usbc-tusb320: Convert to i2c's .probe_new()
    
    [ Upstream commit 5313121b22fd11db0d14f305c110168b8176efdc ]
    
    The probe function doesn't make use of the i2c_device_id * parameter so it
    can be trivially converted.
    
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
    Stable-dep-of: 3adbaa30d973 ("extcon: usbc-tusb320: Unregister typec port on driver removal")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

extcon: usbc-tusb320: Unregister typec port on driver removal [+ + +]
Author: Alvin Šipraga <alsi@bang-olufsen.dk>
Date:   Wed Mar 15 15:15:47 2023 +0100

    extcon: usbc-tusb320: Unregister typec port on driver removal
    
    [ Upstream commit 3adbaa30d973093a4f37927baf9596cca51b593d ]
    
    The driver can register a typec port if suitable firmware properties are
    present. But if the driver is removed through sysfs unbind, rmmod or
    similar, then it does not clean up after itself and the typec port
    device remains registered. This can be seen in sysfs, where stale typec
    ports get left over in /sys/class/typec.
    
    In order to fix this we have to add an i2c_driver remove function and
    call typec_unregister_port(), which is a no-op in the case where no
    typec port is created and the pointer remains NULL.
    
    In the process we should also put the fwnode_handle when the typec port
    isn't registered anymore, including if an error occurs during probe. The
    typec subsystem does not increase or decrease the reference counter for
    us, so we track it in the driver's private data.
    
    Note that the conditional check on TYPEC_PWR_MODE_PD was removed in the
    probe path because a call to tusb320_set_adv_pwr_mode() will perform an
    even more robust validation immediately after, hence there is no
    functional change here.
    
    Fixes: bf7571c00dca ("extcon: usbc-tusb320: Add USB TYPE-C support")
    Cc: stable@vger.kernel.org
    Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
    Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
f2fs: check return value of freeze_super() [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Tue Jun 6 14:19:01 2023 +0800

    f2fs: check return value of freeze_super()
    
    [ Upstream commit 8bec7dd1b3f7d7769d433d67bde404de948a2d95 ]
    
    freeze_super() can fail, it needs to check its return value and do
    error handling in f2fs_resize_fs().
    
    Fixes: 04f0b2eaa3b3 ("f2fs: ioctl for removing a range from F2FS")
    Fixes: b4b10061ef98 ("f2fs: refactor resize_fs to avoid meta updates in progress")
    Signed-off-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED [+ + +]
Author: Yangtao Li <frank.li@vivo.com>
Date:   Wed Apr 26 00:47:11 2023 +0800

    f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED
    
    [ Upstream commit 7cd2e5f75b86a1befa99834f3ed1d735eeff69e6 ]
    
    If a file has FI_COMPRESS_RELEASED, all writes for it should not be
    allowed.
    
    Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
    Signed-off-by: Qi Han <hanqi@vivo.com>
    Signed-off-by: Yangtao Li <frank.li@vivo.com>
    Reviewed-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

f2fs: fix error path handling in truncate_dnode() [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Thu Jun 29 09:41:02 2023 +0800

    f2fs: fix error path handling in truncate_dnode()
    
    [ Upstream commit 0135c482fa97e2fd8245cb462784112a00ed1211 ]
    
    If truncate_node() fails in truncate_dnode(), it missed to call
    f2fs_put_page(), fix it.
    
    Fixes: 7735730d39d7 ("f2fs: fix to propagate error from __get_meta_page()")
    Signed-off-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

f2fs: fix potential deadlock due to unpaired node_write lock use [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Sun May 14 16:07:23 2023 +0800

    f2fs: fix potential deadlock due to unpaired node_write lock use
    
    [ Upstream commit f082c6b205a06953f26c40bdc7621cc5a58ceb7c ]
    
    If S_NOQUOTA is cleared from inode during data page writeback of quota
    file, it may miss to unlock node_write lock, result in potential
    deadlock, fix to use the lock in paired.
    
    Kworker                                 Thread
    - writepage
     if (IS_NOQUOTA())
       f2fs_down_read(&sbi->node_write);
                                            - vfs_cleanup_quota_inode
                                             - inode->i_flags &= ~S_NOQUOTA;
     if (IS_NOQUOTA())
       f2fs_up_read(&sbi->node_write);
    
    Fixes: 79963d967b49 ("f2fs: shrink node_write lock coverage")
    Signed-off-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

f2fs: fix to avoid NULL pointer dereference f2fs_write_end_io() [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Tue May 23 14:17:25 2023 +0800

    f2fs: fix to avoid NULL pointer dereference f2fs_write_end_io()
    
    [ Upstream commit d8189834d4348ae608083e1f1f53792cfcc2a9bc ]
    
    butt3rflyh4ck reports a bug as below:
    
    When a thread always calls F2FS_IOC_RESIZE_FS to resize fs, if resize fs is
    failed, f2fs kernel thread would invoke callback function to update f2fs io
    info, it would call  f2fs_write_end_io and may trigger null-ptr-deref in
    NODE_MAPPING.
    
    general protection fault, probably for non-canonical address
    KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
    RIP: 0010:NODE_MAPPING fs/f2fs/f2fs.h:1972 [inline]
    RIP: 0010:f2fs_write_end_io+0x727/0x1050 fs/f2fs/data.c:370
     <TASK>
     bio_endio+0x5af/0x6c0 block/bio.c:1608
     req_bio_endio block/blk-mq.c:761 [inline]
     blk_update_request+0x5cc/0x1690 block/blk-mq.c:906
     blk_mq_end_request+0x59/0x4c0 block/blk-mq.c:1023
     lo_complete_rq+0x1c6/0x280 drivers/block/loop.c:370
     blk_complete_reqs+0xad/0xe0 block/blk-mq.c:1101
     __do_softirq+0x1d4/0x8ef kernel/softirq.c:571
     run_ksoftirqd kernel/softirq.c:939 [inline]
     run_ksoftirqd+0x31/0x60 kernel/softirq.c:931
     smpboot_thread_fn+0x659/0x9e0 kernel/smpboot.c:164
     kthread+0x33e/0x440 kernel/kthread.c:379
     ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
    
    The root cause is below race case can cause leaving dirty metadata
    in f2fs after filesystem is remount as ro:
    
    Thread A                                Thread B
    - f2fs_ioc_resize_fs
     - f2fs_readonly   --- return false
     - f2fs_resize_fs
                                            - f2fs_remount
                                             - write_checkpoint
                                             - set f2fs as ro
      - free_segment_range
       - update meta_inode's data
    
    Then, if f2fs_put_super()  fails to write_checkpoint due to readonly
    status, and meta_inode's dirty data will be writebacked after node_inode
    is put, finally, f2fs_write_end_io will access NULL pointer on
    sbi->node_inode.
    
    Thread A                                IRQ context
    - f2fs_put_super
     - write_checkpoint fails
     - iput(node_inode)
     - node_inode = NULL
     - iput(meta_inode)
      - write_inode_now
       - f2fs_write_meta_page
                                            - f2fs_write_end_io
                                             - NODE_MAPPING(sbi)
                                             : access NULL pointer on node_inode
    
    Fixes: b4b10061ef98 ("f2fs: refactor resize_fs to avoid meta updates in progress")
    Reported-by: butt3rflyh4ck <butterflyhuangxx@gmail.com>
    Closes: https://lore.kernel.org/r/1684480657-2375-1-git-send-email-yangtiezhu@loongson.cn
    Tested-by: butt3rflyh4ck <butterflyhuangxx@gmail.com>
    Signed-off-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
fanotify: disallow mount/sb marks on kernel internal pseudo fs [+ + +]
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Thu Jun 29 07:20:44 2023 +0300

    fanotify: disallow mount/sb marks on kernel internal pseudo fs
    
    [ Upstream commit 69562eb0bd3e6bb8e522a7b254334e0fb30dff0c ]
    
    Hopefully, nobody is trying to abuse mount/sb marks for watching all
    anonymous pipes/inodes.
    
    I cannot think of a good reason to allow this - it looks like an
    oversight that dated back to the original fanotify API.
    
    Link: https://lore.kernel.org/linux-fsdevel/20230628101132.kvchg544mczxv2pm@quack3/
    Fixes: 0ff21db9fcc3 ("fanotify: hooks the fanotify_mark syscall to the vfsmount code")
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Reviewed-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Message-Id: <20230629042044.25723-1-amir73il@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
fbdev: omapfb: lcd_mipid: Fix an error handling path in mipid_spi_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sun Jun 4 17:42:28 2023 +0200

    fbdev: omapfb: lcd_mipid: Fix an error handling path in mipid_spi_probe()
    
    [ Upstream commit 79a3908d1ea6c35157a6d907b1a9d8ec06015e7a ]
    
    If 'mipid_detect()' fails, we must free 'md' to avoid a memory leak.
    
    Fixes: 66d2f99d0bb5 ("omapfb: add support for MIPI-DCS compatible LCDs")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
fs: avoid empty option when generating legacy mount string [+ + +]
Author: Thomas Weißschuh <linux@weissschuh.net>
Date:   Wed Jun 7 19:28:48 2023 +0200

    fs: avoid empty option when generating legacy mount string
    
    commit 62176420274db5b5127cd7a0083a9aeb461756ee upstream.
    
    As each option string fragment is always prepended with a comma it would
    happen that the whole string always starts with a comma. This could be
    interpreted by filesystem drivers as an empty option and may produce
    errors.
    
    For example the NTFS driver from ntfs.ko behaves like this and fails
    when mounted via the new API.
    
    Link: https://github.com/util-linux/util-linux/issues/2298
    Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
    Fixes: 3e1aeb00e6d1 ("vfs: Implement a filesystem superblock creation/configuration context")
    Cc: stable@vger.kernel.org
    Message-Id: <20230607-fs-empty-option-v1-1-20c8dbf4671b@weissschuh.net>
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

fs: Establish locking order for unrelated directories [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Thu Jun 1 12:58:24 2023 +0200

    fs: Establish locking order for unrelated directories
    
    commit f23ce757185319886ca80c4864ce5f81ac6cc9e9 upstream.
    
    Currently the locking order of inode locks for directories that are not
    in ancestor relationship is not defined because all operations that
    needed to lock two directories like this were serialized by
    sb->s_vfs_rename_mutex. However some filesystems need to lock two
    subdirectories for RENAME_EXCHANGE operations and for this we need the
    locking order established even for two tree-unrelated directories.
    Provide a helper function lock_two_inodes() that establishes lock
    ordering for any two inodes and use it in lock_two_directories().
    
    CC: stable@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Message-Id: <20230601105830.13168-4-jack@suse.cz>
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

fs: Lock moved directories [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Thu Jun 1 12:58:25 2023 +0200

    fs: Lock moved directories
    
    commit 28eceeda130f5058074dd007d9c59d2e8bc5af2e upstream.
    
    When a directory is moved to a different directory, some filesystems
    (udf, ext4, ocfs2, f2fs, and likely gfs2, reiserfs, and others) need to
    update their pointer to the parent and this must not race with other
    operations on the directory. Lock the directories when they are moved.
    Although not all filesystems need this locking, we perform it in
    vfs_rename() because getting the lock ordering right is really difficult
    and we don't want to expose these locking details to filesystems.
    
    CC: stable@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Message-Id: <20230601105830.13168-5-jack@suse.cz>
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

fs: no need to check source [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Mon Jul 3 16:49:11 2023 +0200

    fs: no need to check source
    
    commit 66d8fc0539b0d49941f313c9509a8384e4245ac1 upstream.
    
    The @source inode must be valid. It is even checked via IS_SWAPFILE()
    above making it pretty clear. So no need to check it when we unlock.
    
    What doesn't need to exist is the @target inode. The lock_two_inodes()
    helper currently swaps the @inode1 and @inode2 arguments if @inode1 is
    NULL to have consistent lock class usage. However, we know that at least
    for vfs_rename() that @inode1 is @source and thus is never NULL as per
    above. We also know that @source is a different inode than @target as
    that is checked right at the beginning of vfs_rename(). So we know that
    @source is valid and locked and that @target is locked. So drop the
    check whether @source is non-NULL.
    
    Fixes: 28eceeda130f ("fs: Lock moved directories")
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
    Closes: https://lore.kernel.org/r/202307030026.9sE2pk2x-lkp@intel.com
    Message-Id: <20230703-vfs-rename-source-v1-1-37eebb29b65b@kernel.org>
    [brauner: use commit message from patch I sent concurrently]
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

fs: pipe: reveal missing function protoypes [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 16 21:56:12 2023 +0200

    fs: pipe: reveal missing function protoypes
    
    [ Upstream commit 247c8d2f9837a3e29e3b6b7a4aa9c36c37659dd4 ]
    
    A couple of functions from fs/pipe.c are used both internally
    and for the watch queue code, but the declaration is only
    visible when the latter is enabled:
    
    fs/pipe.c:1254:5: error: no previous prototype for 'pipe_resize_ring'
    fs/pipe.c:758:15: error: no previous prototype for 'account_pipe_buffers'
    fs/pipe.c:764:6: error: no previous prototype for 'too_many_pipe_buffers_soft'
    fs/pipe.c:771:6: error: no previous prototype for 'too_many_pipe_buffers_hard'
    fs/pipe.c:777:6: error: no previous prototype for 'pipe_is_unprivileged_user'
    
    Make the visible unconditionally to avoid these warnings.
    
    Fixes: c73be61cede5 ("pipe: Add general notification queue support")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Message-Id: <20230516195629.551602-1-arnd@kernel.org>
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
gfs2: Fix duplicate should_fault_in_pages() call [+ + +]
Author: Bob Peterson <rpeterso@redhat.com>
Date:   Mon Jun 12 12:26:23 2023 -0500

    gfs2: Fix duplicate should_fault_in_pages() call
    
    [ Upstream commit c8ed1b35931245087968fd95b2ec3dfc50f77769 ]
    
    In gfs2_file_buffered_write(), we currently jump from the second call of
    function should_fault_in_pages() to above the first call, so
    should_fault_in_pages() is getting called twice in a row, causing it to
    accidentally fall back to single-page writes rather than trying the more
    efficient multi-page writes first.
    
    Fix that by moving the retry label to the correct place, behind the
    first call to should_fault_in_pages().
    
    Fixes: e1fa9ea85ce8 ("gfs2: Stop using glock holder auto-demotion for now")
    Signed-off-by: Bob Peterson <rpeterso@redhat.com>
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
gtp: Fix use-after-free in __gtp_encap_destroy(). [+ + +]
Author: Kuniyuki Iwashima <kuniyu@amazon.com>
Date:   Thu Jun 22 14:32:31 2023 -0700

    gtp: Fix use-after-free in __gtp_encap_destroy().
    
    [ Upstream commit ce3aee7114c575fab32a5e9e939d4bbb3dcca79f ]
    
    syzkaller reported use-after-free in __gtp_encap_destroy(). [0]
    
    It shows the same process freed sk and touched it illegally.
    
    Commit e198987e7dd7 ("gtp: fix suspicious RCU usage") added lock_sock()
    and release_sock() in __gtp_encap_destroy() to protect sk->sk_user_data,
    but release_sock() is called after sock_put() releases the last refcnt.
    
    [0]:
    BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
    BUG: KASAN: slab-use-after-free in atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline]
    BUG: KASAN: slab-use-after-free in queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
    BUG: KASAN: slab-use-after-free in do_raw_spin_lock include/linux/spinlock.h:186 [inline]
    BUG: KASAN: slab-use-after-free in __raw_spin_lock_bh include/linux/spinlock_api_smp.h:127 [inline]
    BUG: KASAN: slab-use-after-free in _raw_spin_lock_bh+0x75/0xe0 kernel/locking/spinlock.c:178
    Write of size 4 at addr ffff88800dbef398 by task syz-executor.2/2401
    
    CPU: 1 PID: 2401 Comm: syz-executor.2 Not tainted 6.4.0-rc5-01219-gfa0e21fa4443 #2
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
    Call Trace:
     <TASK>
     __dump_stack lib/dump_stack.c:88 [inline]
     dump_stack_lvl+0x72/0xa0 lib/dump_stack.c:106
     print_address_description mm/kasan/report.c:351 [inline]
     print_report+0xcc/0x620 mm/kasan/report.c:462
     kasan_report+0xb2/0xe0 mm/kasan/report.c:572
     check_region_inline mm/kasan/generic.c:181 [inline]
     kasan_check_range+0x39/0x1c0 mm/kasan/generic.c:187
     instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
     atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline]
     queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
     do_raw_spin_lock include/linux/spinlock.h:186 [inline]
     __raw_spin_lock_bh include/linux/spinlock_api_smp.h:127 [inline]
     _raw_spin_lock_bh+0x75/0xe0 kernel/locking/spinlock.c:178
     spin_lock_bh include/linux/spinlock.h:355 [inline]
     release_sock+0x1f/0x1a0 net/core/sock.c:3526
     gtp_encap_disable_sock drivers/net/gtp.c:651 [inline]
     gtp_encap_disable+0xb9/0x220 drivers/net/gtp.c:664
     gtp_dev_uninit+0x19/0x50 drivers/net/gtp.c:728
     unregister_netdevice_many_notify+0x97e/0x1520 net/core/dev.c:10841
     rtnl_delete_link net/core/rtnetlink.c:3216 [inline]
     rtnl_dellink+0x3c0/0xb30 net/core/rtnetlink.c:3268
     rtnetlink_rcv_msg+0x450/0xb10 net/core/rtnetlink.c:6423
     netlink_rcv_skb+0x15d/0x450 net/netlink/af_netlink.c:2548
     netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
     netlink_unicast+0x700/0x930 net/netlink/af_netlink.c:1365
     netlink_sendmsg+0x91c/0xe30 net/netlink/af_netlink.c:1913
     sock_sendmsg_nosec net/socket.c:724 [inline]
     sock_sendmsg+0x1b7/0x200 net/socket.c:747
     ____sys_sendmsg+0x75a/0x990 net/socket.c:2493
     ___sys_sendmsg+0x11d/0x1c0 net/socket.c:2547
     __sys_sendmsg+0xfe/0x1d0 net/socket.c:2576
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x72/0xdc
    RIP: 0033:0x7f1168b1fe5d
    Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 73 9f 1b 00 f7 d8 64 89 01 48
    RSP: 002b:00007f1167edccc8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 00000000004bbf80 RCX: 00007f1168b1fe5d
    RDX: 0000000000000000 RSI: 00000000200002c0 RDI: 0000000000000003
    RBP: 00000000004bbf80 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
    R13: 000000000000000b R14: 00007f1168b80530 R15: 0000000000000000
     </TASK>
    
    Allocated by task 1483:
     kasan_save_stack+0x22/0x50 mm/kasan/common.c:45
     kasan_set_track+0x25/0x30 mm/kasan/common.c:52
     __kasan_slab_alloc+0x59/0x70 mm/kasan/common.c:328
     kasan_slab_alloc include/linux/kasan.h:186 [inline]
     slab_post_alloc_hook mm/slab.h:711 [inline]
     slab_alloc_node mm/slub.c:3451 [inline]
     slab_alloc mm/slub.c:3459 [inline]
     __kmem_cache_alloc_lru mm/slub.c:3466 [inline]
     kmem_cache_alloc+0x16d/0x340 mm/slub.c:3475
     sk_prot_alloc+0x5f/0x280 net/core/sock.c:2073
     sk_alloc+0x34/0x6c0 net/core/sock.c:2132
     inet6_create net/ipv6/af_inet6.c:192 [inline]
     inet6_create+0x2c7/0xf20 net/ipv6/af_inet6.c:119
     __sock_create+0x2a1/0x530 net/socket.c:1535
     sock_create net/socket.c:1586 [inline]
     __sys_socket_create net/socket.c:1623 [inline]
     __sys_socket_create net/socket.c:1608 [inline]
     __sys_socket+0x137/0x250 net/socket.c:1651
     __do_sys_socket net/socket.c:1664 [inline]
     __se_sys_socket net/socket.c:1662 [inline]
     __x64_sys_socket+0x72/0xb0 net/socket.c:1662
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    Freed by task 2401:
     kasan_save_stack+0x22/0x50 mm/kasan/common.c:45
     kasan_set_track+0x25/0x30 mm/kasan/common.c:52
     kasan_save_free_info+0x2e/0x50 mm/kasan/generic.c:521
     ____kasan_slab_free mm/kasan/common.c:236 [inline]
     ____kasan_slab_free mm/kasan/common.c:200 [inline]
     __kasan_slab_free+0x10c/0x1b0 mm/kasan/common.c:244
     kasan_slab_free include/linux/kasan.h:162 [inline]
     slab_free_hook mm/slub.c:1781 [inline]
     slab_free_freelist_hook mm/slub.c:1807 [inline]
     slab_free mm/slub.c:3786 [inline]
     kmem_cache_free+0xb4/0x490 mm/slub.c:3808
     sk_prot_free net/core/sock.c:2113 [inline]
     __sk_destruct+0x500/0x720 net/core/sock.c:2207
     sk_destruct+0xc1/0xe0 net/core/sock.c:2222
     __sk_free+0xed/0x3d0 net/core/sock.c:2233
     sk_free+0x7c/0xa0 net/core/sock.c:2244
     sock_put include/net/sock.h:1981 [inline]
     __gtp_encap_destroy+0x165/0x1b0 drivers/net/gtp.c:634
     gtp_encap_disable_sock drivers/net/gtp.c:651 [inline]
     gtp_encap_disable+0xb9/0x220 drivers/net/gtp.c:664
     gtp_dev_uninit+0x19/0x50 drivers/net/gtp.c:728
     unregister_netdevice_many_notify+0x97e/0x1520 net/core/dev.c:10841
     rtnl_delete_link net/core/rtnetlink.c:3216 [inline]
     rtnl_dellink+0x3c0/0xb30 net/core/rtnetlink.c:3268
     rtnetlink_rcv_msg+0x450/0xb10 net/core/rtnetlink.c:6423
     netlink_rcv_skb+0x15d/0x450 net/netlink/af_netlink.c:2548
     netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
     netlink_unicast+0x700/0x930 net/netlink/af_netlink.c:1365
     netlink_sendmsg+0x91c/0xe30 net/netlink/af_netlink.c:1913
     sock_sendmsg_nosec net/socket.c:724 [inline]
     sock_sendmsg+0x1b7/0x200 net/socket.c:747
     ____sys_sendmsg+0x75a/0x990 net/socket.c:2493
     ___sys_sendmsg+0x11d/0x1c0 net/socket.c:2547
     __sys_sendmsg+0xfe/0x1d0 net/socket.c:2576
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x3f/0x90 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    The buggy address belongs to the object at ffff88800dbef300
     which belongs to the cache UDPv6 of size 1344
    The buggy address is located 152 bytes inside of
     freed 1344-byte region [ffff88800dbef300, ffff88800dbef840)
    
    The buggy address belongs to the physical page:
    page:00000000d31bfed5 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88800dbeed40 pfn:0xdbe8
    head:00000000d31bfed5 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
    memcg:ffff888008ee0801
    flags: 0x100000000010200(slab|head|node=0|zone=1)
    page_type: 0xffffffff()
    raw: 0100000000010200 ffff88800c7a3000 dead000000000122 0000000000000000
    raw: ffff88800dbeed40 0000000080160015 00000001ffffffff ffff888008ee0801
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff88800dbef280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
     ffff88800dbef300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    >ffff88800dbef380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                ^
     ffff88800dbef400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
     ffff88800dbef480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    
    Fixes: e198987e7dd7 ("gtp: fix suspicious RCU usage")
    Reported-by: syzkaller <syzkaller@googlegroups.com>
    Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
    Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Link: https://lore.kernel.org/r/20230622213231.24651-1-kuniyu@amazon.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
HID: uclogic: Modular KUnit tests should not depend on KUNIT=y [+ + +]
Author: Geert Uytterhoeven <geert+renesas@glider.be>
Date:   Tue May 23 17:10:59 2023 +0200

    HID: uclogic: Modular KUnit tests should not depend on KUNIT=y
    
    [ Upstream commit 49904a0ebf23b15aad288a10f5354e7cd8193121 ]
    
    While KUnit tests that cannot be built as a loadable module must depend
    on "KUNIT=y", this is not true for modular tests, where it adds an
    unnecessary limitation.
    
    Fix this by relaxing the dependency to "KUNIT".
    
    Fixes: 08809e482a1c44d9 ("HID: uclogic: KUnit best practices and naming conventions")
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Reviewed-by: David Gow <davidgow@google.com>
    Reviewed-by: José Expósito <jose.exposito89@gmail.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
hwmon: (f71882fg) prevent possible division by zero [+ + +]
Author: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Date:   Wed May 10 07:35:37 2023 -0700

    hwmon: (f71882fg) prevent possible division by zero
    
    [ Upstream commit 0babf89c9cca7e074d6e59893e462e4886f481cc ]
    
    In the unlikely event that something goes wrong with the device and
    its registers, the fan_from_reg() function may return 0. This value
    will cause a division-by-zero error in the show_pwm() function.
    
    To prevent this, test the value of
    fan_from_reg(data->fan_full_speed[nr]) against 0 before performing
    the division. If the division-by-zero error is avoided, assign 0 to
    the val variable.
    
    Found by Linux Verification Center (linuxtesting.org) with static
    analysis tool SVACE.
    
    Fixes: df9ec2dae094 ("hwmon: (f71882fg) Reorder symbols to get rid of a few forward declarations")
    Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
    Link: https://lore.kernel.org/r/20230510143537.145060-1-n.zhandarovich@fintech.ru
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

hwmon: (gsc-hwmon) fix fan pwm temperature scaling [+ + +]
Author: Tim Harvey <tharvey@gateworks.com>
Date:   Tue Jun 6 08:30:04 2023 -0700

    hwmon: (gsc-hwmon) fix fan pwm temperature scaling
    
    [ Upstream commit a6d80df47ee2c69db99e4f2f8871aa4db154620b ]
    
    The GSC fan pwm temperature register is in centidegrees celcius but the
    Linux hwmon convention is to use milidegrees celcius. Fix the scaling.
    
    Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
    Signed-off-by: Tim Harvey <tharvey@gateworks.com>
    Link: https://lore.kernel.org/r/20230606153004.1448086-1-tharvey@gateworks.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

hwmon: (pmbus/adm1275) Fix problems with temperature monitoring on ADM1272 [+ + +]
Author: Guenter Roeck <linux@roeck-us.net>
Date:   Fri Jun 2 14:34:47 2023 -0700

    hwmon: (pmbus/adm1275) Fix problems with temperature monitoring on ADM1272
    
    [ Upstream commit b153a0bb4199566abd337119207f82b59a8cd1ca ]
    
    The PMON_CONFIG register on ADM1272 is a 16 bit register. Writing a 8 bit
    value into it clears the upper 8 bits of the register, resulting in
    unexpected side effects. Fix by writing the 16 bit register value.
    
    Also, it has been reported that temperature readings are sometimes widely
    inaccurate, to the point where readings may result in device shutdown due
    to errant overtemperature faults. Improve by enabling temperature sampling.
    
    While at it, move the common code for ADM1272 and ADM1278 into a separate
    function, and clarify in the error message that an attempt was made to
    enable both VOUT and temperature monitoring.
    
    Last but not least, return the error code reported by the underlying I2C
    controller and not -ENODEV if updating the PMON_CONFIG register fails.
    After all, this does not indicate that the chip is not present, but an
    error in the communication with the chip.
    
    Fixes: 4ff0ce227a1e ("hwmon: (pmbus/adm1275) Add support for ADM1272")
    Fixes: 9da9c2dc57b2 ("hwmon: (adm1275) enable adm1272 temperature reporting")
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20230602213447.3557346-1-linux@roeck-us.net
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
hwrng: st - keep clock enabled while hwrng is registered [+ + +]
Author: Martin Kaiser <martin@kaiser.cx>
Date:   Fri Jun 16 09:58:13 2023 +0100

    hwrng: st - keep clock enabled while hwrng is registered
    
    [ Upstream commit 501e197a02d4aef157f53ba3a0b9049c3e52fedc ]
    
    The st-rng driver uses devres to register itself with the hwrng core,
    the driver will be unregistered from hwrng when its device goes out of
    scope. This happens after the driver's remove function is called.
    
    However, st-rng's clock is disabled in the remove function. There's a
    short timeframe where st-rng is still registered with the hwrng core
    although its clock is disabled. I suppose the clock must be active to
    access the hardware and serve requests from the hwrng core.
    
    Switch to devm_clk_get_enabled and let devres disable the clock and
    unregister the hwrng. This avoids the race condition.
    
    Fixes: 3e75241be808 ("hwrng: drivers - Use device-managed registration API")
    Signed-off-by: Martin Kaiser <martin@kaiser.cx>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

hwrng: virtio - Fix race on data_avail and actual data [+ + +]
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Thu May 4 11:59:32 2023 +0800

    hwrng: virtio - Fix race on data_avail and actual data
    
    [ Upstream commit ac52578d6e8d300dd50f790f29a24169b1edd26c ]
    
    The virtio rng device kicks off a new entropy request whenever the
    data available reaches zero.  When a new request occurs at the end
    of a read operation, that is, when the result of that request is
    only needed by the next reader, then there is a race between the
    writing of the new data and the next reader.
    
    This is because there is no synchronisation whatsoever between the
    writer and the reader.
    
    Fix this by writing data_avail with smp_store_release and reading
    it with smp_load_acquire when we first enter read.  The subsequent
    reads are safe because they're either protected by the first load
    acquire, or by the completion mechanism.
    
    Also remove the redundant zeroing of data_idx in random_recv_done
    (data_idx must already be zero at this point) and data_avail in
    request_entropy (ditto).
    
    Reported-by: syzbot+726dc8c62c3536431ceb@syzkaller.appspotmail.com
    Fixes: f7f510ec1957 ("virtio: An entropy device, as suggested by hpa.")
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Acked-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
hwtracing: hisi_ptt: Fix potential sleep in atomic context [+ + +]
Author: Yicong Yang <yangyicong@hisilicon.com>
Date:   Wed Jun 21 17:28:04 2023 +0800

    hwtracing: hisi_ptt: Fix potential sleep in atomic context
    
    [ Upstream commit 6c50384ef8b94a527445e3694ae6549e1f15d859 ]
    
    We're using pci_irq_vector() to obtain the interrupt number and then
    bind it to the CPU start perf under the protection of spinlock in
    pmu::start(). pci_irq_vector() might sleep since [1] because it will
    call msi_domain_get_virq() to get the MSI interrupt number and it
    needs to acquire dev->msi.data->mutex. Getting a mutex will sleep on
    contention. So use pci_irq_vector() in an atomic context is problematic.
    
    This patch cached the interrupt number in the probe() and uses the
    cached data instead to avoid potential sleep.
    
    [1] commit 82ff8e6b78fc ("PCI/MSI: Use msi_get_virq() in pci_get_vector()")
    
    Fixes: ff0de066b463 ("hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device")
    Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
    Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Link: https://lore.kernel.org/r/20230621092804.15120-6-yangyicong@huawei.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
i2c: nvidia-gpu: Add ACPI property to align with device-tree [+ + +]
Author: Wayne Chang <waynec@nvidia.com>
Date:   Tue Jan 31 17:57:44 2023 +0000

    i2c: nvidia-gpu: Add ACPI property to align with device-tree
    
    commit f510b0a3565b9231e828e23a7e0f9790b97edf96 upstream.
    
    Device-tree uses the 'firmware-name' string property to pass a name of
    the firmware build to the Cypress CCGx driver. Add a new ACPI string
    property to the NVIDIA GPU I2C driver to align with device-tree so that
    we can migrate to using a common property name for both ACPI and
    device-tree.
    
    Signed-off-by: Wayne Chang <waynec@nvidia.com>
    Co-developed-by: Jon Hunter <jonathanh@nvidia.com>
    Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Acked-by: Ajay Gupta <ajayg@nvidia.com>
    Acked-by: Wolfram Sang <wsa@kernel.org>
    Link: https://lore.kernel.org/r/20230131175748.256423-3-jonathanh@nvidia.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

i2c: nvidia-gpu: Remove ccgx,firmware-build property [+ + +]
Author: Wayne Chang <waynec@nvidia.com>
Date:   Tue Jan 31 17:57:46 2023 +0000

    i2c: nvidia-gpu: Remove ccgx,firmware-build property
    
    commit 430b38764fbb931c6dbd1af13c8b2e4508994662 upstream.
    
    Now the Cypress CCG driver has been updated to support the
    'firmware-name' property to align with device-tree, remove the
    'ccgx,firmware-build' property as this is no longer needed.
    
    Signed-off-by: Wayne Chang <waynec@nvidia.com>
    Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
    Acked-by: Ajay Gupta <ajayg@nvidia.com>
    Acked-by: Wolfram Sang <wsa@kernel.org>
    Link: https://lore.kernel.org/r/20230131175748.256423-5-jonathanh@nvidia.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

i2c: qup: Add missing unwind goto in qup_i2c_probe() [+ + +]
Author: Shuai Jiang <d202180596@hust.edu.cn>
Date:   Tue Apr 18 21:56:12 2023 +0800

    i2c: qup: Add missing unwind goto in qup_i2c_probe()
    
    commit cd9489623c29aa2f8cc07088168afb6e0d5ef06d upstream.
    
    Smatch Warns:
            drivers/i2c/busses/i2c-qup.c:1784 qup_i2c_probe()
            warn: missing unwind goto?
    
    The goto label "fail_runtime" and "fail" will disable qup->pclk,
    but here qup->pclk failed to obtain, in order to be consistent,
    change the direct return to goto label "fail_dma".
    
    Fixes: 9cedf3b2f099 ("i2c: qup: Add bam dma capabilities")
    Signed-off-by: Shuai Jiang <d202180596@hust.edu.cn>
    Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
    Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Cc: <stable@vger.kernel.org> # v4.6+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

i2c: xiic: Don't try to handle more interrupt events after error [+ + +]
Author: Robert Hancock <robert.hancock@calian.com>
Date:   Tue Jun 6 12:25:58 2023 -0600

    i2c: xiic: Don't try to handle more interrupt events after error
    
    [ Upstream commit cb6e45c9a0ad9e0f8664fd06db0227d185dc76ab ]
    
    In xiic_process, it is possible that error events such as arbitration
    lost or TX error can be raised in conjunction with other interrupt flags
    such as TX FIFO empty or bus not busy. Error events result in the
    controller being reset and the error returned to the calling request,
    but the function could potentially try to keep handling the other
    events, such as by writing more messages into the TX FIFO. Since the
    transaction has already failed, this is not helpful and will just cause
    issues.
    
    This problem has been present ever since:
    
    commit 7f9906bd7f72 ("i2c: xiic: Service all interrupts in isr")
    
    which allowed non-error events to be handled after errors, but became
    more obvious after:
    
    commit 743e227a8959 ("i2c: xiic: Defer xiic_wakeup() and
    __xiic_start_xfer() in xiic_process()")
    
    which reworked the code to add a WARN_ON which triggers if both the
    xfer_more and wakeup_req flags were set, since this combination is
    not supposed to happen, but was occurring in this scenario.
    
    Skip further interrupt handling after error flags are detected to avoid
    this problem.
    
    Fixes: 7f9906bd7f72 ("i2c: xiic: Service all interrupts in isr")
    Signed-off-by: Robert Hancock <robert.hancock@calian.com>
    Acked-by: Andi Shyti <andi.shyti@kernel.org>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
i3c: master: svc: fix cpu schedule in spin lock [+ + +]
Author: Clark Wang <xiaoning.wang@nxp.com>
Date:   Wed May 17 11:30:29 2023 +0800

    i3c: master: svc: fix cpu schedule in spin lock
    
    [ Upstream commit 33beadb3b1ab74e69db2c49d9663f3a93a273943 ]
    
    pm_runtime_resume_and_get() may call sleep(). It cannot be used in
    svc_i3c_master_start_xfer_locked(), because it is in a spin lock.
    
    Move the pm runtime operations to svc_i3c_master_enqueue_xfer().
    
    Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
    Fixes: 05be23ef78f7 ("i3c: master: svc: add runtime pm support")
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/r/20230517033030.3068085-2-xiaoning.wang@nxp.com
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
IB/hfi1: Fix wrong mmu_node used for user SDMA packet after invalidate [+ + +]
Author: Brendan Cunningham <bcunningham@cornelisnetworks.com>
Date:   Fri May 19 12:32:16 2023 -0400

    IB/hfi1: Fix wrong mmu_node used for user SDMA packet after invalidate
    
    [ Upstream commit c9358de193ecfb360c3ce75f27ce839ca0b0bc8c ]
    
    The hfi1 user SDMA pinned-page cache will leave a stale cache entry when
    the cache-entry's virtual address range is invalidated but that cache
    entry is in-use by an outstanding SDMA request.
    
    Subsequent user SDMA requests with buffers in or spanning the virtual
    address range of the stale cache entry will result in packets constructed
    from the wrong memory, the physical pages pointed to by the stale cache
    entry.
    
    To fix this, remove mmu_rb_node cache entries from the mmu_rb_handler
    cache independent of the cache entry's refcount. Add 'struct kref
    refcount' to struct mmu_rb_node and manage mmu_rb_node lifetime with
    kref_get() and kref_put().
    
    mmu_rb_node.refcount makes sdma_mmu_node.refcount redundant. Remove
    'atomic_t refcount' from struct sdma_mmu_node and change sdma_mmu_node
    code to use mmu_rb_node.refcount.
    
    Move the mmu_rb_handler destructor call after a
    wait-for-SDMA-request-completion call so mmu_rb_nodes that need
    mmu_rb_handler's workqueue to queue themselves up for destruction from an
    interrupt context may do so.
    
    Fixes: f48ad614c100 ("IB/hfi1: Move driver out of staging")
    Fixes: 00cbce5cbf88 ("IB/hfi1: Fix bugs with non-PAGE_SIZE-end multi-iovec user SDMA requests")
    Link: https://lore.kernel.org/r/168451393605.3700681.13493776139032178861.stgit@awfm-02.cornelisnetworks.com
    Reviewed-by: Dean Luick <dean.luick@cornelisnetworks.com>
    Signed-off-by: Brendan Cunningham <bcunningham@cornelisnetworks.com>
    Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ibmvnic: Do not reset dql stats on NON_FATAL err [+ + +]
Author: Nick Child <nnac123@linux.ibm.com>
Date:   Wed Jun 28 13:22:44 2023 -0500

    ibmvnic: Do not reset dql stats on NON_FATAL err
    
    [ Upstream commit 48538ccb825b05544ec308a509e2cc9c013402db ]
    
    All ibmvnic resets, make a call to netdev_tx_reset_queue() when
    re-opening the device. netdev_tx_reset_queue() resets the num_queued
    and num_completed byte counters. These stats are used in Byte Queue
    Limit (BQL) algorithms. The difference between these two stats tracks
    the number of bytes currently sitting on the physical NIC. ibmvnic
    increases the number of queued bytes though calls to
    netdev_tx_sent_queue() in the drivers xmit function. When, VIOS reports
    that it is done transmitting bytes, the ibmvnic device increases the
    number of completed bytes through calls to netdev_tx_completed_queue().
    It is important to note that the driver batches its transmit calls and
    num_queued is increased every time that an skb is added to the next
    batch, not necessarily when the batch is sent to VIOS for transmission.
    
    Unlike other reset types, a NON FATAL reset will not flush the sub crq
    tx buffers. Therefore, it is possible for the batched skb array to be
    partially full. So if there is call to netdev_tx_reset_queue() when
    re-opening the device, the value of num_queued (0) would not account
    for the skb's that are currently batched. Eventually, when the batch
    is sent to VIOS, the call to netdev_tx_completed_queue() would increase
    num_completed to a value greater than the num_queued. This causes a
    BUG_ON crash:
    
    ibmvnic 30000002: Firmware reports error, cause: adapter problem.
    Starting recovery...
    ibmvnic 30000002: tx error 600
    ibmvnic 30000002: tx error 600
    ibmvnic 30000002: tx error 600
    ibmvnic 30000002: tx error 600
    ------------[ cut here ]------------
    kernel BUG at lib/dynamic_queue_limits.c:27!
    Oops: Exception in kernel mode, sig: 5
    [....]
    NIP dql_completed+0x28/0x1c0
    LR ibmvnic_complete_tx.isra.0+0x23c/0x420 [ibmvnic]
    Call Trace:
    ibmvnic_complete_tx.isra.0+0x3f8/0x420 [ibmvnic] (unreliable)
    ibmvnic_interrupt_tx+0x40/0x70 [ibmvnic]
    __handle_irq_event_percpu+0x98/0x270
    ---[ end trace ]---
    
    Therefore, do not reset the dql stats when performing a NON_FATAL reset.
    
    Fixes: 0d973388185d ("ibmvnic: Introduce xmit_more support using batched subCRQ hcalls")
    Signed-off-by: Nick Child <nnac123@linux.ibm.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ice: handle extts in the miscellaneous interrupt thread [+ + +]
Author: Karol Kolacinski <karol.kolacinski@intel.com>
Date:   Thu Jun 1 14:15:03 2023 -0700

    ice: handle extts in the miscellaneous interrupt thread
    
    [ Upstream commit 6e8b2c88fc8cf95ed09de25946b20b7536c88cd5 ]
    
    The ice_ptp_extts_work() and ice_ptp_periodic_work() functions are both
    scheduled on the same kthread worker, pf.ptp.kworker. The
    ice_ptp_periodic_work() function sends to the firmware to interact with the
    PHY, and must block to wait for responses.
    
    This can cause delay in responding to the PFINT_OICR_TSYN_EVNT interrupt
    cause, ultimately resulting in disruption to processing an input signal of
    the frequency is high enough. In our testing, even 100 Hz signals get
    disrupted.
    
    Fix this by instead processing the signal inside the miscellaneous
    interrupt thread prior to handling Tx timestamps.
    
    Use atomic bits in a new pf->misc_thread bitmap in order to safely
    communicate which tasks require processing within the
    ice_misc_intr_thread_fn(). This ensures the communication of desired tasks
    from the ice_misc_intr() are correctly processed without racing even in the
    event that the interrupt triggers again before the thread function exits.
    
    Fixes: 172db5f91d5f ("ice: add support for auxiliary input/output pins")
    Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
    Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
    Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
igc: Enable and fix RX hash usage by netstack [+ + +]
Author: Jesper Dangaard Brouer <brouer@redhat.com>
Date:   Tue Apr 18 15:30:42 2023 +0200

    igc: Enable and fix RX hash usage by netstack
    
    [ Upstream commit 84214ab4689f962b4bfc47fc9a5838d25ac4274d ]
    
    When function igc_rx_hash() was introduced in v4.20 via commit 0507ef8a0372
    ("igc: Add transmit and receive fastpath and interrupt handlers"), the
    hardware wasn't configured to provide RSS hash, thus it made sense to not
    enable net_device NETIF_F_RXHASH feature bit.
    
    The NIC hardware was configured to enable RSS hash info in v5.2 via commit
    2121c2712f82 ("igc: Add multiple receive queues control supporting"), but
    forgot to set the NETIF_F_RXHASH feature bit.
    
    The original implementation of igc_rx_hash() didn't extract the associated
    pkt_hash_type, but statically set PKT_HASH_TYPE_L3. The largest portions of
    this patch are about extracting the RSS Type from the hardware and mapping
    this to enum pkt_hash_types. This was based on Foxville i225 software user
    manual rev-1.3.1 and tested on Intel Ethernet Controller I225-LM (rev 03).
    
    For UDP it's worth noting that RSS (type) hashing have been disabled both for
    IPv4 and IPv6 (see IGC_MRQC_RSS_FIELD_IPV4_UDP + IGC_MRQC_RSS_FIELD_IPV6_UDP)
    because hardware RSS doesn't handle fragmented pkts well when enabled (can
    cause out-of-order). This results in PKT_HASH_TYPE_L3 for UDP packets, and
    hash value doesn't include UDP port numbers. Not being PKT_HASH_TYPE_L4, have
    the effect that netstack will do a software based hash calc calling into
    flow_dissect, but only when code calls skb_get_hash(), which doesn't
    necessary happen for local delivery.
    
    For QA verification testing I wrote a small bpftrace prog:
     [0] https://github.com/xdp-project/xdp-project/blob/master/areas/hints/monitor_skb_hash_on_dev.bt
    
    Fixes: 2121c2712f82 ("igc: Add multiple receive queues control supporting")
    Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Song Yoong Siang <yoong.siang.song@intel.com>
    Link: https://lore.kernel.org/bpf/168182464270.616355.11391652654430626584.stgit@firesoul
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
iio: accel: fxls8962af: errata bug only applicable for FXLS8962AF [+ + +]
Author: Sean Nyekjaer <sean@geanix.com>
Date:   Mon Jun 5 12:32:22 2023 +0200

    iio: accel: fxls8962af: errata bug only applicable for FXLS8962AF
    
    commit b410a9307bc3a7cdee3c930c98f6fc9cf1d2c484 upstream.
    
    Remove special errata handling if FXLS8964AF is used.
    
    Fixes: af959b7b96b8 ("iio: accel: fxls8962af: fix errata bug E3 - I2C burst reads")
    Signed-off-by: Sean Nyekjaer <sean@geanix.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20230605103223.1400980-2-sean@geanix.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

iio: accel: fxls8962af: fixup buffer scan element type [+ + +]
Author: Sean Nyekjaer <sean@geanix.com>
Date:   Mon Jun 5 12:32:21 2023 +0200

    iio: accel: fxls8962af: fixup buffer scan element type
    
    commit d1cfbd52ede5e5fabc09992894c5733b4057f159 upstream.
    
    Scan elements for x,y,z channels is little endian and requires no bit shifts.
    LE vs. BE is controlled in register SENS_CONFIG2 and bit LE_BE, default
    value is LE.
    
    Fixes: a3e0b51884ee ("iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers")
    Signed-off-by: Sean Nyekjaer <sean@geanix.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20230605103223.1400980-1-sean@geanix.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

iio: adc: ad7192: Fix internal/external clock selection [+ + +]
Author: Fabrizio Lamarque <fl.scratchpad@gmail.com>
Date:   Tue May 30 09:53:08 2023 +0200

    iio: adc: ad7192: Fix internal/external clock selection
    
    commit f7d9e21dd274b97dc0a8dbc136a2ea8506063a96 upstream.
    
    Fix wrong selection of internal clock when mclk is defined.
    
    Resolve a logical inversion introduced in c9ec2cb328e3.
    
    Fixes: c9ec2cb328e3 ("iio: adc: ad7192: use devm_clk_get_optional() for mclk")
    Signed-off-by: Fabrizio Lamarque <fl.scratchpad@gmail.com>
    Reviewed-by: Nuno Sa <nuno.sa@analog.com>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20230530075311.400686-3-fl.scratchpad@gmail.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

iio: adc: ad7192: Fix null ad7192_state pointer access [+ + +]
Author: Fabrizio Lamarque <fl.scratchpad@gmail.com>
Date:   Tue May 30 09:53:07 2023 +0200

    iio: adc: ad7192: Fix null ad7192_state pointer access
    
    commit 9e58e3a6f8e1c483c86a04903b7b7aa0923e4426 upstream.
    
    Pointer to indio_dev structure is obtained via spi_get_drvdata() at
    the beginning of function ad7192_setup(), but the spi->dev->driver_data
    member is not initialized, hence a NULL pointer is returned.
    
    Fix by changing ad7192_setup() signature to take pointer to struct
    iio_dev, and get ad7192_state pointer via st = iio_priv(indio_dev);
    
    Fixes: bd5dcdeb3fd0 ("iio: adc: ad7192: convert to device-managed functions")
    Signed-off-by: Fabrizio Lamarque <fl.scratchpad@gmail.com>
    Reviewed-by: Nuno Sa <nuno.sa@analog.com>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20230530075311.400686-2-fl.scratchpad@gmail.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ima: Fix build warnings [+ + +]
Author: Roberto Sassu <roberto.sassu@huawei.com>
Date:   Tue Jun 6 09:41:13 2023 +0200

    ima: Fix build warnings
    
    [ Upstream commit 95526d13038c2bbddd567a4d8e39fac42484e182 ]
    
    Fix build warnings (function parameters description) for
    ima_collect_modsig(), ima_match_policy() and ima_parse_add_rule().
    
    Fixes: 15588227e086 ("ima: Collect modsig") # v5.4+
    Fixes: 2fe5d6def167 ("ima: integrity appraisal extension") # v5.14+
    Fixes: 4af4662fa4a9 ("integrity: IMA policy") # v3.2+
    Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
    Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Input: adxl34x - do not hardcode interrupt trigger type [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Wed May 10 17:27:55 2023 -0700

    Input: adxl34x - do not hardcode interrupt trigger type
    
    [ Upstream commit e96220bce5176ed2309f77f061dcc0430b82b25e ]
    
    Instead of hardcoding IRQ trigger type to IRQF_TRIGGER_HIGH, let's
    respect the settings specified in the firmware description.
    
    Fixes: e27c729219ad ("Input: add driver for ADXL345/346 Digital Accelerometers")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Acked-by: Michael Hennerich <michael.hennerich@analog.com>
    Link: https://lore.kernel.org/r/20230509203555.549158-1-marex@denx.de
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Input: drv260x - sleep between polling GO bit [+ + +]
Author: Luca Weiss <luca@z3ntu.xyz>
Date:   Mon May 1 17:01:45 2023 -0700

    Input: drv260x - sleep between polling GO bit
    
    [ Upstream commit efef661dfa6bf8cbafe4cd6a97433fcef0118967 ]
    
    When doing the initial startup there's no need to poll without any
    delay and spam the I2C bus.
    
    Let's sleep 15ms between each attempt, which is the same time as used
    in the vendor driver.
    
    Fixes: 7132fe4f5687 ("Input: drv260x - add TI drv260x haptics driver")
    Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
    Link: https://lore.kernel.org/r/20230430-drv260x-improvements-v1-2-1fb28b4cc698@z3ntu.xyz
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Input: pm8941-powerkey - fix debounce on gen2+ PMICs [+ + +]
Author: Caleb Connolly <caleb.connolly@linaro.org>
Date:   Tue Jun 6 12:05:32 2023 -0700

    Input: pm8941-powerkey - fix debounce on gen2+ PMICs
    
    [ Upstream commit 8c9cce9cb81b5fdc6e66bf3f129727b89e8daab7 ]
    
    Since PM8998/PM660, the power key debounce register was redefined to
    support shorter debounce times. On PM8941 the shortest debounce time
    (represented by register value 0) was 15625us, on PM8998 the shortest
    debounce time is 62us, with the default being 2ms.
    
    Adjust the bit shift to correctly program debounce on PM8998 and newer.
    
    Fixes: 68c581d5e7d8 ("Input: add Qualcomm PM8941 power key driver")
    Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
    Link: https://lore.kernel.org/r/20230529-pm8941-pwrkey-debounce-v1-2-c043a6d5c814@linaro.org
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
integrity: Fix possible multiple allocation in integrity_inode_get() [+ + +]
Author: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Date:   Thu Jun 1 14:42:44 2023 +0800

    integrity: Fix possible multiple allocation in integrity_inode_get()
    
    commit 9df6a4870dc371136e90330cfbbc51464ee66993 upstream.
    
    When integrity_inode_get() is querying and inserting the cache, there
    is a conditional race in the concurrent environment.
    
    The race condition is the result of not properly implementing
    "double-checked locking". In this case, it first checks to see if the
    iint cache record exists before taking the lock, but doesn't check
    again after taking the integrity_iint_lock.
    
    Fixes: bf2276d10ce5 ("ima: allocating iint improvements")
    Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
    Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
    Cc: <stable@vger.kernel.org> # v3.10+
    Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
io_uring: Use io_schedule* in cqring wait [+ + +]
Author: Andres Freund <andres@anarazel.de>
Date:   Sun Jul 16 12:13:06 2023 -0600

    io_uring: Use io_schedule* in cqring wait
    
    Commit 8a796565cec3601071cbbd27d6304e202019d014 upstream.
    
    I observed poor performance of io_uring compared to synchronous IO. That
    turns out to be caused by deeper CPU idle states entered with io_uring,
    due to io_uring using plain schedule(), whereas synchronous IO uses
    io_schedule().
    
    The losses due to this are substantial. On my cascade lake workstation,
    t/io_uring from the fio repository e.g. yields regressions between 20%
    and 40% with the following command:
    ./t/io_uring -r 5 -X0 -d 1 -s 1 -c 1 -p 0 -S$use_sync -R 0 /mnt/t2/fio/write.0.0
    
    This is repeatable with different filesystems, using raw block devices
    and using different block devices.
    
    Use io_schedule_prepare() / io_schedule_finish() in
    io_cqring_wait_schedule() to address the difference.
    
    After that using io_uring is on par or surpassing synchronous IO (using
    registered files etc makes it reliably win, but arguably is a less fair
    comparison).
    
    There are other calls to schedule() in io_uring/, but none immediately
    jump out to be similarly situated, so I did not touch them. Similarly,
    it's possible that mutex_lock_io() should be used, but it's not clear if
    there are cases where that matters.
    
    Cc: stable@vger.kernel.org # 5.10+
    Cc: Pavel Begunkov <asml.silence@gmail.com>
    Cc: io-uring@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Andres Freund <andres@anarazel.de>
    Link: https://lore.kernel.org/r/20230707162007.194068-1-andres@anarazel.de
    [axboe: minor style fixup]
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

io_uring: wait interruptibly for request completions on exit [+ + +]
Author: Jens Axboe <axboe@kernel.dk>
Date:   Sun Jun 11 21:14:09 2023 -0600

    io_uring: wait interruptibly for request completions on exit
    
    commit 4826c59453b3b4677d6bf72814e7ababdea86949 upstream.
    
    WHen the ring exits, cleanup is done and the final cancelation and
    waiting on completions is done by io_ring_exit_work. That function is
    invoked by kworker, which doesn't take any signals. Because of that, it
    doesn't really matter if we wait for completions in TASK_INTERRUPTIBLE
    or TASK_UNINTERRUPTIBLE state. However, it does matter to the hung task
    detection checker!
    
    Normally we expect cancelations and completions to happen rather
    quickly. Some test cases, however, will exit the ring and park the
    owning task stopped (eg via SIGSTOP). If the owning task needs to run
    task_work to complete requests, then io_ring_exit_work won't make any
    progress until the task is runnable again. Hence io_ring_exit_work can
    trigger the hung task detection, which is particularly problematic if
    panic-on-hung-task is enabled.
    
    As the ring exit doesn't take signals to begin with, have it wait
    interruptibly rather than uninterruptibly. io_uring has a separate
    stuck-exit warning that triggers independently anyway, so we're not
    really missing anything by making this switch.
    
    Cc: stable@vger.kernel.org # 5.10+
    Link: https://lore.kernel.org/r/b0e4aaef-7088-56ce-244c-976edeac0e66@kernel.dk
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
iommu/virtio: Detach domain on endpoint release [+ + +]
Author: Jean-Philippe Brucker <jean-philippe@linaro.org>
Date:   Mon May 15 12:39:48 2023 +0100

    iommu/virtio: Detach domain on endpoint release
    
    [ Upstream commit 809d0810e3520da669d231303608cdf5fe5c1a70 ]
    
    When an endpoint is released, for example a PCIe VF being destroyed or a
    function hot-unplugged, it should be detached from its domain. Send a
    DETACH request.
    
    Fixes: edcd69ab9a32 ("iommu: Add virtio-iommu driver")
    Reported-by: Akihiko Odaki <akihiko.odaki@daynix.com>
    Link: https://lore.kernel.org/all/15bf1b00-3aa0-973a-3a86-3fa5c4d41d2c@daynix.com/
    Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
    Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
    Link: https://lore.kernel.org/r/20230515113946.1017624-2-jean-philippe@linaro.org
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

iommu/virtio: Return size mapped for a detached domain [+ + +]
Author: Jean-Philippe Brucker <jean-philippe@linaro.org>
Date:   Mon May 15 12:39:50 2023 +0100

    iommu/virtio: Return size mapped for a detached domain
    
    [ Upstream commit 7061b6af34686e7e2364b7240cfb061293218f2d ]
    
    When map() is called on a detached domain, the domain does not exist in
    the device so we do not send a MAP request, but we do update the
    internal mapping tree, to be replayed on the next attach. Since this
    constitutes a successful iommu_map() call, return *mapped in this case
    too.
    
    Fixes: 7e62edd7a33a ("iommu/virtio: Add map/unmap_pages() callbacks implementation")
    Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
    Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
    Link: https://lore.kernel.org/r/20230515113946.1017624-3-jean-philippe@linaro.org
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ipvlan: Fix return value of ipvlan_queue_xmit() [+ + +]
Author: Cambda Zhu <cambda@linux.alibaba.com>
Date:   Mon Jun 26 17:33:47 2023 +0800

    ipvlan: Fix return value of ipvlan_queue_xmit()
    
    [ Upstream commit 8a9922e7be6d042fa00f894c376473b17a162b66 ]
    
    ipvlan_queue_xmit() should return NET_XMIT_XXX, but
    ipvlan_xmit_mode_l2/l3() returns rx_handler_result_t or NET_RX_XXX
    in some cases. ipvlan_rcv_frame() will only return RX_HANDLER_CONSUMED
    in ipvlan_xmit_mode_l2/l3() because 'local' is true. It's equal to
    NET_XMIT_SUCCESS. But dev_forward_skb() can return NET_RX_SUCCESS or
    NET_RX_DROP, and returning NET_RX_DROP(NET_XMIT_DROP) will increase
    both ipvlan and ipvlan->phy_dev drops counter.
    
    The skb to forward can be treated as xmitted successfully. This patch
    makes ipvlan_queue_xmit() return NET_XMIT_SUCCESS for forward skb.
    
    Fixes: 2ad7bf363841 ("ipvlan: Initial check-in of the IPVLAN driver.")
    Signed-off-by: Cambda Zhu <cambda@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20230626093347.7492-1-cambda@linux.alibaba.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ipvs: increase ip_vs_conn_tab_bits range for 64BIT [+ + +]
Author: Abhijeet Rastogi <abhijeet.1989@gmail.com>
Date:   Tue May 16 20:08:49 2023 -0700

    ipvs: increase ip_vs_conn_tab_bits range for 64BIT
    
    commit 04292c695f82b6cf0d25dd5ae494f16ddbb621f6 upstream.
    
    Current range [8, 20] is set purely due to historical reasons
    because at the time, ~1M (2^20) was considered sufficient.
    With this change, 27 is the upper limit for 64-bit, 20 otherwise.
    
    Previous change regarding this limit is here.
    
    Link: https://lore.kernel.org/all/86eabeb9dd62aebf1e2533926fdd13fed48bab1f.1631289960.git.aclaudi@redhat.com/T/#u
    
    Signed-off-by: Abhijeet Rastogi <abhijeet.1989@gmail.com>
    Acked-by: Julian Anastasov <ja@ssi.bg>
    Acked-by: Simon Horman <horms@kernel.org>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Cc: Allen Pais <apais@linux.microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
irqchip/jcore-aic: Fix missing allocation of IRQ descriptors [+ + +]
Author: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date:   Wed May 10 18:33:42 2023 +0200

    irqchip/jcore-aic: Fix missing allocation of IRQ descriptors
    
    [ Upstream commit 4848229494a323eeaab62eee5574ef9f7de80374 ]
    
    The initialization function for the J-Core AIC aic_irq_of_init() is
    currently missing the call to irq_alloc_descs() which allocates and
    initializes all the IRQ descriptors. Add missing function call and
    return the error code from irq_alloc_descs() in case the allocation
    fails.
    
    Fixes: 981b58f66cfc ("irqchip/jcore-aic: Add J-Core AIC driver")
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Tested-by: Rob Landley <rob@landley.net>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20230510163343.43090-1-glaubitz@physik.fu-berlin.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
irqchip/loongson-pch-pic: Fix initialization of HT vector register [+ + +]
Author: Jianmin Lv <lvjianmin@loongson.cn>
Date:   Wed Jun 14 19:59:32 2023 +0800

    irqchip/loongson-pch-pic: Fix initialization of HT vector register
    
    commit f679616565f1cf1a4acb245dbc0032dafcd40637 upstream.
    
    In an ACPI-based dual-bridge system, IRQ of each bridge's
    PCH PIC sent to CPU is always a zero-based number, which
    means that the IRQ on PCH PIC of each bridge is mapped into
    vector range from 0 to 63 of upstream irqchip(e.g. EIOINTC).
    
          EIOINTC N: [0 ... 63 | 64 ... 255]
                      --------   ----------
                          ^          ^
                          |          |
                      PCH PIC N      |
                                 PCH MSI N
    
    For example, the IRQ vector number of sata controller on
    PCH PIC of each bridge is 16, which is sent to upstream
    irqchip of EIOINTC when an interrupt occurs, which will set
    bit 16 of EIOINTC. Since hwirq of 16 on EIOINTC has been
    mapped to a irq_desc for sata controller during hierarchy
    irq allocation, the related mapped IRQ will be found through
    irq_resolve_mapping() in the IRQ domain of EIOINTC.
    
    So, the IRQ number set in HT vector register should be fixed
    to be a zero-based number.
    
    Cc: stable@vger.kernel.org
    Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
    Co-developed-by: liuyun <liuyun@loongson.cn>
    Signed-off-by: liuyun <liuyun@loongson.cn>
    Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20230614115936.5950-2-lvjianmin@loongson.cn
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

irqchip/loongson-pch-pic: Fix potential incorrect hwirq assignment [+ + +]
Author: Liu Peibao <liupeibao@loongson.cn>
Date:   Wed Jun 14 19:59:33 2023 +0800

    irqchip/loongson-pch-pic: Fix potential incorrect hwirq assignment
    
    commit 783422e704ca0fa41cb2fe9ed79e46b6fe7eae29 upstream.
    
    In DeviceTree path, when ht_vec_base is not zero, the hwirq of PCH PIC
    will be assigned incorrectly. Because when pch_pic_domain_translate()
    adds the ht_vec_base to hwirq, the hwirq does not have the ht_vec_base
    subtracted when calling irq_domain_set_info().
    
    The ht_vec_base is designed for the parent irq chip/domain of the PCH PIC.
    It seems not proper to deal this in callbacks of the PCH PIC domain and
    let's put this back like the initial commit ef8c01eb64ca ("irqchip: Add
    Loongson PCH PIC controller").
    
    Fixes: bcdd75c596c8 ("irqchip/loongson-pch-pic: Add ACPI init support")
    Cc: stable@vger.kernel.org
    Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
    Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20230614115936.5950-3-lvjianmin@loongson.cn
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
irqchip/stm32-exti: Fix warning on initialized field overwritten [+ + +]
Author: Antonio Borneo <antonio.borneo@foss.st.com>
Date:   Thu Jun 1 17:56:14 2023 +0200

    irqchip/stm32-exti: Fix warning on initialized field overwritten
    
    [ Upstream commit 48f31e496488a25f443c0df52464da446fb1d10c ]
    
    While compiling with W=1, both gcc and clang complain about a
    tricky way to initialize an array by filling it with a non-zero
    value and then overrride some of the array elements.
    In this case the override is intentional, so just disable the
    specific warning for only this part of the code.
    
    Note: the flag "-Woverride-init" is recognized by both compilers,
    but the warning msg from clang reports "-Winitializer-overrides".
    The doc of clang clarifies that the two flags are synonyms, so use
    here only the flag name common on both compilers.
    
    Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
    Fixes: c297493336b7 ("irqchip/stm32-exti: Simplify irq description table")
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20230601155614.34490-1-antonio.borneo@foss.st.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
jffs2: reduce stack usage in jffs2_build_xattr_subsystem() [+ + +]
Author: Fabian Frederick <fabf@skynet.be>
Date:   Sat May 6 06:56:12 2023 +0200

    jffs2: reduce stack usage in jffs2_build_xattr_subsystem()
    
    commit 1168f095417643f663caa341211e117db552989f upstream.
    
    Use kcalloc() for allocation/flush of 128 pointers table to
    reduce stack usage.
    
    Function now returns -ENOMEM or 0 on success.
    
    stackusage
    Before:
    ./fs/jffs2/xattr.c:775  jffs2_build_xattr_subsystem     1208
    dynamic,bounded
    
    After:
    ./fs/jffs2/xattr.c:775  jffs2_build_xattr_subsystem     192
    dynamic,bounded
    
    Also update definition when CONFIG_JFFS2_FS_XATTR is not enabled
    
    Tested with an MTD mount point and some user set/getfattr.
    
    Many current target on OpenWRT also suffer from a compilation warning
    (that become an error with CONFIG_WERROR) with the following output:
    
    fs/jffs2/xattr.c: In function 'jffs2_build_xattr_subsystem':
    fs/jffs2/xattr.c:887:1: error: the frame size of 1088 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
      887 | }
          | ^
    
    Using dynamic allocation fix this compilation warning.
    
    Fixes: c9f700f840bd ("[JFFS2][XATTR] using 'delete marker' for xdatum/xref deletion")
    Reported-by: Tim Gardner <tim.gardner@canonical.com>
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: Ron Economos <re@w6rz.net>
    Reported-by: Nathan Chancellor <nathan@kernel.org>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Fabian Frederick <fabf@skynet.be>
    Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
    Cc: stable@vger.kernel.org
    Message-Id: <20230506045612.16616-1-ansuelsmth@gmail.com>
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
kbuild: Disable GCOV for *.mod.o [+ + +]
Author: Sami Tolvanen <samitolvanen@google.com>
Date:   Fri Jun 23 00:11:43 2023 +0000

    kbuild: Disable GCOV for *.mod.o
    
    [ Upstream commit 25a21fbb934a0d989e1858f83c2ddf4cfb2ebe30 ]
    
    With GCOV_PROFILE_ALL, Clang injects __llvm_gcov_* functions to each
    object file, including the *.mod.o. As we filter out CC_FLAGS_CFI
    for *.mod.o, the compiler won't generate type hashes for the
    injected functions, and therefore indirectly calling them during
    module loading trips indirect call checking.
    
    Enabling CFI for *.mod.o isn't sufficient to fix this issue after
    commit 0c3e806ec0f9 ("x86/cfi: Add boot time hash randomization"),
    as *.mod.o aren't processed by objtool, which means any hashes
    emitted there won't be randomized. Therefore, in addition to
    disabling CFI for *.mod.o, also disable GCOV, as the object files
    don't otherwise contain any executable code.
    
    Fixes: cf68fffb66d6 ("add support for Clang CFI")
    Reported-by: Joe Fradley <joefradley@google.com>
    Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
kcsan: Don't expect 64 bits atomic builtins from 32 bits architectures [+ + +]
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Fri May 12 17:31:17 2023 +0200

    kcsan: Don't expect 64 bits atomic builtins from 32 bits architectures
    
    [ Upstream commit 353e7300a1db928e427462f2745f9a2cd1625b3d ]
    
    Activating KCSAN on a 32 bits architecture leads to the following
    link-time failure:
    
        LD      .tmp_vmlinux.kallsyms1
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_load':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_load_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_store':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_store_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_exchange':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_exchange_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_fetch_add':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_fetch_add_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_fetch_sub':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_fetch_sub_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_fetch_and':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_fetch_and_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_fetch_or':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_fetch_or_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_fetch_xor':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_fetch_xor_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_fetch_nand':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_fetch_nand_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_compare_exchange_strong':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_compare_exchange_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_compare_exchange_weak':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_compare_exchange_8'
      powerpc64-linux-ld: kernel/kcsan/core.o: in function `__tsan_atomic64_compare_exchange_val':
      kernel/kcsan/core.c:1273: undefined reference to `__atomic_compare_exchange_8'
    
    32 bits architectures don't have 64 bits atomic builtins. Only
    include DEFINE_TSAN_ATOMIC_OPS(64) on 64 bits architectures.
    
    Fixes: 0f8ad5f2e934 ("kcsan: Add support for atomic builtins")
    Suggested-by: Marco Elver <elver@google.com>
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Reviewed-by: Marco Elver <elver@google.com>
    Acked-by: Marco Elver <elver@google.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/d9c6afc28d0855240171a4e0ad9ffcdb9d07fceb.1683892665.git.christophe.leroy@csgroup.eu
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR [+ + +]
Author: Muchun Song <muchun.song@linux.dev>
Date:   Tue May 23 10:40:17 2023 +0800

    kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
    
    [ Upstream commit 30480b988f88c279752f3202a26b6fee5f586aef ]
    
    The root->ino_idr is supposed to be protected by kernfs_idr_lock, fix
    it.
    
    Fixes: 488dee96bb62 ("kernfs: allow creating kernfs objects with arbitrary uid/gid")
    Signed-off-by: Muchun Song <songmuchun@bytedance.com>
    Acked-by: Tejun Heo <tj@kernel.org>
    Link: https://lore.kernel.org/r/20230523024017.24851-1-songmuchun@bytedance.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
kexec: fix a memory leak in crash_shrink_memory() [+ + +]
Author: Zhen Lei <thunder.leizhen@huawei.com>
Date:   Sat May 27 20:34:34 2023 +0800

    kexec: fix a memory leak in crash_shrink_memory()
    
    [ Upstream commit 1cba6c4309f03de570202c46f03df3f73a0d4c82 ]
    
    Patch series "kexec: enable kexec_crash_size to support two crash kernel
    regions".
    
    When crashkernel=X fails to reserve region under 4G, it will fall back to
    reserve region above 4G and a region of the default size will also be
    reserved under 4G.  Unfortunately, /sys/kernel/kexec_crash_size only
    supports one crash kernel region now, the user cannot sense the low memory
    reserved by reading /sys/kernel/kexec_crash_size.  Also, low memory cannot
    be freed by writing this file.
    
    For example:
    resource_size(crashk_res) = 512M
    resource_size(crashk_low_res) = 256M
    
    The result of 'cat /sys/kernel/kexec_crash_size' is 512M, but it should be
    768M.  When we execute 'echo 0 > /sys/kernel/kexec_crash_size', the size
    of crashk_res becomes 0 and resource_size(crashk_low_res) is still 256 MB,
    which is incorrect.
    
    Since crashk_res manages the memory with high address and crashk_low_res
    manages the memory with low address, crashk_low_res is shrunken only when
    all crashk_res is shrunken.  And because when there is only one crash
    kernel region, crashk_res is always used.  Therefore, if all crashk_res is
    shrunken and crashk_low_res still exists, swap them.
    
    This patch (of 6):
    
    If the value of parameter 'new_size' is in the semi-open and semi-closed
    interval (crashk_res.end - KEXEC_CRASH_MEM_ALIGN + 1, crashk_res.end], the
    calculation result of ram_res is:
    
            ram_res->start = crashk_res.end + 1
            ram_res->end   = crashk_res.end
    
    The operation of insert_resource() fails, and ram_res is not added to
    iomem_resource.  As a result, the memory of the control block ram_res is
    leaked.
    
    In fact, on all architectures, the start address and size of crashk_res
    are already aligned by KEXEC_CRASH_MEM_ALIGN.  Therefore, we do not need
    to round up crashk_res.start again.  Instead, we should round up
    'new_size' in advance.
    
    Link: https://lkml.kernel.org/r/20230527123439.772-1-thunder.leizhen@huawei.com
    Link: https://lkml.kernel.org/r/20230527123439.772-2-thunder.leizhen@huawei.com
    Fixes: 6480e5a09237 ("kdump: add missing RAM resource in crash_shrink_memory()")
    Fixes: 06a7f711246b ("kexec: premit reduction of the reserved memory size")
    Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
    Acked-by: Baoquan He <bhe@redhat.com>
    Cc: Cong Wang <amwang@redhat.com>
    Cc: Eric W. Biederman <ebiederm@xmission.com>
    Cc: Michael Holzheu <holzheu@linux.vnet.ibm.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined [+ + +]
Author: Colin Ian King <colin.i.king@gmail.com>
Date:   Mon Apr 17 11:47:43 2023 +0100

    kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined
    
    [ Upstream commit 375b9ff53cb6f9c042817b75f2be0a650626dc4f ]
    
    In the unlikely case that CLOCK_REALTIME is not defined, variable ret is
    not initialized and further accumulation of return values to ret can leave
    ret in an undefined state. Fix this by initialized ret to zero and changing
    the assignment of ret to an accumulation for the CLOCK_REALTIME case.
    
    Fixes: 03f55c7952c9 ("kselftest: Extend vDSO selftest to clock_getres")
    Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
    Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ksmbd: avoid field overflow warning [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Mon Jun 19 10:19:38 2023 +0200

    ksmbd: avoid field overflow warning
    
    [ Upstream commit 9cedc58bdbe9fff9aacd0ca19ee5777659f28fd7 ]
    
    clang warns about a possible field overflow in a memcpy:
    
    In file included from fs/smb/server/smb_common.c:7:
    include/linux/fortify-string.h:583:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
                            __write_overflow_field(p_size_field, size);
    
    It appears to interpret the "&out[baselen + 4]" as referring to a single
    byte of the character array, while the equivalen "out + baselen + 4" is
    seen as an offset into the array.
    
    I don't see that kind of warning elsewhere, so just go with the simple
    rework.
    
    Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Namjae Jeon <linkinjeon@kernel.org>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
KVM: s390/diag: fix racy access of physical cpu number in diag 9c handler [+ + +]
Author: Christian Borntraeger <borntraeger@linux.ibm.com>
Date:   Mon May 15 10:42:34 2023 +0200

    KVM: s390/diag: fix racy access of physical cpu number in diag 9c handler
    
    [ Upstream commit 0bc380beb78aa352eadbc21d934dd9606fcee808 ]
    
    We do check for target CPU == -1, but this might change at the time we
    are going to use it. Hold the physical target CPU in a local variable to
    avoid out-of-bound accesses to the cpu arrays.
    
    Cc: Pierre Morel <pmorel@linux.ibm.com>
    Fixes: 87e28a15c42c ("KVM: s390: diag9c (directed yield) forwarding")
    Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
    Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
    Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
    Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
    Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

KVM: s390: fix KVM_S390_GET_CMMA_BITS for GFNs in memslot holes [+ + +]
Author: Nico Boehr <nrb@linux.ibm.com>
Date:   Fri Mar 24 15:54:23 2023 +0100

    KVM: s390: fix KVM_S390_GET_CMMA_BITS for GFNs in memslot holes
    
    [ Upstream commit 285cff4c0454340a4dc53f46e67f2cb1c293bd74 ]
    
    The KVM_S390_GET_CMMA_BITS ioctl may return incorrect values when userspace
    specifies a start_gfn outside of memslots.
    
    This can occur when a VM has multiple memslots with a hole in between:
    
    +-----+----------+--------+--------+
    | ... | Slot N-1 | <hole> | Slot N |
    +-----+----------+--------+--------+
          ^          ^        ^        ^
          |          |        |        |
    GFN   A          A+B      |        |
                              A+B+C    |
                                       A+B+C+D
    
    When userspace specifies a GFN in [A+B, A+B+C), it would expect to get the
    CMMA values of the first dirty page in Slot N. However, userspace may get a
    start_gfn of A+B+C+D with a count of 0, hence completely skipping over any
    dirty pages in slot N.
    
    The error is in kvm_s390_next_dirty_cmma(), which assumes
    gfn_to_memslot_approx() will return the memslot _below_ the specified GFN
    when the specified GFN lies outside a memslot. In reality it may return
    either the memslot below or above the specified GFN.
    
    When a memslot above the specified GFN is returned this happens:
    
    - ofs is calculated, but since the memslot's base_gfn is larger than the
      specified cur_gfn, ofs will underflow to a huge number.
    - ofs is passed to find_next_bit(). Since ofs will exceed the memslot's
      number of pages, the number of pages in the memslot is returned,
      completely skipping over all bits in the memslot userspace would be
      interested in.
    
    Fix this by resetting ofs to zero when a memslot _above_ cur_gfn is
    returned (cur_gfn < ms->base_gfn).
    
    Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
    Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
    Fixes: afdad61615cc ("KVM: s390: Fix storage attributes migration with memory slots")
    Message-Id: <20230324145424.293889-2-nrb@linux.ibm.com>
    Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
    Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

KVM: s390: vsie: fix the length of APCB bitmap [+ + +]
Author: Pierre Morel <pmorel@linux.ibm.com>
Date:   Wed May 10 17:42:58 2023 +0200

    KVM: s390: vsie: fix the length of APCB bitmap
    
    [ Upstream commit 246be7d2720ea9a795b576067ecc5e5c7a1e7848 ]
    
    bit_and() uses the count of bits as the woking length.
    Fix the previous implementation and effectively use
    the right bitmap size.
    
    Fixes: 19fd83a64718 ("KVM: s390: vsie: allow CRYCB FORMAT-1")
    Fixes: 56019f9aca22 ("KVM: s390: vsie: Allow CRYCB FORMAT-2")
    
    Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
    Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
    Link: https://lore.kernel.org/kvm/20230511094719.9691-1-pmorel@linux.ibm.com/
    Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
leds: trigger: netdev: Recheck NETDEV_LED_MODE_LINKUP on dev rename [+ + +]
Author: Christian Marangi <ansuelsmth@gmail.com>
Date:   Wed Apr 19 23:07:39 2023 +0200

    leds: trigger: netdev: Recheck NETDEV_LED_MODE_LINKUP on dev rename
    
    commit cee4bd16c3195a701be683f7da9e88c6e11acb73 upstream.
    
    Dev can be renamed also while up for supported device. We currently
    wrongly clear the NETDEV_LED_MODE_LINKUP flag on NETDEV_CHANGENAME
    event.
    
    Fix this by rechecking if the carrier is ok on NETDEV_CHANGENAME and
    correctly set the NETDEV_LED_MODE_LINKUP bit.
    
    Fixes: 5f820ed52371 ("leds: trigger: netdev: fix handling on interface rename")
    Cc: stable@vger.kernel.org # v5.5+
    Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: Lee Jones <lee@kernel.org>
    Link: https://lore.kernel.org/r/20230419210743.3594-2-ansuelsmth@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
lib/bitmap: drop optimization of bitmap_{from,to}_arr64 [+ + +]
Author: Yury Norov <yury.norov@gmail.com>
Date:   Mon Feb 27 11:24:36 2023 -0800

    lib/bitmap: drop optimization of bitmap_{from,to}_arr64
    
    [ Upstream commit c1d2ba10f594046831d14b03f194e8d05e78abad ]
    
    bitmap_{from,to}_arr64() optimization is overly optimistic on 32-bit LE
    architectures when it's wired to bitmap_copy_clear_tail().
    
    bitmap_copy_clear_tail() takes care of unused bits in the bitmap up to
    the next word boundary. But on 32-bit machines when copying bits from
    bitmap to array of 64-bit words, it's expected that the unused part of
    a recipient array must be cleared up to 64-bit boundary, so the last 4
    bytes may stay untouched when nbits % 64 <= 32.
    
    While the copying part of the optimization works correct, that clear-tail
    trick makes corresponding tests reasonably fail:
    
    test_bitmap: bitmap_to_arr64(nbits == 1): tail is not safely cleared: 0xa5a5a5a500000001 (must be 0x0000000000000001)
    
    Fix it by removing bitmap_{from,to}_arr64() optimization for 32-bit LE
    arches.
    
    Reported-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/lkml/20230225184702.GA3587246@roeck-us.net/
    Fixes: 0a97953fd221 ("lib: add bitmap_{from,to}_arr64")
    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
lib/ts_bm: reset initial match offset for every block of text [+ + +]
Author: Jeremy Sowden <jeremy@azazel.net>
Date:   Mon Jun 19 20:06:57 2023 +0100

    lib/ts_bm: reset initial match offset for every block of text
    
    [ Upstream commit 6f67fbf8192da80c4db01a1800c7fceaca9cf1f9 ]
    
    The `shift` variable which indicates the offset in the string at which
    to start matching the pattern is initialized to `bm->patlen - 1`, but it
    is not reset when a new block is retrieved.  This means the implemen-
    tation may start looking at later and later positions in each successive
    block and miss occurrences of the pattern at the beginning.  E.g.,
    consider a HTTP packet held in a non-linear skb, where the HTTP request
    line occurs in the second block:
    
      [... 52 bytes of packet headers ...]
      GET /bmtest HTTP/1.1\r\nHost: www.example.com\r\n\r\n
    
    and the pattern is "GET /bmtest".
    
    Once the first block comprising the packet headers has been examined,
    `shift` will be pointing to somewhere near the end of the block, and so
    when the second block is examined the request line at the beginning will
    be missed.
    
    Reinitialize the variable for each new block.
    
    Fixes: 8082e4ed0a61 ("[LIB]: Boyer-Moore extension for textsearch infrastructure strike #2")
    Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1390
    Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
libbpf: btf_dump_type_data_check_overflow needs to consider BTF_MEMBER_BITFIELD_SIZE [+ + +]
Author: Martin KaFai Lau <martin.lau@kernel.org>
Date:   Thu Apr 27 18:36:38 2023 -0700

    libbpf: btf_dump_type_data_check_overflow needs to consider BTF_MEMBER_BITFIELD_SIZE
    
    [ Upstream commit c39028b333f3a3a765c5c0b9726b8e38aedf0ba1 ]
    
    The btf_dump/struct_data selftest is failing with:
    
      [...]
      test_btf_dump_struct_data:FAIL:unexpected return value dumping fs_context unexpected unexpected return value dumping fs_context: actual -7 != expected 264
      [...]
    
    The reason is in btf_dump_type_data_check_overflow(). It does not use
    BTF_MEMBER_BITFIELD_SIZE from the struct's member (btf_member). Instead,
    it is using the enum size which is 4. It had been working till the recent
    commit 4e04143c869c ("fs_context: drop the unused lsm_flags member")
    removed an integer member which also removed the 4 bytes padding at the
    end of the fs_context. Missing this 4 bytes padding exposed this bug. In
    particular, when btf_dump_type_data_check_overflow() reaches the member
    'phase', -E2BIG is returned.
    
    The fix is to pass bit_sz to btf_dump_type_data_check_overflow(). In
    btf_dump_type_data_check_overflow(), it does a different size check when
    bit_sz is not zero.
    
    The current fs_context:
    
    [3600] ENUM 'fs_context_purpose' encoding=UNSIGNED size=4 vlen=3
            'FS_CONTEXT_FOR_MOUNT' val=0
            'FS_CONTEXT_FOR_SUBMOUNT' val=1
            'FS_CONTEXT_FOR_RECONFIGURE' val=2
    [3601] ENUM 'fs_context_phase' encoding=UNSIGNED size=4 vlen=7
            'FS_CONTEXT_CREATE_PARAMS' val=0
            'FS_CONTEXT_CREATING' val=1
            'FS_CONTEXT_AWAITING_MOUNT' val=2
            'FS_CONTEXT_AWAITING_RECONF' val=3
            'FS_CONTEXT_RECONF_PARAMS' val=4
            'FS_CONTEXT_RECONFIGURING' val=5
            'FS_CONTEXT_FAILED' val=6
    [3602] STRUCT 'fs_context' size=264 vlen=21
            'ops' type_id=3603 bits_offset=0
            'uapi_mutex' type_id=235 bits_offset=64
            'fs_type' type_id=872 bits_offset=1216
            'fs_private' type_id=21 bits_offset=1280
            'sget_key' type_id=21 bits_offset=1344
            'root' type_id=781 bits_offset=1408
            'user_ns' type_id=251 bits_offset=1472
            'net_ns' type_id=984 bits_offset=1536
            'cred' type_id=1785 bits_offset=1600
            'log' type_id=3621 bits_offset=1664
            'source' type_id=42 bits_offset=1792
            'security' type_id=21 bits_offset=1856
            's_fs_info' type_id=21 bits_offset=1920
            'sb_flags' type_id=20 bits_offset=1984
            'sb_flags_mask' type_id=20 bits_offset=2016
            's_iflags' type_id=20 bits_offset=2048
            'purpose' type_id=3600 bits_offset=2080 bitfield_size=8
            'phase' type_id=3601 bits_offset=2088 bitfield_size=8
            'need_free' type_id=67 bits_offset=2096 bitfield_size=1
            'global' type_id=67 bits_offset=2097 bitfield_size=1
            'oldapi' type_id=67 bits_offset=2098 bitfield_size=1
    
    Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data")
    Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Yonghong Song <yhs@fb.com>
    Link: https://lore.kernel.org/bpf/20230428013638.1581263-1-martin.lau@linux.dev
    Signed-off-by: Sasha Levin <sashal@kernel.org>

libbpf: fix offsetof() and container_of() to work with CO-RE [+ + +]
Author: Andrii Nakryiko <andrii@kernel.org>
Date:   Mon May 8 23:55:02 2023 -0700

    libbpf: fix offsetof() and container_of() to work with CO-RE
    
    [ Upstream commit bdeeed3498c7871c17465bb4f11d1bc67f9098af ]
    
    It seems like __builtin_offset() doesn't preserve CO-RE field
    relocations properly. So if offsetof() macro is defined through
    __builtin_offset(), CO-RE-enabled BPF code using container_of() will be
    subtly and silently broken.
    
    To avoid this problem, redefine offsetof() and container_of() in the
    form that works with CO-RE relocations more reliably.
    
    Fixes: 5fbc220862fc ("tools/libpf: Add offsetof/container_of macro in bpf_helpers.h")
    Reported-by: Lennart Poettering <lennart@poettering.net>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Acked-by: Yonghong Song <yhs@fb.com>
    Link: https://lore.kernel.org/r/20230509065502.2306180-1-andrii@kernel.org
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Linux: Linux 6.1.39 [+ + +]
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Jul 19 16:22:18 2023 +0200

    Linux 6.1.39
    
    Link: https://lore.kernel.org/r/20230716194923.861634455@linuxfoundation.org
    Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com>
    Tested-by: Conor Dooley <conor.dooley@microchip.com>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Link: https://lore.kernel.org/r/20230717185609.886113843@linuxfoundation.org
    Link: https://lore.kernel.org/r/20230717201547.359923764@linuxfoundation.org
    Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com>
    Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Chris Paterson (CIP) <chris.paterson2@renesas.com>
    Tested-by: Ron Economos <re@w6rz.net>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Joel Fernandes (Google) <joel@joelfernandes.org>
    Tested-by: Allen Pais <apais@linux.microsoft.com>
    Tested-by: SeongJae Park <sj@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
lkdtm: replace ll_rw_block with submit_bh [+ + +]
Author: Yue Zhao <findns94@gmail.com>
Date:   Thu May 4 00:29:44 2023 +0800

    lkdtm: replace ll_rw_block with submit_bh
    
    [ Upstream commit b290df06811852d4cc36f4b8a2a30c2063197a74 ]
    
    Function ll_rw_block was removed in commit 79f597842069 ("fs/buffer:
    remove ll_rw_block() helper"). There is no unified function to sumbit
    read or write buffer in block layer for now. Consider similar sematics,
    we can choose submit_bh() to replace ll_rw_block() as predefined crash
    point. In submit_bh(), it also takes read or write flag as the first
    argument and invoke submit_bio() to submit I/O request to block layer.
    
    Fixes: 79f597842069 ("fs/buffer: remove ll_rw_block() helper")
    Signed-off-by: Yue Zhao <findns94@gmail.com>
    Acked-by: Kees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20230503162944.3969-1-findns94@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
lockd: drop inappropriate svc_get() from locked_get() [+ + +]
Author: NeilBrown <neilb@suse.de>
Date:   Sat Jun 3 07:14:14 2023 +1000

    lockd: drop inappropriate svc_get() from locked_get()
    
    [ Upstream commit 665e89ab7c5af1f2d260834c861a74b01a30f95f ]
    
    The below-mentioned patch was intended to simplify refcounting on the
    svc_serv used by locked.  The goal was to only ever have a single
    reference from the single thread.  To that end we dropped a call to
    lockd_start_svc() (except when creating thread) which would take a
    reference, and dropped the svc_put(serv) that would drop that reference.
    
    Unfortunately we didn't also remove the svc_get() from
    lockd_create_svc() in the case where the svc_serv already existed.
    So after the patch:
     - on the first call the svc_serv was allocated and the one reference
       was given to the thread, so there are no extra references
     - on subsequent calls svc_get() was called so there is now an extra
       reference.
    This is clearly not consistent.
    
    The inconsistency is also clear in the current code in lockd_get()
    takes *two* references, one on nlmsvc_serv and one by incrementing
    nlmsvc_users.   This clearly does not match lockd_put().
    
    So: drop that svc_get() from lockd_get() (which used to be in
    lockd_create_svc().
    
    Reported-by: Ido Schimmel <idosch@idosch.org>
    Closes: https://lore.kernel.org/linux-nfs/ZHsI%2FH16VX9kJQX1@shredder/T/#u
    Fixes: b73a2972041b ("lockd: move lockd_start_svc() call into lockd_create_svc()")
    Signed-off-by: NeilBrown <neilb@suse.de>
    Tested-by: Ido Schimmel <idosch@nvidia.com>
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
locking/atomic: arm: fix sync ops [+ + +]
Author: Mark Rutland <mark.rutland@arm.com>
Date:   Mon Jun 5 08:00:58 2023 +0100

    locking/atomic: arm: fix sync ops
    
    [ Upstream commit dda5f312bb09e56e7a1c3e3851f2000eb2e9c879 ]
    
    The sync_*() ops on arch/arm are defined in terms of the regular bitops
    with no special handling. This is not correct, as UP kernels elide
    barriers for the fully-ordered operations, and so the required ordering
    is lost when such UP kernels are run under a hypervsior on an SMP
    system.
    
    Fix this by defining sync ops with the required barriers.
    
    Note: On 32-bit arm, the sync_*() ops are currently only used by Xen,
    which requires ARMv7, but the semantics can be implemented for ARMv6+.
    
    Fixes: e54d2f61528165bb ("xen/arm: sync_bitops")
    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20230605070124.3741859-2-mark.rutland@arm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mailbox: ti-msgmgr: Fill non-message tx data fields with 0x0 [+ + +]
Author: Nishanth Menon <nm@ti.com>
Date:   Tue Jun 20 20:00:22 2023 -0500

    mailbox: ti-msgmgr: Fill non-message tx data fields with 0x0
    
    [ Upstream commit 1b712f18c461bd75f018033a15cf381e712806b5 ]
    
    Sec proxy/message manager data buffer is 60 bytes with the last of the
    registers indicating transmission completion. This however poses a bit
    of a challenge.
    
    The backing memory for sec_proxy / message manager is regular memory,
    and all sec proxy does is to trigger a burst of all 60 bytes of data
    over to the target thread backing ring accelerator. It doesn't do a
    memory scrub when it moves data out in the burst. When we transmit
    multiple messages, remnants of previous message is also transmitted
    which results in some random data being set in TISCI fields of
    messages that have been expanded forward.
    
    The entire concept of backward compatibility hinges on the fact that
    the unused message fields remain 0x0 allowing for 0x0 value to be
    specially considered when backward compatibility of message extension
    is done.
    
    So, instead of just writing the completion register, we continue
    to fill the message buffer up with 0x0 (note: for partial message
    involving completion, we already do this).
    
    This allows us to scale and introduce ABI changes back also work with
    other boot stages that may have left data in the internal memory.
    
    While at this, be consistent and explicit with the data_reg pointer
    increment.
    
    Fixes: aace66b170ce ("mailbox: Introduce TI message manager driver")
    Signed-off-by: Nishanth Menon <nm@ti.com>
    Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
md/raid1-10: factor out a helper to add bio to plug [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Mon May 29 21:11:01 2023 +0800

    md/raid1-10: factor out a helper to add bio to plug
    
    [ Upstream commit 5ec6ca140a034682e421e2e808ef5ddfdfd65242 ]
    
    The code in raid1 and raid10 is identical, prepare to limit the number
    of plugged bios.
    
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230529131106.2123367-3-yukuai1@huaweicloud.com
    Stable-dep-of: 7db922bae3ab ("md/raid1-10: submit write io directly if bitmap is not enabled")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

md/raid1-10: factor out a helper to submit normal write [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Mon May 29 21:11:02 2023 +0800

    md/raid1-10: factor out a helper to submit normal write
    
    [ Upstream commit 8295efbe68c080047e98d9c0eb5cb933b238a8cb ]
    
    There are multiple places to do the same thing, factor out a helper to
    prevent redundant code, and the helper will be used in following patch
    as well.
    
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230529131106.2123367-4-yukuai1@huaweicloud.com
    Stable-dep-of: 7db922bae3ab ("md/raid1-10: submit write io directly if bitmap is not enabled")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

md/raid1-10: fix casting from randomized structure in raid1_submit_write() [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Fri Jun 16 09:21:36 2023 +0800

    md/raid1-10: fix casting from randomized structure in raid1_submit_write()
    
    commit b5a99602b74bbfa655be509c615181dd95b0719e upstream.
    
    Following build error triggered while build with clang version 17.0.0
    with W=1(this can't be reporduced with gcc 13.1.0):
    
    drivers/md/raid1-10.c:117:25: error: casting from randomized structure
    pointer type 'struct block_device *' to 'struct md_rdev *'
         117 |         struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev;
             |                                ^
    
    Fix this by casting 'bio->bi_bdev' to 'void *', as it used to be.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Closes: https://lore.kernel.org/oe-kbuild-all/202306142042.fmjfmTF8-lkp@intel.com/
    Fixes: 8295efbe68c0 ("md/raid1-10: factor out a helper to submit normal write")
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230616012136.3047071-1-yukuai1@huaweicloud.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

md/raid1-10: submit write io directly if bitmap is not enabled [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Mon May 29 21:11:03 2023 +0800

    md/raid1-10: submit write io directly if bitmap is not enabled
    
    [ Upstream commit 7db922bae3abdf0a1db81ef7228cc0b996a0c1e3 ]
    
    Commit 6cce3b23f6f8 ("[PATCH] md: write intent bitmap support for raid10")
    add bitmap support, and it changed that write io is submitted through
    daemon thread because bitmap need to be updated before write io. And
    later, plug is used to fix performance regression because all the write io
    will go to demon thread, which means io can't be issued concurrently.
    
    However, if bitmap is not enabled, the write io should not go to daemon
    thread in the first place, and plug is not needed as well.
    
    Fixes: 6cce3b23f6f8 ("[PATCH] md: write intent bitmap support for raid10")
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230529131106.2123367-5-yukuai1@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
md/raid10: check slab-out-of-bounds in md_bitmap_get_counter [+ + +]
Author: Li Nan <linan122@huawei.com>
Date:   Mon May 15 21:48:05 2023 +0800

    md/raid10: check slab-out-of-bounds in md_bitmap_get_counter
    
    [ Upstream commit 301867b1c16805aebbc306aafa6ecdc68b73c7e5 ]
    
    If we write a large number to md/bitmap_set_bits, md_bitmap_checkpage()
    will return -EINVAL because 'page >= bitmap->pages', but the return value
    was not checked immediately in md_bitmap_get_counter() in order to set
    *blocks value and slab-out-of-bounds occurs.
    
    Move check of 'page >= bitmap->pages' to md_bitmap_get_counter() and
    return directly if true.
    
    Fixes: ef4256733506 ("md/bitmap: optimise scanning of empty bitmaps.")
    Signed-off-by: Li Nan <linan122@huawei.com>
    Reviewed-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230515134808.3936750-2-linan666@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

md/raid10: fix io loss while replacement replace rdev [+ + +]
Author: Li Nan <linan122@huawei.com>
Date:   Fri Jun 2 17:18:39 2023 +0800

    md/raid10: fix io loss while replacement replace rdev
    
    [ Upstream commit 2ae6aaf76912bae53c74b191569d2ab484f24bf3 ]
    
    When removing a disk with replacement, the replacement will be used to
    replace rdev. During this process, there is a brief window in which both
    rdev and replacement are read as NULL in raid10_write_request(). This
    will result in io not being submitted but it should be.
    
      //remove                              //write
      raid10_remove_disk                    raid10_write_request
       mirror->rdev = NULL
                                             read rdev -> NULL
       mirror->rdev = mirror->replacement
       mirror->replacement = NULL
                                             read replacement -> NULL
    
    Fix it by reading replacement first and rdev later, meanwhile, use smp_mb()
    to prevent memory reordering.
    
    Fixes: 475b0321a4df ("md/raid10: writes should get directed to replacement as well as original.")
    Signed-off-by: Li Nan <linan122@huawei.com>
    Reviewed-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230602091839.743798-3-linan666@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

md/raid10: fix null-ptr-deref of mreplace in raid10_sync_request [+ + +]
Author: Li Nan <linan122@huawei.com>
Date:   Sat May 27 15:22:15 2023 +0800

    md/raid10: fix null-ptr-deref of mreplace in raid10_sync_request
    
    [ Upstream commit 34817a2441747b48e444cb0e05d84e14bc9443da ]
    
    There are two check of 'mreplace' in raid10_sync_request(). In the first
    check, 'need_replace' will be set and 'mreplace' will be used later if
    no-Faulty 'mreplace' exists, In the second check, 'mreplace' will be
    set to NULL if it is Faulty, but 'need_replace' will not be changed
    accordingly. null-ptr-deref occurs if Faulty is set between two check.
    
    Fix it by merging two checks into one. And replace 'need_replace' with
    'mreplace' because their values are always the same.
    
    Fixes: ee37d7314a32 ("md/raid10: Fix raid10 replace hang when new added disk faulty")
    Signed-off-by: Li Nan <linan122@huawei.com>
    Reviewed-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230527072218.2365857-2-linan666@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

md/raid10: fix overflow of md/safe_mode_delay [+ + +]
Author: Li Nan <linan122@huawei.com>
Date:   Mon May 22 15:25:33 2023 +0800

    md/raid10: fix overflow of md/safe_mode_delay
    
    [ Upstream commit 6beb489b2eed25978523f379a605073f99240c50 ]
    
    There is no input check when echo md/safe_mode_delay in safe_delay_store().
    And msec might also overflow when HZ < 1000 in safe_delay_show(), Fix it by
    checking overflow in safe_delay_store() and use unsigned long conversion in
    safe_delay_show().
    
    Fixes: 72e02075a33f ("md: factor out parsing of fixed-point numbers")
    Signed-off-by: Li Nan <linan122@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230522072535.1523740-2-linan666@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

md/raid10: fix the condition to call bio_end_io_acct() [+ + +]
Author: Li Nan <linan122@huawei.com>
Date:   Fri Jun 9 17:43:20 2023 +0800

    md/raid10: fix the condition to call bio_end_io_acct()
    
    [ Upstream commit 125bfc7cd750e68c99f1d446e2c22abea08c237f ]
    
    /sys/block/[device]/queue/iostats is used to control whether to count io
    stat. Write 0 to it will clear queue_flags QUEUE_FLAG_IO_STAT which means
    iostats is disabled. If we disable iostats and later endable it, the io
    issued during this period will be counted incorrectly, inflight will be
    decreased to -1.
    
      //T1 set iostats
      echo 0 > /sys/block/md0/queue/iostats
       clear QUEUE_FLAG_IO_STAT
    
                            //T2 issue io
                            if (QUEUE_FLAG_IO_STAT) -> false
                             bio_start_io_acct
                              inflight++
    
      echo 1 > /sys/block/md0/queue/iostats
       set QUEUE_FLAG_IO_STAT
    
                                            //T3 io end
                                            if (QUEUE_FLAG_IO_STAT) -> true
                                             bio_end_io_acct
                                              inflight--    -> -1
    
    Also, if iostats is enabled while issuing io but disabled while io end,
    inflight will never be decreased.
    
    Fix it by checking start_time when io end. If start_time is not 0, call
    bio_end_io_acct().
    
    Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting")
    Signed-off-by: Li Nan <linan122@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230609094320.2397604-1-linan666@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

md/raid10: fix wrong setting of max_corr_read_errors [+ + +]
Author: Li Nan <linan122@huawei.com>
Date:   Mon May 22 15:25:34 2023 +0800

    md/raid10: fix wrong setting of max_corr_read_errors
    
    [ Upstream commit f8b20a405428803bd9881881d8242c9d72c6b2b2 ]
    
    There is no input check when echo md/max_read_errors and overflow might
    occur. Add check of input number.
    
    Fixes: 1e50915fe0bb ("raid: improve MD/raid10 handling of correctable read errors.")
    Signed-off-by: Li Nan <linan122@huawei.com>
    Reviewed-by: Yu Kuai <yukuai3@huawei.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Link: https://lore.kernel.org/r/20230522072535.1523740-3-linan666@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
media: amphion: drop repeated codec data for vc1g format [+ + +]
Author: Ming Qian <ming.qian@nxp.com>
Date:   Fri Apr 14 09:55:43 2023 +0800

    media: amphion: drop repeated codec data for vc1g format
    
    [ Upstream commit e1d2ccc2cdd6333584aa3d5386dc667d0837c48f ]
    
    For format V4L2_PIX_FMT_VC1_ANNEX_G,
    the separate codec data is required only once.
    The repeated codec data may introduce some decoding error.
    so drop the repeated codec data.
    
    It's amphion vpu's limitation
    
    Fixes: e670f5d672ef ("media: amphion: only insert the first sequence startcode for vc1l format")
    Signed-off-by: Ming Qian <ming.qian@nxp.com>
    Tested-by: xiahong.bao <xiahong.bao@nxp.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: amphion: drop repeated codec data for vc1l format [+ + +]
Author: Ming Qian <ming.qian@nxp.com>
Date:   Fri Apr 14 09:55:42 2023 +0800

    media: amphion: drop repeated codec data for vc1l format
    
    [ Upstream commit 668ee1a3a1870381225002c246972419b98e4253 ]
    
    For format V4L2_PIX_FMT_VC1_ANNEX_L,
    the codec data is replaced with startcode,
    and then driver drop it, otherwise it may led to decoding error.
    
    It's amphion vpu's limitation
    
    Driver has dropped the first codec data,
    but need to drop the repeated codec data too.
    
    Fixes: e670f5d672ef ("media: amphion: only insert the first sequence startcode for vc1l format")
    Signed-off-by: Ming Qian <ming.qian@nxp.com>
    Tested-by: xiahong.bao <xiahong.bao@nxp.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: amphion: initiate a drain of the capture queue in dynamic resolution change [+ + +]
Author: Ming Qian <ming.qian@nxp.com>
Date:   Sat May 6 16:47:35 2023 +0800

    media: amphion: initiate a drain of the capture queue in dynamic resolution change
    
    [ Upstream commit 076b6289b2c12d76fab248659896682830fa7766 ]
    
    The last buffer from before the change must be marked
    with the V4L2_BUF_FLAG_LAST flag,
    similarly to the Drain sequence above.
    
    initiate a drain of the capture queue in dynamic resolution change
    
    Fixes: 6de8d628df6e ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
    Signed-off-by: Ming Qian <ming.qian@nxp.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: atomisp: gmin_platform: fix out_len in gmin_get_config_dsm_var() [+ + +]
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Fri May 26 12:53:23 2023 +0100

    media: atomisp: gmin_platform: fix out_len in gmin_get_config_dsm_var()
    
    [ Upstream commit 1657f2934daf89e8d9fa4b2697008909eb22c73e ]
    
    Ideally, strlen(cur->string.pointer) and strlen(out) would be the same.
    But this code is using strscpy() to avoid a potential buffer overflow.
    So in the same way we should take the strlen() of the smaller string to
    avoid a buffer overflow in the caller, gmin_get_var_int().
    
    Link: https://lore.kernel.org/r/26124bcd-8132-4483-9d67-225c87d424e8@kili.mountain
    
    Fixes: 387041cda44e ("media: atomisp: improve sensor detection code to use _DSM table")
    Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: cec: i2c: ch7322: also select REGMAP [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Thu Jun 8 04:54:35 2023 +0200

    media: cec: i2c: ch7322: also select REGMAP
    
    [ Upstream commit 29f96ac23648b2259f42d40703c47dd18fd172ca ]
    
    Selecting only REGMAP_I2C can leave REGMAP unset, causing build errors,
    so also select REGMAP to prevent the build errors.
    
    ../drivers/media/cec/i2c/ch7322.c:158:21: error: variable 'ch7322_regmap' has initializer but incomplete type
      158 | static const struct regmap_config ch7322_regmap = {
    ../drivers/media/cec/i2c/ch7322.c:159:10: error: 'const struct regmap_config' has no member named 'reg_bits'
      159 |         .reg_bits = 8,
    ../drivers/media/cec/i2c/ch7322.c:159:21: warning: excess elements in struct initializer
      159 |         .reg_bits = 8,
    ../drivers/media/cec/i2c/ch7322.c:160:10: error: 'const struct regmap_config' has no member named 'val_bits'
      160 |         .val_bits = 8,
    ../drivers/media/cec/i2c/ch7322.c:160:21: warning: excess elements in struct initializer
      160 |         .val_bits = 8,
    ../drivers/media/cec/i2c/ch7322.c:161:10: error: 'const struct regmap_config' has no member named 'max_register'
      161 |         .max_register = 0x7f,
    ../drivers/media/cec/i2c/ch7322.c:161:25: warning: excess elements in struct initializer
      161 |         .max_register = 0x7f,
    ../drivers/media/cec/i2c/ch7322.c:162:10: error: 'const struct regmap_config' has no member named 'disable_locking'
      162 |         .disable_locking = true,
    ../drivers/media/cec/i2c/ch7322.c:162:28: warning: excess elements in struct initializer
      162 |         .disable_locking = true,
    ../drivers/media/cec/i2c/ch7322.c: In function 'ch7322_probe':
    ../drivers/media/cec/i2c/ch7322.c:468:26: error: implicit declaration of function 'devm_regmap_init_i2c' [-Werror=implicit-function-declaration]
      468 |         ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);
    ../drivers/media/cec/i2c/ch7322.c:468:24: warning: assignment to 'struct regmap *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
      468 |         ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);
    ../drivers/media/cec/i2c/ch7322.c: At top level:
    ../drivers/media/cec/i2c/ch7322.c:158:35: error: storage size of 'ch7322_regmap' isn't known
      158 | static const struct regmap_config ch7322_regmap = {
    
    Link: https://lore.kernel.org/linux-media/20230608025435.29249-1-rdunlap@infradead.org
    Fixes: 21b9a47e0ec7 ("media: cec: i2c: ch7322: Add ch7322 CEC controller driver")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Cc: Jeff Chase <jnchase@google.com>
    Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Cc: Joe Tessler <jrt@google.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Mark Brown <broonie@kernel.org>
    Cc: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: hi846: fix usage of pm_runtime_get_if_in_use() [+ + +]
Author: Martin Kepplinger <martink@posteo.de>
Date:   Tue Apr 25 11:47:47 2023 +0200

    media: hi846: fix usage of pm_runtime_get_if_in_use()
    
    [ Upstream commit 04fc06f6dc1592ed5d675311ac50d8fba5db62ab ]
    
    pm_runtime_get_if_in_use() does not only return nonzero values when
    the device is in use, it can return a negative errno too.
    
    And especially during resuming from system suspend, when runtime pm
    is not yet up again, -EAGAIN is being returned, so the subsequent
    pm_runtime_put() call results in a refcount underflow.
    
    Fix system-resume by handling -EAGAIN of pm_runtime_get_if_in_use().
    
    Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
    Fixes: e8c0882685f9 ("media: i2c: add driver for the SK Hynix Hi-846 8M pixel camera")
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: i2c: Correct format propagation for st-mipid02 [+ + +]
Author: Daniel Scally <dan.scally@ideasonboard.com>
Date:   Tue May 2 11:35:46 2023 +0100

    media: i2c: Correct format propagation for st-mipid02
    
    [ Upstream commit 306c3190b30d4d6a098888b9d7d4cefaa0ddcb91 ]
    
    Format propagation in the st-mipid02 driver is incorrect in that when
    setting format for V4L2_SUBDEV_FORMAT_TRY on the source pad, the
    _active_ rather than _try_ format from the sink pad is propagated.
    This causes problems with format negotiation - update the function to
    propagate the correct format.
    
    Fixes: 642bb5e88fed ("media: st-mipid02: MIPID02 CSI-2 to PARALLEL bridge driver")
    Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: mediatek: vcodec: using decoder status instead of core work count [+ + +]
Author: Yunfei Dong <yunfei.dong@mediatek.com>
Date:   Thu May 25 02:40:07 2023 +0100

    media: mediatek: vcodec: using decoder status instead of core work count
    
    [ Upstream commit 2864e304faec04c2674328aad0e820a9cd84cdec ]
    
    Adding the definition of decoder status to separate different decoder
    period for core hardware.
    
    core_work_cnt is the number of core work queued to work queue, the control
    is very complex, leading to some unreasonable test result.
    
    Using parameter status to indicate whether queue core work to work queue.
    
    Fixes: 2e0ef56d81cb ("media: mediatek: vcodec: making sure queue_work successfully")
    Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: usb: Check az6007_read() return value [+ + +]
Author: Daniil Dulov <d.dulov@aladdin.ru>
Date:   Tue Mar 14 10:04:49 2023 -0700

    media: usb: Check az6007_read() return value
    
    [ Upstream commit fdaca63186f59fc664b346c45b76576624b48e57 ]
    
    If az6007_read() returns error, there is no sence to continue.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Fixes: 3af2f4f15a61 ("[media] az6007: Change the az6007 read/write routine parameter")
    Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: usb: siano: Fix warning due to null work_func_t function pointer [+ + +]
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Tue May 23 07:59:32 2023 +0800

    media: usb: siano: Fix warning due to null work_func_t function pointer
    
    [ Upstream commit 6f489a966fbeb0da63d45c2c66a8957eab604bf6 ]
    
    The previous commit ebad8e731c1c ("media: usb: siano: Fix use after
    free bugs caused by do_submit_urb") adds cancel_work_sync() in
    smsusb_stop_streaming(). But smsusb_stop_streaming() may be called,
    even if the work_struct surb->wq has not been initialized. As a result,
    the warning will occur. One of the processes that could lead to warning
    is shown below:
    
    smsusb_probe()
      smsusb_init_device()
        if (!dev->in_ep || !dev->out_ep || align < 0) {
             smsusb_term_device(intf);
               smsusb_stop_streaming()
                 cancel_work_sync(&dev->surbs[i].wq);
                   __cancel_work_timer()
                     __flush_work()
                       if (WARN_ON(!work->func)) // work->func is null
    
    The log reported by syzbot is shown below:
    
    WARNING: CPU: 0 PID: 897 at kernel/workqueue.c:3066 __flush_work+0x798/0xa80 kernel/workqueue.c:3063
    Modules linked in:
    CPU: 0 PID: 897 Comm: kworker/0:2 Not tainted 6.2.0-rc1-syzkaller #0
    RIP: 0010:__flush_work+0x798/0xa80 kernel/workqueue.c:3066
    ...
    RSP: 0018:ffffc9000464ebf8 EFLAGS: 00010246
    RAX: 1ffff11002dbb420 RBX: 0000000000000021 RCX: 1ffffffff204fa4e
    RDX: dffffc0000000000 RSI: 0000000000000001 RDI: ffff888016dda0e8
    RBP: ffffc9000464ed98 R08: 0000000000000001 R09: ffffffff90253b2f
    R10: 0000000000000001 R11: 0000000000000000 R12: ffff888016dda0e8
    R13: ffff888016dda0e8 R14: ffff888016dda100 R15: 0000000000000001
    FS:  0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007ffd4331efe8 CR3: 000000000b48e000 CR4: 00000000003506f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     <TASK>
     __cancel_work_timer+0x315/0x460 kernel/workqueue.c:3160
     smsusb_stop_streaming drivers/media/usb/siano/smsusb.c:182 [inline]
     smsusb_term_device+0xda/0x2d0 drivers/media/usb/siano/smsusb.c:344
     smsusb_init_device+0x400/0x9ce drivers/media/usb/siano/smsusb.c:419
     smsusb_probe+0xbbd/0xc55 drivers/media/usb/siano/smsusb.c:567
    ...
    
    This patch adds check before cancel_work_sync(). If surb->wq has not
    been initialized, the cancel_work_sync() will not be executed.
    
    Reported-by: syzbot+27b0b464864741b18b99@syzkaller.appspotmail.com
    Fixes: ebad8e731c1c ("media: usb: siano: Fix use after free bugs caused by do_submit_urb")
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: venus: helpers: Fix ALIGN() of non power of two [+ + +]
Author: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Date:   Sat Sep 12 20:03:01 2020 +0100

    media: venus: helpers: Fix ALIGN() of non power of two
    
    [ Upstream commit 927e78ac8bc58155316cf6f46026e1912bbbbcfc ]
    
    ALIGN() expects its second argument to be a power of 2, otherwise
    incorrect results are produced for some inputs. The output can be
    both larger or smaller than what is expected.
    
    For example, ALIGN(304, 192) equals 320 instead of 384, and
    ALIGN(65, 192) equals 256 instead of 192.
    
    However, nestling two ALIGN() as is done in this case seem to only
    produce results equal to or bigger than the expected result if ALIGN()
    had handled non powers of two, and that in turn results in framesizes
    that are either the correct size or too large.
    
    Fortunately, since 192 * 4 / 3 equals 256, it turns out that one ALIGN()
    is sufficient.
    
    Fixes: ab1eda449c6e ("media: venus: vdec: handle 10bit bitstreams")
    Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
    Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: videodev2.h: Fix struct v4l2_input tuner index comment [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Thu May 18 15:36:49 2023 +0200

    media: videodev2.h: Fix struct v4l2_input tuner index comment
    
    [ Upstream commit 26ae58f65e64fa7ba61d64bae752e59e08380c6a ]
    
    VIDIOC_ENUMINPUT documentation describes the tuner field of
    struct v4l2_input as index:
    
    Documentation/userspace-api/media/v4l/vidioc-enuminput.rst
    "
    * - __u32
      - ``tuner``
      - Capture devices can have zero or more tuners (RF demodulators).
        When the ``type`` is set to ``V4L2_INPUT_TYPE_TUNER`` this is an
        RF connector and this field identifies the tuner. It corresponds
        to struct :c:type:`v4l2_tuner` field ``index``. For
        details on tuners see :ref:`tuner`.
    "
    
    Drivers I could find also use the 'tuner' field as an index, e.g.:
    drivers/media/pci/bt8xx/bttv-driver.c bttv_enum_input()
    drivers/media/usb/go7007/go7007-v4l2.c vidioc_enum_input()
    
    However, the UAPI comment claims this field is 'enum v4l2_tuner_type':
    include/uapi/linux/videodev2.h
    
    This field being 'enum v4l2_tuner_type' is unlikely as it seems to be
    never used that way in drivers, and documentation confirms it. It seem
    this comment got in accidentally in the commit which this patch fixes.
    Fix the UAPI comment to stop confusion.
    
    This was pointed out by Dmitry while reviewing VIDIOC_ENUMINPUT
    support for strace.
    
    Fixes: 6016af82eafc ("[media] v4l2: use __u32 rather than enums in ioctl() structs")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
memory: brcmstb_dpfe: fix testing array offset after use [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Sat May 13 13:29:31 2023 +0200

    memory: brcmstb_dpfe: fix testing array offset after use
    
    [ Upstream commit 1d9e93fad549bc38f593147479ee063f2872c170 ]
    
    Code should first check for valid value of array offset, then use it as
    the index.  Fixes smatch warning:
    
      drivers/memory/brcmstb_dpfe.c:443 __send_command() error: testing array offset 'cmd' after use.
    
    Fixes: 2f330caff577 ("memory: brcmstb: Add driver for DPFE")
    Acked-by: Markus Mayer <mmayer@broadcom.com>
    Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Link: https://lore.kernel.org/r/20230513112931.176066-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
memstick r592: make memstick_debug_get_tpc_name() static [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 16 22:27:04 2023 +0200

    memstick r592: make memstick_debug_get_tpc_name() static
    
    [ Upstream commit 434587df9f7fd68575f99a889cc5f2efc2eaee5e ]
    
    There are no other files referencing this function, apparently
    it was left global to avoid an 'unused function' warning when
    the only caller is left out. With a 'W=1' build, it causes
    a 'missing prototype' warning though:
    
    drivers/memstick/host/r592.c:47:13: error: no previous prototype for 'memstick_debug_get_tpc_name' [-Werror=missing-prototypes]
    
    Annotate the function as 'static __maybe_unused' to avoid both
    problems.
    
    Fixes: 926341250102 ("memstick: add driver for Ricoh R5C592 card reader")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Link: https://lore.kernel.org/r/20230516202714.560929-1-arnd@kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mfd: intel-lpss: Add missing check for platform_get_resource [+ + +]
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Fri Jun 9 09:48:18 2023 +0800

    mfd: intel-lpss: Add missing check for platform_get_resource
    
    [ Upstream commit d918e0d5824495a75d00b879118b098fcab36fdb ]
    
    Add the missing check for platform_get_resource and return error
    if it fails.
    
    Fixes: 4b45efe85263 ("mfd: Add support for Intel Sunrisepoint LPSS devices")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Signed-off-by: Lee Jones <lee@kernel.org>
    Link: https://lore.kernel.org/r/20230609014818.28475-1-jiasheng@iscas.ac.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

mfd: rt5033: Drop rt5033-battery sub-device [+ + +]
Author: Stephan Gerhold <stephan@gerhold.net>
Date:   Mon May 15 22:57:10 2023 +0200

    mfd: rt5033: Drop rt5033-battery sub-device
    
    [ Upstream commit 43db1344e0f8c1eb687a1d6cd5b0de3009ab66cb ]
    
    The fuel gauge in the RT5033 PMIC (rt5033-battery) has its own I2C bus
    and interrupt lines. Therefore, it is not part of the MFD device
    and needs to be specified separately in the device tree.
    
    Fixes: 0b271258544b ("mfd: rt5033: Add Richtek RT5033 driver core.")
    Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
    Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Lee Jones <lee@kernel.org>
    Link: https://lore.kernel.org/r/6a8a19bc67b5be3732882e8131ad2ffcb546ac03.1684182964.git.jahau@rocketmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

mfd: stmfx: Fix error path in stmfx_chip_init [+ + +]
Author: Amelie Delaunay <amelie.delaunay@foss.st.com>
Date:   Fri Jun 9 11:28:03 2023 +0200

    mfd: stmfx: Fix error path in stmfx_chip_init
    
    [ Upstream commit f592cf624531286f8b52e40dcfc157a5a7fb115c ]
    
    In error path, disable vdd regulator if it exists, but don't overload ret.
    Because if regulator_disable() is successful, stmfx_chip_init will exit
    successfully while chip init failed.
    
    Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
    Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
    Link: https://lore.kernel.org/r/20230609092804.793100-1-amelie.delaunay@foss.st.com
    Signed-off-by: Lee Jones <lee@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

mfd: stmfx: Nullify stmfx->vdd in case of error [+ + +]
Author: Amelie Delaunay <amelie.delaunay@foss.st.com>
Date:   Fri Jun 9 11:28:04 2023 +0200

    mfd: stmfx: Nullify stmfx->vdd in case of error
    
    [ Upstream commit 7c81582c0bccb4757186176f0ee12834597066ad ]
    
    Nullify stmfx->vdd in case devm_regulator_get_optional() returns an error.
    And simplify code by returning an error only if return code is not -ENODEV,
    which means there is no vdd regulator and it is not an issue.
    
    Fixes: d75846ed08e6 ("mfd: stmfx: Fix dev_err_probe() call in stmfx_chip_init()")
    Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
    Link: https://lore.kernel.org/r/20230609092804.793100-2-amelie.delaunay@foss.st.com
    Signed-off-by: Lee Jones <lee@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

mfd: stmpe: Only disable the regulators if they are enabled [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat Jun 17 12:43:16 2023 +0200

    mfd: stmpe: Only disable the regulators if they are enabled
    
    [ Upstream commit 104d32bd81f620bb9f67fbf7d1159c414e89f05f ]
    
    In stmpe_probe(), if some regulator_enable() calls fail, probing continues
    and there is only a dev_warn().
    
    So, if stmpe_probe() is called the regulator may not be enabled. It is
    cleaner to test it before calling regulator_disable() in the remove
    function.
    
    Fixes: 9c9e321455fb ("mfd: stmpe: add optional regulators")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Link: https://lore.kernel.org/r/8de3aaf297931d655b9ad6aed548f4de8b85425a.1686998575.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Lee Jones <lee@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat May 20 09:10:54 2023 +0200

    mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe()
    
    [ Upstream commit f190b4891a3f9fac123a7afd378d4143a2723313 ]
    
    If devm_gpiod_get_optional() fails, some resources need to be released, as
    already done in the .remove() function.
    
    While at it, remove the unneeded error code from a dev_err_probe() call.
    It is already added in a human readable way by dev_err_probe() itself.
    
    Fixes: 6a0ee2a61a31 ("mfd: wcd934x: Replace legacy gpio interface for gpiod")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/02d8447f6d1df52cc8357aae698152e9a9be67c6.1684565021.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Lee Jones <lee@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
misc: fastrpc: check return value of devm_kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Thu Jun 15 13:25:46 2023 +0300

    misc: fastrpc: check return value of devm_kasprintf()
    
    [ Upstream commit af2e19d82a116bc622eea84c9faadd5f7e20bec4 ]
    
    devm_kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: 3abe3ab3cdab ("misc: fastrpc: add secure domain support")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20230615102546.581899-1-claudiu.beznea@microchip.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init [+ + +]
Author: Zhengchao Shao <shaozhengchao@huawei.com>
Date:   Fri Jun 30 09:26:47 2023 +0800

    mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
    
    [ Upstream commit 08fc75735fda3be97194bfbf3c899c87abb3d0fe ]
    
    The line cards array is not freed in the error path of
    mlxsw_m_linecards_init(), which can lead to a memory leak. Fix by
    freeing the array in the error path, thereby making the error path
    identical to mlxsw_m_linecards_fini().
    
    Fixes: 01328e23a476 ("mlxsw: minimal: Extend module to port mapping with slot index")
    Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
    Reviewed-by: Petr Machata <petrm@nvidia.com>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Link: https://lore.kernel.org/r/20230630012647.1078002-1-shaozhengchao@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mm/damon/ops-common: atomically test and clear young on ptes and pmds [+ + +]
Author: Ryan Roberts <ryan.roberts@arm.com>
Date:   Fri Jun 2 10:29:47 2023 +0100

    mm/damon/ops-common: atomically test and clear young on ptes and pmds
    
    commit c11d34fa139e4b0fb4249a30f37b178353533fa1 upstream.
    
    It is racy to non-atomically read a pte, then clear the young bit, then
    write it back as this could discard dirty information.  Further, it is bad
    practice to directly set a pte entry within a table.  Instead clearing
    young must go through the arch-provided helper,
    ptep_test_and_clear_young() to ensure it is modified atomically and to
    give the arch code visibility and allow it to check (and potentially
    modify) the operation.
    
    Link: https://lkml.kernel.org/r/20230602092949.545577-3-ryan.roberts@arm.com
    Fixes: 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces").
    Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
    Reviewed-by: Zi Yan <ziy@nvidia.com>
    Reviewed-by: SeongJae Park <sj@kernel.org>
    Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Lorenzo Stoakes <lstoakes@gmail.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
    Cc: Yu Zhao <yuzhao@google.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mm/mmap: Fix extra maple tree write [+ + +]
Author: Liam R. Howlett <Liam.Howlett@oracle.com>
Date:   Thu Jul 6 14:51:35 2023 -0400

    mm/mmap: Fix extra maple tree write
    
    based on commit 0503ea8f5ba73eb3ab13a81c1eefbaf51405385a upstream.
    
    This was inadvertently fixed during the removal of __vma_adjust().
    
    When __vma_adjust() is adjusting next with a negative value (pushing
    vma->vm_end lower), there would be two writes to the maple tree.  The
    first write is unnecessary and uses all allocated nodes in the maple
    state.  The second write is necessary but will need to allocate nodes
    since the first write has used the allocated nodes.  This may be a
    problem as it may not be safe to allocate at this time, such as a low
    memory situation.  Fix the issue by avoiding the first write and only
    write the adjusted "next" VMA.
    
    Reported-by: John Hsu <John.Hsu@mediatek.com>
    Link: https://lore.kernel.org/lkml/9cb8c599b1d7f9c1c300d1a334d5eb70ec4d7357.camel@mediatek.com/
    Cc: stable@vger.kernel.org
    Cc: linux-mm@kvack.org
    Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mm/mmap: Fix VM_LOCKED check in do_vmi_align_munmap() [+ + +]
Author: Suren Baghdasaryan <surenb@google.com>
Date:   Mon Jul 10 17:46:32 2023 -0700

    mm/mmap: Fix VM_LOCKED check in do_vmi_align_munmap()
    
    6.1 backport of the patch [1] uses 'next' vma instead of 'split' vma.
    Fix the mistake.
    
    [1] commit 606c812eb1d5 ("mm/mmap: Fix error path in do_vmi_align_munmap()")
    
    Fixes: a149174ff8bb ("mm/mmap: Fix error path in do_vmi_align_munmap()")
    Signed-off-by: Suren Baghdasaryan <surenb@google.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mm: call arch_swap_restore() from do_swap_page() [+ + +]
Author: Peter Collingbourne <pcc@google.com>
Date:   Mon May 22 17:43:08 2023 -0700

    mm: call arch_swap_restore() from do_swap_page()
    
    commit 6dca4ac6fc91fd41ea4d6c4511838d37f4e0eab2 upstream.
    
    Commit c145e0b47c77 ("mm: streamline COW logic in do_swap_page()") moved
    the call to swap_free() before the call to set_pte_at(), which meant that
    the MTE tags could end up being freed before set_pte_at() had a chance to
    restore them.  Fix it by adding a call to the arch_swap_restore() hook
    before the call to swap_free().
    
    Link: https://lkml.kernel.org/r/20230523004312.1807357-2-pcc@google.com
    Link: https://linux-review.googlesource.com/id/I6470efa669e8bd2f841049b8c61020c510678965
    Fixes: c145e0b47c77 ("mm: streamline COW logic in do_swap_page()")
    Signed-off-by: Peter Collingbourne <pcc@google.com>
    Reported-by: Qun-wei Lin <Qun-wei.Lin@mediatek.com>
    Closes: https://lore.kernel.org/all/5050805753ac469e8d727c797c2218a9d780d434.camel@mediatek.com/
    Acked-by: David Hildenbrand <david@redhat.com>
    Acked-by: "Huang, Ying" <ying.huang@intel.com>
    Reviewed-by: Steven Price <steven.price@arm.com>
    Acked-by: Catalin Marinas <catalin.marinas@arm.com>
    Cc: <stable@vger.kernel.org>    [6.1+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston Canvas Go Plus from 11/2019 [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Tue Jun 20 12:27:13 2023 +0200

    mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston Canvas Go Plus from 11/2019
    
    [ Upstream commit c467c8f081859d4f4ca4eee4fba54bb5d85d6c97 ]
    
    This microSD card never clears Flush Cache bit after cache flush has
    been started in sd_flush_cache(). This leads e.g. to failure to mount
    file system. Add a quirk which disables the SD cache for this specific
    card from specific manufacturing date of 11/2019, since on newer dated
    cards from 05/2023 the cache flush works correctly.
    
    Fixes: 08ebf903af57 ("mmc: core: Fixup support for writeback-cache for eMMC and SD")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Link: https://lore.kernel.org/r/20230620102713.7701-1-marex@denx.de
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

mmc: core: disable TRIM on Kingston EMMC04G-M627 [+ + +]
Author: Robert Marko <robimarko@gmail.com>
Date:   Mon Jun 19 21:35:58 2023 +0200

    mmc: core: disable TRIM on Kingston EMMC04G-M627
    
    commit f1738a1f816233e6dfc2407f24a31d596643fd90 upstream.
    
    It seems that Kingston EMMC04G-M627 despite advertising TRIM support does
    not work when the core is trying to use REQ_OP_WRITE_ZEROES.
    
    We are seeing I/O errors in OpenWrt under 6.1 on Zyxel NBG7815 that we did
    not previously have and tracked it down to REQ_OP_WRITE_ZEROES.
    
    Trying to use fstrim seems to also throw errors like:
    [93010.835112] I/O error, dev loop0, sector 16902 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 2
    
    Disabling TRIM makes the error go away, so lets add a quirk for this eMMC
    to disable TRIM.
    
    Signed-off-by: Robert Marko <robimarko@gmail.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20230619193621.437358-1-robimarko@gmail.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mmc: core: disable TRIM on Micron MTFC4GACAJCN-1M [+ + +]
Author: Robert Marko <robimarko@gmail.com>
Date:   Tue May 30 23:32:59 2023 +0200

    mmc: core: disable TRIM on Micron MTFC4GACAJCN-1M
    
    commit dbfbddcddcebc9ce8a08757708d4e4a99d238e44 upstream.
    
    It seems that Micron MTFC4GACAJCN-1M despite advertising TRIM support does
    not work when the core is trying to use REQ_OP_WRITE_ZEROES.
    
    We are seeing the following errors in OpenWrt under 6.1 on Qnap Qhora 301W
    that we did not previously have and tracked it down to REQ_OP_WRITE_ZEROES:
    [   18.085950] I/O error, dev loop0, sector 596 op 0x9:(WRITE_ZEROES) flags 0x800 phys_seg 0 prio class 2
    
    Disabling TRIM makes the error go away, so lets add a quirk for this eMMC
    to disable TRIM.
    
    Signed-off-by: Robert Marko <robimarko@gmail.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20230530213259.1776512-1-robimarko@gmail.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mmc: mediatek: Avoid ugly error message when SDIO wakeup IRQ isn't used [+ + +]
Author: Douglas Anderson <dianders@chromium.org>
Date:   Wed May 10 06:44:54 2023 -0700

    mmc: mediatek: Avoid ugly error message when SDIO wakeup IRQ isn't used
    
    [ Upstream commit a3332b7aad346b14770797e03ddd02ebdb14db41 ]
    
    When I boot a kukui-kodama board, I see an ugly warning in my kernel
    log:
      mtk-msdc 11240000.mmc: error -ENXIO: IRQ sdio_wakeup not found
    
    It's pretty normal not to have an "sdio_wakeup" IRQ defined. In fact,
    no device trees in mainline seem to have it. Let's use the
    platform_get_irq_byname_optional() to avoid the error message.
    
    Fixes: 527f36f5efa4 ("mmc: mediatek: add support for SDIO eint wakup IRQ")
    Signed-off-by: Douglas Anderson <dianders@chromium.org>
    Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
    Link: https://lore.kernel.org/r/20230510064434.1.I935404c5396e6bf952e99bb7ffb744c6f7fd430b@changeid
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

mmc: mmci: Set PROBE_PREFER_ASYNCHRONOUS [+ + +]
Author: Ulf Hansson <ulf.hansson@linaro.org>
Date:   Mon Jun 12 16:37:30 2023 +0200

    mmc: mmci: Set PROBE_PREFER_ASYNCHRONOUS
    
    commit 3108eb2e8aa7e955a9dd3a4c1bf19a7898961822 upstream.
    
    All mmc host drivers should have the asynchronous probe option enabled, but
    it seems like we failed to set it for mmci, so let's do that now.
    
    Fixes: 21b2cec61c04 ("mmc: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in v4.4")
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Tested-by: Linus Walleij <linus.walleij@linaro.org>
    Tested-by: Yann Gautier <yann.gautier@foss.st.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20230612143730.210390-1-ulf.hansson@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mmc: sdhci: fix DMA configure compatibility issue when 64bit DMA mode is used. [+ + +]
Author: Chevron Li <chevron.li@bayhubtech.com>
Date:   Tue May 23 19:11:14 2023 +0800

    mmc: sdhci: fix DMA configure compatibility issue when 64bit DMA mode is used.
    
    commit 20dbd07ef0a8bc29eb03d6a95258ac8934cbe52d upstream.
    
    Bayhub SD host has hardware limitation:
    1.The upper 32bit address is inhibited to be written at SD Host Register
      [03E][13]=0 (32bits addressing) mode, is admitted to be written only at
      SD Host Register [03E][13]=1 (64bits addressing) mode.
    2.Because of above item#1, need to configure SD Host Register [03E][13] to
      1(64bits addressing mode) before set 64bit ADMA system address's higher
      32bits SD Host Register [05F~05C] if 64 bits addressing mode is used.
    
    The hardware limitation is reasonable for below reasons:
    1.Normal flow should set DMA working mode first, then do
      DMA-transfer-related configuration, such as system address.
    2.The hardware limitation may avoid the software to configure wrong higher
      32bit address at 32bits addressing mode although it is redundant.
    
    The change that set 32bits/64bits addressing mode before set ADMA address,
      has no side-effect to other host IPs for below reason:
    The setting order is reasonable and standard: DMA Mode setting first and
      then DMA address setting. It meets all DMA setting sequence.
    
    Signed-off-by: Chevron Li <chevron.li@bayhubtech.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20230523111114.18124-1-chevron_li@126.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
modpost: fix off by one in is_executable_section() [+ + +]
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Thu Jun 8 11:23:40 2023 +0300

    modpost: fix off by one in is_executable_section()
    
    [ Upstream commit 3a3f1e573a105328a2cca45a7cfbebabbf5e3192 ]
    
    The > comparison should be >= to prevent an out of bounds array
    access.
    
    Fixes: 52dc0595d540 ("modpost: handle relocations mismatch in __ex_table.")
    Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

modpost: fix section mismatch message for R_ARM_ABS32 [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Thu Jun 1 21:09:55 2023 +0900

    modpost: fix section mismatch message for R_ARM_ABS32
    
    [ Upstream commit b7c63520f6703a25eebb4f8138fed764fcae1c6f ]
    
    addend_arm_rel() processes R_ARM_ABS32 in a wrong way.
    
    Here, test code.
    
      [test code 1]
    
        #include <linux/init.h>
    
        int __initdata foo;
        int get_foo(void) { return foo; }
    
    If you compile it with ARM versatile_defconfig, modpost will show the
    symbol name, (unknown).
    
      WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> (unknown) (section: .init.data)
    
    (You need to use GNU linker instead of LLD to reproduce it.)
    
    If you compile it for other architectures, modpost will show the correct
    symbol name.
    
      WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> foo (section: .init.data)
    
    For R_ARM_ABS32, addend_arm_rel() sets r->r_addend to a wrong value.
    
    I just mimicked the code in arch/arm/kernel/module.c.
    
    However, there is more difficulty for ARM.
    
    Here, test code.
    
      [test code 2]
    
        #include <linux/init.h>
    
        int __initdata foo;
        int get_foo(void) { return foo; }
    
        int __initdata bar;
        int get_bar(void) { return bar; }
    
    With this commit applied, modpost will show the following messages
    for ARM versatile_defconfig:
    
      WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> foo (section: .init.data)
      WARNING: modpost: vmlinux.o: section mismatch in reference: get_bar (section: .text) -> foo (section: .init.data)
    
    The reference from 'get_bar' to 'foo' seems wrong.
    
    I have no solution for this because it is true in assembly level.
    
    In the following output, relocation at 0x1c is no longer associated
    with 'bar'. The two relocation entries point to the same symbol, and
    the offset to 'bar' is encoded in the instruction 'r0, [r3, #4]'.
    
      Disassembly of section .text:
    
      00000000 <get_foo>:
         0: e59f3004          ldr     r3, [pc, #4]   @ c <get_foo+0xc>
         4: e5930000          ldr     r0, [r3]
         8: e12fff1e          bx      lr
         c: 00000000          .word   0x00000000
    
      00000010 <get_bar>:
        10: e59f3004          ldr     r3, [pc, #4]   @ 1c <get_bar+0xc>
        14: e5930004          ldr     r0, [r3, #4]
        18: e12fff1e          bx      lr
        1c: 00000000          .word   0x00000000
    
      Relocation section '.rel.text' at offset 0x244 contains 2 entries:
       Offset     Info    Type            Sym.Value  Sym. Name
      0000000c  00000c02 R_ARM_ABS32       00000000   .init.data
      0000001c  00000c02 R_ARM_ABS32       00000000   .init.data
    
    When find_elf_symbol() gets into a situation where relsym->st_name is
    zero, there is no guarantee to get the symbol name as written in C.
    
    I am keeping the current logic because it is useful in many architectures,
    but the symbol name is not always correct depending on the optimization.
    I left some comments in find_tosym().
    
    Fixes: 56a974fa2d59 ("kbuild: make better section mismatch reports on arm")
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

modpost: fix section mismatch message for R_ARM_{PC24,CALL,JUMP24} [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Thu Jun 1 21:09:56 2023 +0900

    modpost: fix section mismatch message for R_ARM_{PC24,CALL,JUMP24}
    
    [ Upstream commit 56a24b8ce6a7f9c4a21b2276a8644f6f3d8fc14d ]
    
    addend_arm_rel() processes R_ARM_PC24, R_ARM_CALL, R_ARM_JUMP24 in a
    wrong way.
    
    Here, test code.
    
    [test code for R_ARM_JUMP24]
    
      .section .init.text,"ax"
      bar:
              bx      lr
    
      .section .text,"ax"
      .globl foo
      foo:
              b       bar
    
    [test code for R_ARM_CALL]
    
      .section .init.text,"ax"
      bar:
              bx      lr
    
      .section .text,"ax"
      .globl foo
      foo:
              push    {lr}
              bl      bar
              pop     {pc}
    
    If you compile it with ARM multi_v7_defconfig, modpost will show the
    symbol name, (unknown).
    
      WARNING: modpost: vmlinux.o: section mismatch in reference: foo (section: .text) -> (unknown) (section: .init.text)
    
    (You need to use GNU linker instead of LLD to reproduce it.)
    
    Fix the code to make modpost show the correct symbol name.
    
    I imported (with adjustment) sign_extend32() from include/linux/bitops.h.
    
    The '+8' is the compensation for pc-relative instruction. It is
    documented in "ELF for the Arm Architecture" [1].
    
      "If the relocation is pc-relative then compensation for the PC bias
      (the PC value is 8 bytes ahead of the executing instruction in Arm
      state and 4 bytes in Thumb state) must be encoded in the relocation
      by the object producer."
    
    [1]: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst
    
    Fixes: 56a974fa2d59 ("kbuild: make better section mismatch reports on arm")
    Fixes: 6e2e340b59d2 ("ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers")
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

modpost: remove broken calculation of exception_table_entry size [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Mon May 15 00:27:19 2023 +0900

    modpost: remove broken calculation of exception_table_entry size
    
    [ Upstream commit d0acc76a49aa917c1a455d11d32d34a01e8b2835 ]
    
    find_extable_entry_size() is completely broken. It has awesome comments
    about how to calculate sizeof(struct exception_table_entry).
    
    It was based on these assumptions:
    
      - struct exception_table_entry has two fields
      - both of the fields have the same size
    
    Then, we came up with this equation:
    
      (offset of the second field) * 2 == (size of struct)
    
    It was true for all architectures when commit 52dc0595d540 ("modpost:
    handle relocations mismatch in __ex_table.") was applied.
    
    Our mathematics broke when commit 548acf19234d ("x86/mm: Expand the
    exception table logic to allow new handling options") introduced the
    third field.
    
    Now, the definition of exception_table_entry is highly arch-dependent.
    
    For x86, sizeof(struct exception_table_entry) is apparently 12, but
    find_extable_entry_size() sets extable_entry_size to 8.
    
    I could fix it, but I do not see much value in this code.
    
    extable_entry_size is used just for selecting a slightly different
    error message.
    
    If the first field ("insn") references to a non-executable section,
    
        The relocation at %s+0x%lx references
        section "%s" which is not executable, IOW
        it is not possible for the kernel to fault
        at that address.  Something is seriously wrong
        and should be fixed.
    
    If the second field ("fixup") references to a non-executable section,
    
        The relocation at %s+0x%lx references
        section "%s" which is not executable, IOW
        the kernel will fault if it ever tries to
        jump to it.  Something is seriously wrong
        and should be fixed.
    
    Merge the two error messages rather than adding even more complexity.
    
    Change fatal() to error() to make it continue running and catch more
    possible errors.
    
    Fixes: 548acf19234d ("x86/mm: Expand the exception table logic to allow new handling options")
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mtd: parsers: refer to ARCH_BCMBCA instead of ARCH_BCM4908 [+ + +]
Author: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Date:   Wed Nov 16 13:49:32 2022 +0100

    mtd: parsers: refer to ARCH_BCMBCA instead of ARCH_BCM4908
    
    commit 085679b15b5af65f9610f619afde41da0f966194 upstream.
    
    Commit dd5c672d7ca9 ("arm64: bcmbca: Merge ARCH_BCM4908 to ARCH_BCMBCA")
    removes config ARCH_BCM4908 as config ARCH_BCMBCA has the same intent.
    
    Probably due to concurrent development, commit 002181f5b150 ("mtd: parsers:
    add Broadcom's U-Boot parser") introduces 'Broadcom's U-Boot partition
    parser' that depends on ARCH_BCM4908, but this use was not visible during
    the config refactoring from the commit above. Hence, these two changes
    create a reference to a non-existing config symbol.
    
    Adjust the MTD_BRCM_U_BOOT definition to refer to ARCH_BCMBCA instead of
    ARCH_BCM4908 to remove the reference to the non-existing config symbol
    ARCH_BCM4908.
    
    Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/linux-mtd/20221116124932.4748-1-lukas.bulwahn@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
net/sched: act_ipt: add sanity checks on skb before calling target [+ + +]
Author: Florian Westphal <fw@strlen.de>
Date:   Tue Jun 27 14:38:12 2023 +0200

    net/sched: act_ipt: add sanity checks on skb before calling target
    
    [ Upstream commit b2dc32dcba08bf55cec600caa76f4afd2e3614df ]
    
    Netfilter targets make assumptions on the skb state, for example
    iphdr is supposed to be in the linear area.
    
    This is normally done by IP stack, but in act_ipt case no
    such checks are made.
    
    Some targets can even assume that skb_dst will be valid.
    Make a minimum effort to check for this:
    
    - Don't call the targets eval function for non-ipv4 skbs.
    - Don't call the targets eval function for POSTROUTING
      emulation when the skb has no dst set.
    
    v3: use skb_protocol helper (Davide Caratti)
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net/sched: act_ipt: add sanity checks on table name and hook locations [+ + +]
Author: Florian Westphal <fw@strlen.de>
Date:   Tue Jun 27 14:38:11 2023 +0200

    net/sched: act_ipt: add sanity checks on table name and hook locations
    
    [ Upstream commit b4ee93380b3c891fea996af8d1d3ca0e36ad31f0 ]
    
    Looks like "tc" hard-codes "mangle" as the only supported table
    name, but on kernel side there are no checks.
    
    This is wrong.  Not all xtables targets are safe to call from tc.
    E.g. "nat" targets assume skb has a conntrack object assigned to it.
    Normally those get called from netfilter nat core which consults the
    nat table to obtain the address mapping.
    
    "tc" userspace either sets PRE or POSTROUTING as hook number, but there
    is no validation of this on kernel side, so update netlink policy to
    reject bogus numbers.  Some targets may assume skb_dst is set for
    input/forward hooks, so prevent those from being used.
    
    act_ipt uses the hook number in two places:
    1. the state hook number, this is fine as-is
    2. to set par.hook_mask
    
    The latter is a bit mask, so update the assignment to make
    xt_check_target() to the right thing.
    
    Followup patch adds required checks for the skb/packet headers before
    calling the targets evaluation function.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX [+ + +]
Author: Lin Ma <linma@zju.edu.cn>
Date:   Mon Jul 3 19:08:42 2023 +0800

    net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX
    
    [ Upstream commit 30c45b5361d39b4b793780ffac5538090b9e2eb1 ]
    
    The attribute TCA_PEDIT_PARMS_EX is not be included in pedit_policy and
    one malicious user could fake a TCA_PEDIT_PARMS_EX whose length is
    smaller than the intended sizeof(struct tc_pedit). Hence, the
    dereference in tcf_pedit_init() could access dirty heap data.
    
    static int tcf_pedit_init(...)
    {
      // ...
      pattr = tb[TCA_PEDIT_PARMS]; // TCA_PEDIT_PARMS is included
      if (!pattr)
        pattr = tb[TCA_PEDIT_PARMS_EX]; // but this is not
    
      // ...
      parm = nla_data(pattr);
    
      index = parm->index; // parm is able to be smaller than 4 bytes
                           // and this dereference gets dirty skb_buff
                           // data created in netlink_sendmsg
    }
    
    This commit adds TCA_PEDIT_PARMS_EX length in pedit_policy which avoid
    the above case, just like the TCA_PEDIT_PARMS.
    
    Fixes: 71d0ed7079df ("net/act_pedit: Support using offset relative to the conventional network headers")
    Signed-off-by: Lin Ma <linma@zju.edu.cn>
    Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
    Link: https://lore.kernel.org/r/20230703110842.590282-1-linma@zju.edu.cn
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
net: add a couple of helpers for iph tot_len [+ + +]
Author: Xin Long <lucien.xin@gmail.com>
Date:   Sat Jan 28 10:58:30 2023 -0500

    net: add a couple of helpers for iph tot_len
    
    [ Upstream commit 058a8f7f73aae1cc22b53fcefec031b9e391b54d ]
    
    This patch adds three APIs to replace the iph->tot_len setting
    and getting in all places where IPv4 BIG TCP packets may reach,
    they will be used in the following patches.
    
    Note that iph_totlen() will be used when iph is not in linear
    data of the skb.
    
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Stable-dep-of: b2dc32dcba08 ("net/sched: act_ipt: add sanity checks on skb before calling target")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: axienet: Move reset before 64-bit DMA detection [+ + +]
Author: Maxim Kochetkov <fido_max@inbox.ru>
Date:   Thu Jun 22 22:22:45 2023 +0300

    net: axienet: Move reset before 64-bit DMA detection
    
    [ Upstream commit f1bc9fc4a06de0108e0dca2a9a7e99ba1fc632f9 ]
    
    64-bit DMA detection will fail if axienet was started before (by boot
    loader, boot ROM, etc). In this state axienet will not start properly.
    XAXIDMA_TX_CDESC_OFFSET + 4 register (MM2S_CURDESC_MSB) is used to detect
    64-bit DMA capability here. But datasheet says: When DMACR.RS is 1
    (axienet is in enabled state), CURDESC_PTR becomes Read Only (RO) and
    is used to fetch the first descriptor. So iowrite32()/ioread32() trick
    to this register to detect 64-bit DMA will not work.
    So move axienet reset before 64-bit DMA detection.
    
    Fixes: f735c40ed93c ("net: axienet: Autodetect 64-bit DMA capability")
    Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
    Reviewed-by: Robert Hancock <robert.hancock@calian.com>
    Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
    Link: https://lore.kernel.org/r/20230622192245.116864-1-fido_max@inbox.ru
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: bridge: keep ports without IFF_UNICAST_FLT in BR_PROMISC mode [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Fri Jun 30 19:41:18 2023 +0300

    net: bridge: keep ports without IFF_UNICAST_FLT in BR_PROMISC mode
    
    [ Upstream commit 6ca3c005d0604e8d2b439366e3923ea58db99641 ]
    
    According to the synchronization rules for .ndo_get_stats() as seen in
    Documentation/networking/netdevices.rst, acquiring a plain spin_lock()
    should not be illegal, but the bridge driver implementation makes it so.
    
    After running these commands, I am being faced with the following
    lockdep splat:
    
    $ ip link add link swp0 name macsec0 type macsec encrypt on && ip link set swp0 up
    $ ip link add dev br0 type bridge vlan_filtering 1 && ip link set br0 up
    $ ip link set macsec0 master br0 && ip link set macsec0 up
    
      ========================================================
      WARNING: possible irq lock inversion dependency detected
      6.4.0-04295-g31b577b4bd4a #603 Not tainted
      --------------------------------------------------------
      swapper/1/0 just changed the state of lock:
      ffff6bd348724cd8 (&br->lock){+.-.}-{3:3}, at: br_forward_delay_timer_expired+0x34/0x198
      but this lock took another, SOFTIRQ-unsafe lock in the past:
       (&ocelot->stats_lock){+.+.}-{3:3}
    
      and interrupts could create inverse lock ordering between them.
    
      other info that might help us debug this:
      Chain exists of:
        &br->lock --> &br->hash_lock --> &ocelot->stats_lock
    
       Possible interrupt unsafe locking scenario:
    
             CPU0                    CPU1
             ----                    ----
        lock(&ocelot->stats_lock);
                                     local_irq_disable();
                                     lock(&br->lock);
                                     lock(&br->hash_lock);
        <Interrupt>
          lock(&br->lock);
    
       *** DEADLOCK ***
    
    (details about the 3 locks skipped)
    
    swp0 is instantiated by drivers/net/dsa/ocelot/felix.c, and this
    only matters to the extent that its .ndo_get_stats64() method calls
    spin_lock(&ocelot->stats_lock).
    
    Documentation/locking/lockdep-design.rst says:
    
    | A lock is irq-safe means it was ever used in an irq context, while a lock
    | is irq-unsafe means it was ever acquired with irq enabled.
    
    (...)
    
    | Furthermore, the following usage based lock dependencies are not allowed
    | between any two lock-classes::
    |
    |    <hardirq-safe>   ->  <hardirq-unsafe>
    |    <softirq-safe>   ->  <softirq-unsafe>
    
    Lockdep marks br->hash_lock as softirq-safe, because it is sometimes
    taken in softirq context (for example br_fdb_update() which runs in
    NET_RX softirq), and when it's not in softirq context it blocks softirqs
    by using spin_lock_bh().
    
    Lockdep marks ocelot->stats_lock as softirq-unsafe, because it never
    blocks softirqs from running, and it is never taken from softirq
    context. So it can always be interrupted by softirqs.
    
    There is a call path through which a function that holds br->hash_lock:
    fdb_add_hw_addr() will call a function that acquires ocelot->stats_lock:
    ocelot_port_get_stats64(). This can be seen below:
    
    ocelot_port_get_stats64+0x3c/0x1e0
    felix_get_stats64+0x20/0x38
    dsa_slave_get_stats64+0x3c/0x60
    dev_get_stats+0x74/0x2c8
    rtnl_fill_stats+0x4c/0x150
    rtnl_fill_ifinfo+0x5cc/0x7b8
    rtmsg_ifinfo_build_skb+0xe4/0x150
    rtmsg_ifinfo+0x5c/0xb0
    __dev_notify_flags+0x58/0x200
    __dev_set_promiscuity+0xa0/0x1f8
    dev_set_promiscuity+0x30/0x70
    macsec_dev_change_rx_flags+0x68/0x88
    __dev_set_promiscuity+0x1a8/0x1f8
    __dev_set_rx_mode+0x74/0xa8
    dev_uc_add+0x74/0xa0
    fdb_add_hw_addr+0x68/0xd8
    fdb_add_local+0xc4/0x110
    br_fdb_add_local+0x54/0x88
    br_add_if+0x338/0x4a0
    br_add_slave+0x20/0x38
    do_setlink+0x3a4/0xcb8
    rtnl_newlink+0x758/0x9d0
    rtnetlink_rcv_msg+0x2f0/0x550
    netlink_rcv_skb+0x128/0x148
    rtnetlink_rcv+0x24/0x38
    
    the plain English explanation for it is:
    
    The macsec0 bridge port is created without p->flags & BR_PROMISC,
    because it is what br_manage_promisc() decides for a VLAN filtering
    bridge with a single auto port.
    
    As part of the br_add_if() procedure, br_fdb_add_local() is called for
    the MAC address of the device, and this results in a call to
    dev_uc_add() for macsec0 while the softirq-safe br->hash_lock is taken.
    
    Because macsec0 does not have IFF_UNICAST_FLT, dev_uc_add() ends up
    calling __dev_set_promiscuity() for macsec0, which is propagated by its
    implementation, macsec_dev_change_rx_flags(), to the lower device: swp0.
    This triggers the call path:
    
    dev_set_promiscuity(swp0)
    -> rtmsg_ifinfo()
       -> dev_get_stats()
          -> ocelot_port_get_stats64()
    
    with a calling context that lockdep doesn't like (br->hash_lock held).
    
    Normally we don't see this, because even though many drivers that can be
    bridge ports don't support IFF_UNICAST_FLT, we need a driver that
    
    (a) doesn't support IFF_UNICAST_FLT, *and*
    (b) it forwards the IFF_PROMISC flag to another driver, and
    (c) *that* driver implements ndo_get_stats64() using a softirq-unsafe
        spinlock.
    
    Condition (b) is necessary because the first __dev_set_rx_mode() calls
    __dev_set_promiscuity() with "bool notify=false", and thus, the
    rtmsg_ifinfo() code path won't be entered.
    
    The same criteria also hold true for DSA switches which don't report
    IFF_UNICAST_FLT. When the DSA master uses a spin_lock() in its
    ndo_get_stats64() method, the same lockdep splat can be seen.
    
    I think the deadlock possibility is real, even though I didn't reproduce
    it, and I'm thinking of the following situation to support that claim:
    
    fdb_add_hw_addr() runs on a CPU A, in a context with softirqs locally
    disabled and br->hash_lock held, and may end up attempting to acquire
    ocelot->stats_lock.
    
    In parallel, ocelot->stats_lock is currently held by a thread B (say,
    ocelot_check_stats_work()), which is interrupted while holding it by a
    softirq which attempts to lock br->hash_lock.
    
    Thread B cannot make progress because br->hash_lock is held by A. Whereas
    thread A cannot make progress because ocelot->stats_lock is held by B.
    
    When taking the issue at face value, the bridge can avoid that problem
    by simply making the ports promiscuous from a code path with a saner
    calling context (br->hash_lock not held). A bridge port without
    IFF_UNICAST_FLT is going to become promiscuous as soon as we call
    dev_uc_add() on it (which we do unconditionally), so why not be
    preemptive and make it promiscuous right from the beginning, so as to
    not be taken by surprise.
    
    With this, we've broken the links between code that holds br->hash_lock
    or br->lock and code that calls into the ndo_change_rx_flags() or
    ndo_get_stats64() ops of the bridge port.
    
    Fixes: 2796d0c648c9 ("bridge: Automatically manage port promiscuous mode.")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: felix: don't drop PTP frames with tag_8021q when RX timestamping is disabled [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Jun 27 19:31:14 2023 +0300

    net: dsa: felix: don't drop PTP frames with tag_8021q when RX timestamping is disabled
    
    [ Upstream commit 2edcfcbb3c5946609be1d8875473a240b170673b ]
    
    The driver implements a workaround for the fact that it doesn't have an
    IRQ source to tell it whether PTP frames are available through the
    extraction registers, for those frames to be processed and passed
    towards the network stack. That workaround is to configure the switch,
    through felix_hwtstamp_set() -> felix_update_trapping_destinations(),
    to create two copies of PTP packets: one sent over Ethernet to the DSA
    master, and one to be consumed through the aforementioned CPU extraction
    queue registers.
    
    The reason why we want PTP packets to be consumed through the CPU
    extraction registers in the first place is because we want to see their
    hardware RX timestamp. With tag_8021q, that is only visible that way,
    and it isn't visible with the copy of the packet that's transmitted over
    Ethernet.
    
    The problem with the workaround implementation is that it drops the
    packet received over Ethernet, in expectation of its copy being present
    in the CPU extraction registers. However, if felix_hwtstamp_set() hasn't
    run (aka PTP RX timestamping is disabled), the driver will drop the
    original PTP frame and there will be no copy of it in the CPU extraction
    registers. So, the network stack will simply not see any PTP frame.
    
    Look at the port's trapping configuration to see whether the driver has
    previously enabled the CPU extraction registers. If it hasn't, just
    don't RX timestamp the frame and let it be passed up the stack by DSA,
    which is perfectly fine.
    
    Fixes: 0a6f17c6ae21 ("net: dsa: tag_ocelot_8021q: add support for PTP timestamping")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: sja1105: always enable the INCL_SRCPT option [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Jun 27 12:42:06 2023 +0300

    net: dsa: sja1105: always enable the INCL_SRCPT option
    
    [ Upstream commit b4638af8885af93cd70351081da1909c59342440 ]
    
    Link-local traffic on bridged SJA1105 ports is sometimes tagged by the
    hardware with source port information (when the port is under a VLAN
    aware bridge).
    
    The tag_8021q source port identification has become more loose
    ("imprecise") and will report a plausible rather than exact bridge port,
    when under a bridge (be it VLAN-aware or VLAN-unaware). But link-local
    traffic always needs to know the precise source port.
    
    Modify the driver logic (and therefore: the tagging protocol itself) to
    always include the source port information with link-local packets,
    regardless of whether the port is standalone, under a VLAN-aware or
    VLAN-unaware bridge. This makes it possible for the tagging driver to
    give priority to that information over the tag_8021q VLAN header.
    
    The big drawback with INCL_SRCPT is that it makes it impossible to
    distinguish between an original MAC DA of 01:80:C2:XX:YY:ZZ and
    01:80:C2:AA:BB:ZZ, because the tagger just patches MAC DA bytes 3 and 4
    with zeroes. Only if PTP RX timestamping is enabled, the switch will
    generate a META follow-up frame containing the RX timestamp and the
    original bytes 3 and 4 of the MAC DA. Those will be used to patch up the
    original packet. Nonetheless, in the absence of PTP RX timestamping, we
    have to live with this limitation, since it is more important to have
    the more precise source port information for link-local traffic.
    
    Fixes: d7f9787a763f ("net: dsa: tag_8021q: add support for imprecise RX based on the VBID")
    Fixes: 91495f21fcec ("net: dsa: tag_8021q: replace the SVL bridging with VLAN-unaware IVL bridging")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: sja1105: always enable the send_meta options [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Jul 4 01:05:45 2023 +0300

    net: dsa: sja1105: always enable the send_meta options
    
    [ Upstream commit a372d66af48506d9f7aaae2a474cd18f14d98cb8 ]
    
    incl_srcpt has the limitation, mentioned in commit b4638af8885a ("net:
    dsa: sja1105: always enable the INCL_SRCPT option"), that frames with a
    MAC DA of 01:80:c2:xx:yy:zz will be received as 01:80:c2:00:00:zz unless
    PTP RX timestamping is enabled.
    
    The incl_srcpt option was initially unconditionally enabled, then that
    changed with commit 42824463d38d ("net: dsa: sja1105: Limit use of
    incl_srcpt to bridge+vlan mode"), then again with b4638af8885a ("net:
    dsa: sja1105: always enable the INCL_SRCPT option"). Bottom line is that
    it now needs to be always enabled, otherwise the driver does not have a
    reliable source of information regarding source_port and switch_id for
    link-local traffic (tag_8021q VLANs may be imprecise since now they
    identify an entire bridging domain when ports are not standalone).
    
    If we accept that PTP RX timestamping (and therefore, meta frame
    generation) is always enabled in hardware, then that limitation could be
    avoided and packets with any MAC DA can be properly received, because
    meta frames do contain the original bytes from the MAC DA of their
    associated link-local packet.
    
    This change enables meta frame generation unconditionally, which also
    has the nice side effects of simplifying the switch control path
    (a switch reset is no longer required on hwtstamping settings change)
    and the tagger data path (it no longer needs to be informed whether to
    expect meta frames or not - it always does).
    
    Fixes: 227d07a07ef1 ("net: dsa: sja1105: Add support for traffic through standalone ports")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Jun 27 12:42:07 2023 +0300

    net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT
    
    [ Upstream commit c1ae02d876898b1b8ca1e12c6f84d7b406263800 ]
    
    Currently the sja1105 tagging protocol prefers using the source port
    information from the VLAN header if that is available, falling back to
    the INCL_SRCPT option if it isn't. The VLAN header is available for all
    frames except for META frames initiated by the switch (containing RX
    timestamps), and thus, the "if (is_link_local)" branch is practically
    dead.
    
    The tag_8021q source port identification has become more loose
    ("imprecise") and will report a plausible rather than exact bridge port,
    when under a bridge (be it VLAN-aware or VLAN-unaware). But link-local
    traffic always needs to know the precise source port. With incorrect
    source port reporting, for example PTP traffic over 2 bridged ports will
    all be seen on sockets opened on the first such port, which is incorrect.
    
    Now that the tagging protocol has been changed to make link-local frames
    always contain source port information, we can reverse the order of the
    checks so that we always give precedence to that information (which is
    always precise) in lieu of the tag_8021q VID which is only precise for a
    standalone port.
    
    Fixes: d7f9787a763f ("net: dsa: tag_8021q: add support for imprecise RX based on the VBID")
    Fixes: 91495f21fcec ("net: dsa: tag_8021q: replace the SVL bridging with VLAN-unaware IVL bridging")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: tag_sja1105: fix MAC DA patching from meta frames [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Jul 4 01:05:44 2023 +0300

    net: dsa: tag_sja1105: fix MAC DA patching from meta frames
    
    [ Upstream commit 1dcf6efd5f0c1f4496b3ef7ec5a7db104a53b38c ]
    
    The SJA1105 manual says that at offset 4 into the meta frame payload we
    have "MAC destination byte 2" and at offset 5 we have "MAC destination
    byte 1". These are counted from the LSB, so byte 1 is h_dest[ETH_HLEN-2]
    aka h_dest[4] and byte 2 is h_dest[ETH_HLEN-3] aka h_dest[3].
    
    The sja1105_meta_unpack() function decodes these the other way around,
    so a frame with MAC DA 01:80:c2:11:22:33 is received by the network
    stack as having 01:80:c2:22:11:33.
    
    Fixes: e53e18a6fe4d ("net: dsa: sja1105: Receive and decode meta frames")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: tag_sja1105: fix source port decoding in vlan_filtering=0 bridge mode [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Sat Jul 1 01:20:10 2023 +0300

    net: dsa: tag_sja1105: fix source port decoding in vlan_filtering=0 bridge mode
    
    [ Upstream commit a398b9ea0c3b791b7a0f4c6029a62cf628f97f22 ]
    
    There was a regression introduced by the blamed commit, where pinging to
    a VLAN-unaware bridge would fail with the repeated message "Couldn't
    decode source port" coming from the tagging protocol driver.
    
    When receiving packets with a bridge_vid as determined by
    dsa_tag_8021q_bridge_join(), dsa_8021q_rcv() will decode:
    - source_port = 0 (which isn't really valid, more like "don't know")
    - switch_id = 0 (which isn't really valid, more like "don't know")
    - vbid = value in range 1-7
    
    Since the blamed patch has reversed the order of the checks, we are now
    going to believe that source_port != -1 and switch_id != -1, so they're
    valid, but they aren't.
    
    The minimal solution to the problem is to only populate source_port and
    switch_id with what dsa_8021q_rcv() came up with, if the vbid is zero,
    i.e. the source port information is trustworthy.
    
    Fixes: c1ae02d87689 ("net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: vsc73xx: fix MTU configuration [+ + +]
Author: Pawel Dembicki <paweldembicki@gmail.com>
Date:   Wed Jun 28 21:43:27 2023 +0200

    net: dsa: vsc73xx: fix MTU configuration
    
    [ Upstream commit 3cf62c8177adb0db9e15c8b898c44f997acf3ebf ]
    
    Switch in MAXLEN register stores the maximum size of a data frame.
    The MTU size is 18 bytes smaller than the frame size.
    
    The current settings are causing problems with packet forwarding.
    This patch fixes the MTU settings to proper values.
    
    Fixes: fb77ffc6ec86 ("net: dsa: vsc73xx: make the MTU configurable")
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
    Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
    Link: https://lore.kernel.org/r/20230628194327.1765644-1-paweldembicki@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: fix net_dev_start_xmit trace event vs skb_transport_offset() [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Sat Jul 1 02:48:24 2023 +0000

    net: fix net_dev_start_xmit trace event vs skb_transport_offset()
    
    [ Upstream commit f88fcb1d7d961b4b402d675109726f94db87571c ]
    
    After blamed commit, we must be more careful about using
    skb_transport_offset(), as reminded us by syzbot:
    
    WARNING: CPU: 0 PID: 10 at include/linux/skbuff.h:2868 skb_transport_offset include/linux/skbuff.h:2977 [inline]
    WARNING: CPU: 0 PID: 10 at include/linux/skbuff.h:2868 perf_trace_net_dev_start_xmit+0x89a/0xce0 include/trace/events/net.h:14
    Modules linked in:
    CPU: 0 PID: 10 Comm: kworker/u4:1 Not tainted 6.1.30-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
    Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet
    RIP: 0010:skb_transport_header include/linux/skbuff.h:2868 [inline]
    RIP: 0010:skb_transport_offset include/linux/skbuff.h:2977 [inline]
    RIP: 0010:perf_trace_net_dev_start_xmit+0x89a/0xce0 include/trace/events/net.h:14
    Code: 8b 04 25 28 00 00 00 48 3b 84 24 c0 00 00 00 0f 85 4e 04 00 00 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc e8 56 22 01 fd <0f> 0b e9 f6 fc ff ff 89 f9 80 e1 07 80 c1 03 38 c1 0f 8c 86 f9 ff
    RSP: 0018:ffffc900002bf700 EFLAGS: 00010293
    RAX: ffffffff8485d8ca RBX: 000000000000ffff RCX: ffff888100914280
    RDX: 0000000000000000 RSI: 000000000000ffff RDI: 000000000000ffff
    RBP: ffffc900002bf818 R08: ffffffff8485d5b6 R09: fffffbfff0f8fb5e
    R10: 0000000000000000 R11: dffffc0000000001 R12: 1ffff110217d8f67
    R13: ffff88810bec7b3a R14: dffffc0000000000 R15: dffffc0000000000
    FS: 0000000000000000(0000) GS:ffff8881f6a00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007f96cf6d52f0 CR3: 000000012224c000 CR4: 0000000000350ef0
    Call Trace:
    <TASK>
    [<ffffffff84715e35>] trace_net_dev_start_xmit include/trace/events/net.h:14 [inline]
    [<ffffffff84715e35>] xmit_one net/core/dev.c:3643 [inline]
    [<ffffffff84715e35>] dev_hard_start_xmit+0x705/0x980 net/core/dev.c:3660
    [<ffffffff8471a232>] __dev_queue_xmit+0x16b2/0x3370 net/core/dev.c:4324
    [<ffffffff85416493>] dev_queue_xmit include/linux/netdevice.h:3030 [inline]
    [<ffffffff85416493>] batadv_send_skb_packet+0x3f3/0x680 net/batman-adv/send.c:108
    [<ffffffff85416744>] batadv_send_broadcast_skb+0x24/0x30 net/batman-adv/send.c:127
    [<ffffffff853bc52a>] batadv_iv_ogm_send_to_if net/batman-adv/bat_iv_ogm.c:393 [inline]
    [<ffffffff853bc52a>] batadv_iv_ogm_emit net/batman-adv/bat_iv_ogm.c:421 [inline]
    [<ffffffff853bc52a>] batadv_iv_send_outstanding_bat_ogm_packet+0x69a/0x840 net/batman-adv/bat_iv_ogm.c:1701
    [<ffffffff8151023c>] process_one_work+0x8ac/0x1170 kernel/workqueue.c:2289
    [<ffffffff81511938>] worker_thread+0xaa8/0x12d0 kernel/workqueue.c:2436
    
    Fixes: 66e4c8d95008 ("net: warn if transport header was not set")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: mscc: ocelot: don't keep PTP configuration of all ports in single structure [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Jun 27 19:31:13 2023 +0300

    net: mscc: ocelot: don't keep PTP configuration of all ports in single structure
    
    [ Upstream commit 45d0fcb5bc9558d0bf3d2fa7fabc5d8a88d35439 ]
    
    In a future change, the driver will need to determine whether PTP RX
    timestamping is enabled on a port (including whether traps were set up
    on that port in particular) and that is currently not possible.
    
    The driver supports different RX filters (L2, L4) and kinds of TX
    timestamping (one-step, two-step) on its ports, but it saves all
    configuration in a single struct hwtstamp_config that is global to the
    switch. So, the latest timestamping configuration on one port
    (including a request to disable timestamping) affects what gets reported
    for all ports, even though the configuration itself is still individual
    to each port.
    
    The port timestamping configurations are only coupled because of the
    common structure, so replace the hwtstamp_config with a mask of trapped
    protocols saved per port. We also have the ptp_cmd to distinguish
    between one-step and two-step PTP timestamping, so with those 2 bits of
    information we can fully reconstruct a descriptive struct
    hwtstamp_config for each port, during the SIOCGHWTSTAMP ioctl.
    
    Fixes: 4e3b0468e6d7 ("net: mscc: PTP Hardware Clock (PHC) support")
    Fixes: 96ca08c05838 ("net: mscc: ocelot: set up traps for PTP packets")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: mscc: ocelot: don't report that RX timestamping is enabled by default [+ + +]
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Jun 27 19:31:12 2023 +0300

    net: mscc: ocelot: don't report that RX timestamping is enabled by default
    
    [ Upstream commit 4fd44b82b7aceaa35c2901c6546d2c4198e0799d ]
    
    PTP RX timestamping should be enabled when the user requests it, not by
    default. If it is enabled by default, it can be problematic when the
    ocelot driver is a DSA master, and it sidesteps what DSA tries to avoid
    through __dsa_master_hwtstamp_validate().
    
    Additionally, after the change which made ocelot trap PTP packets only
    to the CPU at ocelot_hwtstamp_set() time, it is no longer even true that
    RX timestamping is enabled by default, because until ocelot_hwtstamp_set()
    is called, the PTP traps are actually not set up. So the rx_filter field
    of ocelot->hwtstamp_config reflects an incorrect reality.
    
    Fixes: 96ca08c05838 ("net: mscc: ocelot: set up traps for PTP packets")
    Fixes: 4e3b0468e6d7 ("net: mscc: PTP Hardware Clock (PHC) support")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: nfc: Fix use-after-free caused by nfc_llcp_find_local [+ + +]
Author: Lin Ma <linma@zju.edu.cn>
Date:   Sun Jun 25 17:10:07 2023 +0800

    net: nfc: Fix use-after-free caused by nfc_llcp_find_local
    
    [ Upstream commit 6709d4b7bc2e079241fdef15d1160581c5261c10 ]
    
    This commit fixes several use-after-free that caused by function
    nfc_llcp_find_local(). For example, one UAF can happen when below buggy
    time window occurs.
    
    // nfc_genl_llc_get_params   | // nfc_unregister_device
                                 |
    dev = nfc_get_device(idx);   | device_lock(...)
    if (!dev)                    | dev->shutting_down = true;
        return -ENODEV;          | device_unlock(...);
                                 |
    device_lock(...);            |   // nfc_llcp_unregister_device
                                 |   nfc_llcp_find_local()
    nfc_llcp_find_local(...);    |
                                 |   local_cleanup()
    if (!local) {                |
        rc = -ENODEV;            |     // nfc_llcp_local_put
        goto exit;               |     kref_put(.., local_release)
    }                            |
                                 |       // local_release
                                 |       list_del(&local->list)
      // nfc_genl_send_params    |       kfree()
      local->dev->idx !!!UAF!!!  |
                                 |
    
    and the crash trace for the one of the discussed UAF like:
    
    BUG: KASAN: slab-use-after-free in nfc_genl_llc_get_params+0x72f/0x780  net/nfc/netlink.c:1045
    Read of size 8 at addr ffff888105b0e410 by task 20114
    
    Call Trace:
     <TASK>
     __dump_stack  lib/dump_stack.c:88 [inline]
     dump_stack_lvl+0x72/0xa0  lib/dump_stack.c:106
     print_address_description  mm/kasan/report.c:319 [inline]
     print_report+0xcc/0x620  mm/kasan/report.c:430
     kasan_report+0xb2/0xe0  mm/kasan/report.c:536
     nfc_genl_send_params  net/nfc/netlink.c:999 [inline]
     nfc_genl_llc_get_params+0x72f/0x780  net/nfc/netlink.c:1045
     genl_family_rcv_msg_doit.isra.0+0x1ee/0x2e0  net/netlink/genetlink.c:968
     genl_family_rcv_msg  net/netlink/genetlink.c:1048 [inline]
     genl_rcv_msg+0x503/0x7d0  net/netlink/genetlink.c:1065
     netlink_rcv_skb+0x161/0x430  net/netlink/af_netlink.c:2548
     genl_rcv+0x28/0x40  net/netlink/genetlink.c:1076
     netlink_unicast_kernel  net/netlink/af_netlink.c:1339 [inline]
     netlink_unicast+0x644/0x900  net/netlink/af_netlink.c:1365
     netlink_sendmsg+0x934/0xe70  net/netlink/af_netlink.c:1913
     sock_sendmsg_nosec  net/socket.c:724 [inline]
     sock_sendmsg+0x1b6/0x200  net/socket.c:747
     ____sys_sendmsg+0x6e9/0x890  net/socket.c:2501
     ___sys_sendmsg+0x110/0x1b0  net/socket.c:2555
     __sys_sendmsg+0xf7/0x1d0  net/socket.c:2584
     do_syscall_x64  arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x3f/0x90  arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x72/0xdc
    RIP: 0033:0x7f34640a2389
    RSP: 002b:00007f3463415168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 00007f34641c1f80 RCX: 00007f34640a2389
    RDX: 0000000000000000 RSI: 0000000020000240 RDI: 0000000000000006
    RBP: 00007f34640ed493 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
    R13: 00007ffe38449ecf R14: 00007f3463415300 R15: 0000000000022000
     </TASK>
    
    Allocated by task 20116:
     kasan_save_stack+0x22/0x50  mm/kasan/common.c:45
     kasan_set_track+0x25/0x30  mm/kasan/common.c:52
     ____kasan_kmalloc  mm/kasan/common.c:374 [inline]
     __kasan_kmalloc+0x7f/0x90  mm/kasan/common.c:383
     kmalloc  include/linux/slab.h:580 [inline]
     kzalloc  include/linux/slab.h:720 [inline]
     nfc_llcp_register_device+0x49/0xa40  net/nfc/llcp_core.c:1567
     nfc_register_device+0x61/0x260  net/nfc/core.c:1124
     nci_register_device+0x776/0xb20  net/nfc/nci/core.c:1257
     virtual_ncidev_open+0x147/0x230  drivers/nfc/virtual_ncidev.c:148
     misc_open+0x379/0x4a0  drivers/char/misc.c:165
     chrdev_open+0x26c/0x780  fs/char_dev.c:414
     do_dentry_open+0x6c4/0x12a0  fs/open.c:920
     do_open  fs/namei.c:3560 [inline]
     path_openat+0x24fe/0x37e0  fs/namei.c:3715
     do_filp_open+0x1ba/0x410  fs/namei.c:3742
     do_sys_openat2+0x171/0x4c0  fs/open.c:1356
     do_sys_open  fs/open.c:1372 [inline]
     __do_sys_openat  fs/open.c:1388 [inline]
     __se_sys_openat  fs/open.c:1383 [inline]
     __x64_sys_openat+0x143/0x200  fs/open.c:1383
     do_syscall_x64  arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x3f/0x90  arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    Freed by task 20115:
     kasan_save_stack+0x22/0x50  mm/kasan/common.c:45
     kasan_set_track+0x25/0x30  mm/kasan/common.c:52
     kasan_save_free_info+0x2e/0x50  mm/kasan/generic.c:521
     ____kasan_slab_free  mm/kasan/common.c:236 [inline]
     ____kasan_slab_free  mm/kasan/common.c:200 [inline]
     __kasan_slab_free+0x10a/0x190  mm/kasan/common.c:244
     kasan_slab_free  include/linux/kasan.h:162 [inline]
     slab_free_hook  mm/slub.c:1781 [inline]
     slab_free_freelist_hook  mm/slub.c:1807 [inline]
     slab_free  mm/slub.c:3787 [inline]
     __kmem_cache_free+0x7a/0x190  mm/slub.c:3800
     local_release  net/nfc/llcp_core.c:174 [inline]
     kref_put  include/linux/kref.h:65 [inline]
     nfc_llcp_local_put  net/nfc/llcp_core.c:182 [inline]
     nfc_llcp_local_put  net/nfc/llcp_core.c:177 [inline]
     nfc_llcp_unregister_device+0x206/0x290  net/nfc/llcp_core.c:1620
     nfc_unregister_device+0x160/0x1d0  net/nfc/core.c:1179
     virtual_ncidev_close+0x52/0xa0  drivers/nfc/virtual_ncidev.c:163
     __fput+0x252/0xa20  fs/file_table.c:321
     task_work_run+0x174/0x270  kernel/task_work.c:179
     resume_user_mode_work  include/linux/resume_user_mode.h:49 [inline]
     exit_to_user_mode_loop  kernel/entry/common.c:171 [inline]
     exit_to_user_mode_prepare+0x108/0x110  kernel/entry/common.c:204
     __syscall_exit_to_user_mode_work  kernel/entry/common.c:286 [inline]
     syscall_exit_to_user_mode+0x21/0x50  kernel/entry/common.c:297
     do_syscall_64+0x4c/0x90  arch/x86/entry/common.c:86
     entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    Last potentially related work creation:
     kasan_save_stack+0x22/0x50  mm/kasan/common.c:45
     __kasan_record_aux_stack+0x95/0xb0  mm/kasan/generic.c:491
     kvfree_call_rcu+0x29/0xa80  kernel/rcu/tree.c:3328
     drop_sysctl_table+0x3be/0x4e0  fs/proc/proc_sysctl.c:1735
     unregister_sysctl_table.part.0+0x9c/0x190  fs/proc/proc_sysctl.c:1773
     unregister_sysctl_table+0x24/0x30  fs/proc/proc_sysctl.c:1753
     neigh_sysctl_unregister+0x5f/0x80  net/core/neighbour.c:3895
     addrconf_notify+0x140/0x17b0  net/ipv6/addrconf.c:3684
     notifier_call_chain+0xbe/0x210  kernel/notifier.c:87
     call_netdevice_notifiers_info+0xb5/0x150  net/core/dev.c:1937
     call_netdevice_notifiers_extack  net/core/dev.c:1975 [inline]
     call_netdevice_notifiers  net/core/dev.c:1989 [inline]
     dev_change_name+0x3c3/0x870  net/core/dev.c:1211
     dev_ifsioc+0x800/0xf70  net/core/dev_ioctl.c:376
     dev_ioctl+0x3d9/0xf80  net/core/dev_ioctl.c:542
     sock_do_ioctl+0x160/0x260  net/socket.c:1213
     sock_ioctl+0x3f9/0x670  net/socket.c:1316
     vfs_ioctl  fs/ioctl.c:51 [inline]
     __do_sys_ioctl  fs/ioctl.c:870 [inline]
     __se_sys_ioctl  fs/ioctl.c:856 [inline]
     __x64_sys_ioctl+0x19e/0x210  fs/ioctl.c:856
     do_syscall_x64  arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x3f/0x90  arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    The buggy address belongs to the object at ffff888105b0e400
     which belongs to the cache kmalloc-1k of size 1024
    The buggy address is located 16 bytes inside of
     freed 1024-byte region [ffff888105b0e400, ffff888105b0e800)
    
    The buggy address belongs to the physical page:
    head:ffffea000416c200 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
    flags: 0x200000000010200(slab|head|node=0|zone=2)
    raw: 0200000000010200 ffff8881000430c0 ffffea00044c7010 ffffea0004510e10
    raw: 0000000000000000 00000000000a000a 00000001ffffffff 0000000000000000
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff888105b0e300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
     ffff888105b0e380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    >ffff888105b0e400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                             ^
     ffff888105b0e480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
     ffff888105b0e500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    
    In summary, this patch solves those use-after-free by
    
    1. Re-implement the nfc_llcp_find_local(). The current version does not
    grab the reference when getting the local from the linked list.  For
    example, the llcp_sock_bind() gets the reference like below:
    
    // llcp_sock_bind()
    
        local = nfc_llcp_find_local(dev); // A
        ..... \
               | raceable
        ..... /
        llcp_sock->local = nfc_llcp_local_get(local); // B
    
    There is an apparent race window that one can  drop the reference
    and free the local object fetched in (A) before (B) gets the reference.
    
    2. Some callers of the nfc_llcp_find_local() do not grab the reference
    at all. For example, the nfc_genl_llc_{{get/set}_params/sdreq} functions.
    We add the nfc_llcp_local_put() for them. Moreover, we add the necessary
    error handling function to put the reference.
    
    3. Add the nfc_llcp_remove_local() helper. The local object is removed
    from the linked list in local_release() when all reference is gone. This
    patch removes it when nfc_llcp_unregister_device() is called.
    
    Therefore, every caller of nfc_llcp_find_local() will get a reference
    even when the nfc_llcp_unregister_device() is called. This promises no
    use-after-free for the local object is ever possible.
    
    Fixes: 52feb444a903 ("NFC: Extend netlink interface for LTO, RW, and MIUX parameters support")
    Fixes: c7aa12252f51 ("NFC: Take a reference on the LLCP local pointer when creating a socket")
    Signed-off-by: Lin Ma <linma@zju.edu.cn>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: stmmac: fix double serdes powerdown [+ + +]
Author: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Date:   Wed Jun 21 15:55:37 2023 +0200

    net: stmmac: fix double serdes powerdown
    
    [ Upstream commit c4fc88ad2a765224a648db8ab35f125e120fe41b ]
    
    Commit 49725ffc15fc ("net: stmmac: power up/down serdes in
    stmmac_open/release") correctly added a call to the serdes_powerdown()
    callback to stmmac_release() but did not remove the one from
    stmmac_remove() which leads to a doubled call to serdes_powerdown().
    
    This can lead to all kinds of problems: in the case of the qcom ethqos
    driver, it caused an unbalanced regulator disable splat.
    
    Fixes: 49725ffc15fc ("net: stmmac: power up/down serdes in stmmac_open/release")
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Acked-by: Junxiao Chang <junxiao.chang@intel.com>
    Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
    Tested-by: Andrew Halaney <ahalaney@redhat.com>
    Link: https://lore.kernel.org/r/20230621135537.376649-1-brgl@bgdev.pl
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
netfilter: conntrack: Avoid nf_ct_helper_hash uses after free [+ + +]
Author: Florent Revest <revest@chromium.org>
Date:   Mon Jul 3 16:52:16 2023 +0200

    netfilter: conntrack: Avoid nf_ct_helper_hash uses after free
    
    commit 6eef7a2b933885a17679eb8ed0796ddf0ee5309b upstream.
    
    If nf_conntrack_init_start() fails (for example due to a
    register_nf_conntrack_bpf() failure), the nf_conntrack_helper_fini()
    clean-up path frees the nf_ct_helper_hash map.
    
    When built with NF_CONNTRACK=y, further netfilter modules (e.g:
    netfilter_conntrack_ftp) can still be loaded and call
    nf_conntrack_helpers_register(), independently of whether nf_conntrack
    initialized correctly. This accesses the nf_ct_helper_hash dangling
    pointer and causes a uaf, possibly leading to random memory corruption.
    
    This patch guards nf_conntrack_helper_register() from accessing a freed
    or uninitialized nf_ct_helper_hash pointer and fixes possible
    uses-after-free when loading a conntrack module.
    
    Cc: stable@vger.kernel.org
    Fixes: 12f7a505331e ("netfilter: add user-space connection tracking helper infrastructure")
    Signed-off-by: Florent Revest <revest@chromium.org>
    Reviewed-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

netfilter: conntrack: dccp: copy entire header to stack buffer, not just basic one [+ + +]
Author: Florian Westphal <fw@strlen.de>
Date:   Wed Jun 21 17:56:53 2023 +0200

    netfilter: conntrack: dccp: copy entire header to stack buffer, not just basic one
    
    [ Upstream commit ff0a3a7d52ff7282dbd183e7fc29a1fe386b0c30 ]
    
    Eric Dumazet says:
      nf_conntrack_dccp_packet() has an unique:
    
      dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
    
      And nothing more is 'pulled' from the packet, depending on the content.
      dh->dccph_doff, and/or dh->dccph_x ...)
      So dccp_ack_seq() is happily reading stuff past the _dh buffer.
    
    BUG: KASAN: stack-out-of-bounds in nf_conntrack_dccp_packet+0x1134/0x11c0
    Read of size 4 at addr ffff000128f66e0c by task syz-executor.2/29371
    [..]
    
    Fix this by increasing the stack buffer to also include room for
    the extra sequence numbers and all the known dccp packet type headers,
    then pull again after the initial validation of the basic header.
    
    While at it, mark packets invalid that lack 48bit sequence bit but
    where RFC says the type MUST use them.
    
    Compile tested only.
    
    v2: first skb_header_pointer() now needs to adjust the size to
        only pull the generic header. (Eric)
    
    Heads-up: I intend to remove dccp conntrack support later this year.
    
    Fixes: 2bc780499aa3 ("[NETFILTER]: nf_conntrack: add DCCP protocol support")
    Reported-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

netfilter: nf_conntrack_sip: fix the ct_sip_parse_numerical_param() return value. [+ + +]
Author: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
Date:   Fri Jun 23 11:23:46 2023 +0000

    netfilter: nf_conntrack_sip: fix the ct_sip_parse_numerical_param() return value.
    
    [ Upstream commit f188d30087480eab421cd8ca552fb15f55d57f4d ]
    
    ct_sip_parse_numerical_param() returns only 0 or 1 now.
    But process_register_request() and process_register_response() imply
    checking for a negative value if parsing of a numerical header parameter
    failed.
    The invocation in nf_nat_sip() looks correct:
            if (ct_sip_parse_numerical_param(...) > 0 &&
                ...) { ... }
    
    Make the return value of the function ct_sip_parse_numerical_param()
    a tristate to fix all the cases
    a) return 1 if value is found; *val is set
    b) return 0 if value is not found; *val is unchanged
    c) return -1 on error; *val is undefined
    
    Found by InfoTeCS on behalf of Linux Verification Center
    (linuxtesting.org) with SVACE.
    
    Fixes: 0f32a40fc91a ("[NETFILTER]: nf_conntrack_sip: create signalling expectations")
    Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Reviewed-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

netfilter: nf_tables: do not ignore genmask when looking up chain by id [+ + +]
Author: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Date:   Wed Jul 5 09:12:55 2023 -0300

    netfilter: nf_tables: do not ignore genmask when looking up chain by id
    
    commit 515ad530795c118f012539ed76d02bacfd426d89 upstream.
    
    When adding a rule to a chain referring to its ID, if that chain had been
    deleted on the same batch, the rule might end up referring to a deleted
    chain.
    
    This will lead to a WARNING like following:
    
    [   33.098431] ------------[ cut here ]------------
    [   33.098678] WARNING: CPU: 5 PID: 69 at net/netfilter/nf_tables_api.c:2037 nf_tables_chain_destroy+0x23d/0x260
    [   33.099217] Modules linked in:
    [   33.099388] CPU: 5 PID: 69 Comm: kworker/5:1 Not tainted 6.4.0+ #409
    [   33.099726] Workqueue: events nf_tables_trans_destroy_work
    [   33.100018] RIP: 0010:nf_tables_chain_destroy+0x23d/0x260
    [   33.100306] Code: 8b 7c 24 68 e8 64 9c ed fe 4c 89 e7 e8 5c 9c ed fe 48 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d 31 c0 89 c6 89 c7 c3 cc cc cc cc <0f> 0b 48 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d 31 c0 89 c6 89 c7
    [   33.101271] RSP: 0018:ffffc900004ffc48 EFLAGS: 00010202
    [   33.101546] RAX: 0000000000000001 RBX: ffff888006fc0a28 RCX: 0000000000000000
    [   33.101920] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
    [   33.102649] RBP: ffffc900004ffc78 R08: 0000000000000000 R09: 0000000000000000
    [   33.103018] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880135ef500
    [   33.103385] R13: 0000000000000000 R14: dead000000000122 R15: ffff888006fc0a10
    [   33.103762] FS:  0000000000000000(0000) GS:ffff888024c80000(0000) knlGS:0000000000000000
    [   33.104184] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [   33.104493] CR2: 00007fe863b56a50 CR3: 00000000124b0001 CR4: 0000000000770ee0
    [   33.104872] PKRU: 55555554
    [   33.104999] Call Trace:
    [   33.105113]  <TASK>
    [   33.105214]  ? show_regs+0x72/0x90
    [   33.105371]  ? __warn+0xa5/0x210
    [   33.105520]  ? nf_tables_chain_destroy+0x23d/0x260
    [   33.105732]  ? report_bug+0x1f2/0x200
    [   33.105902]  ? handle_bug+0x46/0x90
    [   33.106546]  ? exc_invalid_op+0x19/0x50
    [   33.106762]  ? asm_exc_invalid_op+0x1b/0x20
    [   33.106995]  ? nf_tables_chain_destroy+0x23d/0x260
    [   33.107249]  ? nf_tables_chain_destroy+0x30/0x260
    [   33.107506]  nf_tables_trans_destroy_work+0x669/0x680
    [   33.107782]  ? mark_held_locks+0x28/0xa0
    [   33.107996]  ? __pfx_nf_tables_trans_destroy_work+0x10/0x10
    [   33.108294]  ? _raw_spin_unlock_irq+0x28/0x70
    [   33.108538]  process_one_work+0x68c/0xb70
    [   33.108755]  ? lock_acquire+0x17f/0x420
    [   33.108977]  ? __pfx_process_one_work+0x10/0x10
    [   33.109218]  ? do_raw_spin_lock+0x128/0x1d0
    [   33.109435]  ? _raw_spin_lock_irq+0x71/0x80
    [   33.109634]  worker_thread+0x2bd/0x700
    [   33.109817]  ? __pfx_worker_thread+0x10/0x10
    [   33.110254]  kthread+0x18b/0x1d0
    [   33.110410]  ? __pfx_kthread+0x10/0x10
    [   33.110581]  ret_from_fork+0x29/0x50
    [   33.110757]  </TASK>
    [   33.110866] irq event stamp: 1651
    [   33.111017] hardirqs last  enabled at (1659): [<ffffffffa206a209>] __up_console_sem+0x79/0xa0
    [   33.111379] hardirqs last disabled at (1666): [<ffffffffa206a1ee>] __up_console_sem+0x5e/0xa0
    [   33.111740] softirqs last  enabled at (1616): [<ffffffffa1f5d40e>] __irq_exit_rcu+0x9e/0xe0
    [   33.112094] softirqs last disabled at (1367): [<ffffffffa1f5d40e>] __irq_exit_rcu+0x9e/0xe0
    [   33.112453] ---[ end trace 0000000000000000 ]---
    
    This is due to the nft_chain_lookup_byid ignoring the genmask. After this
    change, adding the new rule will fail as it will not find the chain.
    
    Fixes: 837830a4b439 ("netfilter: nf_tables: add NFTA_RULE_CHAIN_ID attribute")
    Cc: stable@vger.kernel.org
    Reported-by: Mingi Cho of Theori working with ZDI
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Reviewed-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

netfilter: nf_tables: prevent OOB access in nft_byteorder_eval [+ + +]
Author: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Date:   Wed Jul 5 18:05:35 2023 -0300

    netfilter: nf_tables: prevent OOB access in nft_byteorder_eval
    
    commit caf3ef7468f7534771b5c44cd8dbd6f7f87c2cbd upstream.
    
    When evaluating byteorder expressions with size 2, a union with 32-bit and
    16-bit members is used. Since the 16-bit members are aligned to 32-bit,
    the array accesses will be out-of-bounds.
    
    It may lead to a stack-out-of-bounds access like the one below:
    
    [   23.095215] ==================================================================
    [   23.095625] BUG: KASAN: stack-out-of-bounds in nft_byteorder_eval+0x13c/0x320
    [   23.096020] Read of size 2 at addr ffffc90000007948 by task ping/115
    [   23.096358]
    [   23.096456] CPU: 0 PID: 115 Comm: ping Not tainted 6.4.0+ #413
    [   23.096770] Call Trace:
    [   23.096910]  <IRQ>
    [   23.097030]  dump_stack_lvl+0x60/0xc0
    [   23.097218]  print_report+0xcf/0x630
    [   23.097388]  ? nft_byteorder_eval+0x13c/0x320
    [   23.097577]  ? kasan_addr_to_slab+0xd/0xc0
    [   23.097760]  ? nft_byteorder_eval+0x13c/0x320
    [   23.097949]  kasan_report+0xc9/0x110
    [   23.098106]  ? nft_byteorder_eval+0x13c/0x320
    [   23.098298]  __asan_load2+0x83/0xd0
    [   23.098453]  nft_byteorder_eval+0x13c/0x320
    [   23.098659]  nft_do_chain+0x1c8/0xc50
    [   23.098852]  ? __pfx_nft_do_chain+0x10/0x10
    [   23.099078]  ? __kasan_check_read+0x11/0x20
    [   23.099295]  ? __pfx___lock_acquire+0x10/0x10
    [   23.099535]  ? __pfx___lock_acquire+0x10/0x10
    [   23.099745]  ? __kasan_check_read+0x11/0x20
    [   23.099929]  nft_do_chain_ipv4+0xfe/0x140
    [   23.100105]  ? __pfx_nft_do_chain_ipv4+0x10/0x10
    [   23.100327]  ? lock_release+0x204/0x400
    [   23.100515]  ? nf_hook.constprop.0+0x340/0x550
    [   23.100779]  nf_hook_slow+0x6c/0x100
    [   23.100977]  ? __pfx_nft_do_chain_ipv4+0x10/0x10
    [   23.101223]  nf_hook.constprop.0+0x334/0x550
    [   23.101443]  ? __pfx_ip_local_deliver_finish+0x10/0x10
    [   23.101677]  ? __pfx_nf_hook.constprop.0+0x10/0x10
    [   23.101882]  ? __pfx_ip_rcv_finish+0x10/0x10
    [   23.102071]  ? __pfx_ip_local_deliver_finish+0x10/0x10
    [   23.102291]  ? rcu_read_lock_held+0x4b/0x70
    [   23.102481]  ip_local_deliver+0xbb/0x110
    [   23.102665]  ? __pfx_ip_rcv+0x10/0x10
    [   23.102839]  ip_rcv+0x199/0x2a0
    [   23.102980]  ? __pfx_ip_rcv+0x10/0x10
    [   23.103140]  __netif_receive_skb_one_core+0x13e/0x150
    [   23.103362]  ? __pfx___netif_receive_skb_one_core+0x10/0x10
    [   23.103647]  ? mark_held_locks+0x48/0xa0
    [   23.103819]  ? process_backlog+0x36c/0x380
    [   23.103999]  __netif_receive_skb+0x23/0xc0
    [   23.104179]  process_backlog+0x91/0x380
    [   23.104350]  __napi_poll.constprop.0+0x66/0x360
    [   23.104589]  ? net_rx_action+0x1cb/0x610
    [   23.104811]  net_rx_action+0x33e/0x610
    [   23.105024]  ? _raw_spin_unlock+0x23/0x50
    [   23.105257]  ? __pfx_net_rx_action+0x10/0x10
    [   23.105485]  ? mark_held_locks+0x48/0xa0
    [   23.105741]  __do_softirq+0xfa/0x5ab
    [   23.105956]  ? __dev_queue_xmit+0x765/0x1c00
    [   23.106193]  do_softirq.part.0+0x49/0xc0
    [   23.106423]  </IRQ>
    [   23.106547]  <TASK>
    [   23.106670]  __local_bh_enable_ip+0xf5/0x120
    [   23.106903]  __dev_queue_xmit+0x789/0x1c00
    [   23.107131]  ? __pfx___dev_queue_xmit+0x10/0x10
    [   23.107381]  ? find_held_lock+0x8e/0xb0
    [   23.107585]  ? lock_release+0x204/0x400
    [   23.107798]  ? neigh_resolve_output+0x185/0x350
    [   23.108049]  ? mark_held_locks+0x48/0xa0
    [   23.108265]  ? neigh_resolve_output+0x185/0x350
    [   23.108514]  neigh_resolve_output+0x246/0x350
    [   23.108753]  ? neigh_resolve_output+0x246/0x350
    [   23.109003]  ip_finish_output2+0x3c3/0x10b0
    [   23.109250]  ? __pfx_ip_finish_output2+0x10/0x10
    [   23.109510]  ? __pfx_nf_hook+0x10/0x10
    [   23.109732]  __ip_finish_output+0x217/0x390
    [   23.109978]  ip_finish_output+0x2f/0x130
    [   23.110207]  ip_output+0xc9/0x170
    [   23.110404]  ip_push_pending_frames+0x1a0/0x240
    [   23.110652]  raw_sendmsg+0x102e/0x19e0
    [   23.110871]  ? __pfx_raw_sendmsg+0x10/0x10
    [   23.111093]  ? lock_release+0x204/0x400
    [   23.111304]  ? __mod_lruvec_page_state+0x148/0x330
    [   23.111567]  ? find_held_lock+0x8e/0xb0
    [   23.111777]  ? find_held_lock+0x8e/0xb0
    [   23.111993]  ? __rcu_read_unlock+0x7c/0x2f0
    [   23.112225]  ? aa_sk_perm+0x18a/0x550
    [   23.112431]  ? filemap_map_pages+0x4f1/0x900
    [   23.112665]  ? __pfx_aa_sk_perm+0x10/0x10
    [   23.112880]  ? find_held_lock+0x8e/0xb0
    [   23.113098]  inet_sendmsg+0xa0/0xb0
    [   23.113297]  ? inet_sendmsg+0xa0/0xb0
    [   23.113500]  ? __pfx_inet_sendmsg+0x10/0x10
    [   23.113727]  sock_sendmsg+0xf4/0x100
    [   23.113924]  ? move_addr_to_kernel.part.0+0x4f/0xa0
    [   23.114190]  __sys_sendto+0x1d4/0x290
    [   23.114391]  ? __pfx___sys_sendto+0x10/0x10
    [   23.114621]  ? __pfx_mark_lock.part.0+0x10/0x10
    [   23.114869]  ? lock_release+0x204/0x400
    [   23.115076]  ? find_held_lock+0x8e/0xb0
    [   23.115287]  ? rcu_is_watching+0x23/0x60
    [   23.115503]  ? __rseq_handle_notify_resume+0x6e2/0x860
    [   23.115778]  ? __kasan_check_write+0x14/0x30
    [   23.116008]  ? blkcg_maybe_throttle_current+0x8d/0x770
    [   23.116285]  ? mark_held_locks+0x28/0xa0
    [   23.116503]  ? do_syscall_64+0x37/0x90
    [   23.116713]  __x64_sys_sendto+0x7f/0xb0
    [   23.116924]  do_syscall_64+0x59/0x90
    [   23.117123]  ? irqentry_exit_to_user_mode+0x25/0x30
    [   23.117387]  ? irqentry_exit+0x77/0xb0
    [   23.117593]  ? exc_page_fault+0x92/0x140
    [   23.117806]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
    [   23.118081] RIP: 0033:0x7f744aee2bba
    [   23.118282] Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 f3 0f 1e fa 41 89 ca 64 8b 04 25 18 00 00 00 85 c0 75 15 b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 7e c3 0f 1f 44 00 00 41 54 48 83 ec 30 44 89
    [   23.119237] RSP: 002b:00007ffd04a7c9f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
    [   23.119644] RAX: ffffffffffffffda RBX: 00007ffd04a7e0a0 RCX: 00007f744aee2bba
    [   23.120023] RDX: 0000000000000040 RSI: 000056488e9e6300 RDI: 0000000000000003
    [   23.120413] RBP: 000056488e9e6300 R08: 00007ffd04a80320 R09: 0000000000000010
    [   23.120809] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000040
    [   23.121219] R13: 00007ffd04a7dc38 R14: 00007ffd04a7ca00 R15: 00007ffd04a7e0a0
    [   23.121617]  </TASK>
    [   23.121749]
    [   23.121845] The buggy address belongs to the virtual mapping at
    [   23.121845]  [ffffc90000000000, ffffc90000009000) created by:
    [   23.121845]  irq_init_percpu_irqstack+0x1cf/0x270
    [   23.122707]
    [   23.122803] The buggy address belongs to the physical page:
    [   23.123104] page:0000000072ac19f0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x24a09
    [   23.123609] flags: 0xfffffc0001000(reserved|node=0|zone=1|lastcpupid=0x1fffff)
    [   23.123998] page_type: 0xffffffff()
    [   23.124194] raw: 000fffffc0001000 ffffea0000928248 ffffea0000928248 0000000000000000
    [   23.124610] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
    [   23.125023] page dumped because: kasan: bad access detected
    [   23.125326]
    [   23.125421] Memory state around the buggy address:
    [   23.125682]  ffffc90000007800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    [   23.126072]  ffffc90000007880: 00 00 00 00 00 f1 f1 f1 f1 f1 f1 00 00 f2 f2 00
    [   23.126455] >ffffc90000007900: 00 00 00 00 00 00 00 00 00 f2 f2 f2 f2 00 00 00
    [   23.126840]                                               ^
    [   23.127138]  ffffc90000007980: 00 00 00 00 00 00 00 00 00 00 00 00 00 f3 f3 f3
    [   23.127522]  ffffc90000007a00: f3 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
    [   23.127906] ==================================================================
    [   23.128324] Disabling lock debugging due to kernel taint
    
    Using simple s16 pointers for the 16-bit accesses fixes the problem. For
    the 32-bit accesses, src and dst can be used directly.
    
    Fixes: 96518518cc41 ("netfilter: add nftables")
    Cc: stable@vger.kernel.org
    Reported-by: Tanguy DUBROCA (@SidewayRE) from @Synacktiv working with ZDI
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Reviewed-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

netfilter: nf_tables: unbind non-anonymous set if rule construction fails [+ + +]
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Mon Jun 26 00:42:18 2023 +0200

    netfilter: nf_tables: unbind non-anonymous set if rule construction fails
    
    commit 3e70489721b6c870252c9082c496703677240f53 upstream.
    
    Otherwise a dangling reference to a rule object that is gone remains
    in the set binding list.
    
    Fixes: 26b5a5712eb8 ("netfilter: nf_tables: add NFT_TRANS_PREPARE_ERROR to deal with bound set/chain")
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
netlink: Add __sock_i_ino() for __netlink_diag_dump(). [+ + +]
Author: Kuniyuki Iwashima <kuniyu@amazon.com>
Date:   Mon Jun 26 09:43:13 2023 -0700

    netlink: Add __sock_i_ino() for __netlink_diag_dump().
    
    [ Upstream commit 25a9c8a4431c364f97f75558cb346d2ad3f53fbb ]
    
    syzbot reported a warning in __local_bh_enable_ip(). [0]
    
    Commit 8d61f926d420 ("netlink: fix potential deadlock in
    netlink_set_err()") converted read_lock(&nl_table_lock) to
    read_lock_irqsave() in __netlink_diag_dump() to prevent a deadlock.
    
    However, __netlink_diag_dump() calls sock_i_ino() that uses
    read_lock_bh() and read_unlock_bh().  If CONFIG_TRACE_IRQFLAGS=y,
    read_unlock_bh() finally enables IRQ even though it should stay
    disabled until the following read_unlock_irqrestore().
    
    Using read_lock() in sock_i_ino() would trigger a lockdep splat
    in another place that was fixed in commit f064af1e500a ("net: fix
    a lockdep splat"), so let's add __sock_i_ino() that would be safe
    to use under BH disabled.
    
    [0]:
    WARNING: CPU: 0 PID: 5012 at kernel/softirq.c:376 __local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376
    Modules linked in:
    CPU: 0 PID: 5012 Comm: syz-executor487 Not tainted 6.4.0-rc7-syzkaller-00202-g6f68fc395f49 #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
    RIP: 0010:__local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376
    Code: 45 bf 01 00 00 00 e8 91 5b 0a 00 e8 3c 15 3d 00 fb 65 8b 05 ec e9 b5 7e 85 c0 74 58 5b 5d c3 65 8b 05 b2 b6 b4 7e 85 c0 75 a2 <0f> 0b eb 9e e8 89 15 3d 00 eb 9f 48 89 ef e8 6f 49 18 00 eb a8 0f
    RSP: 0018:ffffc90003a1f3d0 EFLAGS: 00010046
    RAX: 0000000000000000 RBX: 0000000000000201 RCX: 1ffffffff1cf5996
    RDX: 0000000000000000 RSI: 0000000000000201 RDI: ffffffff8805c6f3
    RBP: ffffffff8805c6f3 R08: 0000000000000001 R09: ffff8880152b03a3
    R10: ffffed1002a56074 R11: 0000000000000005 R12: 00000000000073e4
    R13: dffffc0000000000 R14: 0000000000000002 R15: 0000000000000000
    FS:  0000555556726300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 000000000045ad50 CR3: 000000007c646000 CR4: 00000000003506f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     <TASK>
     sock_i_ino+0x83/0xa0 net/core/sock.c:2559
     __netlink_diag_dump+0x45c/0x790 net/netlink/diag.c:171
     netlink_diag_dump+0xd6/0x230 net/netlink/diag.c:207
     netlink_dump+0x570/0xc50 net/netlink/af_netlink.c:2269
     __netlink_dump_start+0x64b/0x910 net/netlink/af_netlink.c:2374
     netlink_dump_start include/linux/netlink.h:329 [inline]
     netlink_diag_handler_dump+0x1ae/0x250 net/netlink/diag.c:238
     __sock_diag_cmd net/core/sock_diag.c:238 [inline]
     sock_diag_rcv_msg+0x31e/0x440 net/core/sock_diag.c:269
     netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2547
     sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280
     netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
     netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1365
     netlink_sendmsg+0x925/0xe30 net/netlink/af_netlink.c:1914
     sock_sendmsg_nosec net/socket.c:724 [inline]
     sock_sendmsg+0xde/0x190 net/socket.c:747
     ____sys_sendmsg+0x71c/0x900 net/socket.c:2503
     ___sys_sendmsg+0x110/0x1b0 net/socket.c:2557
     __sys_sendmsg+0xf7/0x1c0 net/socket.c:2586
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x63/0xcd
    RIP: 0033:0x7f5303aaabb9
    Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
    RSP: 002b:00007ffc7506e548 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5303aaabb9
    RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000003
    RBP: 00007f5303a6ed60 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5303a6edf0
    R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
     </TASK>
    
    Fixes: 8d61f926d420 ("netlink: fix potential deadlock in netlink_set_err()")
    Reported-by: syzbot+5da61cf6a9bc1902d422@syzkaller.appspotmail.com
    Link: https://syzkaller.appspot.com/bug?extid=5da61cf6a9bc1902d422
    Suggested-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Link: https://lore.kernel.org/r/20230626164313.52528-1-kuniyu@amazon.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

netlink: do not hard code device address lenth in fdb dumps [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Jun 21 17:47:20 2023 +0000

    netlink: do not hard code device address lenth in fdb dumps
    
    [ Upstream commit aa5406950726e336c5c9585b09799a734b6e77bf ]
    
    syzbot reports that some netdev devices do not have a six bytes
    address [1]
    
    Replace ETH_ALEN by dev->addr_len.
    
    [1] (Case of a device where dev->addr_len = 4)
    
    BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline]
    BUG: KMSAN: kernel-infoleak in copyout+0xb8/0x100 lib/iov_iter.c:169
    instrument_copy_to_user include/linux/instrumented.h:114 [inline]
    copyout+0xb8/0x100 lib/iov_iter.c:169
    _copy_to_iter+0x6d8/0x1d00 lib/iov_iter.c:536
    copy_to_iter include/linux/uio.h:206 [inline]
    simple_copy_to_iter+0x68/0xa0 net/core/datagram.c:513
    __skb_datagram_iter+0x123/0xdc0 net/core/datagram.c:419
    skb_copy_datagram_iter+0x5c/0x200 net/core/datagram.c:527
    skb_copy_datagram_msg include/linux/skbuff.h:3960 [inline]
    netlink_recvmsg+0x4ae/0x15a0 net/netlink/af_netlink.c:1970
    sock_recvmsg_nosec net/socket.c:1019 [inline]
    sock_recvmsg net/socket.c:1040 [inline]
    ____sys_recvmsg+0x283/0x7f0 net/socket.c:2722
    ___sys_recvmsg+0x223/0x840 net/socket.c:2764
    do_recvmmsg+0x4f9/0xfd0 net/socket.c:2858
    __sys_recvmmsg net/socket.c:2937 [inline]
    __do_sys_recvmmsg net/socket.c:2960 [inline]
    __se_sys_recvmmsg net/socket.c:2953 [inline]
    __x64_sys_recvmmsg+0x397/0x490 net/socket.c:2953
    do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
    entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    Uninit was stored to memory at:
    __nla_put lib/nlattr.c:1009 [inline]
    nla_put+0x1c6/0x230 lib/nlattr.c:1067
    nlmsg_populate_fdb_fill+0x2b8/0x600 net/core/rtnetlink.c:4071
    nlmsg_populate_fdb net/core/rtnetlink.c:4418 [inline]
    ndo_dflt_fdb_dump+0x616/0x840 net/core/rtnetlink.c:4456
    rtnl_fdb_dump+0x14ff/0x1fc0 net/core/rtnetlink.c:4629
    netlink_dump+0x9d1/0x1310 net/netlink/af_netlink.c:2268
    netlink_recvmsg+0xc5c/0x15a0 net/netlink/af_netlink.c:1995
    sock_recvmsg_nosec+0x7a/0x120 net/socket.c:1019
    ____sys_recvmsg+0x664/0x7f0 net/socket.c:2720
    ___sys_recvmsg+0x223/0x840 net/socket.c:2764
    do_recvmmsg+0x4f9/0xfd0 net/socket.c:2858
    __sys_recvmmsg net/socket.c:2937 [inline]
    __do_sys_recvmmsg net/socket.c:2960 [inline]
    __se_sys_recvmmsg net/socket.c:2953 [inline]
    __x64_sys_recvmmsg+0x397/0x490 net/socket.c:2953
    do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
    entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    Uninit was created at:
    slab_post_alloc_hook+0x12d/0xb60 mm/slab.h:716
    slab_alloc_node mm/slub.c:3451 [inline]
    __kmem_cache_alloc_node+0x4ff/0x8b0 mm/slub.c:3490
    kmalloc_trace+0x51/0x200 mm/slab_common.c:1057
    kmalloc include/linux/slab.h:559 [inline]
    __hw_addr_create net/core/dev_addr_lists.c:60 [inline]
    __hw_addr_add_ex+0x2e5/0x9e0 net/core/dev_addr_lists.c:118
    __dev_mc_add net/core/dev_addr_lists.c:867 [inline]
    dev_mc_add+0x9a/0x130 net/core/dev_addr_lists.c:885
    igmp6_group_added+0x267/0xbc0 net/ipv6/mcast.c:680
    ipv6_mc_up+0x296/0x3b0 net/ipv6/mcast.c:2754
    ipv6_mc_remap+0x1e/0x30 net/ipv6/mcast.c:2708
    addrconf_type_change net/ipv6/addrconf.c:3731 [inline]
    addrconf_notify+0x4d3/0x1d90 net/ipv6/addrconf.c:3699
    notifier_call_chain kernel/notifier.c:93 [inline]
    raw_notifier_call_chain+0xe4/0x430 kernel/notifier.c:461
    call_netdevice_notifiers_info net/core/dev.c:1935 [inline]
    call_netdevice_notifiers_extack net/core/dev.c:1973 [inline]
    call_netdevice_notifiers+0x1ee/0x2d0 net/core/dev.c:1987
    bond_enslave+0xccd/0x53f0 drivers/net/bonding/bond_main.c:1906
    do_set_master net/core/rtnetlink.c:2626 [inline]
    rtnl_newlink_create net/core/rtnetlink.c:3460 [inline]
    __rtnl_newlink net/core/rtnetlink.c:3660 [inline]
    rtnl_newlink+0x378c/0x40e0 net/core/rtnetlink.c:3673
    rtnetlink_rcv_msg+0x16a6/0x1840 net/core/rtnetlink.c:6395
    netlink_rcv_skb+0x371/0x650 net/netlink/af_netlink.c:2546
    rtnetlink_rcv+0x34/0x40 net/core/rtnetlink.c:6413
    netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
    netlink_unicast+0xf28/0x1230 net/netlink/af_netlink.c:1365
    netlink_sendmsg+0x122f/0x13d0 net/netlink/af_netlink.c:1913
    sock_sendmsg_nosec net/socket.c:724 [inline]
    sock_sendmsg net/socket.c:747 [inline]
    ____sys_sendmsg+0x999/0xd50 net/socket.c:2503
    ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2557
    __sys_sendmsg net/socket.c:2586 [inline]
    __do_sys_sendmsg net/socket.c:2595 [inline]
    __se_sys_sendmsg net/socket.c:2593 [inline]
    __x64_sys_sendmsg+0x304/0x490 net/socket.c:2593
    do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
    entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    Bytes 2856-2857 of 3500 are uninitialized
    Memory access of size 3500 starts at ffff888018d99104
    Data copied to user address 0000000020000480
    
    Fixes: d83b06036048 ("net: add fdb generic dump routine")
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Link: https://lore.kernel.org/r/20230621174720.1845040-1-edumazet@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

netlink: fix potential deadlock in netlink_set_err() [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Jun 21 15:43:37 2023 +0000

    netlink: fix potential deadlock in netlink_set_err()
    
    [ Upstream commit 8d61f926d42045961e6b65191c09e3678d86a9cf ]
    
    syzbot reported a possible deadlock in netlink_set_err() [1]
    
    A similar issue was fixed in commit 1d482e666b8e ("netlink: disable IRQs
    for netlink_lock_table()") in netlink_lock_table()
    
    This patch adds IRQ safety to netlink_set_err() and __netlink_diag_dump()
    which were not covered by cited commit.
    
    [1]
    
    WARNING: possible irq lock inversion dependency detected
    6.4.0-rc6-syzkaller-00240-g4e9f0ec38852 #0 Not tainted
    
    syz-executor.2/23011 just changed the state of lock:
    ffffffff8e1a7a58 (nl_table_lock){.+.?}-{2:2}, at: netlink_set_err+0x2e/0x3a0 net/netlink/af_netlink.c:1612
    but this lock was taken by another, SOFTIRQ-safe lock in the past:
     (&local->queue_stop_reason_lock){..-.}-{2:2}
    
    and interrupts could create inverse lock ordering between them.
    
    other info that might help us debug this:
     Possible interrupt unsafe locking scenario:
    
           CPU0                    CPU1
           ----                    ----
      lock(nl_table_lock);
                                   local_irq_disable();
                                   lock(&local->queue_stop_reason_lock);
                                   lock(nl_table_lock);
      <Interrupt>
        lock(&local->queue_stop_reason_lock);
    
     *** DEADLOCK ***
    
    Fixes: 1d482e666b8e ("netlink: disable IRQs for netlink_lock_table()")
    Reported-by: syzbot+a7d200a347f912723e5c@syzkaller.appspotmail.com
    Link: https://syzkaller.appspot.com/bug?extid=a7d200a347f912723e5c
    Link: https://lore.kernel.org/netdev/000000000000e38d1605fea5747e@google.com/T/#u
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Johannes Berg <johannes.berg@intel.com>
    Link: https://lore.kernel.org/r/20230621154337.1668594-1-edumazet@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nfc: llcp: fix possible use of uninitialized variable in nfc_llcp_send_connect() [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Sat May 13 13:52:04 2023 +0200

    nfc: llcp: fix possible use of uninitialized variable in nfc_llcp_send_connect()
    
    [ Upstream commit 0d9b41daa5907756a31772d8af8ac5ff25cf17c1 ]
    
    If sock->service_name is NULL, the local variable
    service_name_tlv_length will not be assigned by nfc_llcp_build_tlv(),
    later leading to using value frmo the stack.  Smatch warning:
    
      net/nfc/llcp_commands.c:442 nfc_llcp_send_connect() error: uninitialized symbol 'service_name_tlv_length'.
    
    Fixes: de9e5aeb4f40 ("NFC: llcp: Fix usage of llcp_add_tlv()")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
NFSD: add encoding of op_recall flag for write delegation [+ + +]
Author: Dai Ngo <dai.ngo@oracle.com>
Date:   Tue Jun 6 16:41:02 2023 -0700

    NFSD: add encoding of op_recall flag for write delegation
    
    commit 58f5d894006d82ed7335e1c37182fbc5f08c2f51 upstream.
    
    Modified nfsd4_encode_open to encode the op_recall flag properly
    for OPEN result with write delegation granted.
    
    Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
NFSv4.1: freeze the session table upon receiving NFS4ERR_BADSESSION [+ + +]
Author: Olga Kornievskaia <kolga@netapp.com>
Date:   Sun Jun 18 17:32:25 2023 -0400

    NFSv4.1: freeze the session table upon receiving NFS4ERR_BADSESSION
    
    [ Upstream commit c907e72f58ed979a24a9fdcadfbc447c51d5e509 ]
    
    When the client received NFS4ERR_BADSESSION, it schedules recovery
    and start the state manager thread which in turn freezes the
    session table and does not allow for any new requests to use the
    no-longer valid session. However, it is possible that before
    the state manager thread runs, a new operation would use the
    released slot that received BADSESSION and was therefore not
    updated its sequence number. Such re-use of the slot can lead
    the application errors.
    
    Fixes: 5c441544f045 ("NFSv4.x: Handle bad/dead sessions correctly in nfs41_sequence_process()")
    Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
NFSv4.2: fix wrong shrinker_id [+ + +]
Author: Qi Zheng <zhengqi.arch@bytedance.com>
Date:   Thu Jun 15 11:19:46 2023 +0000

    NFSv4.2: fix wrong shrinker_id
    
    [ Upstream commit 7f7ab336898f281e58540ef781a8fb375acc32a9 ]
    
    Currently, the list_lru::shrinker_id corresponding to the nfs4_xattr
    shrinkers is wrong:
    
    >>> prog["nfs4_xattr_cache_lru"].shrinker_id
    (int)0
    >>> prog["nfs4_xattr_entry_lru"].shrinker_id
    (int)0
    >>> prog["nfs4_xattr_large_entry_lru"].shrinker_id
    (int)0
    >>> prog["nfs4_xattr_cache_shrinker"].id
    (int)18
    >>> prog["nfs4_xattr_entry_shrinker"].id
    (int)19
    >>> prog["nfs4_xattr_large_entry_shrinker"].id
    (int)20
    
    This is not what we expect, which will cause these shrinkers
    not to be found in shrink_slab_memcg().
    
    We should assign shrinker::id before calling list_lru_init_memcg(),
    so that the corresponding list_lru::shrinker_id will be assigned
    the correct value like below:
    
    >>> prog["nfs4_xattr_cache_lru"].shrinker_id
    (int)16
    >>> prog["nfs4_xattr_entry_lru"].shrinker_id
    (int)17
    >>> prog["nfs4_xattr_large_entry_lru"].shrinker_id
    (int)18
    >>> prog["nfs4_xattr_cache_shrinker"].id
    (int)16
    >>> prog["nfs4_xattr_entry_shrinker"].id
    (int)17
    >>> prog["nfs4_xattr_large_entry_shrinker"].id
    (int)18
    
    So just do it.
    
    Fixes: 95ad37f90c33 ("NFSv4.2: add client side xattr caching.")
    Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ntfs: Fix panic about slab-out-of-bounds caused by ntfs_listxattr() [+ + +]
Author: Zeng Heng <zengheng4@huawei.com>
Date:   Thu Dec 8 00:28:07 2022 +0800

    ntfs: Fix panic about slab-out-of-bounds caused by ntfs_listxattr()
    
    [ Upstream commit 3c675ddffb17a8b1e32efad5c983254af18b12c2 ]
    
    Here is a BUG report from syzbot:
    
    BUG: KASAN: slab-out-of-bounds in ntfs_list_ea fs/ntfs3/xattr.c:191 [inline]
    BUG: KASAN: slab-out-of-bounds in ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710
    Read of size 1 at addr ffff888021acaf3d by task syz-executor128/3632
    
    Call Trace:
     ntfs_list_ea fs/ntfs3/xattr.c:191 [inline]
     ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710
     vfs_listxattr fs/xattr.c:457 [inline]
     listxattr+0x293/0x2d0 fs/xattr.c:804
    
    Fix the logic of ea_all iteration. When the ea->name_len is 0,
    return immediately, or Add2Ptr() would visit invalid memory
    in the next loop.
    
    Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
    Reported-by: syzbot+9fcea5ef6dc4dc72d334@syzkaller.appspotmail.com
    Signed-off-by: Zeng Heng <zengheng4@huawei.com>
    [almaz.alexandrovich@paragon-software.com: lines of the patch have changed]
    Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nvme-auth: don't ignore key generation failures when initializing ctrl keys [+ + +]
Author: Sagi Grimberg <sagi@grimberg.me>
Date:   Sun Nov 13 13:24:10 2022 +0200

    nvme-auth: don't ignore key generation failures when initializing ctrl keys
    
    [ Upstream commit 193a8c7e5f1a8481841636cec9c185543ec5c759 ]
    
    nvme_auth_generate_key can fail, don't ignore it upon initialization.
    
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
    Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Stable-dep-of: 7ed5cf8e6d9b ("nvme-core: fix dev_pm_qos memleak")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-auth: no need to reset chap contexts on re-authentication [+ + +]
Author: Sagi Grimberg <sagi@grimberg.me>
Date:   Sun Nov 13 13:24:17 2022 +0200

    nvme-auth: no need to reset chap contexts on re-authentication
    
    [ Upstream commit e8a420efb637f52c586596283d6fd96f2a7ecb5c ]
    
    Now that the chap context is reset upon completion, this is no longer
    needed. Also remove nvme_auth_reset as no callers are left.
    
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
    Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Stable-dep-of: a836ca33c5b0 ("nvme-core: fix memory leak in dhchap_secret_store")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-auth: remove symbol export from nvme_auth_reset [+ + +]
Author: Sagi Grimberg <sagi@grimberg.me>
Date:   Sun Nov 13 13:24:07 2022 +0200

    nvme-auth: remove symbol export from nvme_auth_reset
    
    [ Upstream commit 100b555bc204fc754108351676297805f5affa49 ]
    
    Only the nvme module calls it.
    
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
    Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Stable-dep-of: a836ca33c5b0 ("nvme-core: fix memory leak in dhchap_secret_store")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-auth: rename __nvme_auth_[reset|free] to nvme_auth[reset|free]_dhchap [+ + +]
Author: Sagi Grimberg <sagi@grimberg.me>
Date:   Sun Nov 13 13:24:05 2022 +0200

    nvme-auth: rename __nvme_auth_[reset|free] to nvme_auth[reset|free]_dhchap
    
    [ Upstream commit 0a7ce375f83f4ade7c2a835444093b6870fb8257 ]
    
    nvme_auth_[reset|free] operate on the controller while
    __nvme_auth_[reset|free] operate on a chap struct (which maps to a queue
    context). Rename it for clarity.
    
    Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
    Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Stable-dep-of: a836ca33c5b0 ("nvme-core: fix memory leak in dhchap_secret_store")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-auth: rename authentication work elements [+ + +]
Author: Sagi Grimberg <sagi@grimberg.me>
Date:   Sun Nov 13 13:24:06 2022 +0200

    nvme-auth: rename authentication work elements
    
    [ Upstream commit 0c999e69c40a87285f910c400b550fad866e99d0 ]
    
    Use nvme_ctrl_auth_work and nvme_queue_auth_work for better
    readability.
    
    Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
    Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Stable-dep-of: a836ca33c5b0 ("nvme-core: fix memory leak in dhchap_secret_store")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nvme-core: add missing fault-injection cleanup [+ + +]
Author: Chaitanya Kulkarni <kch@nvidia.com>
Date:   Fri Apr 28 00:31:14 2023 -0700

    nvme-core: add missing fault-injection cleanup
    
    [ Upstream commit 3a12a0b868a512fcada564699d00f5e652c0998c ]
    
    Add missing fault-injection cleanup in nvme_init_ctrl() in the error
    unwind path that also fixes following message for blktests:-
    
    linux-block (for-next) # grep debugfs debugfs-err.log
    [  147.853464] debugfs: Directory 'nvme1' with parent '/' already present!
    [  147.853973] nvme1: failed to create debugfs attr
    [  148.802490] debugfs: Directory 'nvme1' with parent '/' already present!
    [  148.803244] nvme1: failed to create debugfs attr
    [  148.877304] debugfs: Directory 'nvme1' with parent '/' already present!
    [  148.877775] nvme1: failed to create debugfs attr
    [  149.816652] debugfs: Directory 'nvme1' with parent '/' already present!
    [  149.818011] nvme1: failed to create debugfs attr
    
    Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
    Tested-by: Yi Zhang <yi.zhang@redhat.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Stable-dep-of: 7ed5cf8e6d9b ("nvme-core: fix dev_pm_qos memleak")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-core: fix dev_pm_qos memleak [+ + +]
Author: Chaitanya Kulkarni <kch@nvidia.com>
Date:   Fri Apr 28 00:31:15 2023 -0700

    nvme-core: fix dev_pm_qos memleak
    
    [ Upstream commit 7ed5cf8e6d9bfb6a78d0471317edff14f0f2b4dd ]
    
    Call dev_pm_qos_hide_latency_tolerance() in the error unwind patch to
    avoid following kmemleak:-
    
    blktests (master) # kmemleak-clear; ./check nvme/044;
    blktests (master) # kmemleak-scan ; kmemleak-show
    nvme/044 (Test bi-directional authentication)                [passed]
        runtime  2.111s  ...  2.124s
    unreferenced object 0xffff888110c46240 (size 96):
      comm "nvme", pid 33461, jiffies 4345365353 (age 75.586s)
      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:
        [<0000000069ac2cec>] kmalloc_trace+0x25/0x90
        [<000000006acc66d5>] dev_pm_qos_update_user_latency_tolerance+0x6f/0x100
        [<00000000cc376ea7>] nvme_init_ctrl+0x38e/0x410 [nvme_core]
        [<000000007df61b4b>] 0xffffffffc05e88b3
        [<00000000d152b985>] 0xffffffffc05744cb
        [<00000000f04a4041>] vfs_write+0xc5/0x3c0
        [<00000000f9491baf>] ksys_write+0x5f/0xe0
        [<000000001c46513d>] do_syscall_64+0x3b/0x90
        [<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    Link: https://lore.kernel.org/linux-nvme/CAHj4cs-nDaKzMx2txO4dbE+Mz9ePwLtU0e3egz+StmzOUgWUrA@mail.gmail.com/
    Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
    Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
    Tested-by: Yi Zhang <yi.zhang@redhat.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-core: fix memory leak in dhchap_ctrl_secret [+ + +]
Author: Chaitanya Kulkarni <kch@nvidia.com>
Date:   Fri Apr 28 00:31:13 2023 -0700

    nvme-core: fix memory leak in dhchap_ctrl_secret
    
    [ Upstream commit 99c2dcc8ffc24e210a3aa05c204d92f3ef460b05 ]
    
    Free dhchap_secret in nvme_ctrl_dhchap_ctrl_secret_store() before we
    return when nvme_auth_generate_key() returns error.
    
    Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
    Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvme-core: fix memory leak in dhchap_secret_store [+ + +]
Author: Chaitanya Kulkarni <kch@nvidia.com>
Date:   Fri Apr 28 00:31:12 2023 -0700

    nvme-core: fix memory leak in dhchap_secret_store
    
    [ Upstream commit a836ca33c5b07d34dd5347af9f64d25651d12674 ]
    
    Free dhchap_secret in nvme_ctrl_dhchap_secret_store() before we return
    fix following kmemleack:-
    
    unreferenced object 0xffff8886376ea800 (size 64):
      comm "check", pid 22048, jiffies 4344316705 (age 92.199s)
      hex dump (first 32 bytes):
        44 48 48 43 2d 31 3a 30 30 3a 6e 78 72 35 4b 67  DHHC-1:00:nxr5Kg
        75 58 34 75 6f 41 78 73 4a 61 34 63 2f 68 75 4c  uX4uoAxsJa4c/huL
      backtrace:
        [<0000000030ce5d4b>] __kmalloc+0x4b/0x130
        [<000000009be1cdc1>] nvme_ctrl_dhchap_secret_store+0x8f/0x160 [nvme_core]
        [<00000000ac06c96a>] kernfs_fop_write_iter+0x12b/0x1c0
        [<00000000437e7ced>] vfs_write+0x2ba/0x3c0
        [<00000000f9491baf>] ksys_write+0x5f/0xe0
        [<000000001c46513d>] do_syscall_64+0x3b/0x90
        [<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
    unreferenced object 0xffff8886376eaf00 (size 64):
      comm "check", pid 22048, jiffies 4344316736 (age 92.168s)
      hex dump (first 32 bytes):
        44 48 48 43 2d 31 3a 30 30 3a 6e 78 72 35 4b 67  DHHC-1:00:nxr5Kg
        75 58 34 75 6f 41 78 73 4a 61 34 63 2f 68 75 4c  uX4uoAxsJa4c/huL
      backtrace:
        [<0000000030ce5d4b>] __kmalloc+0x4b/0x130
        [<000000009be1cdc1>] nvme_ctrl_dhchap_secret_store+0x8f/0x160 [nvme_core]
        [<00000000ac06c96a>] kernfs_fop_write_iter+0x12b/0x1c0
        [<00000000437e7ced>] vfs_write+0x2ba/0x3c0
        [<00000000f9491baf>] ksys_write+0x5f/0xe0
        [<000000001c46513d>] do_syscall_64+0x3b/0x90
        [<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
    Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
    Tested-by: Yi Zhang <yi.zhang@redhat.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Keith Busch <kbusch@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nvmem: rmem: Use NVMEM_DEVID_AUTO [+ + +]
Author: Phil Elwell <phil@raspberrypi.com>
Date:   Sun Jun 11 15:03:09 2023 +0100

    nvmem: rmem: Use NVMEM_DEVID_AUTO
    
    [ Upstream commit 09dd7b993eddb3b48634fd5ddf27aa799785a9ee ]
    
    It is reasonable to declare multiple nvmem blocks. Unless a unique 'id'
    is passed in for each block there may be name clashes.
    
    Avoid this by using the magic token NVMEM_DEVID_AUTO.
    
    Fixes: 5a3fa75a4d9c ("nvmem: Add driver to expose reserved memory as nvmem")
    Signed-off-by: Phil Elwell <phil@raspberrypi.com>
    Signed-off-by: Ivan T. Ivanov <iivanov@suse.de>
    Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Message-ID: <20230611140330.154222-6-srinivas.kandagatla@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nvmem: sunplus-ocotp: release otp->clk before return [+ + +]
Author: Yi Yingao <m202271736@hust.edu.cn>
Date:   Tue May 9 16:52:36 2023 +0800

    nvmem: sunplus-ocotp: release otp->clk before return
    
    [ Upstream commit 095bb8ba45f28ed15296eb5b7662e03e57d5e34e ]
    
    Smatch reports:
    drivers/nvmem/sunplus-ocotp.c:205 sp_ocotp_probe()
    warn: 'otp->clk' from clk_prepare() not released on lines: 196.
    
    In the function sp_ocotp_probe(struct platform_device *pdev), otp->clk may
    not be released before return.
    
    To fix this issue, using function clk_unprepare() to release otp->clk.
    
    Fixes: 8747ec2e9762 ("nvmem: Add driver for OCOTP in Sunplus SP7021")
    Signed-off-by: Yi Yingao <m202271736@hust.edu.cn>
    Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
    Message-ID: <20230509085237.5917-1-m202271736@hust.edu.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ocfs2: Fix use of slab data with sendpage [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Fri Jun 23 23:55:10 2023 +0100

    ocfs2: Fix use of slab data with sendpage
    
    [ Upstream commit 86d7bd6e66e9925f0f04a7bcf3c92c05fdfefb5a ]
    
    ocfs2 uses kzalloc() to allocate buffers for o2net_hand, o2net_keep_req and
    o2net_keep_resp and then passes these to sendpage.  This isn't really
    allowed as the lifetime of slab objects is not controlled by page ref -
    though in this case it will probably work.  sendmsg() with MSG_SPLICE_PAGES
    will, however, print a warning and give an error.
    
    Fix it to use folio_alloc() instead to allocate a buffer for the handshake
    message, keepalive request and reply messages.
    
    Fixes: 98211489d414 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem")
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Mark Fasheh <mark@fasheh.com>
    cc: Kurt Hackel <kurt.hackel@oracle.com>
    cc: Joel Becker <jlbec@evilplan.org>
    cc: Joseph Qi <joseph.qi@linux.alibaba.com>
    cc: ocfs2-devel@oss.oracle.com
    Link: https://lore.kernel.org/r/20230623225513.2732256-14-dhowells@redhat.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
octeontx-af: fix hardware timestamp configuration [+ + +]
Author: Hariprasad Kelam <hkelam@marvell.com>
Date:   Tue Jul 4 09:56:53 2023 +0530

    octeontx-af: fix hardware timestamp configuration
    
    [ Upstream commit 14bb236b29922c4f57d8c05bfdbcb82677f917c9 ]
    
    MAC block on CN10K (RPM) supports hardware timestamp configuration. The
    previous patch which added timestamp configuration support has a bug.
    Though the netdev driver requests to disable timestamp configuration,
    the driver is always enabling it.
    
    This patch fixes the same.
    
    Fixes: d1489208681d ("octeontx2-af: cn10k: RPM hardware timestamp configuration")
    Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
    Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
octeontx2-af: Add validation before accessing cgx and lmac [+ + +]
Author: Hariprasad Kelam <hkelam@marvell.com>
Date:   Fri Jun 30 11:58:44 2023 +0530

    octeontx2-af: Add validation before accessing cgx and lmac
    
    [ Upstream commit 79ebb53772c95d3a6ae51b3c65f9985fdd430df6 ]
    
    with the addition of new MAC blocks like CN10K RPM and CN10KB
    RPM_USX, LMACs are noncontiguous and CGX blocks are also
    noncontiguous. But during RVU driver initialization, the driver
    is assuming they are contiguous and trying to access
    cgx or lmac with their id which is resulting in kernel panic.
    
    This patch fixes the issue by adding proper checks.
    
    [   23.219150] pc : cgx_lmac_read+0x38/0x70
    [   23.219154] lr : rvu_program_channels+0x3f0/0x498
    [   23.223852] sp : ffff000100d6fc80
    [   23.227158] x29: ffff000100d6fc80 x28: ffff00010009f880 x27:
    000000000000005a
    [   23.234288] x26: ffff000102586768 x25: 0000000000002500 x24:
    fffffffffff0f000
    
    Fixes: 91c6945ea1f9 ("octeontx2-af: cn10k: Add RPM MAC support")
    Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
    Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

octeontx2-af: Fix mapping for NIX block from CGX connection [+ + +]
Author: Hariprasad Kelam <hkelam@marvell.com>
Date:   Fri Jun 30 11:58:43 2023 +0530

    octeontx2-af: Fix mapping for NIX block from CGX connection
    
    [ Upstream commit 2e7bc57b976bb016c6569a54d95c1b8d88f9450a ]
    
    Firmware configures NIX block mapping for all MAC blocks.
    The current implementation reads the configuration and
    creates the mapping between RVU PF  and NIX blocks. But
    this configuration is only valid for silicons that support
    multiple blocks. For all other silicons, all MAC blocks
    map to NIX0.
    
    This patch corrects the mapping by adding a check for the same.
    
    Fixes: c5a73b632b90 ("octeontx2-af: Map NIX block from CGX connection")
    Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
    Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ovl: update of dentry revalidate flags after copy up [+ + +]
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Mon Apr 3 11:29:59 2023 +0300

    ovl: update of dentry revalidate flags after copy up
    
    [ Upstream commit b07d5cc93e1b28df47a72c519d09d0a836043613 ]
    
    After copy up, we may need to update d_flags if upper dentry is on a
    remote fs and lower dentries are not.
    
    Add helpers to allow incremental update of the revalidate flags.
    
    Fixes: bccece1ead36 ("ovl: allow remote upper")
    Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
PCI/ASPM: Disable ASPM on MFD function removal to avoid use-after-free [+ + +]
Author: Ding Hui <dinghui@sangfor.com.cn>
Date:   Sun May 7 11:40:57 2023 +0800

    PCI/ASPM: Disable ASPM on MFD function removal to avoid use-after-free
    
    [ Upstream commit 456d8aa37d0f56fc9e985e812496e861dcd6f2f2 ]
    
    Struct pcie_link_state->downstream is a pointer to the pci_dev of function
    0.  Previously we retained that pointer when removing function 0, and
    subsequent ASPM policy changes dereferenced it, resulting in a
    use-after-free warning from KASAN, e.g.:
    
      # echo 1 > /sys/bus/pci/devices/0000:03:00.0/remove
      # echo powersave > /sys/module/pcie_aspm/parameters/policy
    
      BUG: KASAN: slab-use-after-free in pcie_config_aspm_link+0x42d/0x500
      Call Trace:
       kasan_report+0xae/0xe0
       pcie_config_aspm_link+0x42d/0x500
       pcie_aspm_set_policy+0x8e/0x1a0
       param_attr_store+0x162/0x2c0
       module_attr_store+0x3e/0x80
    
    PCIe spec r6.0, sec 7.5.3.7, recommends that software program the same ASPM
    Control value in all functions of multi-function devices.
    
    Disable ASPM and free the pcie_link_state when any child function is
    removed so we can discard the dangling pcie_link_state->downstream pointer
    and maintain the same ASPM Control configuration for all functions.
    
    [bhelgaas: commit log and comment]
    Debugged-by: Zongquan Qin <qinzongquan@sangfor.com.cn>
    Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
    Fixes: b5a0a9b59c81 ("PCI/ASPM: Read and set up L1 substate capabilities")
    Link: https://lore.kernel.org/r/20230507034057.20970-1-dinghui@sangfor.com.cn
    Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
PCI: Add pci_clear_master() stub for non-CONFIG_PCI [+ + +]
Author: Sui Jingfeng <suijingfeng@loongson.cn>
Date:   Wed May 31 18:27:44 2023 +0800

    PCI: Add pci_clear_master() stub for non-CONFIG_PCI
    
    [ Upstream commit 2aa5ac633259843f656eb6ecff4cf01e8e810c5e ]
    
    Add a pci_clear_master() stub when CONFIG_PCI is not set so drivers that
    support both PCI and platform devices don't need #ifdefs or extra Kconfig
    symbols for the PCI parts.
    
    [bhelgaas: commit log]
    Fixes: 6a479079c072 ("PCI: Add pci_clear_master() as opposite of pci_set_master()")
    Link: https://lore.kernel.org/r/20230531102744.2354313-1-suijingfeng@loongson.cn
    Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: cadence: Fix Gen2 Link Retraining process [+ + +]
Author: Siddharth Vadapalli <s-vadapalli@ti.com>
Date:   Wed Mar 15 12:38:00 2023 +0530

    PCI: cadence: Fix Gen2 Link Retraining process
    
    [ Upstream commit 0e12f830236928b6fadf40d917a7527f0a048d2f ]
    
    The Link Retraining process is initiated to account for the Gen2 defect in
    the Cadence PCIe controller in J721E SoC. The errata corresponding to this
    is i2085, documented at:
    https://www.ti.com/lit/er/sprz455c/sprz455c.pdf
    
    The existing workaround implemented for the errata waits for the Data Link
    initialization to complete and assumes that the link retraining process
    at the Physical Layer has completed. However, it is possible that the
    Physical Layer training might be ongoing as indicated by the
    PCI_EXP_LNKSTA_LT bit in the PCI_EXP_LNKSTA register.
    
    Fix the existing workaround, to ensure that the Physical Layer training
    has also completed, in addition to the Data Link initialization.
    
    Link: https://lore.kernel.org/r/20230315070800.1615527-1-s-vadapalli@ti.com
    Fixes: 4740b969aaf5 ("PCI: cadence: Retrain Link to work around Gen2 training defect")
    Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: endpoint: Fix a Kconfig prompt of vNTB driver [+ + +]
Author: Shunsuke Mie <mie@igel.co.jp>
Date:   Thu Feb 2 19:38:32 2023 +0900

    PCI: endpoint: Fix a Kconfig prompt of vNTB driver
    
    [ Upstream commit 37587673cda963ec950e4983db5023802f9b5ff2 ]
    
    vNTB driver and NTB driver have same Kconfig prompt. Changed to make it
    distinguishable.
    
    Link: https://lore.kernel.org/r/20230202103832.2038286-1-mie@igel.co.jp
    Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP")
    Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: endpoint: Fix Kconfig indent style [+ + +]
Author: Shunsuke Mie <mie@igel.co.jp>
Date:   Mon Aug 15 11:50:06 2022 +0900

    PCI: endpoint: Fix Kconfig indent style
    
    [ Upstream commit 2759ddf7535d63381f9b9b1412e4c46e13ed773a ]
    
    Change to follow the Kconfig style guide. This patch fixes to use tab
    rather than space to indent, while help text is indented an additional
    two spaces.
    
    Link: https://lore.kernel.org/r/20220815025006.48167-1-mie@igel.co.jp
    Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP")
    Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Stable-dep-of: 37587673cda9 ("PCI: endpoint: Fix a Kconfig prompt of vNTB driver")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: endpoint: functions/pci-epf-test: Fix dma_chan direction [+ + +]
Author: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Date:   Wed Apr 12 15:34:47 2023 +0900

    PCI: endpoint: functions/pci-epf-test: Fix dma_chan direction
    
    [ Upstream commit 880d51c729a3fa944794feb19f605eefe55916fc ]
    
    In pci_epf_test_init_dma_chan() epf_test->dma_chan_rx is assigned from
    dma_request_channel() with DMA_DEV_TO_MEM as filter.dma_mask.
    
    However, in pci_epf_test_data_transfer() if the dir is DMA_DEV_TO_MEM,
    epf->dma_chan_rx should be used but instead we are using
    epf_test->dma_chan_tx.
    
    Fix it.
    
    Link: https://lore.kernel.org/r/20230412063447.2841177-1-yoshihiro.shimoda.uh@renesas.com
    Fixes: 8353813c88ef ("PCI: endpoint: Enable DMA tests for endpoints with DMA capabilities")
    Tested-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
    Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: ftpci100: Release the clock resources [+ + +]
Author: Junyan Ye <yejunyan@hust.edu.cn>
Date:   Mon May 8 12:36:41 2023 +0800

    PCI: ftpci100: Release the clock resources
    
    [ Upstream commit c60738de85f40b0b9f5cb23c21f9246e5a47908c ]
    
    Smatch reported:
    1. drivers/pci/controller/pci-ftpci100.c:526 faraday_pci_probe() warn:
    'clk' from clk_prepare_enable() not released on lines: 442,451,462,478,512,517.
    2. drivers/pci/controller/pci-ftpci100.c:526 faraday_pci_probe() warn:
    'p->bus_clk' from clk_prepare_enable() not released on lines: 451,462,478,512,517.
    
    The clock resource is obtained by devm_clk_get(), and then
    clk_prepare_enable() makes the clock resource ready for use. After that,
    clk_disable_unprepare() should be called to release the clock resource
    when it is no longer needed. However, while doing some error handling
    in faraday_pci_probe(), clk_disable_unprepare() is not called to release
    clk and p->bus_clk before returning. These return lines are exactly 442,
    451, 462, 478, 512, 517.
    
    Fix this warning by replacing devm_clk_get() with devm_clk_get_enabled(),
    which is equivalent to devm_clk_get() + clk_prepare_enable(). And with
    devm_clk_get_enabled(), the clock will automatically be disabled,
    unprepared and freed when the device is unbound from the bus.
    
    Link: https://lore.kernel.org/r/20230508043641.23807-1-yejunyan@hust.edu.cn
    Fixes: b3c433efb8a3 ("PCI: faraday: Fix wrong pointer passed to PTR_ERR()")
    Fixes: 2eeb02b28579 ("PCI: faraday: Add clock handling")
    Fixes: 783a862563f7 ("PCI: faraday: Use pci_parse_request_of_pci_ranges()")
    Fixes: d3c68e0a7e34 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI Host Bridge driver")
    Fixes: f1e8bd21e39e ("PCI: faraday: Convert IRQ masking to raw PCI config accessors")
    Signed-off-by: Junyan Ye <yejunyan@hust.edu.cn>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: pciehp: Cancel bringup sequence if card is not present [+ + +]
Author: Rongguang Wei <weirongguang@kylinos.cn>
Date:   Fri May 12 10:15:18 2023 +0800

    PCI: pciehp: Cancel bringup sequence if card is not present
    
    [ Upstream commit e8afd0d9fccc27c8ad263db5cf5952cfcf72d6fe ]
    
    If a PCIe hotplug slot has an Attention Button, the normal hot-add flow is:
    
      - Slot is empty and slot power is off
      - User inserts card in slot and presses Attention Button
      - OS blinks Power Indicator for 5 seconds
      - After 5 seconds, OS turns on Power Indicator, turns on slot power, and
        enumerates the device
    
    Previously, if a user pressed the Attention Button on an *empty* slot,
    pciehp logged the following messages and blinked the Power Indicator
    until a second button press:
    
      [0.000] pciehp: Button press: will power on in 5 sec
      [0.001] # Power Indicator starts blinking
      [5.001] # 5 second timeout; slot is empty, so we should cancel the
                request to power on and turn off Power Indicator
    
      [7.000] # Power Indicator still blinking
      [8.000] # possible card insertion
      [9.000] pciehp: Button press: canceling request to power on
    
    The first button press incorrectly left the slot in BLINKINGON_STATE, so
    the second was interpreted as a "cancel power on" event regardless of
    whether a card was present.
    
    If the slot is empty, turn off the Power Indicator and return from
    BLINKINGON_STATE to OFF_STATE after 5 seconds, effectively canceling the
    request to power on.  Putting the slot in OFF_STATE also means the second
    button press will correctly request a slot power on if the slot is
    occupied.
    
    [bhelgaas: commit log]
    Link: https://lore.kernel.org/r/20230512021518.336460-1-clementwei90@163.com
    Fixes: d331710ea78f ("PCI: pciehp: Become resilient to missed events")
    Suggested-by: Lukas Wunner <lukas@wunner.de>
    Signed-off-by: Rongguang Wei <weirongguang@kylinos.cn>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Lukas Wunner <lukas@wunner.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: qcom: Disable write access to read only registers for IP v2.9.0 [+ + +]
Author: Manivannan Sadhasivam <mani@kernel.org>
Date:   Mon Jun 19 20:34:02 2023 +0530

    PCI: qcom: Disable write access to read only registers for IP v2.9.0
    
    [ Upstream commit 200b8f85f2021362adcc8efb575652a2aa44c099 ]
    
    In the post init sequence of v2.9.0, write access to read only registers
    are not disabled after updating the registers. Fix it by disabling the
    access after register update.
    
    While at it, let's also add a newline after existing dw_pcie_dbi_ro_wr_en()
    guard function to align with rest of the driver.
    
    Link: https://lore.kernel.org/r/20230619150408.8468-4-manivannan.sadhasivam@linaro.org
    Fixes: 0cf7c2efe8ac ("PCI: qcom: Add IPQ60xx support")
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: qcom: Remove PCIE20_ prefix from register definitions [+ + +]
Author: Manivannan Sadhasivam <mani@kernel.org>
Date:   Thu Mar 16 13:41:00 2023 +0530

    PCI: qcom: Remove PCIE20_ prefix from register definitions
    
    [ Upstream commit 39171b33f6523f28c1c1256427e5f50c74b69639 ]
    
    The PCIE part is redundant and 20 doesn't represent anything across the
    SoCs supported now. So let's get rid of the prefix.
    
    This involves adding the IP version suffix to one definition of
    PARF_SLV_ADDR_SPACE_SIZE that defines offset specific to that version.
    The other definition is generic for the rest of the versions.
    
    Also, the register PCIE20_LNK_CONTROL2_LINK_STATUS2 is not used anywhere,
    hence removed.
    
    Link: https://lore.kernel.org/r/20230316081117.14288-3-manivannan.sadhasivam@linaro.org
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Stable-dep-of: 60f0072d7fb7 ("PCI: qcom: Use DWC helpers for modifying the read-only DBI registers")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: qcom: Sort and group registers and bitfield definitions [+ + +]
Author: Manivannan Sadhasivam <mani@kernel.org>
Date:   Thu Mar 16 13:41:01 2023 +0530

    PCI: qcom: Sort and group registers and bitfield definitions
    
    [ Upstream commit 769e49d87b15c302c9aadd87c7d114cfe7052320 ]
    
    Sorting the registers and their bit definitions will make it easier to add
    more definitions in the future and it also helps in maintenance.
    
    While at it, let's also group the registers and bit definitions separately
    as done in the pcie-qcom-ep driver.
    
    Link: https://lore.kernel.org/r/20230316081117.14288-4-manivannan.sadhasivam@linaro.org
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Stable-dep-of: 60f0072d7fb7 ("PCI: qcom: Use DWC helpers for modifying the read-only DBI registers")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: qcom: Use DWC helpers for modifying the read-only DBI registers [+ + +]
Author: Manivannan Sadhasivam <mani@kernel.org>
Date:   Mon Jun 19 20:34:01 2023 +0530

    PCI: qcom: Use DWC helpers for modifying the read-only DBI registers
    
    [ Upstream commit 60f0072d7fb7996b9a524ef0d152e21205473192 ]
    
    DWC core already exposes dw_pcie_dbi_ro_wr_{en/dis} helper APIs for
    enabling and disabling the write access to read only DBI registers. So
    let's use them instead of doing it manually.
    
    Also, the existing code doesn't disable the write access when it's done.
    This is also fixed now.
    
    Link: https://lore.kernel.org/r/20230619150408.8468-3-manivannan.sadhasivam@linaro.org
    Fixes: 5d76117f070d ("PCI: qcom: Add support for IPQ8074 PCIe controller")
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: qcom: Use lower case for hex [+ + +]
Author: Manivannan Sadhasivam <mani@kernel.org>
Date:   Thu Mar 16 13:41:04 2023 +0530

    PCI: qcom: Use lower case for hex
    
    [ Upstream commit 94ebd232dbc84dfdfbf0c406137a8b2aa8b37a01 ]
    
    To maintain uniformity, let's use lower case for representing hexadecimal
    numbers.
    
    Link: https://lore.kernel.org/r/20230316081117.14288-7-manivannan.sadhasivam@linaro.org
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Stable-dep-of: 60f0072d7fb7 ("PCI: qcom: Use DWC helpers for modifying the read-only DBI registers")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: vmd: Fix uninitialized variable usage in vmd_enable_domain() [+ + +]
Author: Xinghui Li <korantli@tencent.com>
Date:   Thu Apr 20 17:43:31 2023 +0800

    PCI: vmd: Fix uninitialized variable usage in vmd_enable_domain()
    
    [ Upstream commit 0c0206dc4f5ba2d18b15e24d2047487d6f73916b ]
    
    The ret variable in the vmd_enable_domain() function was used
    uninitialized when printing a warning message upon failure of
    the pci_reset_bus() function.
    
    Thus, fix the issue by assigning ret with the value returned from
    pci_reset_bus() before referencing it in the warning message.
    
    This was detected by Smatch:
    
      drivers/pci/controller/vmd.c:931 vmd_enable_domain() error: uninitialized symbol 'ret'.
    
    [kwilczynski: drop the second patch from the series, add missing reported
    by tag, commit log]
    Fixes: 0a584655ef89 ("PCI: vmd: Fix secondary bus reset for Intel bridges")
    Link: https://lore.kernel.org/all/202305270219.B96IiIfv-lkp@intel.com
    Link: https://lore.kernel.org/linux-pci/20230420094332.1507900-2-korantwork@gmail.com
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: Dan Carpenter <error27@gmail.com>
    Signed-off-by: Xinghui Li <korantli@tencent.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Nirmal Patel <nirmal.patel@linux.intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: vmd: Reset VMD config register between soft reboots [+ + +]
Author: Nirmal Patel <nirmal.patel@linux.intel.com>
Date:   Fri Feb 24 13:28:11 2023 -0700

    PCI: vmd: Reset VMD config register between soft reboots
    
    [ Upstream commit b61cf04c49c3dfa70a0d6725d3eb40bf9b35cf71 ]
    
    VMD driver can disable or enable MSI remapping by changing
    VMCONFIG_MSI_REMAP register. This register needs to be set to the
    default value during soft reboots. Drives failed to enumerate
    when Windows boots after performing a soft reboot from Linux.
    Windows doesn't support MSI remapping disable feature and stale
    register value hinders Windows VMD driver initialization process.
    Adding vmd_shutdown function to make sure to set the VMCONFIG
    register to the default value.
    
    Link: https://lore.kernel.org/r/20230224202811.644370-1-nirmal.patel@linux.intel.com
    Fixes: ee81ee84f873 ("PCI: vmd: Disable MSI-X remapping when possible")
    Signed-off-by: Nirmal Patel <nirmal.patel@linux.intel.com>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: Jon Derrick <jonathan.derrick@linux.dev>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf bench: Add missing setlocale() call to allow usage of %'d style formatting [+ + +]
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Fri Jun 2 15:38:25 2023 -0300

    perf bench: Add missing setlocale() call to allow usage of %'d style formatting
    
    [ Upstream commit 16203e9cd01896b4244100a8e3fb9f6e612ab2b1 ]
    
    Without this we were not getting the thousands separator for big
    numbers.
    
    Noticed while developing 'perf bench uprobe', but the use of %' predates
    that, for instance 'perf bench syscall' uses it.
    
    Before:
    
      # perf bench uprobe all
      # Running uprobe/baseline benchmark...
      # Executed 1000 usleep(1000) calls
           Total time: 1054082243ns
    
       1054082.243000 nsecs/op
    
      #
    
    After:
    
      # perf bench uprobe all
      # Running uprobe/baseline benchmark...
      # Executed 1,000 usleep(1000) calls
           Total time: 1,053,715,144ns
    
       1,053,715.144000 nsecs/op
    
      #
    
    Fixes: c2a08203052f8975 ("perf bench: Add basic syscall benchmark")
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Andre Fredette <anfredet@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Dave Tucker <datucker@redhat.com>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Cc: Derek Barbosa <debarbos@redhat.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
    Link: https://lore.kernel.org/lkml/ZH3lcepZ4tBYr1jv@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf dwarf-aux: Fix off-by-one in die_get_varname() [+ + +]
Author: Namhyung Kim <namhyung@kernel.org>
Date:   Mon Jun 12 16:41:01 2023 -0700

    perf dwarf-aux: Fix off-by-one in die_get_varname()
    
    [ Upstream commit 3abfcfd847717d232e36963f31a361747c388fe7 ]
    
    The die_get_varname() returns "(unknown_type)" string if it failed to
    find a type for the variable.  But it had a space before the opening
    parenthesis and it made the closing parenthesis cut off due to the
    off-by-one in the string length (14).
    
    Signed-off-by: Namhyung Kim <namhyung@kernel.org>
    Fixes: 88fd633cdfa19060 ("perf probe: No need to use formatting strbuf method")
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: https://lore.kernel.org/r/20230612234102.3909116-1-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf script: Fix allocation of evsel->priv related to per-event dump files [+ + +]
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Tue Jun 6 16:11:10 2023 -0300

    perf script: Fix allocation of evsel->priv related to per-event dump files
    
    [ Upstream commit 36d3e4138e1b6cc9ab179f3f397b5548f8b1eaae ]
    
    When printing output we may want to generate per event files, where the
    --per-event-dump option should be used, creating perf.data.EVENT.dump
    files instead of printing to stdout.
    
    The callback thar processes event thus expects that evsel->priv->fp
    should point to either the per-event FILE descriptor or to stdout.
    
    The a3af66f51bd0bca7 ("perf script: Fix crash because of missing
    evsel->priv") changeset fixed a case where evsel->priv wasn't setup,
    thus set to NULL, causing a segfault when trying to access
    evsel->priv->fp.
    
    But it did it for the non --per-event-dump case by allocating a 'struct
    perf_evsel_script' just to set its ->fp to stdout.
    
    Since evsel->priv is only freed when --per-event-dump is used, we ended
    up with a memory leak, detected using ASAN.
    
    Fix it by using the same method as perf_script__setup_per_event_dump(),
    and reuse that static 'struct perf_evsel_script'.
    
    Also check if evsel_script__new() failed.
    
    Fixes: a3af66f51bd0bca7 ("perf script: Fix crash because of missing evsel->priv")
    Reported-by: Ian Rogers <irogers@google.com>
    Tested-by: Ian Rogers <irogers@google.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
    Link: https://lore.kernel.org/lkml/ZH+F0wGAWV14zvMP@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf tool x86: Consolidate is_amd check into single function [+ + +]
Author: Ravi Bangoria <ravi.bangoria@amd.com>
Date:   Tue Jun 13 15:25:04 2023 +0530

    perf tool x86: Consolidate is_amd check into single function
    
    [ Upstream commit 0cd1ca4650c9cf5f318110f67d39cbebae3693b3 ]
    
    There are multiple places where x86 specific code determines AMD vs
    Intel arch and acts based on that. Consolidate those checks into a
    single function.
    
    Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Acked-by: Ian Rogers <irogers@google.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Ali Saidi <alisaidi@amazon.com>
    Cc: Ananth Narayan <ananth.narayan@amd.com>
    Cc: James Clark <james.clark@arm.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Leo Yan <leo.yan@linaro.org>
    Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Sandipan Das <sandipan.das@amd.com>
    Cc: Santosh Shukla <santosh.shukla@amd.com>
    Link: https://lore.kernel.org/r/20230613095506.547-3-ravi.bangoria@amd.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Stable-dep-of: 99d4850062a8 ("perf tool x86: Fix perf_env memory leak")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

perf tool x86: Fix perf_env memory leak [+ + +]
Author: Ian Rogers <irogers@google.com>
Date:   Tue Jun 13 16:54:16 2023 -0700

    perf tool x86: Fix perf_env memory leak
    
    [ Upstream commit 99d4850062a84564f36923764bb93935ef2ed108 ]
    
    Found by leak sanitizer:
    ```
    ==1632594==ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 21 byte(s) in 1 object(s) allocated from:
        #0 0x7f2953a7077b in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
        #1 0x556701d6fbbf in perf_env__read_cpuid util/env.c:369
        #2 0x556701d70589 in perf_env__cpuid util/env.c:465
        #3 0x55670204bba2 in x86__is_amd_cpu arch/x86/util/env.c:14
        #4 0x5567020487a2 in arch__post_evsel_config arch/x86/util/evsel.c:83
        #5 0x556701d8f78b in evsel__config util/evsel.c:1366
        #6 0x556701ef5872 in evlist__config util/record.c:108
        #7 0x556701cd6bcd in test__PERF_RECORD tests/perf-record.c:112
        #8 0x556701cacd07 in run_test tests/builtin-test.c:236
        #9 0x556701cacfac in test_and_print tests/builtin-test.c:265
        #10 0x556701cadddb in __cmd_test tests/builtin-test.c:402
        #11 0x556701caf2aa in cmd_test tests/builtin-test.c:559
        #12 0x556701d3b557 in run_builtin tools/perf/perf.c:323
        #13 0x556701d3bac8 in handle_internal_command tools/perf/perf.c:377
        #14 0x556701d3be90 in run_argv tools/perf/perf.c:421
        #15 0x556701d3c3f8 in main tools/perf/perf.c:537
        #16 0x7f2952a46189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    
    SUMMARY: AddressSanitizer: 21 byte(s) leaked in 1 allocation(s).
    ```
    
    Fixes: f7b58cbdb3ff36eb ("perf mem/c2c: Add load store event mappings for AMD")
    Signed-off-by: Ian Rogers <irogers@google.com>
    Acked-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Ravi Bangoria <ravi.bangoria@amd.com>
    Link: https://lore.kernel.org/r/20230613235416.1650755-1-irogers@google.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf/arm-cmn: Fix DTC reset [+ + +]
Author: Robin Murphy <robin.murphy@arm.com>
Date:   Wed May 24 17:44:32 2023 +0100

    perf/arm-cmn: Fix DTC reset
    
    [ Upstream commit 71746c995cac92fcf6a65661b51211cf2009d7f0 ]
    
    It turns out that my naive DTC reset logic fails to work as intended,
    since, after checking with the hardware designers, the PMU actually
    needs to be fully enabled in order to correctly clear any pending
    overflows. Therefore, invert the sequence to start with turning on both
    enables so that we can reliably get the DTCs into a known state, then
    moving to our normal counters-stopped state from there. Since all the
    DTM counters have already been unpaired during the initial discovery
    pass, we just need to additionally reset the cycle counters to ensure
    that no other unexpected overflows occur during this period.
    
    Fixes: 0ba64770a2f2 ("perf: Add Arm CMN-600 PMU driver")
    Reported-by: Geoff Blake <blakgeof@amazon.com>
    Signed-off-by: Robin Murphy <robin.murphy@arm.com>
    Link: https://lore.kernel.org/r/0ea4559261ea394f827c9aee5168c77a60aaee03.1684946389.git.robin.murphy@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf/ibs: Fix interface via core pmu events [+ + +]
Author: Ravi Bangoria <ravi.bangoria@amd.com>
Date:   Thu May 4 16:30:01 2023 +0530

    perf/ibs: Fix interface via core pmu events
    
    [ Upstream commit 2fad201fe38ff9a692acedb1990ece2c52a29f95 ]
    
    Although, IBS pmus can be invoked via their own interface, indirect
    IBS invocation via core pmu events is also supported with fixed set
    of events: cpu-cycles:p, r076:p (same as cpu-cycles:p) and r0C1:p
    (micro-ops) for user convenience.
    
    This indirect IBS invocation is broken since commit 66d258c5b048
    ("perf/core: Optimize perf_init_event()"), which added RAW pmu under
    'pmu_idr' list and thus if event_init() fails with RAW pmu, it started
    returning error instead of trying other pmus.
    
    Forward precise events from core pmu to IBS by overwriting 'type' and
    'config' in the kernel copy of perf_event_attr. Overwriting will cause
    perf_init_event() to retry with updated 'type' and 'config', which will
    automatically forward event to IBS pmu.
    
    Without patch:
      $ sudo ./perf record -C 0 -e r076:p -- sleep 1
      Error:
      The r076:p event is not supported.
    
    With patch:
      $ sudo ./perf record -C 0 -e r076:p -- sleep 1
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.341 MB perf.data (37 samples) ]
    
    Fixes: 66d258c5b048 ("perf/core: Optimize perf_init_event()")
    Reported-by: Stephane Eranian <eranian@google.com>
    Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20230504110003.2548-3-ravi.bangoria@amd.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
phy: tegra: xusb: check return value of devm_kzalloc() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Wed May 31 10:39:50 2023 +0300

    phy: tegra: xusb: check return value of devm_kzalloc()
    
    [ Upstream commit 44faada0f38fc333d392af04c343b0e23f8f5d81 ]
    
    devm_kzalloc() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: f67213cee2b3 ("phy: tegra: xusb: Add usb-role-switch support")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Acked-by: Thierry Reding <treding@nvidia.com>
    Link: https://lore.kernel.org/r/20230531073950.145339-1-claudiu.beznea@microchip.com
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

phy: tegra: xusb: Clear the driver reference in usb-phy dev [+ + +]
Author: EJ Hsu <ejh@nvidia.com>
Date:   Fri Jun 9 14:29:32 2023 +0800

    phy: tegra: xusb: Clear the driver reference in usb-phy dev
    
    commit c0c2fcb1325d0d4f3b322b5ee49385f8eca2560d upstream.
    
    For the dual-role port, it will assign the phy dev to usb-phy dev and
    use the port dev driver as the dev driver of usb-phy.
    
    When we try to destroy the port dev, it will destroy its dev driver
    as well. But we did not remove the reference from usb-phy dev. This
    might cause the use-after-free issue in KASAN.
    
    Fixes: e8f7d2f409a1 ("phy: tegra: xusb: Add usb-phy support")
    Cc: stable@vger.kernel.org
    
    Signed-off-by: EJ Hsu <ejh@nvidia.com>
    Signed-off-by: Haotien Hsu <haotienh@nvidia.com>
    Acked-by: Thierry Reding <treding@nvidia.com>
    Acked-by: Jon Hunter <jonathanh@nvidia.com>
    Link: https://lore.kernel.org/r/20230609062932.3276509-1-haotienh@nvidia.com
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
pinctrl: at91-pio4: check return value of devm_kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Thu Jun 15 13:53:33 2023 +0300

    pinctrl: at91-pio4: check return value of devm_kasprintf()
    
    [ Upstream commit f6fd5d4ff8ca0b24cee1af4130bcb1fa96b61aa0 ]
    
    devm_kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: 776180848b57 ("pinctrl: introduce driver for Atmel PIO4 controller")
    Depends-on: 1c4e5c470a56 ("pinctrl: at91: use devm_kasprintf() to avoid potential leaks")
    Depends-on: 5a8f9cf269e8 ("pinctrl: at91-pio4: use proper format specifier for unsigned int")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20230615105333.585304-4-claudiu.beznea@microchip.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

pinctrl: bcm2835: Handle gpiochip_add_pin_range() errors [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sun Apr 16 23:43:41 2023 +0200

    pinctrl: bcm2835: Handle gpiochip_add_pin_range() errors
    
    [ Upstream commit cdf7e616120065007687fe1df0412154f259daec ]
    
    gpiochip_add_pin_range() can fail, so better return its error code than
    a hard coded '0'.
    
    Fixes: d2b67744fd99 ("pinctrl: bcm2835: implement hook for missing gpio-ranges")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/98c3b5890bb72415145c9fe4e1d974711edae376.1681681402.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

pinctrl: cherryview: Return correct value if pin in push-pull mode [+ + +]
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Mon Jun 5 17:37:34 2023 +0300

    pinctrl: cherryview: Return correct value if pin in push-pull mode
    
    [ Upstream commit 5835196a17be5cfdcad0b617f90cf4abe16951a4 ]
    
    Currently the getter returns ENOTSUPP on pin configured in
    the push-pull mode. Fix this by adding the missed switch case.
    
    Fixes: ccdf81d08dbe ("pinctrl: cherryview: add option to set open-drain pin config")
    Fixes: 6e08d6bbebeb ("pinctrl: Add Intel Cherryview/Braswell pin controller support")
    Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

pinctrl: microchip-sgpio: check return value of devm_kasprintf() [+ + +]
Author: Claudiu Beznea <claudiu.beznea@microchip.com>
Date:   Thu Jun 15 13:53:32 2023 +0300

    pinctrl: microchip-sgpio: check return value of devm_kasprintf()
    
    [ Upstream commit 310cd4c206cd04696ccbfd1927b5ab6973e8cc8e ]
    
    devm_kasprintf() returns a pointer to dynamically allocated memory.
    Pointer could be NULL in case allocation fails. Check pointer validity.
    Identified with coccinelle (kmerr.cocci script).
    
    Fixes: 7e5ea974e61c ("pinctrl: pinctrl-microchip-sgpio: Add pinctrl driver for Microsemi Serial GPIO")
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20230615105333.585304-3-claudiu.beznea@microchip.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

pinctrl: npcm7xx: Add missing check for ioremap [+ + +]
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Wed Jun 7 17:58:29 2023 +0800

    pinctrl: npcm7xx: Add missing check for ioremap
    
    [ Upstream commit ad64639417161e90b30dda00486570eb150aeee5 ]
    
    Add check for ioremap() and return the error if it fails in order to
    guarantee the success of ioremap().
    
    Fixes: 3b588e43ee5c ("pinctrl: nuvoton: add NPCM7xx pinctrl and GPIO driver")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Link: https://lore.kernel.org/r/20230607095829.1345-1-jiasheng@iscas.ac.cn
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

pinctrl: sunplus: Add check for kmalloc [+ + +]
Author: Wells Lu <wellslutw@gmail.com>
Date:   Sun May 28 20:34:37 2023 +0800

    pinctrl: sunplus: Add check for kmalloc
    
    [ Upstream commit a5961bed5429cf1134d7f539b4ed60317012f84d ]
    
    Fix Smatch static checker warning:
    potential null dereference 'configs'. (kmalloc returns null)
    
    Fixes: aa74c44be19c ("pinctrl: Add driver for Sunplus SP7021")
    Signed-off-by: Wells Lu <wellslutw@gmail.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Link: https://lore.kernel.org/r/1685277277-12209-1-git-send-email-wellslutw@gmail.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Linux: pinctrl:sunplus: Add check for kmalloc [+ + +]
Author: Wells Lu <wellslutw@gmail.com>
Date:   Sun May 28 20:34:37 2023 +0800

    pinctrl:sunplus: Add check for kmalloc
    
    [ Upstream commit 73f8ce7f961afcb3be49352efeb7c26cc1c00cc4 ]
    
    Fix Smatch static checker warning:
    potential null dereference 'configs'. (kmalloc returns null)
    
    Changes in v2:
    1. Add free allocated memory before returned -ENOMEM.
    2. Add call of_node_put() before returned -ENOMEM.
    
    Fixes: aa74c44be19c ("pinctrl: Add driver for Sunplus SP7021")
    Signed-off-by: Wells Lu <wellslutw@gmail.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Link: https://lore.kernel.org/r/1685277277-12209-1-git-send-email-wellslutw@gmail.com
    [Rebased on the patch from Lu Hongfei]
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
platform/x86/dell/dell-rbtn: Fix resources leaking on error path [+ + +]
Author: Michal Wilczynski <michal.wilczynski@intel.com>
Date:   Tue Jun 13 11:43:10 2023 +0300

    platform/x86/dell/dell-rbtn: Fix resources leaking on error path
    
    [ Upstream commit 966cca72ab20289083521a385fa56035d85a222d ]
    
    Currently rbtn_add() in case of failure is leaking resources. Fix this
    by adding a proper rollback. Move devm_kzalloc() before rbtn_acquire(),
    so it doesn't require rollback in case of failure. While at it, remove
    unnecessary assignment of NULL to device->driver_data and unnecessary
    whitespace, plus add a break for the default case in a switch.
    
    Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Suggested-by: Pali Rohár <pali@kernel.org>
    Fixes: 817a5cdb40c8 ("dell-rbtn: Dell Airplane Mode Switch driver")
    Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Acked-by: Rafael J. Wysocki <rafael@kernel.org>
    Reviewed-by: Pali Rohár <pali@kernel.org>
    Link: https://lore.kernel.org/r/20230613084310.2775896-1-michal.wilczynski@intel.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
platform/x86: lenovo-yogabook: Fix work race on remove() [+ + +]
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Sun Apr 30 18:57:50 2023 +0200

    platform/x86: lenovo-yogabook: Fix work race on remove()
    
    [ Upstream commit 9148cd2eb4450a8e9c49c8a14201fb82f651128f ]
    
    When yogabook_wmi_remove() runs yogabook_wmi_work might still be running
    and using the devices which yogabook_wmi_remove() puts.
    
    To avoid this move to explicitly cancelling the work rather then using
    devm_work_autocancel().
    
    This requires also making the yogabook_backside_hall_irq handler non
    devm managed, so that it cannot re-queue the work while
    yogabook_wmi_remove() runs.
    
    Fixes: c0549b72d99d ("platform/x86: lenovo-yogabook-wmi: Add driver for Lenovo Yoga Book")
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20230430165807.472798-3-hdegoede@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

platform/x86: lenovo-yogabook: Reprobe devices on remove() [+ + +]
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Sun Apr 30 18:57:51 2023 +0200

    platform/x86: lenovo-yogabook: Reprobe devices on remove()
    
    [ Upstream commit 711bcc0cb34e96a60e88d7b0260862781de3e530 ]
    
    Ensure that both the keyboard touchscreen and the digitizer have their
    driver bound after remove(). Without this modprobing lenovo-yogabook-wmi
    after a rmmod fails because lenovo-yogabook-wmi defers probing until
    both devices have their driver bound.
    
    Fixes: c0549b72d99d ("platform/x86: lenovo-yogabook-wmi: Add driver for Lenovo Yoga Book")
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20230430165807.472798-4-hdegoede@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

platform/x86: lenovo-yogabook: Set default keyboard backligh brightness on probe() [+ + +]
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Sun Apr 30 18:57:52 2023 +0200

    platform/x86: lenovo-yogabook: Set default keyboard backligh brightness on probe()
    
    [ Upstream commit 9e6380d6573181c555ca1b5019b08d19a9ee581c ]
    
    Set default keyboard backlight brightness on probe(), this fixes
    the backlight being off after a rmmod + modprobe.
    
    Fixes: c0549b72d99d ("platform/x86: lenovo-yogabook-wmi: Add driver for Lenovo Yoga Book")
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20230430165807.472798-5-hdegoede@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

platform/x86: think-lmi: Correct NVME password handling [+ + +]
Author: Mark Pearson <mpearson-lenovo@squebb.ca>
Date:   Thu Jun 1 16:05:50 2023 -0400

    platform/x86: think-lmi: Correct NVME password handling
    
    [ Upstream commit 4cebb42412248d28df6de01420cfac5654428d41 ]
    
    NVME passwords identifier have been standardised across the Lenovo
    systems and now use udrp and adrp (user and admin level) instead of
    unvp and mnvp.
    
    This should apparently be backwards compatible.
    
    Fixes: 640a5fa50a42 ("platform/x86: think-lmi: Opcode support")
    Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20230601200552.4396-6-mpearson-lenovo@squebb.ca
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

platform/x86: think-lmi: Correct System password interface [+ + +]
Author: Mark Pearson <mpearson-lenovo@squebb.ca>
Date:   Thu Jun 1 16:05:47 2023 -0400

    platform/x86: think-lmi: Correct System password interface
    
    [ Upstream commit 97eef5983372d7aee6549d644d788fd0c10d2b6e ]
    
    The system password identification was incorrect. This means that if
    the password was enabled it wouldn't be detected correctly; and setting
    it would not work.
    Also updated code to use TLMI_SMP_PWD instead of TLMI_SYS_PWD to be in
    sync with Lenovo documentation.
    
    Fixes: 640a5fa50a42 ("platform/x86: think-lmi: Opcode support")
    Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20230601200552.4396-3-mpearson-lenovo@squebb.ca
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

platform/x86: think-lmi: mutex protection around multiple WMI calls [+ + +]
Author: Mark Pearson <mpearson-lenovo@squebb.ca>
Date:   Thu Jun 1 16:05:45 2023 -0400

    platform/x86: think-lmi: mutex protection around multiple WMI calls
    
    [ Upstream commit c41e0121a1221894a1a9c4666156db9e1def4d6c ]
    
    When an attribute is being changed if the Admin account is enabled, or if
    a password is being updated then multiple WMI calls are needed.
    Add mutex protection to ensure no race conditions are introduced.
    
    Fixes: b49f72e7f96d ("platform/x86: think-lmi: Certificate authentication support")
    Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20230601200552.4396-1-mpearson-lenovo@squebb.ca
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

platform/x86: thinkpad_acpi: Fix lkp-tests warnings for platform profiles [+ + +]
Author: Mark Pearson <mpearson-lenovo@squebb.ca>
Date:   Tue Jun 6 11:18:04 2023 -0400

    platform/x86: thinkpad_acpi: Fix lkp-tests warnings for platform profiles
    
    [ Upstream commit f999e23ce66c1555d7b653fba171a88ecee53704 ]
    
    Fix issues identified in dytc_profile_refresh identified by lkp-tests.
    drivers/platform/x86/thinkpad_acpi.c:10538
            dytc_profile_refresh() error: uninitialized symbol 'funcmode'.
    drivers/platform/x86/thinkpad_acpi.c:10531
            dytc_profile_refresh() error: uninitialized symbol 'output'.
    drivers/platform/x86/thinkpad_acpi.c:10537
            dytc_profile_refresh() error: uninitialized symbol 'output'.
    
    These issues should not lead to real problems in the field as the refresh
    function should only be called if MMC or PSC mode enabled. But good to fix.
    
    Thanks to Dan Carpenter and the lkp-tests project for flagging these.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: Dan Carpenter <error27@gmail.com>
    Closes: https://lore.kernel.org/r/202306011202.1hbgLRD4-lkp@intel.com/
    Fixes: 1bc5d819f0b9 ("platform/x86: thinkpad_acpi: Fix profile modes on Intel platforms")
    Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
    Link: https://lore.kernel.org/r/20230606151804.8819-1-mpearson-lenovo@squebb.ca
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
PM: domains: fix integer overflow issues in genpd_parse_state() [+ + +]
Author: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Date:   Tue Apr 18 06:07:43 2023 -0700

    PM: domains: fix integer overflow issues in genpd_parse_state()
    
    [ Upstream commit e5d1c8722083f0332dcd3c85fa1273d85fb6bed8 ]
    
    Currently, while calculating residency and latency values, right
    operands may overflow if resulting values are big enough.
    
    To prevent this, albeit unlikely case, play it safe and convert
    right operands to left ones' type s64.
    
    Found by Linux Verification Center (linuxtesting.org) with static
    analysis tool SVACE.
    
    Fixes: 30f604283e05 ("PM / Domains: Allow domain power states to be read from DT")
    Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
    Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PM: domains: Move the verification of in-params from genpd_add_device() [+ + +]
Author: Ulf Hansson <ulf.hansson@linaro.org>
Date:   Tue May 30 11:55:36 2023 +0200

    PM: domains: Move the verification of in-params from genpd_add_device()
    
    [ Upstream commit 4384a70c8813e8573d1841fd94eee873f80a7e1a ]
    
    Commit f38d1a6d0025 ("PM: domains: Allocate governor data dynamically
    based on a genpd governor") started to use the in-parameters in
    genpd_add_device(), without first doing a verification of them.
    
    This isn't really a big problem, as most callers do a verification already.
    
    Therefore, let's drop the verification from genpd_add_device() and make
    sure all the callers take care of it instead.
    
    Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
    Fixes: f38d1a6d0025 ("PM: domains: Allocate governor data dynamically based on a genpd governor")
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
posix-timers: Prevent RT livelock in itimer_delete() [+ + +]
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jun 1 22:16:34 2023 +0200

    posix-timers: Prevent RT livelock in itimer_delete()
    
    [ Upstream commit 9d9e522010eb5685d8b53e8a24320653d9d4cbbf ]
    
    itimer_delete() has a retry loop when the timer is concurrently expired. On
    non-RT kernels this just spin-waits until the timer callback has completed,
    except for posix CPU timers which have HAVE_POSIX_CPU_TIMERS_TASK_WORK
    enabled.
    
    In that case and on RT kernels the existing task could live lock when
    preempting the task which does the timer delivery.
    
    Replace spin_unlock() with an invocation of timer_wait_running() to handle
    it the same way as the other retry loops in the posix timer code.
    
    Fixes: ec8f954a40da ("posix-timers: Use a callback for cancel synchronization on PREEMPT_RT")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
    Link: https://lore.kernel.org/r/87v8g7c50d.ffs@tglx
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powercap: RAPL: Fix CONFIG_IOSF_MBI dependency [+ + +]
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Tue Jun 6 22:00:00 2023 +0800

    powercap: RAPL: Fix CONFIG_IOSF_MBI dependency
    
    [ Upstream commit 4658fe81b3f8afe8adf37734ec5fe595d90415c6 ]
    
    After commit 3382388d7148 ("intel_rapl: abstract RAPL common code"),
    accessing to IOSF_MBI interface is done in the RAPL common code.
    
    Thus it is the CONFIG_INTEL_RAPL_CORE that has dependency of
    CONFIG_IOSF_MBI, while CONFIG_INTEL_RAPL_MSR does not.
    
    This problem was not exposed previously because all the previous RAPL
    common code users, aka, the RAPL MSR and MMIO I/F drivers, have
    CONFIG_IOSF_MBI selected.
    
    Fix the CONFIG_IOSF_MBI dependency in RAPL code. This also fixes a build
    time failure when the RAPL TPMI I/F driver is introduced without
    selecting CONFIG_IOSF_MBI.
    
    x86_64-linux-ld: vmlinux.o: in function `set_floor_freq_atom':
    intel_rapl_common.c:(.text+0x2dac9b8): undefined reference to `iosf_mbi_write'
    x86_64-linux-ld: intel_rapl_common.c:(.text+0x2daca66): undefined reference to `iosf_mbi_read'
    
    Reference to iosf_mbi.h is also removed from the RAPL MSR I/F driver.
    
    Fixes: 3382388d7148 ("intel_rapl: abstract RAPL common code")
    Reported-by: Arnd Bergmann <arnd@arndb.de>
    Link: https://lore.kernel.org/all/20230601213246.3271412-1-arnd@kernel.org
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/64s: Fix VAS mm use after free [+ + +]
Author: Nicholas Piggin <npiggin@gmail.com>
Date:   Wed Jun 7 20:10:24 2023 +1000

    powerpc/64s: Fix VAS mm use after free
    
    [ Upstream commit b4bda59b47879cce38a6ec5a01cd3cac702b5331 ]
    
    The refcount on mm is dropped before the coprocessor is detached.
    
    Reported-by: Sachin Sant <sachinp@linux.ibm.com>
    Fixes: 7bc6f71bdff5f ("powerpc/vas: Define and use common vas_window struct")
    Fixes: b22f2d88e435c ("powerpc/pseries/vas: Integrate API with open/close windows")
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Tested-by: Sachin Sant <sachinp@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/20230607101024.14559-1-npiggin@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/book3s64/mm: Fix DirectMap stats in /proc/meminfo [+ + +]
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Fri Jun 16 16:38:13 2023 +0530

    powerpc/book3s64/mm: Fix DirectMap stats in /proc/meminfo
    
    [ Upstream commit 0da90af431abc3f497a38ec9ef6e43b0d0dabe80 ]
    
    On memory unplug reduce DirectMap page count correctly.
    root@ubuntu-guest:# grep Direct /proc/meminfo
    DirectMap4k:           0 kB
    DirectMap64k:           0 kB
    DirectMap2M:    115343360 kB
    DirectMap1G:           0 kB
    
    Before fix:
    root@ubuntu-guest:# ndctl disable-namespace all
    disabled 1 namespace
    root@ubuntu-guest:# grep Direct /proc/meminfo
    DirectMap4k:           0 kB
    DirectMap64k:           0 kB
    DirectMap2M:    115343360 kB
    DirectMap1G:           0 kB
    
    After fix:
    root@ubuntu-guest:# ndctl disable-namespace all
    disabled 1 namespace
    root@ubuntu-guest:# grep Direct /proc/meminfo
    DirectMap4k:           0 kB
    DirectMap64k:           0 kB
    DirectMap2M:    104857600 kB
    DirectMap1G:           0 kB
    
    Fixes: a2dc009afa9a ("powerpc/mm/book3s/radix: Add mapping statistics")
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Tested-by: Sachin Sant <sachinp@linux.ibm.com <mailto:sachinp@linux.ibm.com>>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/20230616110826.344417-4-aneesh.kumar@linux.ibm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/interrupt: Don't read MSR from interrupt_exit_kernel_prepare() [+ + +]
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Mon Jun 5 10:55:26 2023 +0200

    powerpc/interrupt: Don't read MSR from interrupt_exit_kernel_prepare()
    
    [ Upstream commit 0eb089a72fda3f7969e6277804bde75dc1474a14 ]
    
    A disassembly of interrupt_exit_kernel_prepare() shows a useless read
    of MSR register. This is shown by r9 being re-used immediately without
    doing anything with the value read.
    
      c000e0e0:       60 00 00 00     nop
      c000e0e4:       7d 3a c2 a6     mfmd_ap r9
      c000e0e8:       7d 20 00 a6     mfmsr   r9
      c000e0ec:       7c 51 13 a6     mtspr   81,r2
      c000e0f0:       81 3f 00 84     lwz     r9,132(r31)
      c000e0f4:       71 29 80 00     andi.   r9,r9,32768
    
    This is due to the use of local_irq_save(). The flags read by
    local_irq_save() are never used, use local_irq_disable() instead.
    
    Fixes: 13799748b957 ("powerpc/64: use interrupt restart table to speed up return from interrupt")
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/df36c6205ab64326fb1b991993c82057e92ace2f.1685955214.git.christophe.leroy@csgroup.eu
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/mm/dax: Fix the condition when checking if altmap vmemap can cross-boundary [+ + +]
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Fri Jun 16 16:38:15 2023 +0530

    powerpc/mm/dax: Fix the condition when checking if altmap vmemap can cross-boundary
    
    [ Upstream commit c8eebc4a99f15280654f23e914e746c40a516e50 ]
    
    Without this fix, the last subsection vmemmap can end up in memory even if
    the namespace is created with -M mem and has sufficient space in the altmap
    area.
    
    Fixes: cf387d9644d8 ("libnvdimm/altmap: Track namespace boundaries in altmap")
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Tested-by: Sachin Sant <sachinp@linux.ibm.com <mailto:sachinp@linux.ibm.com>>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/20230616110826.344417-6-aneesh.kumar@linux.ibm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/powernv/sriov: perform null check on iov before dereferencing iov [+ + +]
Author: Colin Ian King <colin.i.king@gmail.com>
Date:   Thu Jun 8 10:58:49 2023 +0100

    powerpc/powernv/sriov: perform null check on iov before dereferencing iov
    
    [ Upstream commit f4f913c980bc6abe0ccfe88fe3909c125afe4a2d ]
    
    Currently pointer iov is being dereferenced before the null check of iov
    which can lead to null pointer dereference errors. Fix this by moving the
    iov null check before the dereferencing.
    
    Detected using cppcheck static analysis:
    linux/arch/powerpc/platforms/powernv/pci-sriov.c:597:12: warning: Either
    the condition '!iov' is redundant or there is possible null pointer
    dereference: iov. [nullPointerRedundantCheck]
     num_vfs = iov->num_vfs;
               ^
    
    Fixes: 052da31d45fc ("powerpc/powernv/sriov: De-indent setup and teardown")
    Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/20230608095849.1147969-1-colin.i.king@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/signal32: Force inlining of __unsafe_save_user_regs() and save_tm_user_regs_unsafe() [+ + +]
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Mon Jun 5 10:58:35 2023 +0200

    powerpc/signal32: Force inlining of __unsafe_save_user_regs() and save_tm_user_regs_unsafe()
    
    [ Upstream commit a03b1a0b19398a47489fdcef02ec19c2ba05a15d ]
    
    Looking at generated code for handle_signal32() shows calls to a
    function called __unsafe_save_user_regs.constprop.0 while user access
    is open.
    
    And that __unsafe_save_user_regs.constprop.0 function has two nops at
    the begining, allowing it to be traced, which is unexpected during
    user access open window.
    
    The solution could be to mark __unsafe_save_user_regs() no trace, but
    to be on the safe side the most efficient is to flag it __always_inline
    as already done for function __unsafe_restore_general_regs(). The
    function is relatively small and only called twice, so the size
    increase will remain in the noise.
    
    Do the same with save_tm_user_regs_unsafe() as it may suffer the
    same issue.
    
    Fixes: ef75e7318294 ("powerpc/signal32: Transform save_user_regs() and save_tm_user_regs() in 'unsafe' version")
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/7e469c8f01860a69c1ada3ca6a5e2aa65f0f74b2.1685955220.git.christophe.leroy@csgroup.eu
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Fri Jun 30 22:47:12 2023 -0700

    powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y
    
    [ Upstream commit 39f49684036d24af800ff194c33c7b2653c591d7 ]
    
    In a randconfig with CONFIG_SERIAL_CPM=m and
    CONFIG_PPC_EARLY_DEBUG_CPM=y, there is a build error:
    ERROR: modpost: "udbg_putc" [drivers/tty/serial/cpm_uart/cpm_uart.ko] undefined!
    
    Prevent the build error by allowing PPC_EARLY_DEBUG_CPM only when
    SERIAL_CPM=y.
    
    Fixes: c374e00e17f1 ("[POWERPC] Add early debug console for CPM serial ports.")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Reviewed-by: Pali Rohár <pali@kernel.org>
    Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/20230701054714.30512-1-rdunlap@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

powerpc: dts: turris1x.dts: Fix PCIe MEM size for pci2 node [+ + +]
Author: Pali Rohár <pali@kernel.org>
Date:   Fri May 5 19:28:18 2023 +0200

    powerpc: dts: turris1x.dts: Fix PCIe MEM size for pci2 node
    
    [ Upstream commit abaa02fc944f2f9f2c2e1925ddaceaf35c48528c ]
    
    Freescale PCIe controllers on their PCIe Root Ports do not have any
    mappable PCI BAR allocate from PCIe MEM.
    
    Information about 1MB window on BAR0 of PCIe Root Port was misleading
    because Freescale PCIe controllers have at BAR0 position different register
    PEXCSRBAR, and kernel correctly skipts BAR0 for these Freescale PCIe Root
    Ports.
    
    So update comment about P2020 PCIe Root Port and decrease PCIe MEM size
    required for PCIe controller (pci2 node) on which is on-board xHCI
    controller.
    
    lspci confirms that on P2020 PCIe Root Port is no PCI BAR and /proc/iomem
    sees that only c0000000-c000ffff and c0010000-c0011fff ranges are used.
    
    Fixes: 54c15ec3b738 ("powerpc: dts: Add DTS file for CZ.NIC Turris 1.x routers")
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/20230505172818.18416-1-pali@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

powerpc: simplify ppc_save_regs [+ + +]
Author: Nicholas Piggin <npiggin@gmail.com>
Date:   Sun Nov 27 22:49:31 2022 +1000

    powerpc: simplify ppc_save_regs
    
    [ Upstream commit 37195b820d32c23bdefce3f460ed7de48a57e5e4 ]
    
    Adjust the pt_regs pointer so the interrupt frame offsets can be used
    to save registers.
    
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20221127124942.1665522-7-npiggin@gmail.com
    Stable-dep-of: b684c09f09e7 ("powerpc: update ppc_save_regs to save current r1 in pt_regs")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

powerpc: update ppc_save_regs to save current r1 in pt_regs [+ + +]
Author: Aditya Gupta <adityag@linux.ibm.com>
Date:   Thu Jun 15 14:40:47 2023 +0530

    powerpc: update ppc_save_regs to save current r1 in pt_regs
    
    [ Upstream commit b684c09f09e7a6af3794d4233ef785819e72db79 ]
    
    ppc_save_regs() skips one stack frame while saving the CPU register states.
    Instead of saving current R1, it pulls the previous stack frame pointer.
    
    When vmcores caused by direct panic call (such as `echo c >
    /proc/sysrq-trigger`), are debugged with gdb, gdb fails to show the
    backtrace correctly. On further analysis, it was found that it was because
    of mismatch between r1 and NIP.
    
    GDB uses NIP to get current function symbol and uses corresponding debug
    info of that function to unwind previous frames, but due to the
    mismatching r1 and NIP, the unwinding does not work, and it fails to
    unwind to the 2nd frame and hence does not show the backtrace.
    
    GDB backtrace with vmcore of kernel without this patch:
    
    ---------
    (gdb) bt
     #0  0xc0000000002a53e8 in crash_setup_regs (oldregs=<optimized out>,
        newregs=0xc000000004f8f8d8) at ./arch/powerpc/include/asm/kexec.h:69
     #1  __crash_kexec (regs=<optimized out>) at kernel/kexec_core.c:974
     #2  0x0000000000000063 in ?? ()
     #3  0xc000000003579320 in ?? ()
    ---------
    
    Further analysis revealed that the mismatch occurred because
    "ppc_save_regs" was saving the previous stack's SP instead of the current
    r1. This patch fixes this by storing current r1 in the saved pt_regs.
    
    GDB backtrace with vmcore of patched kernel:
    
    --------
    (gdb) bt
     #0  0xc0000000002a53e8 in crash_setup_regs (oldregs=0x0, newregs=0xc00000000670b8d8)
        at ./arch/powerpc/include/asm/kexec.h:69
     #1  __crash_kexec (regs=regs@entry=0x0) at kernel/kexec_core.c:974
     #2  0xc000000000168918 in panic (fmt=fmt@entry=0xc000000001654a60 "sysrq triggered crash\n")
        at kernel/panic.c:358
     #3  0xc000000000b735f8 in sysrq_handle_crash (key=<optimized out>) at drivers/tty/sysrq.c:155
     #4  0xc000000000b742cc in __handle_sysrq (key=key@entry=99, check_mask=check_mask@entry=false)
        at drivers/tty/sysrq.c:602
     #5  0xc000000000b7506c in write_sysrq_trigger (file=<optimized out>, buf=<optimized out>,
        count=2, ppos=<optimized out>) at drivers/tty/sysrq.c:1163
     #6  0xc00000000069a7bc in pde_write (ppos=<optimized out>, count=<optimized out>,
        buf=<optimized out>, file=<optimized out>, pde=0xc00000000362cb40) at fs/proc/inode.c:340
     #7  proc_reg_write (file=<optimized out>, buf=<optimized out>, count=<optimized out>,
        ppos=<optimized out>) at fs/proc/inode.c:352
     #8  0xc0000000005b3bbc in vfs_write (file=file@entry=0xc000000006aa6b00,
        buf=buf@entry=0x61f498b4f60 <error: Cannot access memory at address 0x61f498b4f60>,
        count=count@entry=2, pos=pos@entry=0xc00000000670bda0) at fs/read_write.c:582
     #9  0xc0000000005b4264 in ksys_write (fd=<optimized out>,
        buf=0x61f498b4f60 <error: Cannot access memory at address 0x61f498b4f60>, count=2)
        at fs/read_write.c:637
     #10 0xc00000000002ea2c in system_call_exception (regs=0xc00000000670be80, r0=<optimized out>)
        at arch/powerpc/kernel/syscall.c:171
     #11 0xc00000000000c270 in system_call_vectored_common ()
        at arch/powerpc/kernel/interrupt_64.S:192
    --------
    
    Nick adds:
      So this now saves regs as though it was an interrupt taken in the
      caller, at the instruction after the call to ppc_save_regs, whereas
      previously the NIP was there, but R1 came from the caller's caller and
      that mismatch is what causes gdb's dwarf unwinder to go haywire.
    
    Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
    Fixes: d16a58f8854b1 ("powerpc: Improve ppc_save_regs()")
    Reivewed-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/20230615091047.90433-1-adityag@linux.ibm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
pptp: Fix fib lookup calls. [+ + +]
Author: Guillaume Nault <gnault@redhat.com>
Date:   Mon Jul 3 19:14:46 2023 +0200

    pptp: Fix fib lookup calls.
    
    [ Upstream commit 84bef5b6037c15180ef88ac4216dc621d16df1a6 ]
    
    PPTP uses pppox sockets (struct pppox_sock). These sockets don't embed
    an inet_sock structure, so it's invalid to call inet_sk() on them.
    
    Therefore, the ip_route_output_ports() call in pptp_connect() has two
    problems:
    
      * The tos variable is set with RT_CONN_FLAGS(sk), which calls
        inet_sk() on the pppox socket.
    
      * ip_route_output_ports() tries to retrieve routing flags using
        inet_sk_flowi_flags(), which is also going to call inet_sk() on the
        pppox socket.
    
    While PPTP doesn't use inet sockets, it's actually really layered on
    top of IP and therefore needs a proper way to do fib lookups. So let's
    define pptp_route_output() to get a struct rtable from a pptp socket.
    Let's also replace the ip_route_output_ports() call of pptp_xmit() for
    consistency.
    
    In practice, this means that:
    
      * pptp_connect() sets ->flowi4_tos and ->flowi4_flags to zero instead
        of using bits of unrelated struct pppox_sock fields.
    
      * pptp_xmit() now respects ->sk_mark and ->sk_uid.
    
      * pptp_xmit() now calls the security_sk_classify_flow() security
        hook, thus allowing to set ->flowic_secid.
    
      * pptp_xmit() now passes the pppox socket to xfrm_lookup_route().
    
    Found by code inspection.
    
    Fixes: 00959ade36ac ("PPTP: PPP over IPv4 (Point-to-Point Tunneling Protocol)")
    Signed-off-by: Guillaume Nault <gnault@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
pstore/ram: Add check for kstrdup [+ + +]
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Wed Jun 14 17:37:33 2023 +0800

    pstore/ram: Add check for kstrdup
    
    [ Upstream commit d97038d5ec2062733c1e016caf9baaf68cf64ea1 ]
    
    Add check for the return value of kstrdup() and return the error
    if it fails in order to avoid NULL pointer dereference.
    
    Fixes: e163fdb3f7f8 ("pstore/ram: Regularize prz label allocation lifetime")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20230614093733.36048-1-jiasheng@iscas.ac.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
pwm: ab8500: Fix error code in probe() [+ + +]
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Mon May 22 14:07:42 2023 +0300

    pwm: ab8500: Fix error code in probe()
    
    [ Upstream commit cdcffafc4d845cc0c6392cba168c7a942734cce7 ]
    
    This code accidentally return positive EINVAL instead of negative
    -EINVAL.
    
    Fixes: eb41f334589d ("pwm: ab8500: Fix register offset calculation to not depend on probe order")
    Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
    Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

pwm: imx-tpm: force 'real_period' to be zero in suspend [+ + +]
Author: Fancy Fang <chen.fang@nxp.com>
Date:   Fri May 5 14:58:39 2023 +0800

    pwm: imx-tpm: force 'real_period' to be zero in suspend
    
    [ Upstream commit 661dfb7f46298e53f6c3deaa772fa527aae86193 ]
    
    During suspend, all the tpm registers will lose values.
    So the 'real_period' value of struct 'imx_tpm_pwm_chip'
    should be forced to be zero to force the period update
    code can be executed after system resume back.
    
    Signed-off-by: Fancy Fang <chen.fang@nxp.com>
    Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
    Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Fixes: 738a1cfec2ed ("pwm: Add i.MX TPM PWM driver support")
    Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

pwm: mtk_disp: Fix the disable flow of disp_pwm [+ + +]
Author: Shuijing Li <shuijing.li@mediatek.com>
Date:   Wed May 31 11:10:01 2023 +0800

    pwm: mtk_disp: Fix the disable flow of disp_pwm
    
    [ Upstream commit bc13d60e4e1e945b34769a4a4c2b172e8552abe5 ]
    
    There is a flow error in the original mtk_disp_pwm_apply() function.
    If this function is called when the clock is disabled, there will be a
    chance to operate the disp_pwm register, resulting in disp_pwm exception.
    Fix this accordingly.
    
    Fixes: 888a623db5d0 ("pwm: mtk-disp: Implement atomic API .apply()")
    Signed-off-by: Shuijing Li <shuijing.li@mediatek.com>
    Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
    Tested-by: Fei Shao <fshao@chromium.org>
    Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

pwm: sysfs: Do not apply state to already disabled PWMs [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Fri May 12 18:47:36 2023 +0200

    pwm: sysfs: Do not apply state to already disabled PWMs
    
    [ Upstream commit 38ba83598633373f47951384cfc389181c8d1bed ]
    
    If the PWM is exported but not enabled, do not call pwm_class_apply_state().
    First of all, in this case, period may still be unconfigured and this would
    make pwm_class_apply_state() return -EINVAL, and then suspend would fail.
    Second, it makes little sense to apply state onto PWM that is not enabled
    before suspend.
    
    Failing case:
    "
    $ echo 1 > /sys/class/pwm/pwmchip4/export
    $ echo mem > /sys/power/state
    ...
    pwm pwmchip4: PM: dpm_run_callback(): pwm_class_suspend+0x1/0xa8 returns -22
    pwm pwmchip4: PM: failed to suspend: error -22
    PM: Some devices failed to suspend, or early wake event detected
    "
    
    Working case:
    "
    $ echo 1 > /sys/class/pwm/pwmchip4/export
    $ echo 100 > /sys/class/pwm/pwmchip4/pwm1/period
    $ echo 10 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle
    $ echo mem > /sys/power/state
    ...
    "
    
    Do not call pwm_class_apply_state() in case the PWM is disabled
    to fix this issue.
    
    Fixes: 7fd4edc57bbae ("pwm: sysfs: Add suspend/resume support")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Fixes: ef2bf4997f7d ("pwm: Improve args checking in pwm_apply_state()")
    Reviewed-by: Brian Norris <briannorris@chromium.org>
    Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
radeon: avoid double free in ci_dpm_init() [+ + +]
Author: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Date:   Thu Apr 13 08:12:28 2023 -0700

    radeon: avoid double free in ci_dpm_init()
    
    [ Upstream commit 20c3dffdccbd494e0dd631d1660aeecbff6775f2 ]
    
    Several calls to ci_dpm_fini() will attempt to free resources that
    either have been freed before or haven't been allocated yet. This
    may lead to undefined or dangerous behaviour.
    
    For instance, if r600_parse_extended_power_table() fails, it might
    call r600_free_extended_power_table() as will ci_dpm_fini() later
    during error handling.
    
    Fix this by only freeing pointers to objects previously allocated.
    
    Found by Linux Verification Center (linuxtesting.org) with static
    analysis tool SVACE.
    
    Fixes: cc8dbbb4f62a ("drm/radeon: add dpm support for CI dGPUs (v2)")
    Co-developed-by: Natalia Petrova <n.petrova@fintech.ru>
    Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rcu-tasks: Stop rcu_tasks_invoke_cbs() from using never-onlined CPUs [+ + +]
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Wed Apr 26 11:11:29 2023 -0700

    rcu-tasks: Stop rcu_tasks_invoke_cbs() from using never-onlined CPUs
    
    [ Upstream commit 401b0de3ae4fa49d1014c8941e26d9a25f37e7cf ]
    
    The rcu_tasks_invoke_cbs() function relies on queue_work_on() to silently
    fall back to WORK_CPU_UNBOUND when the specified CPU is offline.  However,
    the queue_work_on() function's silent fallback mechanism relies on that
    CPU having been online at some time in the past.  When queue_work_on()
    is passed a CPU that has never been online, workqueue lockups ensue,
    which can be bad for your kernel's general health and well-being.
    
    This commit therefore checks whether a given CPU has ever been online,
    and, if not substitutes WORK_CPU_UNBOUND in the subsequent call to
    queue_work_on().  Why not simply omit the queue_work_on() call entirely?
    Because this function is flooding callback-invocation notifications
    to all CPUs, and must deal with possibilities that include a sparse
    cpu_possible_mask.
    
    This commit also moves the setting of the rcu_data structure's
    ->beenonline field to rcu_cpu_starting(), which executes on the
    incoming CPU before that CPU has ever enabled interrupts.  This ensures
    that the required workqueues are present.  In addition, because the
    incoming CPU has not yet enabled its interrupts, there cannot yet have
    been any softirq handlers running on this CPU, which means that the
    WARN_ON_ONCE(!rdp->beenonline) within the RCU_SOFTIRQ handler cannot
    have triggered yet.
    
    Fixes: d363f833c6d88 ("rcu-tasks: Use workqueues for multiple rcu_tasks_invoke_cbs() invocations")
    Reported-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rcu/rcuscale: Move rcu_scale_*() after kfree_scale_cleanup() [+ + +]
Author: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Date:   Wed Mar 22 19:42:40 2023 +0800

    rcu/rcuscale: Move rcu_scale_*() after kfree_scale_cleanup()
    
    [ Upstream commit bf5ddd736509a7d9077c0b6793e6f0852214dbea ]
    
    This code-movement-only commit moves the rcu_scale_cleanup() and
    rcu_scale_shutdown() functions to follow kfree_scale_cleanup().
    This is code movement is in preparation for a bug-fix patch that invokes
    kfree_scale_cleanup() from rcu_scale_cleanup().
    
    Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
    Stable-dep-of: 23fc8df26dea ("rcu/rcuscale: Stop kfree_scale_thread thread(s) after unloading rcuscale")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

rcu/rcuscale: Stop kfree_scale_thread thread(s) after unloading rcuscale [+ + +]
Author: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Date:   Wed Mar 22 19:42:41 2023 +0800

    rcu/rcuscale: Stop kfree_scale_thread thread(s) after unloading rcuscale
    
    [ Upstream commit 23fc8df26dead16687ae6eb47b0561a4a832e2f6 ]
    
    Running the 'kfree_rcu_test' test case [1] results in a splat [2].
    The root cause is the kfree_scale_thread thread(s) continue running
    after unloading the rcuscale module.  This commit fixes that isue by
    invoking kfree_scale_cleanup() from rcu_scale_cleanup() when removing
    the rcuscale module.
    
    [1] modprobe rcuscale kfree_rcu_test=1
        // After some time
        rmmod rcuscale
        rmmod torture
    
    [2] BUG: unable to handle page fault for address: ffffffffc0601a87
        #PF: supervisor instruction fetch in kernel mode
        #PF: error_code(0x0010) - not-present page
        PGD 11de4f067 P4D 11de4f067 PUD 11de51067 PMD 112f4d067 PTE 0
        Oops: 0010 [#1] PREEMPT SMP NOPTI
        CPU: 1 PID: 1798 Comm: kfree_scale_thr Not tainted 6.3.0-rc1-rcu+ #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
        RIP: 0010:0xffffffffc0601a87
        Code: Unable to access opcode bytes at 0xffffffffc0601a5d.
        RSP: 0018:ffffb25bc2e57e18 EFLAGS: 00010297
        RAX: 0000000000000000 RBX: ffffffffc061f0b6 RCX: 0000000000000000
        RDX: 0000000000000000 RSI: ffffffff962fd0de RDI: ffffffff962fd0de
        RBP: ffffb25bc2e57ea8 R08: 0000000000000000 R09: 0000000000000000
        R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000
        R13: 0000000000000000 R14: 000000000000000a R15: 00000000001c1dbe
        FS:  0000000000000000(0000) GS:ffff921fa2200000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: ffffffffc0601a5d CR3: 000000011de4c006 CR4: 0000000000370ee0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         <TASK>
         ? kvfree_call_rcu+0xf0/0x3a0
         ? kthread+0xf3/0x120
         ? kthread_complete_and_exit+0x20/0x20
         ? ret_from_fork+0x1f/0x30
         </TASK>
        Modules linked in: rfkill sunrpc ... [last unloaded: torture]
        CR2: ffffffffc0601a87
        ---[ end trace 0000000000000000 ]---
    
    Fixes: e6e78b004fa7 ("rcuperf: Add kfree_rcu() performance Tests")
    Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
    Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
    Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rcu: Make rcu_cpu_starting() rely on interrupts being disabled [+ + +]
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Thu Apr 27 10:50:47 2023 -0700

    rcu: Make rcu_cpu_starting() rely on interrupts being disabled
    
    [ Upstream commit 15d44dfa40305da1648de4bf001e91cc63148725 ]
    
    Currently, rcu_cpu_starting() is written so that it might be invoked
    with interrupts enabled.  However, it is always called when interrupts
    are disabled, either by rcu_init(), notify_cpu_starting(), or from a
    call point prior to the call to notify_cpu_starting().
    
    But why bother requiring that interrupts be disabled?  The purpose is
    to allow the rcu_data structure's ->beenonline flag to be set after all
    early processing has completed for the incoming CPU, thus allowing this
    flag to be used to determine when workqueues have been set up for the
    incoming CPU, while still allowing this flag to be used as a diagnostic
    within rcu_core().
    
    This commit therefore makes rcu_cpu_starting() rely on interrupts being
    disabled.
    
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Stable-dep-of: 401b0de3ae4f ("rcu-tasks: Stop rcu_tasks_invoke_cbs() from using never-onlined CPUs")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rcuscale: Move shutdown from wait_event() to wait_event_idle() [+ + +]
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Tue Jan 31 12:08:54 2023 -0800

    rcuscale: Move shutdown from wait_event() to wait_event_idle()
    
    [ Upstream commit ef1ef3d47677dc191b88650a9f7f91413452cc1b ]
    
    The rcu_scale_shutdown() and kfree_scale_shutdown() kthreads/functions
    use wait_event() to wait for the rcuscale test to complete.  However,
    each updater thread in such a test waits for at least 100 grace periods.
    If each grace period takes more than 1.2 seconds, which is long, but
    not insanely so, this can trigger the hung-task timeout.
    
    This commit therefore replaces those wait_event() calls with calls to
    wait_event_idle(), which do not trigger the hung-task timeout.
    
    Reported-by: kernel test robot <yujie.liu@intel.com>
    Reported-by: Liam Howlett <liam.howlett@oracle.com>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Tested-by: Yujie Liu <yujie.liu@intel.com>
    Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
    Stable-dep-of: 23fc8df26dea ("rcu/rcuscale: Stop kfree_scale_thread thread(s) after unloading rcuscale")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rcutorture: Correct name of use_softirq module parameter [+ + +]
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Tue Mar 21 16:40:08 2023 -0700

    rcutorture: Correct name of use_softirq module parameter
    
    [ Upstream commit b409afe0268faeb77267f028ea85f2d93438fced ]
    
    The BUSTED-BOOST and TREE03 scenarios specify a mythical tree.use_softirq
    module parameter, which means a failure to get full test coverage.  This
    commit therefore corrects the name to rcutree.use_softirq.
    
    Fixes: e2b949d54392 ("rcutorture: Make TREE03 use real-time tree.use_softirq setting")
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
RDMA/bnxt_re: Avoid calling wake_up threads from spin_lock context [+ + +]
Author: Kashyap Desai <kashyap.desai@broadcom.com>
Date:   Fri Jun 9 04:01:39 2023 -0700

    RDMA/bnxt_re: Avoid calling wake_up threads from spin_lock context
    
    [ Upstream commit 3099bcdc19b701f732f638ee45679858c08559bb ]
    
    bnxt_qplib_service_creq can be called from interrupt or tasklet or
    process context. So the function take irq variant  of spin_lock.
    But when wake_up is invoked with the lock held, it is putting the
    calling context to sleep.
    
    [exception RIP: __wake_up_common+190]
    RIP: ffffffffb7539d7e  RSP: ffffa73300207ad8  RFLAGS: 00000083
    RAX: 0000000000000001  RBX: ffff91fa295f69b8  RCX: dead000000000200
    RDX: ffffa733344af940  RSI: ffffa73336527940  RDI: ffffa73336527940
    RBP: 000000000000001c   R8: 0000000000000002   R9: 00000000000299c0
    R10: 0000017230de82c5  R11: 0000000000000002  R12: ffffa73300207b28
    R13: 0000000000000000  R14: ffffa733341bf928  R15: 0000000000000000
    ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
    
    Call the wakeup after releasing the lock.
    
    Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
    Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
    Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
    Link: https://lore.kernel.org/r/1686308514-11996-3-git-send-email-selvin.xavier@broadcom.com
    Signed-off-by: Leon Romanovsky <leon@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

RDMA/bnxt_re: Disable/kill tasklet only if it is enabled [+ + +]
Author: Selvin Xavier <selvin.xavier@broadcom.com>
Date:   Thu May 18 23:48:11 2023 -0700

    RDMA/bnxt_re: Disable/kill tasklet only if it is enabled
    
    [ Upstream commit ab112ee7899d6171da5acd77a7ed7ae103f488de ]
    
    When the ulp hook to start the IRQ fails because the rings are not
    available, tasklets are not enabled. In this case when the driver is
    unloaded, driver calls CREQ tasklet_kill. This causes an indefinite hang
    as the tasklet is not enabled.
    
    Driver shouldn't call tasklet_kill if it is not enabled. So using the
    creq->requested and nq->requested flags to identify if both tasklets/irqs
    are registered. Checking this flag while scheduling the tasklet from
    ISR. Also, added a cleanup for disabling tasklet, in case request_irq
    fails during start_irq.
    
    Check for return value for bnxt_qplib_rcfw_start_irq and in case the
    bnxt_qplib_rcfw_start_irq fails, return bnxt_re_start_irq without
    attempting to start NQ IRQs.
    
    Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
    Link: https://lore.kernel.org/r/1684478897-12247-2-git-send-email-selvin.xavier@broadcom.com
    Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
    Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

RDMA/bnxt_re: Fix to remove an unnecessary log [+ + +]
Author: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Date:   Thu May 18 23:48:15 2023 -0700

    RDMA/bnxt_re: Fix to remove an unnecessary log
    
    [ Upstream commit 43774bc156614346fe5dacabc8e8c229167f2536 ]
    
    During destroy_qp, driver sets the qp handle in the existing CQEs
    belonging to the QP being destroyed to NULL. As a result, a poll_cq after
    destroy_qp can report unnecessary messages.  Remove this noise from system
    logs.
    
    Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
    Link: https://lore.kernel.org/r/1684478897-12247-6-git-send-email-selvin.xavier@broadcom.com
    Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
    Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

RDMA/bnxt_re: Fix to remove unnecessary return labels [+ + +]
Author: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Date:   Thu May 18 23:48:12 2023 -0700

    RDMA/bnxt_re: Fix to remove unnecessary return labels
    
    [ Upstream commit 9b3ee47796f529e5bc31a355d6cb756d68a7079a ]
    
    If there is no cleanup needed then just return directly.  This cleans up
    the code and improve readability.
    
    Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
    Link: https://lore.kernel.org/r/1684478897-12247-3-git-send-email-selvin.xavier@broadcom.com
    Reviewed-by: Kashyap Desai <kashyap.desai@broadcom.com>
    Reviewed-by: Saravanan Vajravel <saravanan.vajravel@broadcom.com>
    Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
    Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

RDMA/bnxt_re: Remove a redundant check inside bnxt_re_update_gid [+ + +]
Author: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Date:   Thu May 18 23:48:14 2023 -0700

    RDMA/bnxt_re: Remove a redundant check inside bnxt_re_update_gid
    
    [ Upstream commit b989f90cef0af48aa5679b6a75476371705ec53c ]
    
    The NULL check inside bnxt_re_update_gid() always return false.  If
    sgid_tbl->tbl is not allocated, then dev_init would have failed.
    
    Fixes: 5fac5b1b297f ("RDMA/bnxt_re: Add vlan tag for untagged RoCE traffic when PFC is configured")
    Link: https://lore.kernel.org/r/1684478897-12247-5-git-send-email-selvin.xavier@broadcom.com
    Reviewed-by: Saravanan Vajravel <saravanan.vajravel@broadcom.com>
    Reviewed-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
    Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
    Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
    Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

RDMA/bnxt_re: Use unique names while registering interrupts [+ + +]
Author: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Date:   Thu May 18 23:48:13 2023 -0700

    RDMA/bnxt_re: Use unique names while registering interrupts
    
    [ Upstream commit ff2e4bfd162cf66a112a81509e419805add44d64 ]
    
    bnxt_re currently uses the names "bnxt_qplib_creq" and "bnxt_qplib_nq-0"
    while registering IRQs. There is no way to distinguish the IRQs of
    different device ports when there are multiple IB devices registered.
    This could make the scenarios worse where one want to pin IRQs of a device
    port to certain CPUs.
    
    Fixed the code to use unique names which has PCI BDF information while
    registering interrupts like: "bnxt_re-nq-0@pci:0000:65:00.0" and
    "bnxt_re-creq@pci:0000:65:00.1".
    
    Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
    Link: https://lore.kernel.org/r/1684478897-12247-4-git-send-email-selvin.xavier@broadcom.com
    Reviewed-by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
    Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
    Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

RDMA/bnxt_re: wraparound mbox producer index [+ + +]
Author: Kashyap Desai <kashyap.desai@broadcom.com>
Date:   Fri Jun 9 04:01:38 2023 -0700

    RDMA/bnxt_re: wraparound mbox producer index
    
    [ Upstream commit 0af91306e17ef3d18e5f100aa58aa787869118af ]
    
    Driver is not handling the wraparound of the mbox producer index correctly.
    Currently the wraparound happens once u32 max is reached.
    
    Bit 31 of the producer index register is special and should be set
    only once for the first command. Because the producer index overflow
    setting bit31 after a long time, FW goes to initialization sequence
    and this causes FW hang.
    
    Fix is to wraparound the mbox producer index once it reaches u16 max.
    
    Fixes: cee0c7bba486 ("RDMA/bnxt_re: Refactor command queue management code")
    Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
    Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
    Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
    Link: https://lore.kernel.org/r/1686308514-11996-2-git-send-email-selvin.xavier@broadcom.com
    Signed-off-by: Leon Romanovsky <leon@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
RDMA/hns: Fix hns_roce_table_get return value [+ + +]
Author: Chengchang Tang <tangchengchang@huawei.com>
Date:   Tue May 23 20:16:40 2023 +0800

    RDMA/hns: Fix hns_roce_table_get return value
    
    [ Upstream commit cf5b608fb0e369c473a8303cad6ddb386505e5b8 ]
    
    The return value of set_hem has been fixed to ENODEV, which will lead a
    diagnostic information missing.
    
    Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver")
    Link: https://lore.kernel.org/r/20230523121641.3132102-3-huangjunxian6@hisilicon.com
    Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
    Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
RDMA/irdma: avoid fortify-string warning in irdma_clr_wqes [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 23 13:18:45 2023 +0200

    RDMA/irdma: avoid fortify-string warning in irdma_clr_wqes
    
    [ Upstream commit b002760f877c0d91ecd3c78565b52f4bbac379dd ]
    
    Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") triggers a
    warning for fortified memset():
    
    In function 'fortify_memset_chk',
        inlined from 'irdma_clr_wqes' at drivers/infiniband/hw/irdma/uk.c:103:4:
    include/linux/fortify-string.h:493:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
      493 |                         __write_overflow_field(p_size_field, size);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    The problem here isthat the inner array only has four 8-byte elements, so
    clearing 4096 bytes overflows that. As this structure is part of an outer
    array, change the code to pass a pointer to the irdma_qp_quanta instead,
    and change the size argument for readability, matching the comment above
    it.
    
    Fixes: 551c46edc769 ("RDMA/irdma: Add user/kernel shared libraries")
    Link: https://lore.kernel.org/r/20230523111859.2197825-1-arnd@kernel.org
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Shiraz Saleem <shiraz.saleem@intel.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
RDMA/rxe: Add ibdev_dbg macros for rxe [+ + +]
Author: Bob Pearson <rpearsonhpe@gmail.com>
Date:   Thu Nov 3 12:09:59 2022 -0500

    RDMA/rxe: Add ibdev_dbg macros for rxe
    
    [ Upstream commit 4554bac48a8c464ff00136a64efe8847e4da4ea8 ]
    
    Add macros borrowed from siw to call dynamic debug macro ibdev_dbg.
    
    Link: https://lore.kernel.org/r/20221103171013.20659-2-rpearsonhpe@gmail.com
    Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Stable-dep-of: 425e1c9018fd ("RDMA/rxe: Fix access checks in rxe_check_bind_mw")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

RDMA/rxe: Fix access checks in rxe_check_bind_mw [+ + +]
Author: Bob Pearson <rpearsonhpe@gmail.com>
Date:   Tue May 30 17:13:32 2023 -0500

    RDMA/rxe: Fix access checks in rxe_check_bind_mw
    
    [ Upstream commit 425e1c9018fdf25cb4531606cc92d9d01a55534f ]
    
    The subroutine rxe_check_bind_mw() in rxe_mw.c performs checks on the mw
    access flags before they are set so they always succeed.  This patch
    instead checks the access flags passed in the send wqe.
    
    Fixes: 32a577b4c3a9 ("RDMA/rxe: Add support for bind MW work requests")
    Link: https://lore.kernel.org/r/20230530221334.89432-4-rpearsonhpe@gmail.com
    Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

RDMA/rxe: Replace pr_xxx by rxe_dbg_xxx in rxe_mw.c [+ + +]
Author: Bob Pearson <rpearsonhpe@gmail.com>
Date:   Thu Nov 3 12:10:03 2022 -0500

    RDMA/rxe: Replace pr_xxx by rxe_dbg_xxx in rxe_mw.c
    
    [ Upstream commit e8a87efdf87455454d0a14fd486c679769bfeee2 ]
    
    Replace calls to pr_xxx() int rxe_mw.c with rxe_dbg_xxx().
    
    Link: https://lore.kernel.org/r/20221103171013.20659-6-rpearsonhpe@gmail.com
    Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Stable-dep-of: 425e1c9018fd ("RDMA/rxe: Fix access checks in rxe_check_bind_mw")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
regulator: core: Fix more error checking for debugfs_create_dir() [+ + +]
Author: Geert Uytterhoeven <geert+renesas@glider.be>
Date:   Thu May 25 13:13:58 2023 +0200

    regulator: core: Fix more error checking for debugfs_create_dir()
    
    [ Upstream commit 2715bb11cfff964aa33946847f9527cfbd4874f5 ]
    
    In case of failure, debugfs_create_dir() does not return NULL, but an
    error pointer.  Most incorrect error checks were fixed, but the one in
    create_regulator() was forgotten.
    
    Fix the remaining error check.
    
    Fixes: 2bf1c45be3b8f3a3 ("regulator: Fix error checking for debugfs_create_dir")
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Link: https://lore.kernel.org/r/ee980a108b5854dd8ce3630f8f673e784e057d17.1685013051.git.geert+renesas@glider.be
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

regulator: core: Streamline debugfs operations [+ + +]
Author: Geert Uytterhoeven <geert+renesas@glider.be>
Date:   Thu May 25 13:13:59 2023 +0200

    regulator: core: Streamline debugfs operations
    
    [ Upstream commit 08880713ceec023dd94d634f1e8902728c385939 ]
    
    If CONFIG_DEBUG_FS is not set:
    
        regulator: Failed to create debugfs directory
        ...
        regulator-dummy: Failed to create debugfs directory
    
    As per the comments for debugfs_create_dir(), errors returned by this
    function should be expected, and ignored:
    
     * If debugfs is not enabled in the kernel, the value -%ENODEV will be
     * returned.
     *
     * NOTE: it's expected that most callers should _ignore_ the errors returned
     * by this function. Other debugfs functions handle the fact that the "dentry"
     * passed to them could be an error and they don't crash in that case.
     * Drivers should generally work fine even if debugfs fails to init anyway.
    
    Adhere to the debugfs spirit, and streamline all operations by:
      1. Demoting the importance of the printed error messages to debug
         level, like is already done in create_regulator(),
      2. Further ignoring any returned errors, as by design, all debugfs
         functions are no-ops when passed an error pointer.
    
    Fixes: 2bf1c45be3b8f3a3 ("regulator: Fix error checking for debugfs_create_dir")
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Link: https://lore.kernel.org/r/2f8bb6e113359ddfab7b59e4d4274bd4c06d6d0a.1685013051.git.geert+renesas@glider.be
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

regulator: tps65219: Fix matching interrupts for their regulators [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Sun May 7 16:46:56 2023 +0200

    regulator: tps65219: Fix matching interrupts for their regulators
    
    commit f050e56de80591fee55bedbdf5b6b998c740cd0c upstream.
    
    The driver's probe() first registers regulators in a loop and then in a
    second loop passes them as irq data to the interrupt handlers.  However
    the function to get the regulator for given name
    tps65219_get_rdev_by_name() was a no-op due to argument passed by value,
    not pointer, thus the second loop assigned always same value - from
    previous loop.  The interrupts, when fired, where executed with wrong
    data.  Compiler also noticed it:
    
      drivers/regulator/tps65219-regulator.c: In function ‘tps65219_get_rdev_by_name’:
      drivers/regulator/tps65219-regulator.c:292:60: error: parameter ‘dev’ set but not used [-Werror=unused-but-set-parameter]
    
    Fixes: c12ac5fc3e0a ("regulator: drivers: Add TI TPS65219 PMIC regulators support")
    Cc: <stable@vger.kernel.org
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org
    Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com
    Link: https://lore.kernel.org/r/20230507144656.192800-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Mark Brown <broonie@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Revert "drm/amd/display: edp do not add non-edid timings" [+ + +]
Author: Hersen Wu <hersenxs.wu@amd.com>
Date:   Mon Jun 26 13:40:58 2023 -0400

    Revert "drm/amd/display: edp do not add non-edid timings"
    
    commit d6149086b45e150c170beaa4546495fd1880724c upstream.
    
    This change causes regression when eDP and external display in mirror
    mode. When external display supports low resolution than eDP, use eDP
    timing to driver external display may cause corruption on external
    display.
    
    This reverts commit e749dd10e5f292061ad63d2b030194bf7d7d452c.
    
    Cc: stable@vger.kernel.org
    Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2655
    Signed-off-by: Hersen Wu <hersenxs.wu@amd.com>
    Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Revert "f2fs: fix potential corruption when moving a directory" [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Thu Jun 1 12:58:23 2023 +0200

    Revert "f2fs: fix potential corruption when moving a directory"
    
    commit cde3c9d7e2a359e337216855dcb333a19daaa436 upstream.
    
    This reverts commit d94772154e524b329a168678836745d2773a6e02. The
    locking is going to be provided by VFS.
    
    CC: Jaegeuk Kim <jaegeuk@kernel.org>
    CC: stable@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Message-Id: <20230601105830.13168-3-jack@suse.cz>
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection" [+ + +]
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Jun 15 11:30:35 2023 +0200

    Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection"
    
    [ Upstream commit df49f2a0ac4a34c0cb4b5c233fcfa0add644c43c ]
    
    This reverts commit edd60d24bd858cef165274e4cd6cab43bdc58d15.
    
    Heikki reports that this should not be a global flag just to work around
    one broken driver and should be fixed differently, so revert it.
    
    Reported-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Fixes: edd60d24bd85 ("usb: common: usb-conn-gpio: Set last role to unknown before initial detection")
    Link: https://lore.kernel.org/r/ZImE4L3YgABnCIsP@kuha.fi.intel.com
    Cc: Prashanth K <quic_prashk@quicinc.com>
    Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
riscv: move memblock_allow_resize() after linear mapping is ready [+ + +]
Author: Woody Zhang <woodylab@foxmail.com>
Date:   Wed Jun 14 21:19:07 2023 +0800

    riscv: move memblock_allow_resize() after linear mapping is ready
    
    [ Upstream commit 85fadc0d04119c2fe4a20287767ab904c6d21ba1 ]
    
    The initial memblock metadata is accessed from kernel image mapping. The
    regions arrays need to "reallocated" from memblock and accessed through
    linear mapping to cover more memblock regions. So the resizing should
    not be allowed until linear mapping is ready. Note that there are
    memblock allocations when building linear mapping.
    
    This patch is similar to 24cc61d8cb5a ("arm64: memblock: don't permit
    memblock resizing until linear mapping is up").
    
    In following log, many memblock regions are reserved before
    create_linear_mapping_page_table(). And then it triggered reallocation
    of memblock.reserved.regions and memcpy the old array in kernel image
    mapping to the new array in linear mapping which caused a page fault.
    
    [    0.000000] memblock_reserve: [0x00000000bf01f000-0x00000000bf01ffff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf021000-0x00000000bf021fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf023000-0x00000000bf023fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf025000-0x00000000bf025fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf027000-0x00000000bf027fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf029000-0x00000000bf029fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf02b000-0x00000000bf02bfff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf02d000-0x00000000bf02dfff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf02f000-0x00000000bf02ffff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] memblock_reserve: [0x00000000bf030000-0x00000000bf030fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6
    [    0.000000] OF: reserved mem: 0x0000000080000000..0x000000008007ffff (512 KiB) map non-reusable mmode_resv0@80000000
    [    0.000000] memblock_reserve: [0x00000000bf000000-0x00000000bf001fed] paging_init+0x19a/0x5ae
    [    0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c
    [    0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128
    [    0.000000] memblock: reserved is doubled to 256 at [0x000000017fffd000-0x000000017fffe7ff]
    [    0.000000] Unable to handle kernel paging request at virtual address ff600000ffffd000
    [    0.000000] Oops [#1]
    [    0.000000] Modules linked in:
    [    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.4.0-rc1-00011-g99a670b2069c #66
    [    0.000000] Hardware name: riscv-virtio,qemu (DT)
    [    0.000000] epc : __memcpy+0x60/0xf8
    [    0.000000]  ra : memblock_double_array+0x192/0x248
    [    0.000000] epc : ffffffff8081d214 ra : ffffffff80a3dfc0 sp : ffffffff81403bd0
    [    0.000000]  gp : ffffffff814fbb38 tp : ffffffff8140dac0 t0 : 0000000001600000
    [    0.000000]  t1 : 0000000000000000 t2 : 000000008f001000 s0 : ffffffff81403c60
    [    0.000000]  s1 : ffffffff80c0bc98 a0 : ff600000ffffd000 a1 : ffffffff80c0bcd8
    [    0.000000]  a2 : 0000000000000c00 a3 : ffffffff80c0c8d8 a4 : 0000000080000000
    [    0.000000]  a5 : 0000000000080000 a6 : 0000000000000000 a7 : 0000000080200000
    [    0.000000]  s2 : ff600000ffffd000 s3 : 0000000000002000 s4 : 0000000000000c00
    [    0.000000]  s5 : ffffffff80c0bc60 s6 : ffffffff80c0bcc8 s7 : 0000000000000000
    [    0.000000]  s8 : ffffffff814fd0a8 s9 : 000000017fffe7ff s10: 0000000000000000
    [    0.000000]  s11: 0000000000001000 t3 : 0000000000001000 t4 : 0000000000000000
    [    0.000000]  t5 : 000000008f003000 t6 : ff600000ffffd000
    [    0.000000] status: 0000000200000100 badaddr: ff600000ffffd000 cause: 000000000000000f
    [    0.000000] [<ffffffff8081d214>] __memcpy+0x60/0xf8
    [    0.000000] [<ffffffff80a3e1a2>] memblock_add_range.isra.14+0x12c/0x162
    [    0.000000] [<ffffffff80a3e36a>] memblock_reserve+0x6e/0x8c
    [    0.000000] [<ffffffff80a123fc>] memblock_alloc_range_nid+0xb8/0x128
    [    0.000000] [<ffffffff80a1256a>] memblock_phys_alloc_range+0x5e/0x6a
    [    0.000000] [<ffffffff80a04732>] alloc_pmd_fixmap+0x14/0x1c
    [    0.000000] [<ffffffff80a0475a>] alloc_p4d_fixmap+0xc/0x14
    [    0.000000] [<ffffffff80a04a36>] create_pgd_mapping+0x98/0x17c
    [    0.000000] [<ffffffff80a04e9e>] create_linear_mapping_range.constprop.10+0xe4/0x112
    [    0.000000] [<ffffffff80a05bb8>] paging_init+0x3ec/0x5ae
    [    0.000000] [<ffffffff80a03354>] setup_arch+0xb2/0x576
    [    0.000000] [<ffffffff80a00726>] start_kernel+0x72/0x57e
    [    0.000000] Code: b303 0285 b383 0305 be03 0385 be83 0405 bf03 0485 (b023) 00ef
    [    0.000000] ---[ end trace 0000000000000000 ]---
    [    0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
    [    0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
    
    Fixes: 671f9a3e2e24 ("RISC-V: Setup initial page tables in two stages")
    Signed-off-by: Woody Zhang <woodylab@foxmail.com>
    Tested-by: Song Shuai <songshuaishuai@tinylab.org>
    Link: https://lore.kernel.org/r/tencent_FBB94CE615C5CCE7701CD39C15CCE0EE9706@qq.com
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

riscv: uprobes: Restore thread.bad_cause [+ + +]
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date:   Sun Apr 23 09:42:26 2023 +0800

    riscv: uprobes: Restore thread.bad_cause
    
    [ Upstream commit 58b1294dd1d65bb62f08dddbf418f954210c2057 ]
    
    thread.bad_cause is saved in arch_uprobe_pre_xol(), it should be restored
    in arch_uprobe_{post,abort}_xol() accordingly, otherwise the save operation
    is meaningless, this change is similar with x86 and powerpc.
    
    Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
    Acked-by: Oleg Nesterov <oleg@redhat.com>
    Reviewed-by: Guo Ren <guoren@kernel.org>
    Fixes: 74784081aac8 ("riscv: Add uprobes supported")
    Link: https://lore.kernel.org/r/1682214146-3756-1-git-send-email-yangtiezhu@loongson.cn
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rtc: st-lpc: Release some resources in st_rtc_probe() in case of error [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Thu Jun 8 21:11:42 2023 +0200

    rtc: st-lpc: Release some resources in st_rtc_probe() in case of error
    
    [ Upstream commit 06c6e1b01d9261f03629cefd1f3553503291e6cf ]
    
    If an error occurs after clk_get(), the corresponding resources should be
    released.
    
    Use devm_clk_get() to fix it.
    
    Fixes: b5b2bdfc2893 ("rtc: st: Add new driver for ST's LPC RTC")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/866af6adbc7454a7b4505eb6c28fbdc86ccff39e.1686251455.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rtnetlink: extend RTEXT_FILTER_SKIP_STATS to IFLA_VF_INFO [+ + +]
Author: Edwin Peer <edwin.peer@broadcom.com>
Date:   Sun Jun 11 13:51:08 2023 +0300

    rtnetlink: extend RTEXT_FILTER_SKIP_STATS to IFLA_VF_INFO
    
    [ Upstream commit fa0e21fa44438a0e856d42224bfa24641d37b979 ]
    
    This filter already exists for excluding IPv6 SNMP stats. Extend its
    definition to also exclude IFLA_VF_INFO stats in RTM_GETLINK.
    
    This patch constitutes a partial fix for a netlink attribute nesting
    overflow bug in IFLA_VFINFO_LIST. By excluding the stats when the
    requester doesn't need them, the truncation of the VF list is avoided.
    
    While it was technically only the stats added in commit c5a9f6f0ab40
    ("net/core: Add drop counters to VF statistics") breaking the camel's
    back, the appreciable size of the stats data should never have been
    included without due consideration for the maximum number of VFs
    supported by PCI.
    
    Fixes: 3b766cd83232 ("net/core: Add reading VF statistics through the PF netdevice")
    Fixes: c5a9f6f0ab40 ("net/core: Add drop counters to VF statistics")
    Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>
    Cc: Edwin Peer <espeer@gmail.com>
    Signed-off-by: Gal Pressman <gal@nvidia.com>
    Link: https://lore.kernel.org/r/20230611105108.122586-1-gal@nvidia.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
s390/qeth: Fix vipa deletion [+ + +]
Author: Thorsten Winkler <twinkler@linux.ibm.com>
Date:   Tue Jul 4 16:41:21 2023 +0200

    s390/qeth: Fix vipa deletion
    
    [ Upstream commit 80de809bd35e2a8999edf9f5aaa2d8de18921f11 ]
    
    Change boolean parameter of function "qeth_l3_vipa_store" inside the
    "qeth_l3_dev_vipa_del4_store" function from "true" to "false" because
    "true" is used for adding a virtual ip address and "false" for deleting.
    
    Fixes: 2390166a6b45 ("s390/qeth: clean up L3 sysfs code")
    
    Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
    Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
    Signed-off-by: Thorsten Winkler <twinkler@linux.ibm.com>
    Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
samples/bpf: Fix buffer overflow in tcp_basertt [+ + +]
Author: Pengcheng Yang <yangpc@wangsu.com>
Date:   Fri May 5 16:50:58 2023 +0800

    samples/bpf: Fix buffer overflow in tcp_basertt
    
    [ Upstream commit f4dea9689c5fea3d07170c2cb0703e216f1a0922 ]
    
    Using sizeof(nv) or strlen(nv)+1 is correct.
    
    Fixes: c890063e4404 ("bpf: sample BPF_SOCKET_OPS_BASE_RTT program")
    Signed-off-by: Pengcheng Yang <yangpc@wangsu.com>
    Link: https://lore.kernel.org/r/1683276658-2860-1-git-send-email-yangpc@wangsu.com
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

samples/bpf: xdp1 and xdp2 reduce XDPBUFSIZE to 60 [+ + +]
Author: Jesper Dangaard Brouer <brouer@redhat.com>
Date:   Tue May 30 16:30:41 2023 +0200

    samples/bpf: xdp1 and xdp2 reduce XDPBUFSIZE to 60
    
    [ Upstream commit 60548b825b082cedf89b275c21c28b1e1d030e50 ]
    
    Default samples/pktgen scripts send 60 byte packets as hardware adds
    4-bytes FCS checksum, which fulfils minimum Ethernet 64 bytes frame
    size.
    
    XDP layer will not necessary have access to the 4-bytes FCS checksum.
    
    This leads to bpf_xdp_load_bytes() failing as it tries to copy 64-bytes
    from an XDP packet that only have 60-bytes available.
    
    Fixes: 772251742262 ("samples/bpf: fixup some tools to be able to support xdp multibuffer")
    Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Link: https://lore.kernel.org/bpf/168545704139.2996228.2516528552939485216.stgit@firesoul
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
scsi: 3w-xxxx: Add error handling for initialization failure in tw_probe() [+ + +]
Author: Yuchen Yang <u202114568@hust.edu.cn>
Date:   Fri May 5 22:12:55 2023 +0800

    scsi: 3w-xxxx: Add error handling for initialization failure in tw_probe()
    
    [ Upstream commit 2e2fe5ac695a00ab03cab4db1f4d6be07168ed9d ]
    
    Smatch complains that:
    
    tw_probe() warn: missing error code 'retval'
    
    This patch adds error checking to tw_probe() to handle initialization
    failure. If tw_reset_sequence() function returns a non-zero value, the
    function will return -EINVAL to indicate initialization failure.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Yuchen Yang <u202114568@hust.edu.cn>
    Link: https://lore.kernel.org/r/20230505141259.7730-1-u202114568@hust.edu.cn
    Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

scsi: lpfc: Revise NPIV ELS unsol rcv cmpl logic to drop ndlp based on nlp_state [+ + +]
Author: Justin Tee <justin.tee@broadcom.com>
Date:   Tue May 23 11:32:01 2023 -0700

    scsi: lpfc: Revise NPIV ELS unsol rcv cmpl logic to drop ndlp based on nlp_state
    
    [ Upstream commit 9914a3d033d3e1d836a43e93e9738e7dd44a096a ]
    
    When NPIV ports are zoned to devices that support both initiator and target
    mode, a remote device's initiated PRLI results in unintended final kref
    clean up of the device's ndlp structure.  This disrupts NPIV ports'
    discovery for target devices that support both initiator and target mode.
    
    Modify the NPIV lpfc_drop_node clause such that we allow the ndlp to live
    so long as it was in NLP_STE_PLOGI_ISSUE, NLP_STE_REG_LOGIN_ISSUE, or
    NLP_STE_PRLI_ISSUE nlp_state.  This allows lpfc's issued PRLI completion
    routine to determine if the final kref clean up should execute rather than
    a remote device's issued PRLI.
    
    Fixes: db651ec22524 ("scsi: lpfc: Correct used_rpi count when devloss tmo fires with no recovery")
    Signed-off-by: Justin Tee <justin.tee@broadcom.com>
    Link: https://lore.kernel.org/r/20230523183206.7728-5-justintee8345@gmail.com
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

scsi: qedf: Fix NULL dereference in error handling [+ + +]
Author: Jinhong Zhu <jinhongzhu@hust.edu.cn>
Date:   Tue May 2 22:00:21 2023 +0800

    scsi: qedf: Fix NULL dereference in error handling
    
    [ Upstream commit f025312b089474a54e4859f3453771314d9e3d4f ]
    
    Smatch reported:
    
    drivers/scsi/qedf/qedf_main.c:3056 qedf_alloc_global_queues()
    warn: missing unwind goto?
    
    At this point in the function, nothing has been allocated so we can return
    directly. In particular the "qedf->global_queues" have not been allocated
    so calling qedf_free_global_queues() will lead to a NULL dereference when
    we check if (!gl[i]) and "gl" is NULL.
    
    Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
    Signed-off-by: Jinhong Zhu <jinhongzhu@hust.edu.cn>
    Link: https://lore.kernel.org/r/20230502140022.2852-1-jinhongzhu@hust.edu.cn
    Reviewed-by: Dan Carpenter <error27@gmail.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
sctp: add bpf_bypass_getsockopt proto callback [+ + +]
Author: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Date:   Thu May 11 15:25:06 2023 +0200

    sctp: add bpf_bypass_getsockopt proto callback
    
    [ Upstream commit 2598619e012cee5273a2821441b9a051ad931249 ]
    
    Implement ->bpf_bypass_getsockopt proto callback and filter out
    SCTP_SOCKOPT_PEELOFF, SCTP_SOCKOPT_PEELOFF_FLAGS and SCTP_SOCKOPT_CONNECTX3
    socket options from running eBPF hook on them.
    
    SCTP_SOCKOPT_PEELOFF and SCTP_SOCKOPT_PEELOFF_FLAGS options do fd_install(),
    and if BPF_CGROUP_RUN_PROG_GETSOCKOPT hook returns an error after success of
    the original handler sctp_getsockopt(...), userspace will receive an error
    from getsockopt syscall and will be not aware that fd was successfully
    installed into a fdtable.
    
    As pointed by Marcelo Ricardo Leitner it seems reasonable to skip
    bpf getsockopt hook for SCTP_SOCKOPT_CONNECTX3 sockopt too.
    Because internaly, it triggers connect() and if error is masked
    then userspace will be confused.
    
    This patch was born as a result of discussion around a new SCM_PIDFD interface:
    https://lore.kernel.org/all/20230413133355.350571-3-aleksandr.mikhalitsyn@canonical.com/
    
    Fixes: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks")
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Christian Brauner <brauner@kernel.org>
    Cc: Stanislav Fomichev <sdf@google.com>
    Cc: Neil Horman <nhorman@tuxdriver.com>
    Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Cc: Xin Long <lucien.xin@gmail.com>
    Cc: linux-sctp@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Suggested-by: Stanislav Fomichev <sdf@google.com>
    Acked-by: Stanislav Fomichev <sdf@google.com>
    Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
    Acked-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

sctp: fix potential deadlock on &net->sctp.addr_wq_lock [+ + +]
Author: Chengfeng Ye <dg573847474@gmail.com>
Date:   Tue Jun 27 12:03:40 2023 +0000

    sctp: fix potential deadlock on &net->sctp.addr_wq_lock
    
    [ Upstream commit 6feb37b3b06e9049e20dcf7e23998f92c9c5be9a ]
    
    As &net->sctp.addr_wq_lock is also acquired by the timer
    sctp_addr_wq_timeout_handler() in protocal.c, the same lock acquisition
    at sctp_auto_asconf_init() seems should disable irq since it is called
    from sctp_accept() under process context.
    
    Possible deadlock scenario:
    sctp_accept()
        -> sctp_sock_migrate()
        -> sctp_auto_asconf_init()
        -> spin_lock(&net->sctp.addr_wq_lock)
            <timer interrupt>
            -> sctp_addr_wq_timeout_handler()
            -> spin_lock_bh(&net->sctp.addr_wq_lock); (deadlock here)
    
    This flaw was found using an experimental static analysis tool we are
    developing for irq-related deadlock.
    
    The tentative patch fix the potential deadlock by spin_lock_bh().
    
    Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
    Fixes: 34e5b0118685 ("sctp: delay auto_asconf init until binding the first addr")
    Acked-by: Xin Long <lucien.xin@gmail.com>
    Link: https://lore.kernel.org/r/20230627120340.19432-1-dg573847474@gmail.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
selftests/bpf: Do not use sign-file as testcase [+ + +]
Author: Alexey Gladkov <legion@kernel.org>
Date:   Wed May 17 11:49:46 2023 +0200

    selftests/bpf: Do not use sign-file as testcase
    
    [ Upstream commit f04a32b2c5b539e3c097cb5c7c1df12a8f4a0cf0 ]
    
    The sign-file utility (from scripts/) is used in prog_tests/verify_pkcs7_sig.c,
    but the utility should not be called as a test. Executing this utility produces
    the following error:
    
      selftests: /linux/tools/testing/selftests/bpf: urandom_read
      ok 16 selftests: /linux/tools/testing/selftests/bpf: urandom_read
    
      selftests: /linux/tools/testing/selftests/bpf: sign-file
      not ok 17 selftests: /linux/tools/testing/selftests/bpf: sign-file # exit=2
    
    Also, urandom_read is mistakenly used as a test. It does not lead to an error,
    but should be moved over to TEST_GEN_FILES as well. The empty TEST_CUSTOM_PROGS
    can then be removed.
    
    Fixes: fc97590668ae ("selftests/bpf: Add test for bpf_verify_pkcs7_signature() kfunc")
    Signed-off-by: Alexey Gladkov <legion@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com>
    Acked-by: Stanislav Fomichev <sdf@google.com>
    Link: https://lore.kernel.org/bpf/ZEuWFk3QyML9y5QQ@example.org
    Link: https://lore.kernel.org/bpf/88e3ab23029d726a2703adcf6af8356f7a2d3483.1684316821.git.legion@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

selftests/bpf: Fix check_mtu using wrong variable type [+ + +]
Author: Jesper Dangaard Brouer <brouer@redhat.com>
Date:   Tue Jun 6 13:30:47 2023 +0200

    selftests/bpf: Fix check_mtu using wrong variable type
    
    [ Upstream commit 095641817e1bf6aa2560e025e47575188ee3edaf ]
    
    Dan Carpenter found via Smatch static checker, that unsigned 'mtu_lo' is
    never less than zero.
    
    Variable mtu_lo should have been an 'int', because read_mtu_device_lo()
    uses minus as error indications.
    
    Fixes: b62eba563229 ("selftests/bpf: Tests using bpf_check_mtu BPF-helper")
    Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
    Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Link: https://lore.kernel.org/bpf/168605104733.3636467.17945947801753092590.stgit@firesoul
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
selftests: cgroup: fix unexpected failure on test_memcg_low [+ + +]
Author: Haifeng Xu <haifeng.xu@shopee.com>
Date:   Mon May 22 09:52:33 2023 +0000

    selftests: cgroup: fix unexpected failure on test_memcg_low
    
    [ Upstream commit 19ab365762c6cc39dfdee9e13ab0d12fe4b5540d ]
    
    Since commit f079a020ba95 ("selftests: memcg: factor out common parts of
    memory.{low,min} tests"), the value used in second alloc_anon has changed
    from 148M to 170M.  Because memory.low allows reclaiming page cache in
    child cgroups, so the memory.current is close to 30M instead of 50M.
    Therefore, adjust the expected value of parent cgroup.
    
    Link: https://lkml.kernel.org/r/20230522095233.4246-2-haifeng.xu@shopee.com
    Fixes: f079a020ba95 ("selftests: memcg: factor out common parts of memory.{low,min} tests")
    Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Roman Gushchin <roman.gushchin@linux.dev>
    Cc: Shakeel Butt <shakeelb@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

selftests: rtnetlink: remove netdevsim device after ipsec offload test [+ + +]
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Thu Jun 22 23:03:34 2023 +0200

    selftests: rtnetlink: remove netdevsim device after ipsec offload test
    
    [ Upstream commit 5f789f103671fec3733ebe756e56adf15c90c21d ]
    
    On systems where netdevsim is built-in or loaded before the test
    starts, kci_test_ipsec_offload doesn't remove the netdevsim device it
    created during the test.
    
    Fixes: e05b2d141fef ("netdevsim: move netdev creation/destruction to dev probe")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Link: https://lore.kernel.org/r/e1cb94f4f82f4eca4a444feec4488a1323396357.1687466906.git.sd@queasysnail.net
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
serial: 8250: lock port for stop_rx() in omap8250_irq() [+ + +]
Author: John Ogness <john.ogness@linutronix.de>
Date:   Thu May 25 11:37:54 2023 +0206

    serial: 8250: lock port for stop_rx() in omap8250_irq()
    
    [ Upstream commit ca73a892c5bec4b08a2fa22b3015e98ed905abb7 ]
    
    The uarts_ops stop_rx() callback expects that the port->lock is
    taken and interrupts are disabled.
    
    Fixes: 1fe0e1fa3209 ("serial: 8250_omap: Handle optional overrun-throttle-ms property")
    Signed-off-by: John Ogness <john.ogness@linutronix.de>
    Reviewed-by: Tony Lindgren <tony@atomide.com>
    Link: https://lore.kernel.org/r/20230525093159.223817-4-john.ogness@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: 8250: lock port for UART_IER access in omap8250_irq() [+ + +]
Author: John Ogness <john.ogness@linutronix.de>
Date:   Thu May 25 11:37:58 2023 +0206

    serial: 8250: lock port for UART_IER access in omap8250_irq()
    
    [ Upstream commit 25614735a647693c1260f253dc3ab32127697806 ]
    
    omap8250_irq() accesses UART_IER. This register is modified twice
    by each console write (serial8250_console_write()) under the port
    lock. omap8250_irq() must also take the port lock to guanentee
    synchronized access to UART_IER.
    
    Since the port lock is already being taken for the stop_rx() callback
    and since it is safe to call cancel_delayed_work() while holding the
    port lock, simply extend the port lock region to include UART_IER
    access.
    
    Fixes: 1fe0e1fa3209 ("serial: 8250_omap: Handle optional overrun-throttle-ms property")
    Signed-off-by: John Ogness <john.ogness@linutronix.de>
    Reviewed-by: Tony Lindgren <tony@atomide.com>
    Link: https://lore.kernel.org/r/20230525093159.223817-8-john.ogness@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: 8250: omap: Fix freeing of resources on failed register [+ + +]
Author: Tony Lindgren <tony@atomide.com>
Date:   Mon May 8 11:20:11 2023 +0300

    serial: 8250: omap: Fix freeing of resources on failed register
    
    [ Upstream commit b9ab22c2bc8652324a803b3e2be69838920b4025 ]
    
    If serial8250_register_8250_port() fails, the SoC can hang as the
    deferred PMQoS work will still run as is not flushed and removed.
    
    Fixes: 61929cf0169d ("tty: serial: Add 8250-core based omap driver")
    Signed-off-by: Tony Lindgren <tony@atomide.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20230508082014.23083-2-tony@atomide.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: 8250_omap: Use force_suspend and resume for system suspend [+ + +]
Author: Tony Lindgren <tony@atomide.com>
Date:   Wed Jun 14 07:59:19 2023 +0300

    serial: 8250_omap: Use force_suspend and resume for system suspend
    
    [ Upstream commit 20a41a62618df85f3a2981008edec5cadd785e0a ]
    
    We should not rely on autosuspend timeout for system suspend. Instead,
    let's use force_suspend and force_resume functions. Otherwise the serial
    port controller device may not be idled on suspend.
    
    As we are doing a register write on suspend to configure the serial port,
    we still need to runtime PM resume the port on suspend.
    
    While at it, let's switch to pm_runtime_resume_and_get() and check for
    errors returned. And let's add the missing line break before return to the
    suspend function while at it.
    
    Fixes: 09d8b2bdbc5c ("serial: 8250: omap: Provide ability to enable/disable UART as wakeup source")
    Signed-off-by: Tony Lindgren <tony@atomide.com>
    Tested-by: Dhruva Gole <d-gole@ti.com>
    Message-ID: <20230614045922.4798-1-tony@atomide.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: core: lock port for start_rx() in uart_resume_port() [+ + +]
Author: John Ogness <john.ogness@linutronix.de>
Date:   Thu May 25 11:37:55 2023 +0206

    serial: core: lock port for start_rx() in uart_resume_port()
    
    [ Upstream commit 51e45fba14bf08b66bca764a083c7f2e2ff62f01 ]
    
    The only user of the start_rx() callback (qcom_geni) directly calls
    its own stop_rx() callback. Since stop_rx() requires that the
    port->lock is taken and interrupts are disabled, the start_rx()
    callback has the same requirement.
    
    Fixes: cfab87c2c271 ("serial: core: Introduce callback for start_rx and do stop_rx in suspend only if this callback implementation is present.")
    Signed-off-by: John Ogness <john.ogness@linutronix.de>
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Link: https://lore.kernel.org/r/20230525093159.223817-5-john.ogness@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: core: lock port for stop_rx() in uart_suspend_port() [+ + +]
Author: John Ogness <john.ogness@linutronix.de>
Date:   Thu May 25 11:37:53 2023 +0206

    serial: core: lock port for stop_rx() in uart_suspend_port()
    
    [ Upstream commit abcb0cf1f5b2d99b1d117a4dbce334120e358d6d ]
    
    The uarts_ops stop_rx() callback expects that the port->lock is
    taken and interrupts are disabled.
    
    Fixes: c9d2325cdb92 ("serial: core: Do stop_rx in suspend path for console if console_suspend is disabled")
    Signed-off-by: John Ogness <john.ogness@linutronix.de>
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Link: https://lore.kernel.org/r/20230525093159.223817-3-john.ogness@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
sfc: fix crash when reading stats while NIC is resetting [+ + +]
Author: Edward Cree <ecree.xilinx@gmail.com>
Date:   Fri Jun 23 15:34:48 2023 +0100

    sfc: fix crash when reading stats while NIC is resetting
    
    [ Upstream commit d1b355438b8325a486f087e506d412c4e852f37b ]
    
    efx_net_stats() (.ndo_get_stats64) can be called during an ethtool
     selftest, during which time nic_data->mc_stats is NULL as the NIC has
     been fini'd.  In this case do not attempt to fetch the latest stats
     from the hardware, else we will crash on a NULL dereference:
        BUG: kernel NULL pointer dereference, address: 0000000000000038
        RIP efx_nic_update_stats
        abridged calltrace:
        efx_ef10_update_stats_pf
        efx_net_stats
        dev_get_stats
        dev_seq_printf_stats
    Skipping the read is safe, we will simply give out stale stats.
    To ensure that the free in efx_ef10_fini_nic() does not race against
     efx_ef10_update_stats_pf(), which could cause a TOCTTOU bug, take the
     efx->stats_lock in fini_nic (it is already held across update_stats).
    
    Fixes: d3142c193dca ("sfc: refactor EF10 stats handling")
    Reviewed-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>
    Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
sh: Avoid using IRQ0 on SH3 and SH4 [+ + +]
Author: Sergey Shtylyov <s.shtylyov@omp.ru>
Date:   Thu Jun 1 23:22:17 2023 +0300

    sh: Avoid using IRQ0 on SH3 and SH4
    
    [ Upstream commit a8ac2961148e8c720dc760f2e06627cd5c55a154 ]
    
    IRQ0 is no longer returned by platform_get_irq() and its ilk -- they now
    return -EINVAL instead.  However, the kernel code supporting SH3/4-based
    SoCs still maps the IRQ #s starting at 0 -- modify that code to start the
    IRQ #s from 16 instead.
    
    The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they
    indeed are using IRQ0 for the SMSC911x compatible Ethernet chip.
    
    Fixes: ce753ad1549c ("platform: finally disallow IRQ0 in platform_get_irq() and its ilk")
    Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Link: https://lore.kernel.org/r/71105dbf-cdb0-72e1-f9eb-eeda8e321696@omp.ru
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

sh: dma: Fix DMA channel offset calculation [+ + +]
Author: Artur Rojek <contact@artur-rojek.eu>
Date:   Sat May 27 18:44:50 2023 +0200

    sh: dma: Fix DMA channel offset calculation
    
    [ Upstream commit e82e47584847129a20b8c9f4a1dcde09374fb0e0 ]
    
    Various SoCs of the SH3, SH4 and SH4A family, which use this driver,
    feature a differing number of DMA channels, which can be distributed
    between up to two DMAC modules. The existing implementation fails to
    correctly accommodate for all those variations, resulting in wrong
    channel offset calculations and leading to kernel panics.
    
    Rewrite dma_base_addr() in order to properly calculate channel offsets
    in a DMAC module. Fix dmaor_read_reg() and dmaor_write_reg(), so that
    the correct DMAC module base is selected for the DMAOR register.
    
    Fixes: 7f47c7189b3e8f19 ("sh: dma: More legacy cpu dma chainsawing.")
    Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Link: https://lore.kernel.org/r/20230527164452.64797-2-contact@artur-rojek.eu
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

sh: hd64461: Handle virq offset for offchip IRQ base and HD64461 IRQ [+ + +]
Author: Artur Rojek <contact@artur-rojek.eu>
Date:   Tue Jul 11 01:31:32 2023 +0200

    sh: hd64461: Handle virq offset for offchip IRQ base and HD64461 IRQ
    
    commit 7c28a35e19fafa1d3b367bcd3ec4021427a9397b upstream.
    
    A recent change to start counting SuperH IRQ #s from 16 breaks support
    for the Hitachi HD64461 companion chip.
    
    Move the offchip IRQ base and HD64461 IRQ # by 16 in order to
    accommodate for the new virq numbering rules.
    
    Fixes: a8ac2961148e ("sh: Avoid using IRQ0 on SH3 and SH4")
    Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Link: https://lore.kernel.org/r/20230710233132.69734-1-contact@artur-rojek.eu
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

sh: j2: Use ioremap() to translate device tree address into kernel memory [+ + +]
Author: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date:   Wed May 3 14:57:41 2023 +0200

    sh: j2: Use ioremap() to translate device tree address into kernel memory
    
    [ Upstream commit bc9d1f0cecd2407cfb2364a7d4be2f52d1d46a9d ]
    
    Addresses the following warning when building j2_defconfig:
    
    arch/sh/kernel/cpu/sh2/probe.c: In function 'scan_cache':
    arch/sh/kernel/cpu/sh2/probe.c:24:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       24 |  j2_ccr_base = (u32 __iomem *)of_flat_dt_translate_address(node);
          |
    
    Fixes: 5a846abad07f ("sh: add support for J-Core J2 processor")
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Tested-by: Rob Landley <rob@landley.net>
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Link: https://lore.kernel.org/r/20230503125746.331835-1-glaubitz@physik.fu-berlin.de
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

sh: mach-dreamcast: Handle virq offset in cascaded IRQ demux [+ + +]
Author: Geert Uytterhoeven <geert+renesas@glider.be>
Date:   Sun Jul 9 15:10:43 2023 +0200

    sh: mach-dreamcast: Handle virq offset in cascaded IRQ demux
    
    commit 3d20f7a6eb76afdf9d4ad9cb864c2e2da9c38e1f upstream.
    
    Take into account the virq offset when translating cascaded interrupts.
    
    Fixes: a8ac2961148e8c72 ("sh: Avoid using IRQ0 on SH3 and SH4")
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Link: https://lore.kernel.org/r/7d0cb246c9f1cd24bb1f637ec5cb67e799a4c3b8.1688908227.git.geert+renesas@glider.be
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

sh: mach-highlander: Handle virq offset in cascaded IRL demux [+ + +]
Author: Geert Uytterhoeven <geert+renesas@glider.be>
Date:   Sun Jul 9 15:10:23 2023 +0200

    sh: mach-highlander: Handle virq offset in cascaded IRL demux
    
    commit a2601b8d8f077368c6d113b4d496559415c6d495 upstream.
    
    Take into account the virq offset when translating cascaded IRL
    interrupts.
    
    Fixes: a8ac2961148e8c72 ("sh: Avoid using IRQ0 on SH3 and SH4")
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Link: https://lore.kernel.org/r/4fcb0d08a2b372431c41e04312742dc9e41e1be4.1688908186.git.geert+renesas@glider.be
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

sh: mach-r2d: Handle virq offset in cascaded IRL demux [+ + +]
Author: Geert Uytterhoeven <geert+renesas@glider.be>
Date:   Sun Jul 9 13:15:49 2023 +0200

    sh: mach-r2d: Handle virq offset in cascaded IRL demux
    
    commit ab8aa4f0956d2e0fb8344deadb823ef743581795 upstream.
    
    When booting rts7751r2dplus_defconfig on QEMU, the system hangs due to
    an interrupt storm on IRQ 20.  IRQ 20 aka event 0x280 is a cascaded IRL
    interrupt, which maps to IRQ_VOYAGER, the interrupt used by the Silicon
    Motion SM501 multimedia companion chip.  As rts7751r2d_irq_demux() does
    not take into account the new virq offset, the interrupt is no longer
    translated, leading to an unhandled interrupt.
    
    Fix this by taking into account the virq offset when translating
    cascaded IRL interrupts.
    
    Fixes: a8ac2961148e8c72 ("sh: Avoid using IRQ0 on SH3 and SH4")
    Reported-by: Guenter Roeck <linux@roeck-us.net>
    Closes: https://lore.kernel.org/r/fbfea3ad-d327-4ad5-ac9c-648c7ca3fe1f@roeck-us.net
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/2c99d5df41c40691f6c407b7b6a040d406bc81ac.1688901306.git.geert+renesas@glider.be
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
shmem: use ramfs_kill_sb() for kill_sb method of ramfs-based tmpfs [+ + +]
Author: Roberto Sassu <roberto.sassu@huawei.com>
Date:   Wed Jun 7 18:15:23 2023 +0200

    shmem: use ramfs_kill_sb() for kill_sb method of ramfs-based tmpfs
    
    commit 36ce9d76b0a93bae799e27e4f5ac35478c676592 upstream.
    
    As the ramfs-based tmpfs uses ramfs_init_fs_context() for the
    init_fs_context method, which allocates fc->s_fs_info, use ramfs_kill_sb()
    to free it and avoid a memory leak.
    
    Link: https://lkml.kernel.org/r/20230607161523.2876433-1-roberto.sassu@huaweicloud.com
    Fixes: c3b1b1cbf002 ("ramfs: add support for "mode=" mount option")
    Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: David Howells <dhowells@redhat.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
SMB3: Do not send lease break acknowledgment if all file handles have been closed [+ + +]
Author: Bharath SM <bharathsm@microsoft.com>
Date:   Sun Jun 18 19:02:24 2023 +0000

    SMB3: Do not send lease break acknowledgment if all file handles have been closed
    
    [ Upstream commit da787d5b74983f7525d1eb4b9c0b4aff2821511a ]
    
    In case if all existing file handles are deferred handles and if all of
    them gets closed due to handle lease break then we dont need to send
    lease break acknowledgment to server, because last handle close will be
    considered as lease break ack.
    After closing deferred handels, we check for openfile list of inode,
    if its empty then we skip sending lease break ack.
    
    Fixes: 59a556aebc43 ("SMB3: drop reference to cfile before sending oplock break")
    Reviewed-by: Tom Talpey <tom@talpey.com>
    Signed-off-by: Bharath SM <bharathsm@microsoft.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
smb: client: fix broken file attrs with nodfs mounts [+ + +]
Author: Paulo Alcantara <pc@manguebit.com>
Date:   Tue Jun 27 21:24:49 2023 -0300

    smb: client: fix broken file attrs with nodfs mounts
    
    [ Upstream commit d439b29057e26464120fc6c18f97433aa003b5fe ]
    
    *_get_inode_info() functions expect -EREMOTE when query path info
    calls find a DFS link, regardless whether !CONFIG_CIFS_DFS_UPCALL or
    'nodfs' mount option.  Otherwise, those files will miss the fake DFS
    file attributes.
    
    Before patch
    
      $ mount.cifs //srv/dfs /mnt/1 -o ...,nodfs
      $ ls -l /mnt/1
      ls: cannot access '/mnt/1/link': Operation not supported
      total 0
      -rwxr-xr-x 1 root root 0 Jul 26  2022 dfstest2_file1.txt
      drwxr-xr-x 2 root root 0 Aug  8  2022 dir1
      d????????? ? ?    ?    ?            ? link
    
    After patch
    
      $ mount.cifs //srv/dfs /mnt/1 -o ...,nodfs
      $ ls -l /mnt/1
      total 0
      -rwxr-xr-x 1 root root 0 Jul 26  2022 dfstest2_file1.txt
      drwxr-xr-x 2 root root 0 Aug  8  2022 dir1
      drwx--x--x 2 root root 0 Jun 26 20:29 link
    
    Fixes: c877ce47e137 ("cifs: reduce roundtrips on create/qinfo requests")
    Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
soc/fsl/qe: fix usb.c build errors [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Sun May 21 15:52:16 2023 -0700

    soc/fsl/qe: fix usb.c build errors
    
    [ Upstream commit 7b1a78babd0d2cd27aa07255dee0c2d7ac0f31e3 ]
    
    Fix build errors in soc/fsl/qe/usb.c when QUICC_ENGINE is not set.
    This happens when PPC_EP88XC is set, which selects CPM1 & CPM.
    When CPM is set, USB_FSL_QE can be set without QUICC_ENGINE
    being set. When USB_FSL_QE is set, QE_USB deafults to y, which
    causes build errors when QUICC_ENGINE is not set. Making
    QE_USB depend on QUICC_ENGINE prevents QE_USB from defaulting to y.
    
    Fixes these build errors:
    
    drivers/soc/fsl/qe/usb.o: in function `qe_usb_clock_set':
    usb.c:(.text+0x1e): undefined reference to `qe_immr'
    powerpc-linux-ld: usb.c:(.text+0x2a): undefined reference to `qe_immr'
    powerpc-linux-ld: usb.c:(.text+0xbc): undefined reference to `qe_setbrg'
    powerpc-linux-ld: usb.c:(.text+0xca): undefined reference to `cmxgcr_lock'
    powerpc-linux-ld: usb.c:(.text+0xce): undefined reference to `cmxgcr_lock'
    
    Fixes: 5e41486c408e ("powerpc/QE: add support for QE USB clocks routing")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Reported-by: kernel test robot <lkp@intel.com>
    Link: https://lore.kernel.org/all/202301101500.pillNv6R-lkp@intel.com/
    Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
    Cc: Leo Li <leoyang.li@nxp.com>
    Cc: Masahiro Yamada <masahiroy@kernel.org>
    Cc: Nicolas Schier <nicolas@fjasle.eu>
    Cc: Qiang Zhao <qiang.zhao@nxp.com>
    Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: Kumar Gala <galak@kernel.crashing.org>
    Acked-by: Nicolas Schier <nicolas@jasle.eu>
    Signed-off-by: Li Yang <leoyang.li@nxp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
soc: mediatek: SVS: Fix MT8192 GPU node name [+ + +]
Author: Chen-Yu Tsai <wenst@chromium.org>
Date:   Wed May 31 14:35:30 2023 +0800

    soc: mediatek: SVS: Fix MT8192 GPU node name
    
    [ Upstream commit 95094495401bdf6a0649d220dfd095e6079b5e39 ]
    
    Device tree node names should be generic. The planned device node name
    for the GPU, according to the bindings and posted DT changes, is "gpu",
    not "mali".
    
    Fix the GPU node name in the SVS driver to follow.
    
    Fixes: 0bbb09b2af9d ("soc: mediatek: SVS: add mt8192 SVS GPU driver")
    Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
    Link: https://lore.kernel.org/r/20230531063532.2240038-1-wenst@chromium.org
    Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
spi: bcm-qspi: return error if neither hif_mspi nor mspi is available [+ + +]
Author: Jonas Gorski <jonas.gorski@gmail.com>
Date:   Thu Jun 29 15:43:05 2023 +0200

    spi: bcm-qspi: return error if neither hif_mspi nor mspi is available
    
    [ Upstream commit 7c1f23ad34fcdace50275a6aa1e1969b41c6233f ]
    
    If neither a "hif_mspi" nor "mspi" resource is present, the driver will
    just early exit in probe but still return success. Apart from not doing
    anything meaningful, this would then also lead to a null pointer access
    on removal, as platform_get_drvdata() would return NULL, which it would
    then try to dereference when trying to unregister the spi master.
    
    Fix this by unconditionally calling devm_ioremap_resource(), as it can
    handle a NULL res and will then return a viable ERR_PTR() if we get one.
    
    The "return 0;" was previously a "goto qspi_resource_err;" where then
    ret was returned, but since ret was still initialized to 0 at this place
    this was a valid conversion in 63c5395bb7a9 ("spi: bcm-qspi: Fix
    use-after-free on unbind"). The issue was not introduced by this commit,
    only made more obvious.
    
    Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver")
    Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
    Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com>
    Link: https://lore.kernel.org/r/20230629134306.95823-1-jonas.gorski@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

spi: dw: Round of n_bytes to power of 2 [+ + +]
Author: Joy Chakraborty <joychakr@google.com>
Date:   Fri May 12 10:47:45 2023 +0000

    spi: dw: Round of n_bytes to power of 2
    
    [ Upstream commit 9f34baf67e4d08908fd94ff29c825bb673295336 ]
    
    n_bytes variable in the driver represents the number of bytes per word
    that needs to be sent/copied to fifo. Bits/word can be between 8 and 32
    bits from the client but in memory they are a power of 2, same is mentioned
    in spi.h header:
    "
     * @bits_per_word: Data transfers involve one or more words; word sizes
     *      like eight or 12 bits are common.  In-memory wordsizes are
     *      powers of two bytes (e.g. 20 bit samples use 32 bits).
     *      This may be changed by the device's driver, or left at the
     *      default (0) indicating protocol words are eight bit bytes.
     *      The spi_transfer.bits_per_word can override this for each transfer.
    "
    
    Hence, round of n_bytes to a power of 2 to avoid values like 3 which
    would generate unalligned/odd accesses to memory/fifo.
    
    * tested on Baikal-T1 based system with DW SPI-looped back interface
    transferring a chunk of data with DFS:8,12,16.
    
    Fixes: a51acc2400d4 ("spi: dw: Add support for 32-bits max xfer size")
    Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com
    Signed-off-by: Joy Chakraborty <joychakr@google.com
    Reviewed-by: Serge Semin <fancer.lancer@gmail.com
    Tested-by: Serge Semin <fancer.lancer@gmail.com
    Link: https://lore.kernel.org/r/20230512104746.1797865-4-joychakr@google.com
    Signed-off-by: Mark Brown <broonie@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

spi: spi-geni-qcom: Correct CS_TOGGLE bit in SPI_TRANS_CFG [+ + +]
Author: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com>
Date:   Tue Apr 25 14:12:08 2023 +0530

    spi: spi-geni-qcom: Correct CS_TOGGLE bit in SPI_TRANS_CFG
    
    [ Upstream commit 5fd7c99ecf45c8ee8a9b1268f0ffc91cc6271da2 ]
    
    The CS_TOGGLE bit when set is supposed to instruct FW to
    toggle CS line between words. The driver with intent of
    disabling this behaviour has been unsetting BIT(0). This has
    not caused any trouble so far because the original BIT(1)
    is untouched and BIT(0) likely wasn't being used.
    
    Correct this to prevent a potential future bug.
    
    Signed-off-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com
    Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org
    Fixes: 561de45f72bd ("spi: spi-geni-qcom: Add SPI driver support for GENI based QUP")
    Reviewed-by: Douglas Anderson <dianders@chromium.org
    Link: https://lore.kernel.org/r/1682412128-1913-1-git-send-email-quic_vnivarth@quicinc.com
    Signed-off-by: Mark Brown <broonie@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

spi: spi-geni-qcom: enable SPI_CONTROLLER_MUST_TX for GPI DMA mode [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Thu Jun 29 12:58:47 2023 +0300

    spi: spi-geni-qcom: enable SPI_CONTROLLER_MUST_TX for GPI DMA mode
    
    [ Upstream commit d10005837be83906bbd2078c3b4f9dfcbd6c95b6 ]
    
    The GPI DMA mode requires for TX DMA to be prepared. Force SPI core to
    provide TX buffer even if the caller didn't provide one by setting the
    SPI_CONTROLLER_MUST_TX flag.
    
    Fixes: b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma")
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Link: https://lore.kernel.org/r/20230629095847.3648597-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
staging: vchiq_arm: mark vchiq_platform_init() static [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 16 22:25:55 2023 +0200

    staging: vchiq_arm: mark vchiq_platform_init() static
    
    [ Upstream commit e152c58d7a48194d6b530d8e004d650fd01568b6 ]
    
    This function has no callers from other files, and the declaration
    was removed a while ago, causing a W=1 warning:
    
    drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for 'vchiq_platform_init'
    
    Marking it static solves this problem but introduces a new warning
    since gcc determines that 'g_fragments_base' is never initialized
    in some kernel configurations:
    
    In file included from include/linux/string.h:254,
                     from include/linux/bitmap.h:11,
                     from include/linux/cpumask.h:12,
                     from include/linux/mm_types_task.h:14,
                     from include/linux/mm_types.h:5,
                     from include/linux/buildid.h:5,
                     from include/linux/module.h:14,
                     from drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:8:
    In function 'memcpy_to_page',
        inlined from 'free_pagelist' at drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:433:4:
    include/linux/fortify-string.h:57:33: error: argument 2 null where non-null expected [-Werror=nonnull]
    include/linux/highmem.h:427:9: note: in expansion of macro 'memcpy'
      427 |         memcpy(to + offset, from, len);
          |         ^~~~~~
    
    Add a NULL pointer check for this in addition to the static annotation
    to avoid both.
    
    Fixes: 89cc4218f640 ("staging: vchiq_arm: drop unnecessary declarations")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
    Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
    Link: https://lore.kernel.org/r/20230516202603.560554-1-arnd@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
SUNRPC: Fix UAF in svc_tcp_listen_data_ready() [+ + +]
Author: Ding Hui <dinghui@sangfor.com.cn>
Date:   Mon May 15 10:13:07 2023 +0800

    SUNRPC: Fix UAF in svc_tcp_listen_data_ready()
    
    commit fc80fc2d4e39137869da3150ee169b40bf879287 upstream.
    
    After the listener svc_sock is freed, and before invoking svc_tcp_accept()
    for the established child sock, there is a window that the newsock
    retaining a freed listener svc_sock in sk_user_data which cloning from
    parent. In the race window, if data is received on the newsock, we will
    observe use-after-free report in svc_tcp_listen_data_ready().
    
    Reproduce by two tasks:
    
    1. while :; do rpc.nfsd 0 ; rpc.nfsd; done
    2. while :; do echo "" | ncat -4 127.0.0.1 2049 ; done
    
    KASAN report:
    
      ==================================================================
      BUG: KASAN: slab-use-after-free in svc_tcp_listen_data_ready+0x1cf/0x1f0 [sunrpc]
      Read of size 8 at addr ffff888139d96228 by task nc/102553
      CPU: 7 PID: 102553 Comm: nc Not tainted 6.3.0+ #18
      Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020
      Call Trace:
       <IRQ>
       dump_stack_lvl+0x33/0x50
       print_address_description.constprop.0+0x27/0x310
       print_report+0x3e/0x70
       kasan_report+0xae/0xe0
       svc_tcp_listen_data_ready+0x1cf/0x1f0 [sunrpc]
       tcp_data_queue+0x9f4/0x20e0
       tcp_rcv_established+0x666/0x1f60
       tcp_v4_do_rcv+0x51c/0x850
       tcp_v4_rcv+0x23fc/0x2e80
       ip_protocol_deliver_rcu+0x62/0x300
       ip_local_deliver_finish+0x267/0x350
       ip_local_deliver+0x18b/0x2d0
       ip_rcv+0x2fb/0x370
       __netif_receive_skb_one_core+0x166/0x1b0
       process_backlog+0x24c/0x5e0
       __napi_poll+0xa2/0x500
       net_rx_action+0x854/0xc90
       __do_softirq+0x1bb/0x5de
       do_softirq+0xcb/0x100
       </IRQ>
       <TASK>
       ...
       </TASK>
    
      Allocated by task 102371:
       kasan_save_stack+0x1e/0x40
       kasan_set_track+0x21/0x30
       __kasan_kmalloc+0x7b/0x90
       svc_setup_socket+0x52/0x4f0 [sunrpc]
       svc_addsock+0x20d/0x400 [sunrpc]
       __write_ports_addfd+0x209/0x390 [nfsd]
       write_ports+0x239/0x2c0 [nfsd]
       nfsctl_transaction_write+0xac/0x110 [nfsd]
       vfs_write+0x1c3/0xae0
       ksys_write+0xed/0x1c0
       do_syscall_64+0x38/0x90
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
      Freed by task 102551:
       kasan_save_stack+0x1e/0x40
       kasan_set_track+0x21/0x30
       kasan_save_free_info+0x2a/0x50
       __kasan_slab_free+0x106/0x190
       __kmem_cache_free+0x133/0x270
       svc_xprt_free+0x1e2/0x350 [sunrpc]
       svc_xprt_destroy_all+0x25a/0x440 [sunrpc]
       nfsd_put+0x125/0x240 [nfsd]
       nfsd_svc+0x2cb/0x3c0 [nfsd]
       write_threads+0x1ac/0x2a0 [nfsd]
       nfsctl_transaction_write+0xac/0x110 [nfsd]
       vfs_write+0x1c3/0xae0
       ksys_write+0xed/0x1c0
       do_syscall_64+0x38/0x90
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    Fix the UAF by simply doing nothing in svc_tcp_listen_data_ready()
    if state != TCP_LISTEN, that will avoid dereferencing svsk for all
    child socket.
    
    Link: https://lore.kernel.org/lkml/20230507091131.23540-1-dinghui@sangfor.com.cn/
    Fixes: fa9251afc33c ("SUNRPC: Call the default socket callbacks instead of open coding")
    Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
svcrdma: Prevent page release when nothing was received [+ + +]
Author: Chuck Lever <chuck.lever@oracle.com>
Date:   Mon Jun 12 10:10:20 2023 -0400

    svcrdma: Prevent page release when nothing was received
    
    [ Upstream commit baf6d18b116b7dc84ed5e212c3a89f17cdc3f28c ]
    
    I noticed that svc_rqst_release_pages() was still unnecessarily
    releasing a page when svc_rdma_recvfrom() returns zero.
    
    Fixes: a53d5cb0646a ("svcrdma: Avoid releasing a page in svc_xprt_release()")
    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tcp: annotate data races in __tcp_oow_rate_limited() [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Jun 29 16:41:50 2023 +0000

    tcp: annotate data races in __tcp_oow_rate_limited()
    
    [ Upstream commit 998127cdb4699b9d470a9348ffe9f1154346be5f ]
    
    request sockets are lockless, __tcp_oow_rate_limited() could be called
    on the same object from different cpus. This is harmless.
    
    Add READ_ONCE()/WRITE_ONCE() annotations to avoid a KCSAN report.
    
    Fixes: 4ce7e93cb3fe ("tcp: rate limit ACK sent by SYN_RECV request sockets")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
thermal/drivers/sun8i: Fix some error handling paths in sun8i_ths_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sun May 14 20:46:05 2023 +0200

    thermal/drivers/sun8i: Fix some error handling paths in sun8i_ths_probe()
    
    [ Upstream commit 89382022b370dfd34eaae9c863baa123fcd4d132 ]
    
    Should an error occur after calling sun8i_ths_resource_init() in the probe
    function, some resources need to be released, as already done in the
    .remove() function.
    
    Switch to the devm_clk_get_enabled() helper and add a new devm_action to
    turn sun8i_ths_resource_init() into a fully managed function.
    
    Move the place where reset_control_deassert() is called so that the
    recommended order of reset release/clock enable steps is kept.
    A64 manual states that:
    
            3.3.6.4. Gating and reset
    
            Make sure that the reset signal has been released before the release of
            module clock gating;
    
    This fixes the issue and removes some LoC at the same time.
    
    Fixes: dccc5c3b6f30 ("thermal/drivers/sun8i: Add thermal driver for H6/H5/H3/A64/A83T/R40")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Acked-by: Maxime Ripard <maxime@cerno.tech>
    Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Link: https://lore.kernel.org/r/a8ae84bd2dc4b55fe428f8e20f31438bf8bb6762.1684089931.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tick/rcu: Fix bogus ratelimit condition [+ + +]
Author: Wen Yang <wenyang.linux@foxmail.com>
Date:   Fri May 5 00:12:53 2023 +0800

    tick/rcu: Fix bogus ratelimit condition
    
    [ Upstream commit a7e282c77785c7eabf98836431b1f029481085ad ]
    
    The ratelimit logic in report_idle_softirq() is broken because the
    exit condition is always true:
    
            static int ratelimit;
    
            if (ratelimit < 10)
                    return false;  ---> always returns here
    
            ratelimit++;           ---> no chance to run
    
    Make it check for >= 10 instead.
    
    Fixes: 0345691b24c0 ("tick/rcu: Stop allowing RCU_SOFTIRQ in idle")
    Signed-off-by: Wen Yang <wenyang.linux@foxmail.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/tencent_5AAA3EEAB42095C9B7740BE62FBF9A67E007@qq.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tracing/timer: Add missing hrtimer modes to decode_hrtimer_mode(). [+ + +]
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:   Tue Apr 18 16:38:54 2023 +0200

    tracing/timer: Add missing hrtimer modes to decode_hrtimer_mode().
    
    [ Upstream commit 2951580ba6adb082bb6b7154a5ecb24e7c1f7569 ]
    
    The trace output for the HRTIMER_MODE_.*_HARD modes is seen as a number
    since these modes are not decoded. The author was not aware of the fancy
    decoding function which makes the life easier.
    
    Extend decode_hrtimer_mode() with the additional HRTIMER_MODE_.*_HARD
    modes.
    
    Fixes: ae6683d815895 ("hrtimer: Introduce HARD expiry mode")
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Mukesh Ojha <quic_mojha@quicinc.com>
    Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Link: https://lore.kernel.org/r/20230418143854.8vHWQKLM@linutronix.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tty: serial: fsl_lpuart: add earlycon for imx8ulp platform [+ + +]
Author: Sherry Sun <sherry.sun@nxp.com>
Date:   Mon Jun 19 16:06:13 2023 +0800

    tty: serial: fsl_lpuart: add earlycon for imx8ulp platform
    
    commit e0edfdc15863ec80a1d9ac6e174dbccc00206dd0 upstream.
    
    Add earlycon support for imx8ulp platform.
    
    Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
    Cc: stable <stable@kernel.org>
    Link: https://lore.kernel.org/r/20230619080613.16522-1-sherry.sun@nxp.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
um: Use HOST_DIR for mrproper [+ + +]
Author: Kees Cook <keescook@chromium.org>
Date:   Tue Jun 6 15:24:45 2023 -0700

    um: Use HOST_DIR for mrproper
    
    commit a5a319ec2c2236bb96d147c16196d2f1f3799301 upstream.
    
    When HEADER_ARCH was introduced, the MRPROPER_FILES (then MRPROPER_DIRS)
    list wasn't adjusted, leaving SUBARCH as part of the path argument.
    This resulted in the "mrproper" target not cleaning up arch/x86/... when
    SUBARCH was specified. Since HOST_DIR is arch/$(HEADER_ARCH), use it
    instead to get the correct path.
    
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
    Cc: Johannes Berg <johannes@sipsolutions.net>
    Cc: Azeem Shaikh <azeemshaikh38@gmail.com>
    Cc: linux-um@lists.infradead.org
    Fixes: 7bbe7204e937 ("um: merge Makefile-{i386,x86_64}")
    Cc: stable@vger.kernel.org
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20230606222442.never.807-kees@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
usb: common: usb-conn-gpio: Set last role to unknown before initial detection [+ + +]
Author: Prashanth K <quic_prashk@quicinc.com>
Date:   Wed May 31 20:11:14 2023 +0530

    usb: common: usb-conn-gpio: Set last role to unknown before initial detection
    
    [ Upstream commit edd60d24bd858cef165274e4cd6cab43bdc58d15 ]
    
    Currently if we bootup a device without cable connected, then
    usb-conn-gpio won't call set_role() since last_role is same as
    current role. This happens because during probe last_role gets
    initialised to zero.
    
    To avoid this, added a new constant in enum usb_role, last_role
    is set to USB_ROLE_UNKNOWN before performing initial detection.
    
    While at it, also handle default case for the usb_role switch
    in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid
    build warnings.
    
    Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection detection driver")
    Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Message-ID: <1685544074-17337-1-git-send-email-quic_prashk@quicinc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: dwc2: Fix some error handling paths [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Fri May 5 19:15:08 2023 +0200

    usb: dwc2: Fix some error handling paths
    
    [ Upstream commit ada050c69108bc34be13ecc11f7fad0f20ebadc4 ]
    
    dwc2_driver_probe() calls dwc2_lowlevel_hw_init() which deassert some reset
    lines.
    Should an error happen in dwc2_lowlevel_hw_init() after calling
    reset_control_deassert() or in the probe after calling
    dwc2_lowlevel_hw_init(), the reset lines remain deasserted.
    
    Add some devm_add_action_or_reset() calls to re-assert the lines if needed.
    
    Update the remove function accordingly.
    
    This change is compile-tested only.
    
    Fixes: 83f8da562f8b ("usb: dwc2: Add reset control to dwc2")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/c64537b5339342bd00f7c2152b8fc23792b9f95a.1683306479.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: dwc2: platform: Improve error reporting for problems during .remove() [+ + +]
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Mon Oct 17 21:59:14 2022 +0200

    usb: dwc2: platform: Improve error reporting for problems during .remove()
    
    [ Upstream commit 55f223b8b408cbfd85fb1c5b74ab85ccab319a69 ]
    
    Returning an error value in a platform driver's remove callback results in
    a generic error message being emitted by the driver core, but otherwise it
    doesn't make a difference. The device goes away anyhow.
    
    For each case where ret is non-zero the driver already emits an error
    message, so suppress the generic error message by returning zero
    unconditionally. (Side note: The return value handling was unreliable
    anyhow as the value returned by dwc2_exit_hibernation() was overwritten
    anyhow if hsotg->in_ppd was non-zero.)
    
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Acked-by: Minas Harutyunyan <hminas@synopsys.com>
    Link: https://lore.kernel.org/r/20221017195914.1426297-1-u.kleine-koenig@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Stable-dep-of: ada050c69108 ("usb: dwc2: Fix some error handling paths")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: dwc3-meson-g12a: Fix an error handling path in dwc3_meson_g12a_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat Jun 10 15:32:52 2023 +0200

    usb: dwc3-meson-g12a: Fix an error handling path in dwc3_meson_g12a_probe()
    
    [ Upstream commit 01052b91c9808e3c3b068ae2721cb728ec9aa4c0 ]
    
    If dwc3_meson_g12a_otg_init() fails, resources allocated by the previous
    of_platform_populate() call should be released, as already done in the
    error handling path.
    
    Fixes: 1e355f21d3fb ("usb: dwc3: Add Amlogic A1 DWC3 glue")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
    Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
    Message-ID: <9d28466de1808ccc756b4cc25fc72c482d133d13.1686403934.git.christophe.jaillet@wanadoo.fr>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: dwc3: gadget: Propagate core init errors to UDC during pullup [+ + +]
Author: Krishna Kurapati <quic_kriskura@quicinc.com>
Date:   Sun Jun 18 17:39:49 2023 +0530

    usb: dwc3: gadget: Propagate core init errors to UDC during pullup
    
    commit c0aabed9cabe057309779a9e26fe86a113d24dad upstream.
    
    In scenarios where pullup relies on resume (get sync) to initialize
    the controller and set the run stop bit, then core_init is followed by
    gadget_resume which will eventually set run stop bit.
    
    But in cases where the core_init fails, the return value is not sent
    back to udc appropriately. So according to UDC the controller has
    started but in reality we never set the run stop bit.
    
    On systems like Android, there are uevents sent to HAL depending on
    whether the configfs_bind / configfs_disconnect were invoked. In the
    above mentioned scnenario, if the core init fails, the run stop won't
    be set and the cable plug-out won't result in generation of any
    disconnect event and userspace would never get any uevent regarding
    cable plug out and we never call pullup(0) again. Furthermore none of
    the next Plug-In/Plug-Out's would be known to configfs.
    
    Return back the appropriate result to UDC to let the userspace/
    configfs know that the pullup failed so they can take appropriate
    action.
    
    Fixes: 77adb8bdf422 ("usb: dwc3: gadget: Allow runtime suspend if UDC unbinded")
    Cc: stable <stable@kernel.org>
    Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
    Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Message-ID: <20230618120949.14868-1-quic_kriskura@quicinc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: dwc3: qcom: Fix an error handling path in dwc3_qcom_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sun Jun 4 16:56:34 2023 +0200

    usb: dwc3: qcom: Fix an error handling path in dwc3_qcom_probe()
    
    [ Upstream commit 4a944da707123686d372ec01ea60056902fadf35 ]
    
    If dwc3_qcom_create_urs_usb_platdev() fails, some resources still need to
    be released, as already done in the other error handling path of the
    probe.
    
    Fixes: c25c210f590e ("usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
    Message-ID: <b69fa8dd68d816e7d24c88d3eda776ceb28c5dc5.1685890571.git.christophe.jaillet@wanadoo.fr>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: dwc3: qcom: Fix potential memory leak [+ + +]
Author: Vladislav Efanov <VEfanov@ispras.ru>
Date:   Wed May 17 20:25:18 2023 +0300

    usb: dwc3: qcom: Fix potential memory leak
    
    [ Upstream commit 097fb3ee710d4de83b8d4f5589e8ee13e0f0541e ]
    
    Function dwc3_qcom_probe() allocates memory for resource structure
    which is pointed by parent_res pointer. This memory is not
    freed. This leads to memory leak. Use stack memory to prevent
    memory leak.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
    Signed-off-by: Vladislav Efanov <VEfanov@ispras.ru>
    Acked-by: Shawn Guo <shawn.guo@linaro.org>
    Link: https://lore.kernel.org/r/20230517172518.442591-1-VEfanov@ispras.ru
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sun Jun 4 17:04:37 2023 +0200

    usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()
    
    [ Upstream commit 8fd95da2cfb5046c4bb5a3cdc9eb7963ba8b10dd ]
    
    In the probe, some resources are allocated with
    dwc3_qcom_of_register_core() or dwc3_qcom_acpi_register_core(). The
    corresponding resources are already coorectly freed in the error handling
    path of the probe, but not in the remove function.
    
    Fix it.
    
    Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
    Message-ID: <c0215a84cdf18fb3514c81842783ec53cf149deb.1685891059.git.christophe.jaillet@wanadoo.fr>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: gadget: u_serial: Add null pointer check in gserial_suspend [+ + +]
Author: Prashanth K <quic_prashk@quicinc.com>
Date:   Fri May 5 14:48:37 2023 +0530

    usb: gadget: u_serial: Add null pointer check in gserial_suspend
    
    [ Upstream commit 2f6ecb89fe8feb2b60a53325b0eeb9866d88909a ]
    
    Consider a case where gserial_disconnect has already cleared
    gser->ioport. And if gserial_suspend gets called afterwards,
    it will lead to accessing of gser->ioport and thus causing
    null pointer dereference.
    
    Avoid this by adding a null pointer check. Added a static
    spinlock to prevent gser->ioport from becoming null after
    the newly added null pointer check.
    
    Fixes: aba3a8d01d62 ("usb: gadget: u_serial: add suspend resume callbacks")
    Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
    Link: https://lore.kernel.org/r/1683278317-11774-1-git-send-email-quic_prashk@quicinc.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: hide unused usbfs_notify_suspend/resume functions [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue May 16 22:17:42 2023 +0200

    usb: hide unused usbfs_notify_suspend/resume functions
    
    [ Upstream commit 8e6bd945e6dde64fbc60ec3fe252164493a8d3a2 ]
    
    The declaration is in an #ifdef, which causes warnings when building
    with 'make W=1' and without CONFIG_PM:
    
    drivers/usb/core/devio.c:742:6: error: no previous prototype for 'usbfs_notify_suspend'
    drivers/usb/core/devio.c:747:6: error: no previous prototype for 'usbfs_notify_resume'
    
    Use the same #ifdef check around the function definitions to avoid
    the warnings and slightly shrink the USB core.
    
    Fixes: 7794f486ed0b ("usbfs: Add ioctls for runtime power management")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Link: https://lore.kernel.org/r/20230516202103.558301-1-arnd@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: misc: eud: Fix eud sysfs path (use 'qcom_eud') [+ + +]
Author: Bhupesh Sharma <bhupesh.sharma@linaro.org>
Date:   Thu May 18 02:47:51 2023 +0530

    usb: misc: eud: Fix eud sysfs path (use 'qcom_eud')
    
    [ Upstream commit f16135918b5f8b510db014ecf0a069e34c02382e ]
    
    The eud sysfs enablement path is currently mentioned in the
    Documentation as:
      /sys/bus/platform/drivers/eud/.../enable
    
    Instead it should be:
      /sys/bus/platform/drivers/qcom_eud/.../enable
    
    Fix the same.
    
    Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
    Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
    Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
    Link: https://lore.kernel.org/r/20230517211756.2483552-2-bhupesh.sharma@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe() [+ + +]
Author: Li Yang <lidaxian@hust.edu.cn>
Date:   Thu Apr 20 22:08:31 2023 +0800

    usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
    
    [ Upstream commit 342161c11403ea00e9febc16baab1d883d589d04 ]
    
    Smatch reports:
    drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
    warn: missing unwind goto?
    
    After geting irq, if ret < 0, it will return without error handling to
    free memory.
    Just add error handling to fix this problem.
    
    Fixes: 0d45a1373e66 ("usb: phy: tahvo: add IRQ check")
    Signed-off-by: Li Yang <lidaxian@hust.edu.cn>
    Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
    Link: https://lore.kernel.org/r/20230420140832.9110-1-lidaxian@hust.edu.cn
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
USB: serial: option: add LARA-R6 01B PIDs [+ + +]
Author: Davide Tronchin <davide.tronchin.94@gmail.com>
Date:   Thu Jun 22 11:29:21 2023 +0200

    USB: serial: option: add LARA-R6 01B PIDs
    
    commit ffa5f7a3bf28c1306eef85d4056539c2d4b8eb09 upstream.
    
    The new LARA-R6 product variant identified by the "01B" string can be
    configured (by AT interface) in three different USB modes:
    
    * Default mode (Vendor ID: 0x1546 Product ID: 0x1311) with 4 serial
    interfaces
    
    * RmNet mode (Vendor ID: 0x1546 Product ID: 0x1312) with 4 serial
    interfaces and 1 RmNet virtual network interface
    
    * CDC-ECM mode (Vendor ID: 0x1546 Product ID: 0x1313) with 4 serial
    interface and 1 CDC-ECM virtual network interface
    The first 4 interfaces of all the 3 USB configurations (default, RmNet,
    CDC-ECM) are the same.
    
    In default mode LARA-R6 01B exposes the following interfaces:
    If 0: Diagnostic
    If 1: AT parser
    If 2: AT parser
    If 3: AT parser/alternative functions
    
    In RmNet mode LARA-R6 01B exposes the following interfaces:
    If 0: Diagnostic
    If 1: AT parser
    If 2: AT parser
    If 3: AT parser/alternative functions
    If 4: RMNET interface
    
    In CDC-ECM mode LARA-R6 01B exposes the following interfaces:
    If 0: Diagnostic
    If 1: AT parser
    If 2: AT parser
    If 3: AT parser/alternative functions
    If 4: CDC-ECM interface
    
    Signed-off-by: Davide Tronchin <davide.tronchin.94@gmail.com>
    Link: https://lore.kernel.org/r/20230622092921.12651-1-davide.tronchin.94@gmail.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
usb: typec: ucsi: Mark dGPUs as DEVICE scope [+ + +]
Author: Mario Limonciello <mario.limonciello@amd.com>
Date:   Thu May 18 11:11:50 2023 -0500

    usb: typec: ucsi: Mark dGPUs as DEVICE scope
    
    commit a7fbfd44c0204f0629288edfd0d77829edb4a2f8 upstream.
    
    power_supply_is_system_supplied() checks whether any power
    supplies are present that aren't batteries to decide whether
    the system is running on DC or AC.  Downstream drivers use
    this to make performance decisions.
    
    Navi dGPUs include an UCSI function that has been exported
    since commit 17631e8ca2d3 ("i2c: designware: Add driver
    support for AMD NAVI GPU").
    
    This UCSI function registers a power supply since commit
    992a60ed0d5e ("usb: typec: ucsi: register with power_supply class")
    but this is not a system power supply.
    
    As the power supply for a dGPU is only for powering devices connected
    to dGPU, create a device property to indicate that the UCSI endpoint
    is only for the scope of `POWER_SUPPLY_SCOPE_DEVICE`.
    
    Link: https://lore.kernel.org/lkml/20230516182541.5836-2-mario.limonciello@amd.com/
    Reviewed-by: Evan Quan <evan.quan@amd.com>
    Tested-by: Evan Quan <evan.quan@amd.com>
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
    Acked-by: Andi Shyti <andi.shyti@kernel.org>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
vfio/mdev: Move the compat_class initialization to module init [+ + +]
Author: Eric Farman <farman@linux.ibm.com>
Date:   Mon Jun 26 15:36:42 2023 +0200

    vfio/mdev: Move the compat_class initialization to module init
    
    [ Upstream commit ff598081e5b9d0bdd6874bfe340811bbb75b35e4 ]
    
    The pointer to mdev_bus_compat_class is statically defined at the top
    of mdev_core, and was originally (commit 7b96953bc640 ("vfio: Mediated
    device Core driver") serialized by the parent_list_lock. The blamed
    commit removed this mutex, leaving the pointer initialization
    unserialized. As a result, the creation of multiple MDEVs in parallel
    (such as during boot) can encounter errors during the creation of the
    sysfs entries, such as:
    
      [    8.337509] sysfs: cannot create duplicate filename '/class/mdev_bus'
      [    8.337514] vfio_ccw 0.0.01d8: MDEV: Registered
      [    8.337516] CPU: 13 PID: 946 Comm: driverctl Not tainted 6.4.0-rc7 #20
      [    8.337522] Hardware name: IBM 3906 M05 780 (LPAR)
      [    8.337525] Call Trace:
      [    8.337528]  [<0000000162b0145a>] dump_stack_lvl+0x62/0x80
      [    8.337540]  [<00000001622aeb30>] sysfs_warn_dup+0x78/0x88
      [    8.337549]  [<00000001622aeca6>] sysfs_create_dir_ns+0xe6/0xf8
      [    8.337552]  [<0000000162b04504>] kobject_add_internal+0xf4/0x340
      [    8.337557]  [<0000000162b04d48>] kobject_add+0x78/0xd0
      [    8.337561]  [<0000000162b04e0a>] kobject_create_and_add+0x6a/0xb8
      [    8.337565]  [<00000001627a110e>] class_compat_register+0x5e/0x90
      [    8.337572]  [<000003ff7fd815da>] mdev_register_parent+0x102/0x130 [mdev]
      [    8.337581]  [<000003ff7fdc7f2c>] vfio_ccw_sch_probe+0xe4/0x178 [vfio_ccw]
      [    8.337588]  [<0000000162a7833c>] css_probe+0x44/0x80
      [    8.337599]  [<000000016279f4da>] really_probe+0xd2/0x460
      [    8.337603]  [<000000016279fa08>] driver_probe_device+0x40/0xf0
      [    8.337606]  [<000000016279fb78>] __device_attach_driver+0xc0/0x140
      [    8.337610]  [<000000016279cbe0>] bus_for_each_drv+0x90/0xd8
      [    8.337618]  [<00000001627a00b0>] __device_attach+0x110/0x190
      [    8.337621]  [<000000016279c7c8>] bus_rescan_devices_helper+0x60/0xb0
      [    8.337626]  [<000000016279cd48>] drivers_probe_store+0x48/0x80
      [    8.337632]  [<00000001622ac9b0>] kernfs_fop_write_iter+0x138/0x1f0
      [    8.337635]  [<00000001621e5e14>] vfs_write+0x1ac/0x2f8
      [    8.337645]  [<00000001621e61d8>] ksys_write+0x70/0x100
      [    8.337650]  [<0000000162b2bdc4>] __do_syscall+0x1d4/0x200
      [    8.337656]  [<0000000162b3c828>] system_call+0x70/0x98
      [    8.337664] kobject: kobject_add_internal failed for mdev_bus with -EEXIST, don't try to register things with the same name in the same directory.
      [    8.337668] kobject: kobject_create_and_add: kobject_add error: -17
      [    8.337674] vfio_ccw: probe of 0.0.01d9 failed with error -12
      [    8.342941] vfio_ccw_mdev aeb9ca91-10c6-42bc-a168-320023570aea: Adding to iommu group 2
    
    Move the initialization of the mdev_bus_compat_class pointer to the
    init path, to match the cleanup in module exit. This way the code
    in mdev_register_parent() can simply link the new parent to it,
    rather than determining whether initialization is required first.
    
    Fixes: 89345d5177aa ("vfio/mdev: embedd struct mdev_parent in the parent data structure")
    Reported-by: Alexander Egorenkov <egorenar@linux.ibm.com>
    Signed-off-by: Eric Farman <farman@linux.ibm.com>
    Reviewed-by: Kevin Tian <kevin.tian@intel.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>
    Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
    Link: https://lore.kernel.org/r/20230626133642.2939168-1-farman@linux.ibm.com
    Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
virt: sevguest: Add CONFIG_CRYPTO dependency [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Tue Jan 17 18:13:56 2023 +0100

    virt: sevguest: Add CONFIG_CRYPTO dependency
    
    [ Upstream commit 84b9b44b99780d35fe72ac63c4724f158771e898 ]
    
    This driver fails to link when CRYPTO is disabled, or in a loadable
    module:
    
      WARNING: unmet direct dependencies detected for CRYPTO_GCM
      WARNING: unmet direct dependencies detected for CRYPTO_AEAD2
        Depends on [m]: CRYPTO [=m]
        Selected by [y]:
        - SEV_GUEST [=y] && VIRT_DRIVERS [=y] && AMD_MEM_ENCRYPT [=y]
    
    x86_64-linux-ld: crypto/aead.o: in function `crypto_register_aeads':
    
    Fixes: fce96cf04430 ("virt: Add SEV-SNP guest driver")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20230117171416.2715125-1-arnd@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
w1: fix loop in w1_fini() [+ + +]
Author: Dan Carpenter <error27@gmail.com>
Date:   Wed May 19 17:17:45 2021 +0300

    w1: fix loop in w1_fini()
    
    [ Upstream commit 83f3fcf96fcc7e5405b37d9424c7ef26bfa203f8 ]
    
    The __w1_remove_master_device() function calls:
    
            list_del(&dev->w1_master_entry);
    
    So presumably this can cause an endless loop.
    
    Fixes: 7785925dd8e0 ("[PATCH] w1: cleanups.")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

w1: w1_therm: fix locking behavior in convert_t [+ + +]
Author: Stefan Wahren <stefan.wahren@i2se.com>
Date:   Thu Apr 27 13:21:52 2023 +0200

    w1: w1_therm: fix locking behavior in convert_t
    
    [ Upstream commit dca5480ab7b77a889088ab7cac81934604510ac7 ]
    
    The commit 67b392f7b8ed ("w1_therm: optimizing temperature read timings")
    accidentially inverted the logic for lock handling of the bus mutex.
    
    Before:
      pullup -> release lock before sleep
      no pullup -> release lock after sleep
    
    After:
      pullup -> release lock after sleep
      no pullup -> release lock before sleep
    
    This cause spurious measurements of 85 degree (powerup value) on the
    Tarragon board with connected 1-w temperature sensor
    (w1_therm.w1_strong_pull=0).
    
    In the meantime a new feature for polling the conversion
    completion has been integrated in these branches with
    commit 021da53e65fd ("w1: w1_therm: Add sysfs entries to control
    conversion time and driver features"). But this feature isn't
    available for parasite power mode, so handle this separately.
    
    Link: https://lore.kernel.org/regressions/2023042645-attentive-amends-7b0b@gregkh/T/
    Fixes: 67b392f7b8ed ("w1_therm: optimizing temperature read timings")
    Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
    Link: https://lore.kernel.org/r/20230427112152.12313-1-stefan.wahren@i2se.com
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
watch_queue: prevent dangling pipe pointer [+ + +]
Author: Siddh Raman Pant <code@siddh.me>
Date:   Mon Jun 5 20:06:16 2023 +0530

    watch_queue: prevent dangling pipe pointer
    
    commit 943211c87427f25bd22e0e63849fb486bb5f87fa upstream.
    
    NULL the dangling pipe reference while clearing watch_queue.
    
    If not done, a reference to a freed pipe remains in the watch_queue,
    as this function is called before freeing a pipe in free_pipe_info()
    (see line 834 of fs/pipe.c).
    
    The sole use of wqueue->defunct is for checking if the watch queue has
    been cleared, but wqueue->pipe is also NULLed while clearing.
    
    Thus, wqueue->defunct is superfluous, as wqueue->pipe can be checked
    for NULL. Hence, the former can be removed.
    
    Tested with keyutils testsuite.
    
    Cc: stable@vger.kernel.org # 6.1
    Signed-off-by: Siddh Raman Pant <code@siddh.me>
    Acked-by: David Howells <dhowells@redhat.com>
    Message-Id: <20230605143616.640517-1-code@siddh.me>
    Signed-off-by: Christian Brauner <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
watchdog/perf: define dummy watchdog_update_hrtimer_threshold() on correct config [+ + +]
Author: Douglas Anderson <dianders@chromium.org>
Date:   Fri May 19 10:18:25 2023 -0700

    watchdog/perf: define dummy watchdog_update_hrtimer_threshold() on correct config
    
    [ Upstream commit 5e008df11c55228a86a1bae692cc2002503572c9 ]
    
    Patch series "watchdog/hardlockup: Add the buddy hardlockup detector", v5.
    
    This patch series adds the "buddy" hardlockup detector.  In brief, the
    buddy hardlockup detector can detect hardlockups without arch-level
    support by having CPUs checkup on a "buddy" CPU periodically.
    
    Given the new design of this patch series, testing all combinations is
    fairly difficult. I've attempted to make sure that all combinations of
    CONFIG_ options are good, but it wouldn't surprise me if I missed
    something. I apologize in advance and I'll do my best to fix any
    problems that are found.
    
    This patch (of 18):
    
    The real watchdog_update_hrtimer_threshold() is defined in
    kernel/watchdog_hld.c.  That file is included if
    CONFIG_HARDLOCKUP_DETECTOR_PERF and the function is defined in that file
    if CONFIG_HARDLOCKUP_CHECK_TIMESTAMP.
    
    The dummy version of the function in "nmi.h" didn't get that quite right.
    While this doesn't appear to be a huge deal, it's nice to make it
    consistent.
    
    It doesn't break builds because CHECK_TIMESTAMP is only defined by x86 so
    others don't get a double definition, and x86 uses perf lockup detector,
    so it gets the out of line version.
    
    Link: https://lkml.kernel.org/r/20230519101840.v5.18.Ia44852044cdcb074f387e80df6b45e892965d4a1@changeid
    Link: https://lkml.kernel.org/r/20230519101840.v5.1.I8cbb2f4fa740528fcfade4f5439b6cdcdd059251@changeid
    Fixes: 7edaeb6841df ("kernel/watchdog: Prevent false positives with turbo modes")
    Signed-off-by: Douglas Anderson <dianders@chromium.org>
    Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
    Reviewed-by: Petr Mladek <pmladek@suse.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Chen-Yu Tsai <wens@csie.org>
    Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
    Cc: Daniel Thompson <daniel.thompson@linaro.org>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Guenter Roeck <groeck@chromium.org>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Lecopzer Chen <lecopzer.chen@mediatek.com>
    Cc: Marc Zyngier <maz@kernel.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Masayoshi Mizuma <msys.mizuma@gmail.com>
    Cc: Matthias Kaehlcke <mka@chromium.org>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Pingfan Liu <kernelfans@gmail.com>
    Cc: Randy Dunlap <rdunlap@infradead.org>
    Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
    Cc: Ricardo Neri <ricardo.neri@intel.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Stephen Boyd <swboyd@chromium.org>
    Cc: Sumit Garg <sumit.garg@linaro.org>
    Cc: Tzung-Bi Shih <tzungbi@chromium.org>
    Cc: Will Deacon <will@kernel.org>
    Cc: Colin Cross <ccross@android.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

watchdog/perf: more properly prevent false positives with turbo modes [+ + +]
Author: Douglas Anderson <dianders@chromium.org>
Date:   Fri May 19 10:18:26 2023 -0700

    watchdog/perf: more properly prevent false positives with turbo modes
    
    [ Upstream commit 4379e59fe5665cfda737e45b8bf2f05321ef049c ]
    
    Currently, in the watchdog_overflow_callback() we first check to see if
    the watchdog had been touched and _then_ we handle the workaround for
    turbo mode.  This order should be reversed.
    
    Specifically, "touching" the hardlockup detector's watchdog should avoid
    lockups being detected for one period that should be roughly the same
    regardless of whether we're running turbo or not.  That means that we
    should do the extra accounting for turbo _before_ we look at (and clear)
    the global indicating that we've been touched.
    
    NOTE: this fix is made based on code inspection.  I am not aware of any
    reports where the old code would have generated false positives.  That
    being said, this order seems more correct and also makes it easier down
    the line to share code with the "buddy" hardlockup detector.
    
    Link: https://lkml.kernel.org/r/20230519101840.v5.2.I843b0d1de3e096ba111a179f3adb16d576bef5c7@changeid
    Fixes: 7edaeb6841df ("kernel/watchdog: Prevent false positives with turbo modes")
    Signed-off-by: Douglas Anderson <dianders@chromium.org>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Chen-Yu Tsai <wens@csie.org>
    Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
    Cc: Colin Cross <ccross@android.com>
    Cc: Daniel Thompson <daniel.thompson@linaro.org>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Guenter Roeck <groeck@chromium.org>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Lecopzer Chen <lecopzer.chen@mediatek.com>
    Cc: Marc Zyngier <maz@kernel.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Masayoshi Mizuma <msys.mizuma@gmail.com>
    Cc: Matthias Kaehlcke <mka@chromium.org>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Pingfan Liu <kernelfans@gmail.com>
    Cc: Randy Dunlap <rdunlap@infradead.org>
    Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
    Cc: Ricardo Neri <ricardo.neri@intel.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Stephen Boyd <swboyd@chromium.org>
    Cc: Sumit Garg <sumit.garg@linaro.org>
    Cc: Tzung-Bi Shih <tzungbi@chromium.org>
    Cc: Will Deacon <will@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
wifi: ath10k: Serialize wake_tx_queue ops [+ + +]
Author: Alexander Wetzel <alexander@wetzel-home.de>
Date:   Thu Mar 23 17:55:27 2023 +0100

    wifi: ath10k: Serialize wake_tx_queue ops
    
    commit b719ebc37a1eacd4fd4f1264f731b016e5ec0c6e upstream.
    
    Serialize the ath10k implementation of the wake_tx_queue ops.
    ath10k_mac_op_wake_tx_queue() must not run concurrent since it's using
    ieee80211_txq_schedule_start().
    
    The intend of this patch is to sort out an issue discovered in the discussion
    referred to by the Link tag.
    
    I can't test it with real hardware and thus just implemented the per-ac queue
    lock Felix suggested. One obvious alternative to the per-ac lock would be to
    bring back the txqs_lock commit bb2edb733586 ("ath10k: migrate to mac80211 txq
    scheduling") dropped.
    
    Fixes: bb2edb733586 ("ath10k: migrate to mac80211 txq scheduling")
    Reported-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/519b5bb9-8899-ae7c-4eff-f3116cdfdb56@nbd.name
    CC: <stable@vger.kernel.org>
    Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20230323165527.156414-1-alexander@wetzel-home.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

wifi: ath10k: Trigger STA disconnect after reconfig complete on hardware restart [+ + +]
Author: Youghandhar Chintala <quic_youghand@quicinc.com>
Date:   Fri May 26 12:41:08 2023 +0300

    wifi: ath10k: Trigger STA disconnect after reconfig complete on hardware restart
    
    [ Upstream commit 75bd32f5ce94bc365ba0b9b68bcf9de84a391d37 ]
    
    Currently, on WCN3990, the station disconnect after hardware recovery is
    not working as expected. This is because of setting the
    IEEE80211_SDATA_DISCONNECT_HW_RESTART flag very early in the hardware
    recovery process even before the driver invokes ieee80211_hw_restart().
    On the contrary, mac80211 expects this flag to be set after
    ieee80211_hw_restart() is invoked for it to trigger station disconnect.
    
    Set the IEEE80211_SDATA_DISCONNECT_HW_RESTART flag in
    ath10k_reconfig_complete() instead to fix this.
    
    The other targets are not affected by this change, since the hardware
    params flag is not set.
    
    Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1
    
    Fixes: 2c3fc50591ff ("ath10k: Trigger sta disconnect on hardware restart")
    Signed-off-by: Youghandhar Chintala <quic_youghand@quicinc.com>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20230518101515.3820-1-quic_youghand@quicinc.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: ath11k: Add missing check for ioremap [+ + +]
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Tue Jun 13 12:19:40 2023 +0300

    wifi: ath11k: Add missing check for ioremap
    
    [ Upstream commit 16e0077e14a73866e9b0f4a6bf4ad3d4a5cb0f2a ]
    
    Add check for ioremap() and return the error if it fails in order to
    guarantee the success of ioremap(), same as in
    ath11k_qmi_load_file_target_mem().
    
    Fixes: 6ac04bdc5edb ("ath11k: Use reserved host DDR addresses from DT for PCI devices")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20230608022858.27405-1-jiasheng@iscas.ac.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: ath9k: avoid referencing uninit memory in ath9k_wmi_ctrl_rx [+ + +]
Author: Fedor Pchelkin <pchelkin@ispras.ru>
Date:   Wed Apr 26 17:35:01 2023 +0300

    wifi: ath9k: avoid referencing uninit memory in ath9k_wmi_ctrl_rx
    
    [ Upstream commit f24292e827088bba8de7158501ac25a59b064953 ]
    
    For the reasons also described in commit b383e8abed41 ("wifi: ath9k: avoid
    uninit memory read in ath9k_htc_rx_msg()"), ath9k_htc_rx_msg() should
    validate pkt_len before accessing the SKB.
    
    For example, the obtained SKB may have been badly constructed with
    pkt_len = 8. In this case, the SKB can only contain a valid htc_frame_hdr
    but after being processed in ath9k_htc_rx_msg() and passed to
    ath9k_wmi_ctrl_rx() endpoint RX handler, it is expected to have a WMI
    command header which should be located inside its data payload.
    
    Implement sanity checking inside ath9k_wmi_ctrl_rx(). Otherwise, uninit
    memory can be referenced.
    
    Tested on Qualcomm Atheros Communications AR9271 802.11n .
    
    Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
    
    Fixes: fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
    Reported-and-tested-by: syzbot+f2cb6e0ffdb961921e4d@syzkaller.appspotmail.com
    Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
    Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20230424183348.111355-1-pchelkin@ispras.ru
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: ath9k: convert msecs to jiffies where needed [+ + +]
Author: Dmitry Antipov <dmantipov@yandex.ru>
Date:   Tue Jun 13 16:46:55 2023 +0300

    wifi: ath9k: convert msecs to jiffies where needed
    
    [ Upstream commit 2aa083acea9f61be3280184384551178f510ff51 ]
    
    Since 'ieee80211_queue_delayed_work()' expects timeout in
    jiffies and not milliseconds, 'msecs_to_jiffies()' should
    be used in 'ath_restart_work()' and '__ath9k_flush()'.
    
    Fixes: d63ffc45c5d3 ("ath9k: rename tx_complete_work to hw_check_work")
    Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
    Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20230613134655.248728-1-dmantipov@yandex.ru
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: ath9k: don't allow to overwrite ENDPOINT0 attributes [+ + +]
Author: Fedor Pchelkin <pchelkin@ispras.ru>
Date:   Wed May 17 18:03:17 2023 +0300

    wifi: ath9k: don't allow to overwrite ENDPOINT0 attributes
    
    [ Upstream commit 061b0cb9327b80d7a0f63a33e7c3e2a91a71f142 ]
    
    A bad USB device is able to construct a service connection response
    message with target endpoint being ENDPOINT0 which is reserved for
    HTC_CTRL_RSVD_SVC and should not be modified to be used for any other
    services.
    
    Reject such service connection responses.
    
    Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
    
    Fixes: fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
    Reported-by: syzbot+b68fbebe56d8362907e8@syzkaller.appspotmail.com
    Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
    Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20230516150427.79469-1-pchelkin@ispras.ru
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: ath9k: fix AR9003 mac hardware hang check register offset calculation [+ + +]
Author: Peter Seiderer <ps.report@gmx.net>
Date:   Wed Apr 26 17:35:00 2023 +0300

    wifi: ath9k: fix AR9003 mac hardware hang check register offset calculation
    
    [ Upstream commit 3e56c80931c7615250fe4bf83f93b57881969266 ]
    
    Fix ath9k_hw_verify_hang()/ar9003_hw_detect_mac_hang() register offset
    calculation (do not overflow the shift for the second register/queues
    above five, use the register layout described in the comments above
    ath9k_hw_verify_hang() instead).
    
    Fixes: 222e04830ff0 ("ath9k: Fix MAC HW hang check for AR9003")
    
    Reported-by: Gregg Wonderly <greggwonderly@seqtechllc.com>
    Link: https://lore.kernel.org/linux-wireless/E3A9C354-0CB7-420C-ADEF-F0177FB722F4@seqtechllc.com/
    Signed-off-by: Peter Seiderer <ps.report@gmx.net>
    Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20230422212423.26065-1-ps.report@gmx.net
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: ath9k: Fix possible stall on ath9k_txq_list_has_key() [+ + +]
Author: Remi Pommarel <repk@triplefau.lt>
Date:   Fri Jun 9 11:37:44 2023 +0200

    wifi: ath9k: Fix possible stall on ath9k_txq_list_has_key()
    
    [ Upstream commit 75086cc6dee046e3fbb3dba148b376d8802f83bc ]
    
    On EDMA capable hardware, ath9k_txq_list_has_key() can enter infinite
    loop if it is called while all txq_fifos have packets that use different
    key that the one we are looking for. Fix it by exiting the loop if all
    txq_fifos have been checked already.
    
    Because this loop is called under spin_lock_bh() (see ath_txq_lock) it
    causes the following rcu stall:
    
    rcu: INFO: rcu_sched self-detected stall on CPU
    ath10k_pci 0000:01:00.0: failed to read temperature -11
    rcu:    1-....: (5254 ticks this GP) idle=189/1/0x4000000000000002 softirq=8442983/8442984 fqs=2579
            (t=5257 jiffies g=17983297 q=334)
    Task dump for CPU 1:
    task:hostapd         state:R  running task     stack:    0 pid:  297 ppid:   289 flags:0x0000000a
    Call trace:
     dump_backtrace+0x0/0x170
     show_stack+0x1c/0x24
     sched_show_task+0x140/0x170
     dump_cpu_task+0x48/0x54
     rcu_dump_cpu_stacks+0xf0/0x134
     rcu_sched_clock_irq+0x8d8/0x9fc
     update_process_times+0xa0/0xec
     tick_sched_timer+0x5c/0xd0
     __hrtimer_run_queues+0x154/0x320
     hrtimer_interrupt+0x120/0x2f0
     arch_timer_handler_virt+0x38/0x44
     handle_percpu_devid_irq+0x9c/0x1e0
     handle_domain_irq+0x64/0x90
     gic_handle_irq+0x78/0xb0
     call_on_irq_stack+0x28/0x38
     do_interrupt_handler+0x54/0x5c
     el1_interrupt+0x2c/0x4c
     el1h_64_irq_handler+0x14/0x1c
     el1h_64_irq+0x74/0x78
     ath9k_txq_has_key+0x1bc/0x250 [ath9k]
     ath9k_set_key+0x1cc/0x3dc [ath9k]
     drv_set_key+0x78/0x170
     ieee80211_key_replace+0x564/0x6cc
     ieee80211_key_link+0x174/0x220
     ieee80211_add_key+0x11c/0x300
     nl80211_new_key+0x12c/0x330
     genl_family_rcv_msg_doit+0xbc/0x11c
     genl_rcv_msg+0xd8/0x1c4
     netlink_rcv_skb+0x40/0x100
     genl_rcv+0x3c/0x50
     netlink_unicast+0x1ec/0x2c0
     netlink_sendmsg+0x198/0x3c0
     ____sys_sendmsg+0x210/0x250
     ___sys_sendmsg+0x78/0xc4
     __sys_sendmsg+0x4c/0x90
     __arm64_sys_sendmsg+0x28/0x30
     invoke_syscall.constprop.0+0x60/0x100
     do_el0_svc+0x48/0xd0
     el0_svc+0x14/0x50
     el0t_64_sync_handler+0xa8/0xb0
     el0t_64_sync+0x158/0x15c
    
    This rcu stall is hard to reproduce as is, but changing ATH_TXFIFO_DEPTH
    from 8 to 2 makes it reasonably easy to reproduce.
    
    Fixes: ca2848022c12 ("ath9k: Postpone key cache entry deletion for TXQ frames reference it")
    Signed-off-by: Remi Pommarel <repk@triplefau.lt>
    Tested-by: Nicolas Escande <nico.escande@gmail.com>
    Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20230609093744.1985-1-repk@triplefau.lt
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: atmel: Fix an error handling path in atmel_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat May 20 09:53:14 2023 +0200

    wifi: atmel: Fix an error handling path in atmel_probe()
    
    [ Upstream commit 6b92e4351a29af52c285fe235e6e4d1a75de04b2 ]
    
    Should atmel_config() fail, some resources need to be released as already
    done in the remove function.
    
    While at it, remove a useless and erroneous comment. The probe is
    atmel_probe(), not atmel_attach().
    
    Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/1e65f174607a83348034197fa7d603bab10ba4a9.1684569156.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: cfg80211/mac80211: Fix ML element common size calculation [+ + +]
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Wed Sep 7 17:23:09 2022 +0300

    wifi: cfg80211/mac80211: Fix ML element common size calculation
    
    [ Upstream commit 1403b109c9a5244dc6ab79154f04eecc209ef3d2 ]
    
    The common size is part of the length in the data
    so don't add it again.
    
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Stable-dep-of: ce6e1f600b0c ("wifi: ieee80211: Fix the common size calculation for reconfiguration ML")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: cfg80211: drop incorrect nontransmitted BSS update code [+ + +]
Author: Benjamin Berg <benjamin.berg@intel.com>
Date:   Fri Jun 16 09:54:04 2023 +0300

    wifi: cfg80211: drop incorrect nontransmitted BSS update code
    
    [ Upstream commit 39432f8a3752a87a53fd8d5e51824a43aaae5cab ]
    
    The removed code ran for any BSS that was not included in the MBSSID
    element in order to update it. However, instead of using the correct
    inheritance rules, it would simply copy the elements from the
    transmitting AP. The result is that we would report incorrect elements
    in this case.
    
    After some discussions, it seems that there are likely not even APs
    actually using this feature. Either way, removing the code decreases
    complexity and makes the cfg80211 behaviour more correct.
    
    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230616094949.cfd6d8db1f26.Ia1044902b86cd7d366400a4bfb93691b8f05d68c@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: cfg80211: fix regulatory disconnect for non-MLO [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Jun 16 22:28:44 2023 +0200

    wifi: cfg80211: fix regulatory disconnect for non-MLO
    
    commit b22552fcaf1970360005c805d7fba4046cf2ab4a upstream.
    
    The multi-link loop here broke disconnect when multi-link
    operation (MLO) isn't active for a given interface, since
    in that case valid_links is 0 (indicating no links, i.e.
    no MLO.)
    
    Fix this by taking that into account properly and skipping
    the link only if there are valid_links in the first place.
    
    Cc: stable@vger.kernel.org
    Fixes: 7b0a0e3c3a88 ("wifi: cfg80211: do some rework towards MLO link APIs")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Link: https://lore.kernel.org/r/20230616222844.eb073d650c75.I72739923ef80919889ea9b50de9e4ba4baa836ae@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

wifi: cfg80211: fix regulatory disconnect with OCB/NAN [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Jun 16 22:28:45 2023 +0200

    wifi: cfg80211: fix regulatory disconnect with OCB/NAN
    
    [ Upstream commit e8c2af660ba0790afd14d5cbc2fd05c6dc85e207 ]
    
    Since regulatory disconnect was added, OCB and NAN interface
    types were added, which made it completely unusable for any
    driver that allowed OCB/NAN. Add OCB/NAN (though NAN doesn't
    do anything, we don't have any info) and also remove all the
    logic that opts out, so it won't be broken again if/when new
    interface types are added.
    
    Fixes: 6e0bd6c35b02 ("cfg80211: 802.11p OCB mode handling")
    Fixes: cb3b7d87652a ("cfg80211: add start / stop NAN commands")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Link: https://lore.kernel.org/r/20230616222844.2794d1625a26.I8e78a3789a29e6149447b3139df724a6f1b46fc3@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: cfg80211: rewrite merging of inherited elements [+ + +]
Author: Benjamin Berg <benjamin.berg@intel.com>
Date:   Fri Jun 16 09:54:03 2023 +0300

    wifi: cfg80211: rewrite merging of inherited elements
    
    [ Upstream commit dfd9aa3e7a456d57b18021d66472ab7ff8373ab7 ]
    
    The cfg80211_gen_new_ie function merges the IEs using inheritance rules.
    Rewrite this function to fix issues around inheritance rules. In
    particular, vendor elements do not require any special handling, as they
    are either all inherited or overridden by the subprofile.
    Also, add fragmentation handling as this may be needed in some cases.
    
    This also changes the function to not require making a copy. The new
    version could be optimized a bit by explicitly tracking which IEs have
    been handled already rather than looking that up again every time.
    
    Note that a small behavioural change is the removal of the SSID special
    handling. This should be fine for the MBSSID element, as the SSID must
    be included in the subelement.
    
    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230616094949.bc6152e146db.I2b5f3bc45085e1901e5b5192a674436adaf94748@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: ieee80211: Fix the common size calculation for reconfiguration ML [+ + +]
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Sun Jun 18 21:49:45 2023 +0300

    wifi: ieee80211: Fix the common size calculation for reconfiguration ML
    
    [ Upstream commit ce6e1f600b0cfc563a7d607de702262a58cd835d ]
    
    The common information length is found in the first octet of the common
    information.
    
    Fixes: 0f48b8b88aa9 ("wifi: ieee80211: add definitions for multi-link element")
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230618214435.3c7ed4817338.I42ef706cb827b4dade6e4ffbb6e7f341eaccd398@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: iwlwifi: mvm: indicate HW decrypt for beacon protection [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Tue Jun 20 13:04:01 2023 +0300

    wifi: iwlwifi: mvm: indicate HW decrypt for beacon protection
    
    [ Upstream commit 2db72b8a700943aa54dce0aabe6ff1b72b615162 ]
    
    We've already done the 'decryption' here, so tell
    mac80211 it need not do it again.
    
    Fixes: b1fdc2505abc ("iwlwifi: mvm: advertise BIGTK client support if available")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230620125813.a50cf68fbf2e.Ieceacbe3789d81ea02ae085ad8d1f8813a33c31b@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: iwlwifi: pcie: fix NULL pointer dereference in iwl_pcie_irq_rx_msix_handler() [+ + +]
Author: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Date:   Wed Jun 14 12:41:32 2023 +0300

    wifi: iwlwifi: pcie: fix NULL pointer dereference in iwl_pcie_irq_rx_msix_handler()
    
    [ Upstream commit 1902f1953b8ba100ee8705cb8a6f1a9795550eca ]
    
    rxq can be NULL only when trans_pcie->rxq is NULL and entry->entry
    is zero. For the case when entry->entry is not equal to 0, rxq
    won't be NULL even if trans_pcie->rxq is NULL. Modify checker to
    check for trans_pcie->rxq.
    
    Fixes: abc599efa67b ("iwlwifi: pcie: don't crash when rx queues aren't allocated in interrupt")
    Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230614123446.5a5eb3889a4a.I375a1d58f16b48cd2044e7b7caddae512d7c86fd@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: iwlwifi: pull from TXQs with softirqs disabled [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Wed Jun 14 12:41:22 2023 +0300

    wifi: iwlwifi: pull from TXQs with softirqs disabled
    
    [ Upstream commit 96fb6f47db24a712d650b0a9b9074873f273fb0e ]
    
    In mac80211, it's required that we pull from TXQs by calling
    ieee80211_tx_dequeue() only with softirqs disabled. However,
    in iwl_mvm_queue_state_change() we're often called with them
    enabled, e.g. from flush if anything was flushed, triggering
    a mac80211 warning.
    
    Fix that by disabling the softirqs across the TX call.
    
    Fixes: cfbc6c4c5b91 ("iwlwifi: mvm: support mac80211 TXQs model")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230614123446.0feef7fa81db.I4dd62542d955b40dd8f0af34fa4accb9d0d17c7e@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: mac80211: Fix permissions for valid_links debugfs entry [+ + +]
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Sun Jun 11 12:14:28 2023 +0300

    wifi: mac80211: Fix permissions for valid_links debugfs entry
    
    [ Upstream commit 4cacadc0dbd8013e6161aa8843d8e9d8ad435b47 ]
    
    The entry should be a read only one and not a write only one. Fix it.
    
    Fixes: 3d9011029227 ("wifi: mac80211: implement link switching")
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230611121219.c75316990411.I1565a7fcba8a37f83efffb0cc6b71c572b896e94@changeid
    [remove x16 change since it doesn't work yet]
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: mac80211: recalc min chandef for new STA links [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Sun Jun 4 12:11:20 2023 +0300

    wifi: mac80211: recalc min chandef for new STA links
    
    [ Upstream commit ba7af2654e3b7b810c750b3c6106f6f20b81cc88 ]
    
    When adding a new link to a station, this needs to cause a
    recalculation of the minimum chandef since otherwise we can
    have a higher bandwidth station connected on that link than
    the link is operating at. Do the appropriate recalc.
    
    Fixes: cb71f1d136a6 ("wifi: mac80211: add sta link addition/removal")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230604120651.377adf3c789a.I91bf28f399e16e6ac1f83bacd1029a698b4e6685@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: mac80211: Remove "Missing iftype sband data/EHT cap" spam [+ + +]
Author: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Date:   Wed Jun 14 15:26:48 2023 +0200

    wifi: mac80211: Remove "Missing iftype sband data/EHT cap" spam
    
    [ Upstream commit 6e21e7b8cd897193cee3c2649640efceb3004ba5 ]
    
    In mesh mode, ieee80211_chandef_he_6ghz_oper() is called by
    mesh_matches_local() for every received mesh beacon.
    
    On a 6 GHz mesh of a HE-only phy, this spams that the hardware does not
    have EHT capabilities, even if the received mesh beacon does not have an
    EHT element.
    
    Unlike HE, not supporting EHT in the 6 GHz band is not an error so do
    not print anything in this case.
    
    Fixes: 5dca295dd767 ("mac80211: Add initial support for EHT and 320 MHz channels")
    
    Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Link: https://lore.kernel.org/r/20230614132648.28995-1-nicolas.cavallari@green-communications.fr
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: mt76: mt7921e: fix init command fail with enabled device [+ + +]
Author: Quan Zhou <quan.zhou@mediatek.com>
Date:   Wed Jul 5 23:26:38 2023 +0800

    wifi: mt76: mt7921e: fix init command fail with enabled device
    
    commit 525c469e5de9bf7e53574396196e80fc716ac9eb upstream.
    
    For some cases as below, we may encounter the unpreditable chip stats
    in driver probe()
    * The system reboot flow do not work properly, such as kernel oops while
      rebooting, and then the driver do not go back to default status at
      this moment.
    * Similar to the flow above. If the device was enabled in BIOS or UEFI,
      the system may switch to Linux without driver fully shutdown.
    
    To avoid the problem, force push the device back to default in probe()
    * mt7921e_mcu_fw_pmctrl() : return control privilege to chip side.
    * mt7921_wfsys_reset()    : cleanup chip config before resource init.
    
    Error log
    [59007.600714] mt7921e 0000:02:00.0: ASIC revision: 79220010
    [59010.889773] mt7921e 0000:02:00.0: Message 00000010 (seq 1) timeout
    [59010.889786] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59014.217839] mt7921e 0000:02:00.0: Message 00000010 (seq 2) timeout
    [59014.217852] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59017.545880] mt7921e 0000:02:00.0: Message 00000010 (seq 3) timeout
    [59017.545893] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59020.874086] mt7921e 0000:02:00.0: Message 00000010 (seq 4) timeout
    [59020.874099] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59024.202019] mt7921e 0000:02:00.0: Message 00000010 (seq 5) timeout
    [59024.202033] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59027.530082] mt7921e 0000:02:00.0: Message 00000010 (seq 6) timeout
    [59027.530096] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59030.857888] mt7921e 0000:02:00.0: Message 00000010 (seq 7) timeout
    [59030.857904] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59034.185946] mt7921e 0000:02:00.0: Message 00000010 (seq 8) timeout
    [59034.185961] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59037.514249] mt7921e 0000:02:00.0: Message 00000010 (seq 9) timeout
    [59037.514262] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59040.842362] mt7921e 0000:02:00.0: Message 00000010 (seq 10) timeout
    [59040.842375] mt7921e 0000:02:00.0: Failed to get patch semaphore
    [59040.923845] mt7921e 0000:02:00.0: hardware init failed
    
    Cc: stable@vger.kernel.org
    Fixes: 5c14a5f944b9 ("mt76: mt7921: introduce mt7921e support")
    Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Tested-by: Juan Martinez <juan.martinez@amd.com>
    Co-developed-by: Leon Yen <leon.yen@mediatek.com>
    Signed-off-by: Leon Yen <leon.yen@mediatek.com>
    Signed-off-by: Quan Zhou <quan.zhou@mediatek.com>
    Signed-off-by: Deren Wu <deren.wu@mediatek.com>
    Message-ID: <39fcb7cee08d4ab940d38d82f21897483212483f.1688569385.git.deren.wu@mediatek.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

wifi: mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat May 6 15:53:15 2023 +0200

    wifi: mwifiex: Fix the size of a memory allocation in mwifiex_ret_802_11_scan()
    
    [ Upstream commit d9aef04fcfa81ee4fb2804a21a3712b7bbd936af ]
    
    The type of "mwifiex_adapter->nd_info" is "struct cfg80211_wowlan_nd_info",
    not "struct cfg80211_wowlan_nd_match".
    
    Use struct_size() to ease the computation of the needed size.
    
    The current code over-allocates some memory, so is safe.
    But it wastes 32 bytes.
    
    Fixes: 7d7f07d8c5d3 ("mwifiex: add wowlan net-detect support")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/7a6074fb056d2181e058a3cc6048d8155c20aec7.1683371982.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: orinoco: Fix an error handling path in orinoco_cs_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat May 20 09:38:22 2023 +0200

    wifi: orinoco: Fix an error handling path in orinoco_cs_probe()
    
    [ Upstream commit 67a81d911c01225f426cc6bee2373df044c1a9b7 ]
    
    Should orinoco_cs_config() fail, some resources need to be released as
    already done in the remove function.
    
    While at it, remove a useless and erroneous comment. The probe is
    orinoco_cs_probe(), not orinoco_cs_attach().
    
    Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/e24735ce4d82901d5f7ea08419eea53bfdde3d65.1684568286.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: orinoco: Fix an error handling path in spectrum_cs_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat May 20 09:29:46 2023 +0200

    wifi: orinoco: Fix an error handling path in spectrum_cs_probe()
    
    [ Upstream commit 925244325159824385209e3e0e3f91fa6bf0646c ]
    
    Should spectrum_cs_config() fail, some resources need to be released as
    already done in the remove function.
    
    While at it, remove a useless and erroneous comment. The probe is
    spectrum_cs_probe(), not spectrum_cs_attach().
    
    Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/c0bc0c21c58ca477fc5521607615bafbf2aef8eb.1684567733.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: ray_cs: Fix an error handling path in ray_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat May 20 10:13:22 2023 +0200

    wifi: ray_cs: Fix an error handling path in ray_probe()
    
    [ Upstream commit 4f8d66a9fb2edcd05c1e563456a55a08910bfb37 ]
    
    Should ray_config() fail, some resources need to be released as already
    done in the remove function.
    
    While at it, remove a useless and erroneous comment. The probe is
    ray_probe(), not ray_attach().
    
    Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/8c544d18084f8b37dd108e844f7e79e85ff708ff.1684570373.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: rsi: Do not configure WoWlan in shutdown hook if not enabled [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Sun May 28 00:28:33 2023 +0200

    wifi: rsi: Do not configure WoWlan in shutdown hook if not enabled
    
    [ Upstream commit b241e260820b68c09586e8a0ae0fc23c0e3215bd ]
    
    In case WoWlan was never configured during the operation of the system,
    the hw->wiphy->wowlan_config will be NULL. rsi_config_wowlan() checks
    whether wowlan_config is non-NULL and if it is not, then WARNs about it.
    The warning is valid, as during normal operation the rsi_config_wowlan()
    should only ever be called with non-NULL wowlan_config. In shutdown this
    rsi_config_wowlan() should only ever be called if WoWlan was configured
    before by the user.
    
    Add checks for non-NULL wowlan_config into the shutdown hook. While at it,
    check whether the wiphy is also non-NULL before accessing wowlan_config .
    Drop the single-use wowlan_config variable, just inline it into function
    call.
    
    Fixes: 16bbc3eb8372 ("rsi: fix null pointer dereference during rsi_shutdown()")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20230527222833.273741-1-marex@denx.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: rsi: Do not set MMC_PM_KEEP_POWER in shutdown [+ + +]
Author: Marek Vasut <marex@denx.de>
Date:   Sun May 28 00:28:59 2023 +0200

    wifi: rsi: Do not set MMC_PM_KEEP_POWER in shutdown
    
    [ Upstream commit e74f562328b03fbe9cf438f958464dff3a644dfc ]
    
    It makes no sense to set MMC_PM_KEEP_POWER in shutdown. The flag
    indicates to the MMC subsystem to keep the slot powered on during
    suspend, but in shutdown the slot should actually be powered off.
    Drop this call.
    
    Fixes: 063848c3e155 ("rsi: sdio: Add WOWLAN support for S5 shutdown state")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20230527222859.273768-1-marex@denx.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: wilc1000: fix for absent RSN capabilities WFA testcase [+ + +]
Author: Amisha Patel <amisha.patel@microchip.com>
Date:   Fri Apr 21 18:10:20 2023 +0000

    wifi: wilc1000: fix for absent RSN capabilities WFA testcase
    
    [ Upstream commit 9ce4bb09123e9754996e358bd808d39f5d112899 ]
    
    Mandatory WFA testcase
    CT_Security_WPA2Personal_STA_RSNEBoundsVerification-AbsentRSNCap,
    performs bounds verfication on Beacon and/or Probe response frames. It
    failed and observed the reason to be absence of cipher suite and AKM
    suite in RSN information. To fix this, enable the RSN flag before extracting RSN
    capabilities.
    
    Fixes: cd21d99e595e ("wifi: wilc1000: validate pairwise and authentication suite offsets")
    Signed-off-by: Amisha Patel <amisha.patel@microchip.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20230421181005.4865-1-amisha.patel@microchip.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

wifi: wl3501_cs: Fix an error handling path in wl3501_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat May 20 10:05:08 2023 +0200

    wifi: wl3501_cs: Fix an error handling path in wl3501_probe()
    
    [ Upstream commit 391af06a02e7642039ac5f6c4b2c034ab0992b5d ]
    
    Should wl3501_config() fail, some resources need to be released as already
    done in the remove function.
    
    Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/7cc9c9316489b7d69b36aeb0edd3123538500b41.1684569865.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
wireguard: netlink: send staged packets when setting initial private key [+ + +]
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Mon Jul 3 03:27:05 2023 +0200

    wireguard: netlink: send staged packets when setting initial private key
    
    commit f58d0a9b4c6a7a5199c3af967e43cc8b654604d4 upstream.
    
    Packets bound for peers can queue up prior to the device private key
    being set. For example, if persistent keepalive is set, a packet is
    queued up to be sent as soon as the device comes up. However, if the
    private key hasn't been set yet, the handshake message never sends, and
    no timer is armed to retry, since that would be pointless.
    
    But, if a user later sets a private key, the expectation is that those
    queued packets, such as a persistent keepalive, are actually sent. So
    adjust the configuration logic to account for this edge case, and add a
    test case to make sure this works.
    
    Maxim noticed this with a wg-quick(8) config to the tune of:
    
        [Interface]
        PostUp = wg set %i private-key somefile
    
        [Peer]
        PublicKey = ...
        Endpoint = ...
        PersistentKeepalive = 25
    
    Here, the private key gets set after the device comes up using a PostUp
    script, triggering the bug.
    
    Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
    Cc: stable@vger.kernel.org
    Reported-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
    Tested-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
    Link: https://lore.kernel.org/wireguard/87fs7xtqrv.fsf@gmail.com/
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

wireguard: queueing: use saner cpu selection wrapping [+ + +]
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Mon Jul 3 03:27:04 2023 +0200

    wireguard: queueing: use saner cpu selection wrapping
    
    commit 7387943fa35516f6f8017a3b0e9ce48a3bef9faa upstream.
    
    Using `% nr_cpumask_bits` is slow and complicated, and not totally
    robust toward dynamic changes to CPU topologies. Rather than storing the
    next CPU in the round-robin, just store the last one, and also return
    that value. This simplifies the loop drastically into a much more common
    pattern.
    
    Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
    Cc: stable@vger.kernel.org
    Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
    Tested-by: Manuel Leiner <manuel.leiner@gmx.de>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
x86/efi: Make efi_set_virtual_address_map IBT safe [+ + +]
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jun 29 21:35:19 2023 +0200

    x86/efi: Make efi_set_virtual_address_map IBT safe
    
    [ Upstream commit 0303c9729afc4094ef53e552b7b8cff7436028d6 ]
    
    Niklāvs reported a boot regression on an Alderlake machine and bisected it
    to commit 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier").
    
    By moving the invocation of arch_cpu_finalize_init() further down he
    identified that efi_enter_virtual_mode() is the function which causes the
    boot hang.
    
    The main difference of the earlier invocation is that the boot CPU is
    already fully initialized and mitigations and alternatives are applied.
    
    But the only really interesting change turned out to be IBT, which is now
    enabled before efi_enter_virtual_mode(). "ibt=off" on the kernel command
    line cured the problem.
    
    Inspection of the involved calls in efi_enter_virtual_mode() unearthed that
    efi_set_virtual_address_map() is the only place in the kernel which invokes
    an EFI call without the IBT safe wrapper. This went obviously unnoticed so
    far as IBT was enabled later.
    
    Use arch_efi_call_virt() instead of efi_call() to cure that.
    
    Fixes: fe379fa4d199 ("x86/ibt: Disable IBT around firmware")
    Fixes: 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier")
    Reported-by: Niklāvs Koļesņikovs <pinkflames.linux@gmail.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=217602
    Link: https://lore.kernel.org/r/87jzvm12q0.ffs@tglx
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86/mm: Allow guest.enc_status_change_prepare() to fail [+ + +]
Author: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Date:   Tue Jun 6 12:56:20 2023 +0300

    x86/mm: Allow guest.enc_status_change_prepare() to fail
    
    [ Upstream commit 3f6819dd192ef4f0c568ec3e9d6d408b3fa1ad3d ]
    
    TDX code is going to provide guest.enc_status_change_prepare() that is
    able to fail. TDX will use the call to convert the GPA range from shared
    to private. This operation can fail.
    
    Add a way to return an error from the callback.
    
    Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
    Link: https://lore.kernel.org/all/20230606095622.1939-2-kirill.shutemov%40linux.intel.com
    Stable-dep-of: 195edce08b63 ("x86/tdx: Fix race between set_memory_encrypted() and load_unaligned_zeropad()")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

x86/mm: Fix __swp_entry_to_pte() for Xen PV guests [+ + +]
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Mar 6 13:32:59 2023 +0100

    x86/mm: Fix __swp_entry_to_pte() for Xen PV guests
    
    [ Upstream commit 0f88130e8a6fd185b0aeb5d8e286083735f2585a ]
    
    Normally __swp_entry_to_pte() is never called with a value translating
    to a valid PTE. The only known exception is pte_swap_tests(), resulting
    in a WARN splat in Xen PV guests, as __pte_to_swp_entry() did
    translate the PFN of the valid PTE to a guest local PFN, while
    __swp_entry_to_pte() doesn't do the opposite translation.
    
    Fix that by using __pte() in __swp_entry_to_pte() instead of open
    coding the native variant of it.
    
    For correctness do the similar conversion for __swp_entry_to_pmd().
    
    Fixes: 05289402d717 ("mm/debug_vm_pgtable: add tests validating arch helpers for core MM features")
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20230306123259.12461-1-jgross@suse.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86/resctrl: Only show tasks' pid in current pid namespace [+ + +]
Author: Shawn Wang <shawnwang@linux.alibaba.com>
Date:   Mon May 15 14:04:48 2023 +0800

    x86/resctrl: Only show tasks' pid in current pid namespace
    
    [ Upstream commit 2997d94b5dd0e8b10076f5e0b6f18410c73e28bd ]
    
    When writing a task id to the "tasks" file in an rdtgroup,
    rdtgroup_tasks_write() treats the pid as a number in the current pid
    namespace. But when reading the "tasks" file, rdtgroup_tasks_show() shows
    the list of global pids from the init namespace, which is confusing and
    incorrect.
    
    To be more robust, let the "tasks" file only show pids in the current pid
    namespace.
    
    Fixes: e02737d5b826 ("x86/intel_rdt: Add tasks files")
    Signed-off-by: Shawn Wang <shawnwang@linux.alibaba.com>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Acked-by: Reinette Chatre <reinette.chatre@intel.com>
    Acked-by: Fenghua Yu <fenghua.yu@intel.com>
    Tested-by: Reinette Chatre <reinette.chatre@intel.com>
    Link: https://lore.kernel.org/all/20230116071246.97717-1-shawnwang@linux.alibaba.com/
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86/sev: Fix calculation of end address based on number of pages [+ + +]
Author: Tom Lendacky <thomas.lendacky@amd.com>
Date:   Tue Jun 6 09:51:22 2023 -0500

    x86/sev: Fix calculation of end address based on number of pages
    
    [ Upstream commit 5dee19b6b2b194216919b99a1f5af2949a754016 ]
    
    When calculating an end address based on an unsigned int number of pages,
    any value greater than or equal to 0x100000 that is shift PAGE_SHIFT bits
    results in a 0 value, resulting in an invalid end address. Change the
    number of pages variable in various routines from an unsigned int to an
    unsigned long to calculate the end address correctly.
    
    Fixes: 5e5ccff60a29 ("x86/sev: Add helper for validating pages in early enc attribute changes")
    Fixes: dc3f3d2474b8 ("x86/mm: Validate memory when changing the C-bit")
    Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/6a6e4eea0e1414402bac747744984fa4e9c01bb6.1686063086.git.thomas.lendacky@amd.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86/tdx: Fix race between set_memory_encrypted() and load_unaligned_zeropad() [+ + +]
Author: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Date:   Tue Jun 6 12:56:21 2023 +0300

    x86/tdx: Fix race between set_memory_encrypted() and load_unaligned_zeropad()
    
    [ Upstream commit 195edce08b63d293377f615f4f7f086715d2d212 ]
    
    tl;dr: There is a race in the TDX private<=>shared conversion code
           which could kill the TDX guest.  Fix it by changing conversion
           ordering to eliminate the window.
    
    TDX hardware maintains metadata to track which pages are private and
    shared. Additionally, TDX guests use the guest x86 page tables to
    specify whether a given mapping is intended to be private or shared.
    Bad things happen when the intent and metadata do not match.
    
    So there are two thing in play:
     1. "the page" -- the physical TDX page metadata
     2. "the mapping" -- the guest-controlled x86 page table intent
    
    For instance, an unrecoverable exit to VMM occurs if a guest touches a
    private mapping that points to a shared physical page.
    
    In summary:
            * Private mapping => Private Page == OK (obviously)
            * Shared mapping  => Shared Page  == OK (obviously)
            * Private mapping => Shared Page  == BIG BOOM!
            * Shared mapping  => Private Page == OK-ish
              (It will read generate a recoverable #VE via handle_mmio())
    
    Enter load_unaligned_zeropad(). It can touch memory that is adjacent but
    otherwise unrelated to the memory it needs to touch. It will cause one
    of those unrecoverable exits (aka. BIG BOOM) if it blunders into a
    shared mapping pointing to a private page.
    
    This is a problem when __set_memory_enc_pgtable() converts pages from
    shared to private. It first changes the mapping and second modifies
    the TDX page metadata.  It's moving from:
    
            * Shared mapping  => Shared Page  == OK
    to:
            * Private mapping => Shared Page  == BIG BOOM!
    
    This means that there is a window with a shared mapping pointing to a
    private page where load_unaligned_zeropad() can strike.
    
    Add a TDX handler for guest.enc_status_change_prepare(). This converts
    the page from shared to private *before* the page becomes private.  This
    ensures that there is never a private mapping to a shared page.
    
    Leave a guest.enc_status_change_finish() in place but only use it for
    private=>shared conversions.  This will delay updating the TDX metadata
    marking the page private until *after* the mapping matches the metadata.
    This also ensures that there is never a private mapping to a shared page.
    
    [ dhansen: rewrite changelog ]
    
    Fixes: 7dbde7631629 ("x86/mm/cpa: Add support for TDX shared memory")
    Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
    Link: https://lore.kernel.org/all/20230606095622.1939-3-kirill.shutemov%40linux.intel.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
xfs: check that per-cpu inodegc workers actually run on that cpu [+ + +]
Author: Darrick J. Wong <djwong@kernel.org>
Date:   Sat Jul 15 09:31:12 2023 +0300

    xfs: check that per-cpu inodegc workers actually run on that cpu
    
    commit b37c4c8339cd394ea6b8b415026603320a185651 upstream.
    
    Now that we've allegedly worked out the problem of the per-cpu inodegc
    workers being scheduled on the wrong cpu, let's put in a debugging knob
    to let us know if a worker ever gets mis-scheduled again.
    
    Signed-off-by: Darrick J. Wong <djwong@kernel.org>
    Reviewed-by: Dave Chinner <dchinner@redhat.com>
    Signed-off-by: Dave Chinner <david@fromorbit.com>
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Acked-by: Darrick J. Wong <djwong@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

xfs: disable reaping in fscounters scrub [+ + +]
Author: Darrick J. Wong <djwong@kernel.org>
Date:   Sat Jul 15 09:31:13 2023 +0300

    xfs: disable reaping in fscounters scrub
    
    commit 2d5f38a31980d7090f5bf91021488dc61a0ba8ee upstream.
    
    The fscounters scrub code doesn't work properly because it cannot
    quiesce updates to the percpu counters in the filesystem, hence it
    returns false corruption reports.  This has been fixed properly in
    one of the online repair patchsets that are under review by replacing
    the xchk_disable_reaping calls with an exclusive filesystem freeze.
    Disabling background gc isn't sufficient to fix the problem.
    
    In other words, scrub doesn't need to call xfs_inodegc_stop, which is
    just as well since it wasn't correct to allow scrub to call
    xfs_inodegc_start when something else could be calling xfs_inodegc_stop
    (e.g. trying to freeze the filesystem).
    
    Neuter the scrubber for now, and remove the xchk_*_reaping functions.
    
    Signed-off-by: Darrick J. Wong <djwong@kernel.org>
    Reviewed-by: Dave Chinner <dchinner@redhat.com>
    Signed-off-by: Dave Chinner <david@fromorbit.com>
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Acked-by: Darrick J. Wong <djwong@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

xfs: explicitly specify cpu when forcing inodegc delayed work to run immediately [+ + +]
Author: Darrick J. Wong <djwong@kernel.org>
Date:   Sat Jul 15 09:31:11 2023 +0300

    xfs: explicitly specify cpu when forcing inodegc delayed work to run immediately
    
    commit 03e0add80f4cf3f7393edb574eeb3a89a1db7758 upstream.
    
    I've been noticing odd racing behavior in the inodegc code that could
    only be explained by one cpu adding an inode to its inactivation llist
    at the same time that another cpu is processing that cpu's llist.
    Preemption is disabled between get/put_cpu_ptr, so the only explanation
    is scheduler mayhem.  I inserted the following debug code into
    xfs_inodegc_worker (see the next patch):
    
            ASSERT(gc->cpu == smp_processor_id());
    
    This assertion tripped during overnight tests on the arm64 machines, but
    curiously not on x86_64.  I think we haven't observed any resource leaks
    here because the lockfree list code can handle simultaneous llist_add
    and llist_del_all functions operating on the same list.  However, the
    whole point of having percpu inodegc lists is to take advantage of warm
    memory caches by inactivating inodes on the last processor to touch the
    inode.
    
    The incorrect scheduling seems to occur after an inodegc worker is
    subjected to mod_delayed_work().  This wraps mod_delayed_work_on with
    WORK_CPU_UNBOUND specified as the cpu number.  Unbound allows for
    scheduling on any cpu, not necessarily the same one that scheduled the
    work.
    
    Because preemption is disabled for as long as we have the gc pointer, I
    think it's safe to use current_cpu() (aka smp_processor_id) to queue the
    delayed work item on the correct cpu.
    
    Fixes: 7cf2b0f9611b ("xfs: bound maximum wait time for inodegc work")
    Signed-off-by: Darrick J. Wong <djwong@kernel.org>
    Reviewed-by: Dave Chinner <dchinner@redhat.com>
    Signed-off-by: Dave Chinner <david@fromorbit.com>
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Acked-by: Darrick J. Wong <djwong@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

xfs: fix xfs_inodegc_stop racing with mod_delayed_work [+ + +]
Author: Darrick J. Wong <djwong@kernel.org>
Date:   Sat Jul 15 09:31:14 2023 +0300

    xfs: fix xfs_inodegc_stop racing with mod_delayed_work
    
    commit 2254a7396a0ca6309854948ee1c0a33fa4268cec upstream.
    
    syzbot reported this warning from the faux inodegc shrinker that tries
    to kick off inodegc work:
    
    ------------[ cut here ]------------
    WARNING: CPU: 1 PID: 102 at kernel/workqueue.c:1445 __queue_work+0xd44/0x1120 kernel/workqueue.c:1444
    RIP: 0010:__queue_work+0xd44/0x1120 kernel/workqueue.c:1444
    Call Trace:
     __queue_delayed_work+0x1c8/0x270 kernel/workqueue.c:1672
     mod_delayed_work_on+0xe1/0x220 kernel/workqueue.c:1746
     xfs_inodegc_shrinker_scan fs/xfs/xfs_icache.c:2212 [inline]
     xfs_inodegc_shrinker_scan+0x250/0x4f0 fs/xfs/xfs_icache.c:2191
     do_shrink_slab+0x428/0xaa0 mm/vmscan.c:853
     shrink_slab+0x175/0x660 mm/vmscan.c:1013
     shrink_one+0x502/0x810 mm/vmscan.c:5343
     shrink_many mm/vmscan.c:5394 [inline]
     lru_gen_shrink_node mm/vmscan.c:5511 [inline]
     shrink_node+0x2064/0x35f0 mm/vmscan.c:6459
     kswapd_shrink_node mm/vmscan.c:7262 [inline]
     balance_pgdat+0xa02/0x1ac0 mm/vmscan.c:7452
     kswapd+0x677/0xd60 mm/vmscan.c:7712
     kthread+0x2e8/0x3a0 kernel/kthread.c:376
     ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
    
    This warning corresponds to this code in __queue_work:
    
            /*
             * For a draining wq, only works from the same workqueue are
             * allowed. The __WQ_DESTROYING helps to spot the issue that
             * queues a new work item to a wq after destroy_workqueue(wq).
             */
            if (unlikely(wq->flags & (__WQ_DESTROYING | __WQ_DRAINING) &&
                         WARN_ON_ONCE(!is_chained_work(wq))))
                    return;
    
    For this to trip, we must have a thread draining the inodedgc workqueue
    and a second thread trying to queue inodegc work to that workqueue.
    This can happen if freezing or a ro remount race with reclaim poking our
    faux inodegc shrinker and another thread dropping an unlinked O_RDONLY
    file:
    
    Thread 0        Thread 1        Thread 2
    
    xfs_inodegc_stop
    
                                    xfs_inodegc_shrinker_scan
                                    xfs_is_inodegc_enabled
                                    <yes, will continue>
    
    xfs_clear_inodegc_enabled
    xfs_inodegc_queue_all
    <list empty, do not queue inodegc worker>
    
                    xfs_inodegc_queue
                    <add to list>
                    xfs_is_inodegc_enabled
                    <no, returns>
    
    drain_workqueue
    <set WQ_DRAINING>
    
                                    llist_empty
                                    <no, will queue list>
                                    mod_delayed_work_on(..., 0)
                                    __queue_work
                                    <sees WQ_DRAINING, kaboom>
    
    In other words, everything between the access to inodegc_enabled state
    and the decision to poke the inodegc workqueue requires some kind of
    coordination to avoid the WQ_DRAINING state.  We could perhaps introduce
    a lock here, but we could also try to eliminate WQ_DRAINING from the
    picture.
    
    We could replace the drain_workqueue call with a loop that flushes the
    workqueue and queues workers as long as there is at least one inode
    present in the per-cpu inodegc llists.  We've disabled inodegc at this
    point, so we know that the number of queued inodes will eventually hit
    zero as long as xfs_inodegc_start cannot reactivate the workers.
    
    There are four callers of xfs_inodegc_start.  Three of them come from the
    VFS with s_umount held: filesystem thawing, failed filesystem freezing,
    and the rw remount transition.  The fourth caller is mounting rw (no
    remount or freezing possible).
    
    There are three callers ofs xfs_inodegc_stop.  One is unmounting (no
    remount or thaw possible).  Two of them come from the VFS with s_umount
    held: fs freezing and ro remount transition.
    
    Hence, it is correct to replace the drain_workqueue call with a loop
    that drains the inodegc llists.
    
    Fixes: 6191cf3ad59f ("xfs: flush inodegc workqueue tasks before cancel")
    Signed-off-by: Darrick J. Wong <djwong@kernel.org>
    Reviewed-by: Dave Chinner <dchinner@redhat.com>
    Signed-off-by: Dave Chinner <david@fromorbit.com>
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Acked-by: Darrick J. Wong <djwong@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
xsk: Honor SO_BINDTODEVICE on bind [+ + +]
Author: Ilya Maximets <i.maximets@ovn.org>
Date:   Mon Jul 3 19:53:29 2023 +0200

    xsk: Honor SO_BINDTODEVICE on bind
    
    [ Upstream commit f7306acec9aae9893d15e745c8791124d42ab10a ]
    
    Initial creation of an AF_XDP socket requires CAP_NET_RAW capability. A
    privileged process might create the socket and pass it to a non-privileged
    process for later use. However, that process will be able to bind the socket
    to any network interface. Even though it will not be able to receive any
    traffic without modification of the BPF map, the situation is not ideal.
    
    Sockets already have a mechanism that can be used to restrict what interface
    they can be attached to. That is SO_BINDTODEVICE.
    
    To change the SO_BINDTODEVICE binding the process will need CAP_NET_RAW.
    
    Make xsk_bind() honor the SO_BINDTODEVICE in order to allow safer workflow
    when non-privileged process is using AF_XDP.
    
    The intended workflow is following:
    
      1. First process creates a bare socket with socket(AF_XDP, ...).
      2. First process loads the XSK program to the interface.
      3. First process adds the socket fd to a BPF map.
      4. First process ties socket fd to a particular interface using
         SO_BINDTODEVICE.
      5. First process sends socket fd to a second process.
      6. Second process allocates UMEM.
      7. Second process binds socket to the interface with bind(...).
      8. Second process sends/receives the traffic.
    
    All the steps above are possible today if the first process is privileged
    and the second one has sufficient RLIMIT_MEMLOCK and no capabilities.
    However, the second process will be able to bind the socket to any interface
    it wants on step 7 and send traffic from it. With the proposed change, the
    second process will be able to bind the socket only to a specific interface
    chosen by the first process at step 4.
    
    Fixes: 965a99098443 ("xsk: add support for bind for Rx")
    Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
    Acked-by: John Fastabend <john.fastabend@gmail.com>
    Acked-by: Jason Wang <jasowang@redhat.com>
    Link: https://lore.kernel.org/bpf/20230703175329.3259672-1-i.maximets@ovn.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>