Linux 5.4.198

 
ACPI: PM: Block ASUS B1400CEAE from suspend to idle by default [+ + +]
Author: Mario Limonciello <mario.limonciello@amd.com>
Date:   Tue May 10 08:11:36 2022 -0500

    ACPI: PM: Block ASUS B1400CEAE from suspend to idle by default
    
    [ Upstream commit d52848620de00cde4a3a5df908e231b8c8868250 ]
    
    ASUS B1400CEAE fails to resume from suspend to idle by default.  This was
    bisected back to commit df4f9bc4fb9c ("nvme-pci: add support for ACPI
    StorageD3Enable property") but this is a red herring to the problem.
    
    Before this commit the system wasn't getting into deepest sleep state.
    Presumably this commit is allowing entry into deepest sleep state as
    advertised by firmware, but there are some other problems related to
    the wakeup.
    
    As it is confirmed the system works properly with S3, set the default for
    this system to S3.
    
    Reported-by: Jian-Hong Pan <jhp@endlessos.org>
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=215742
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Tested-by: Jian-Hong Pan <jhp@endlessos.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ACPI: property: Release subnode properties with data nodes [+ + +]
Author: Sakari Ailus <sakari.ailus@linux.intel.com>
Date:   Wed Apr 6 16:12:08 2022 +0300

    ACPI: property: Release subnode properties with data nodes
    
    commit 3bd561e1572ee02a50cd1a5be339abf1a5b78d56 upstream.
    
    struct acpi_device_properties describes one source of properties present
    on either struct acpi_device or struct acpi_data_node. When properties are
    parsed, both are populated but when released, only those properties that
    are associated with the device node are freed.
    
    Fix this by also releasing memory of the data node properties.
    
    Fixes: 5f5e4890d57a ("ACPI / property: Allow multiple property compatible _DSD entries")
    Cc: 4.20+ <stable@vger.kernel.org> # 4.20+
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ACPICA: Avoid cache flush inside virtual machines [+ + +]
Author: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Date:   Wed Apr 6 02:29:38 2022 +0300

    ACPICA: Avoid cache flush inside virtual machines
    
    [ Upstream commit e2efb6359e620521d1e13f69b2257de8ceaa9475 ]
    
    While running inside virtual machine, the kernel can bypass cache
    flushing. Changing sleep state in a virtual machine doesn't affect the
    host system sleep state and cannot lead to data loss.
    
    Before entering sleep states, the ACPI code flushes caches to prevent
    data loss using the WBINVD instruction.  This mechanism is required on
    bare metal.
    
    But, any use WBINVD inside of a guest is worthless.  Changing sleep
    state in a virtual machine doesn't affect the host system sleep state
    and cannot lead to data loss, so most hypervisors simply ignore it.
    Despite this, the ACPI code calls WBINVD unconditionally anyway.
    It's useless, but also normally harmless.
    
    In TDX guests, though, WBINVD stops being harmless; it triggers a
    virtualization exception (#VE).  If the ACPI cache-flushing WBINVD
    were left in place, TDX guests would need handling to recover from
    the exception.
    
    Avoid using WBINVD whenever running under a hypervisor.  This both
    removes the useless WBINVDs and saves TDX from implementing WBINVD
    handling.
    
    Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lkml.kernel.org/r/20220405232939.73860-30-kirill.shutemov@linux.intel.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
af_unix: Fix a data-race in unix_dgram_peer_wake_me(). [+ + +]
Author: Kuniyuki Iwashima <kuniyu@amazon.com>
Date:   Sun Jun 5 16:23:25 2022 -0700

    af_unix: Fix a data-race in unix_dgram_peer_wake_me().
    
    [ Upstream commit 662a80946ce13633ae90a55379f1346c10f0c432 ]
    
    unix_dgram_poll() calls unix_dgram_peer_wake_me() without `other`'s
    lock held and check if its receive queue is full.  Here we need to
    use unix_recvq_full_lockless() instead of unix_recvq_full(), otherwise
    KCSAN will report a data-race.
    
    Fixes: 7d267278a9ec ("unix: avoid use-after-free in ep_remove_wait_queue")
    Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
    Link: https://lore.kernel.org/r/20220605232325.11804-1-kuniyu@amazon.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
afs: Fix infinite loop found by xfstest generic/676 [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Tue May 31 09:30:40 2022 +0100

    afs: Fix infinite loop found by xfstest generic/676
    
    [ Upstream commit 17eabd42560f4636648ad65ba5b20228071e2363 ]
    
    In AFS, a directory is handled as a file that the client downloads and
    parses locally for the purposes of performing lookup and getdents
    operations.  The in-kernel afs filesystem has a number of functions that
    do this.
    
    A directory file is arranged as a series of 2K blocks divided into
    32-byte slots, where a directory entry occupies one or more slots, plus
    each block starts with one or more metadata blocks.
    
    When parsing a block, if the last slots are occupied by a dirent that
    occupies more than a single slot and the file position points at a slot
    that's not the initial one, the logic in afs_dir_iterate_block() that
    skips over it won't advance the file pointer to the end of it.  This
    will cause an infinite loop in getdents() as it will keep retrying that
    block and failing to advance beyond the final entry.
    
    Fix this by advancing the file pointer if the next entry will be beyond
    it when we skip a block.
    
    This was found by the generic/676 xfstest but can also be triggered with
    something like:
    
            ~/xfstests-dev/src/t_readdir_3 /xfstest.test/z 4000 1
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
    Tested-by: Marc Dionne <marc.dionne@auristor.com>
    cc: linux-afs@lists.infradead.org
    Link: http://lore.kernel.org/r/165391973497.110268.2939296942213894166.stgit@warthog.procyon.org.uk/
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ALSA: hda/conexant - Fix loopback issue with CX20632 [+ + +]
Author: huangwenhui <huangwenhuia@uniontech.com>
Date:   Tue Jun 7 14:56:31 2022 +0800

    ALSA: hda/conexant - Fix loopback issue with CX20632
    
    commit d5ea7544c32ba27c2c5826248e4ff58bd50a2518 upstream.
    
    On a machine with CX20632, Alsamixer doesn't have 'Loopback
    Mixing' and 'Line'.
    
    Signed-off-by: huangwenhui <huangwenhuia@uniontech.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220607065631.10708-1-huangwenhuia@uniontech.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: hda/realtek - Fix microphone noise on ASUS TUF B550M-PLUS [+ + +]
Author: Marios Levogiannis <marios.levogiannis@gmail.com>
Date:   Mon May 30 10:41:31 2022 +0300

    ALSA: hda/realtek - Fix microphone noise on ASUS TUF B550M-PLUS
    
    commit 9bfa7b36343c7d84370bc61c9ed774635b05e4eb upstream.
    
    Set microphone pins 0x18 (rear) and 0x19 (front) to VREF_50 to fix the
    microphone noise on ASUS TUF B550M-PLUS which uses the ALCS1200A codec.
    The initial value was VREF_80.
    
    The same issue is also present on Windows using both the default Windows
    driver and all tested Realtek drivers before version 6.0.9049.1. Comparing
    Realtek driver 6.0.9049.1 (the first one without the microphone noise) to
    Realtek driver 6.0.9047.1 (the last one with the microphone noise)
    revealed that the fix is the result of setting pins 0x18 and 0x19 to
    VREF_50.
    
    This fix may also work for other boards that have been reported to have
    the same microphone issue and use the ALC1150 and ALCS1200A codecs, since
    these codecs are similar and the fix in the Realtek driver on Windows is
    common for both. However, it is currently enabled only for ASUS TUF
    B550M-PLUS as this is the only board that could be tested.
    
    Signed-off-by: Marios Levogiannis <marios.levogiannis@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220530074131.12258-1-marios.levogiannis@gmail.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: jack: Access input_dev under mutex [+ + +]
Author: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Date:   Tue Apr 12 11:16:28 2022 +0200

    ALSA: jack: Access input_dev under mutex
    
    [ Upstream commit 1b6a6fc5280e97559287b61eade2d4b363e836f2 ]
    
    It is possible when using ASoC that input_dev is unregistered while
    calling snd_jack_report, which causes NULL pointer dereference.
    In order to prevent this serialize access to input_dev using mutex lock.
    
    Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
    Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
    Link: https://lore.kernel.org/r/20220412091628.3056922-1-amadeuszx.slawinski@linux.intel.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
arm64: compat: Do not treat syscall number as ESR_ELx for a bad syscall [+ + +]
Author: Alexandru Elisei <alexandru.elisei@arm.com>
Date:   Mon Apr 25 12:44:41 2022 +0100

    arm64: compat: Do not treat syscall number as ESR_ELx for a bad syscall
    
    [ Upstream commit 3fed9e551417b84038b15117732ea4505eee386b ]
    
    If a compat process tries to execute an unknown system call above the
    __ARM_NR_COMPAT_END number, the kernel sends a SIGILL signal to the
    offending process. Information about the error is printed to dmesg in
    compat_arm_syscall() -> arm64_notify_die() -> arm64_force_sig_fault() ->
    arm64_show_signal().
    
    arm64_show_signal() interprets a non-zero value for
    current->thread.fault_code as an exception syndrome and displays the
    message associated with the ESR_ELx.EC field (bits 31:26).
    current->thread.fault_code is set in compat_arm_syscall() ->
    arm64_notify_die() with the bad syscall number instead of a valid ESR_ELx
    value. This means that the ESR_ELx.EC field has the value that the user set
    for the syscall number and the kernel can end up printing bogus exception
    messages*. For example, for the syscall number 0x68000000, which evaluates
    to ESR_ELx.EC value of 0x1A (ESR_ELx_EC_FPAC) the kernel prints this error:
    
    [   18.349161] syscall[300]: unhandled exception: ERET/ERETAA/ERETAB, ESR 0x68000000, Oops - bad compat syscall(2) in syscall[10000+50000]
    [   18.350639] CPU: 2 PID: 300 Comm: syscall Not tainted 5.18.0-rc1 #79
    [   18.351249] Hardware name: Pine64 RockPro64 v2.0 (DT)
    [..]
    
    which is misleading, as the bad compat syscall has nothing to do with
    pointer authentication.
    
    Stop arm64_show_signal() from printing exception syndrome information by
    having compat_arm_syscall() set the ESR_ELx value to 0, as it has no
    meaning for an invalid system call number. The example above now becomes:
    
    [   19.935275] syscall[301]: unhandled exception: Oops - bad compat syscall(2) in syscall[10000+50000]
    [   19.936124] CPU: 1 PID: 301 Comm: syscall Not tainted 5.18.0-rc1-00005-g7e08006d4102 #80
    [   19.936894] Hardware name: Pine64 RockPro64 v2.0 (DT)
    [..]
    
    which although shows less information because the syscall number,
    wrongfully advertised as the ESR value, is missing, it is better than
    showing plainly wrong information. The syscall number can be easily
    obtained with strace.
    
    *A 32-bit value above or equal to 0x8000_0000 is interpreted as a negative
    integer in compat_arm_syscal() and the condition scno < __ARM_NR_COMPAT_END
    evaluates to true; the syscall will exit to userspace in this case with the
    ENOSYS error code instead of arm64_notify_die() being called.
    
    Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20220425114444.368693-3-alexandru.elisei@arm.com
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

arm64: dts: qcom: ipq8074: fix the sleep clock frequency [+ + +]
Author: Kathiravan T <quic_kathirav@quicinc.com>
Date:   Fri Feb 11 17:44:15 2022 +0530

    arm64: dts: qcom: ipq8074: fix the sleep clock frequency
    
    commit f607dd767f5d6800ffbdce5b99ba81763b023781 upstream.
    
    Sleep clock frequency should be 32768Hz. Lets fix it.
    
    Cc: stable@vger.kernel.org
    Fixes: 41dac73e243d ("arm64: dts: Add ipq8074 SoC and HK01 board support")
    Link: https://lore.kernel.org/all/e2a447f8-6024-0369-f698-2027b6edcf9e@codeaurora.org/
    Signed-off-by: Kathiravan T <quic_kathirav@quicinc.com>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/1644581655-11568-1-git-send-email-quic_kathirav@quicinc.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

arm64: dts: rockchip: Move drive-impedance-ohm to emmc phy on rk3399 [+ + +]
Author: Shawn Lin <shawn.lin@rock-chips.com>
Date:   Tue Mar 15 17:27:06 2022 +0800

    arm64: dts: rockchip: Move drive-impedance-ohm to emmc phy on rk3399
    
    [ Upstream commit 4246d0bab2a8685e3d4aec2cb0ef8c526689ce96 ]
    
    drive-impedance-ohm is introduced for emmc phy instead of pcie phy.
    
    Fixes: fb8b7460c995 ("arm64: dts: rockchip: Define drive-impedance-ohm for RK3399's emmc-phy.")
    Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
    Link: https://lore.kernel.org/r/1647336426-154797-1-git-send-email-shawn.lin@rock-chips.com
    Signed-off-by: Heiko Stuebner <heiko@sntech.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ARM: dts: bcm2835-rpi-b: Fix GPIO line names [+ + +]
Author: Stefan Wahren <stefan.wahren@i2se.com>
Date:   Mon Apr 11 22:01:41 2022 +0200

    ARM: dts: bcm2835-rpi-b: Fix GPIO line names
    
    [ Upstream commit 97bd8659c1c46c23e4daea7e040befca30939950 ]
    
    Recently this has been fixed in the vendor tree, so upstream this.
    
    Fixes: 731b26a6ac17 ("ARM: bcm2835: Add names for the Raspberry Pi GPIO lines")
    Signed-off-by: Phil Elwell <phil@raspberrypi.com>
    Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: bcm2835-rpi-zero-w: Fix GPIO line name for Wifi/BT [+ + +]
Author: Phil Elwell <phil@raspberrypi.com>
Date:   Mon Apr 11 22:01:38 2022 +0200

    ARM: dts: bcm2835-rpi-zero-w: Fix GPIO line name for Wifi/BT
    
    [ Upstream commit 2c663e5e5bbf2a5b85e0f76ccb69663f583c3e33 ]
    
    The GPIOs 30 to 39 are connected to the Cypress CYW43438 (Wifi/BT).
    So fix the GPIO line names accordingly.
    
    Fixes: 2c7c040c73e9 ("ARM: dts: bcm2835: Add Raspberry Pi Zero W")
    Signed-off-by: Phil Elwell <phil@raspberrypi.com>
    Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: bcm2837-rpi-3-b-plus: Fix GPIO line name of power LED [+ + +]
Author: Phil Elwell <phil@raspberrypi.com>
Date:   Mon Apr 11 22:01:40 2022 +0200

    ARM: dts: bcm2837-rpi-3-b-plus: Fix GPIO line name of power LED
    
    [ Upstream commit 57f718aa4b93392fb1a8c0a874ab882b9e18136a ]
    
    The red LED on the Raspberry Pi 3 B Plus is the power LED.
    So fix the GPIO line name accordingly.
    
    Fixes: 71c0cd2283f2 ("ARM: dts: bcm2837: Add Raspberry Pi 3 B+")
    Signed-off-by: Phil Elwell <phil@raspberrypi.com>
    Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: bcm2837-rpi-cm3-io3: Fix GPIO line names for SMPS I2C [+ + +]
Author: Phil Elwell <phil@raspberrypi.com>
Date:   Mon Apr 11 22:01:39 2022 +0200

    ARM: dts: bcm2837-rpi-cm3-io3: Fix GPIO line names for SMPS I2C
    
    [ Upstream commit 9fd26fd02749ec964eb0d588a3bab9e09bf77927 ]
    
    The GPIOs 46 & 47 are already used for a I2C interface to a SMPS.
    So fix the GPIO line names accordingly.
    
    Fixes: a54fe8a6cf66 ("ARM: dts: add Raspberry Pi Compute Module 3 and IO board")
    Signed-off-by: Phil Elwell <phil@raspberrypi.com>
    Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: exynos: add atmel,24c128 fallback to Samsung EEPROM [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Tue Apr 26 20:34:43 2022 +0200

    ARM: dts: exynos: add atmel,24c128 fallback to Samsung EEPROM
    
    [ Upstream commit f038e8186fbc5723d7d38c6fa1d342945107347e ]
    
    The Samsung s524ad0xd1 EEPROM should use atmel,24c128 fallback,
    according to the AT24 EEPROM bindings.
    
    Reported-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Link: https://lore.kernel.org/r/20220426183443.243113-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: ox820: align interrupt controller node name with dtschema [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Thu Apr 7 21:29:59 2022 +0200

    ARM: dts: ox820: align interrupt controller node name with dtschema
    
    [ Upstream commit fbcd5ad7a419ad40644a0bb8b4152bc660172d8a ]
    
    Fixes dtbs_check warnings like:
    
      gic@1000: $nodename:0: 'gic@1000' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
    
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Acked-by: Neil Armstrong <narmstrong@baylibre.com>
    Link: https://lore.kernel.org/r/20220317115705.450427-1-krzysztof.kozlowski@canonical.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: dts: suniv: F1C100: fix watchdog compatible [+ + +]
Author: Andre Przywara <andre.przywara@arm.com>
Date:   Thu Mar 17 16:23:40 2022 +0000

    ARM: dts: suniv: F1C100: fix watchdog compatible
    
    [ Upstream commit 01a850ee61cbf0ab77dcbf26bb133fec2dd640d6 ]
    
    The F1C100 series of SoCs actually have their watchdog IP being
    compatible with the newer Allwinner generation, not the older one.
    
    The currently described sun4i-a10-wdt actually does not work, neither
    the watchdog functionality (just never fires), nor the reset part
    (reboot hangs).
    
    Replace the compatible string with the one used by the newer generation.
    Verified to work with both the watchdog and reboot functionality on a
    LicheePi Nano.
    
    Also add the missing interrupt line and clock source, to make it binding
    compliant.
    
    Fixes: 4ba16d17efdd ("ARM: dts: suniv: add initial DTSI file for F1C100s")
    Signed-off-by: Andre Przywara <andre.przywara@arm.com>
    Acked-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
    Link: https://lore.kernel.org/r/20220317162349.739636-4-andre.przywara@arm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: hisi: Add missing of_node_put after of_find_compatible_node [+ + +]
Author: Peng Wu <wupeng58@huawei.com>
Date:   Thu Apr 28 10:43:06 2022 +0000

    ARM: hisi: Add missing of_node_put after of_find_compatible_node
    
    [ Upstream commit 9bc72e47d4630d58a840a66a869c56b29554cfe4 ]
    
    of_find_compatible_node  will increment the refcount of the returned
    device_node. Calling of_node_put() to avoid the refcount leak
    
    Signed-off-by: Peng Wu <wupeng58@huawei.com>
    Signed-off-by: Wei Xu <xuwei5@hisilicon.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
arm: mediatek: select arch timer for mt7629 [+ + +]
Author: Chuanhong Guo <gch981213@gmail.com>
Date:   Sat Apr 9 17:13:47 2022 +0800

    arm: mediatek: select arch timer for mt7629
    
    [ Upstream commit d66aea197d534e23d4989eb72fca9c0c114b97c9 ]
    
    This chip has an armv7 arch timer according to the dts. Select it in
    Kconfig to enforce the support for it.
    Otherwise the system time is just completely wrong if user forget to
    enable ARM_ARCH_TIMER in kernel config.
    
    Fixes: a43379dddf1b ("arm: mediatek: add MT7629 smp bring up code")
    Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
    Link: https://lore.kernel.org/r/20220409091347.2473449-1-gch981213@gmail.com
    Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ARM: OMAP1: clock: Fix UART rate reporting algorithm [+ + +]
Author: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Date:   Sun Apr 10 15:07:54 2022 +0200

    ARM: OMAP1: clock: Fix UART rate reporting algorithm
    
    [ Upstream commit 338d5d476cde853dfd97378d20496baabc2ce3c0 ]
    
    Since its introduction to the mainline kernel, omap1_uart_recalc() helper
    makes incorrect use of clk->enable_bit as a ready to use bitmap mask while
    it only provides the bit number.  Fix it.
    
    Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
    Acked-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ARM: pxa: maybe fix gpio lookup tables [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed Sep 11 22:31:51 2019 +0200

    ARM: pxa: maybe fix gpio lookup tables
    
    commit 2672a4bff6c03a20d5ae460a091f67ee782c3eff upstream.
    
    From inspection I found a couple of GPIO lookups that are
    listed with device "gpio-pxa", but actually have a number
    from a different gpio controller.
    
    Try to rectify that here, with a guess of what the actual
    device name is.
    
    Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ARM: versatile: Add missing of_node_put in dcscb_init [+ + +]
Author: Peng Wu <wupeng58@huawei.com>
Date:   Fri Apr 29 01:03:56 2022 +0200

    ARM: versatile: Add missing of_node_put in dcscb_init
    
    [ Upstream commit 23b44f9c649bbef10b45fa33080cd8b4166800ae ]
    
    The device_node pointer is returned by of_find_compatible_node
    with refcount incremented. We should use of_node_put() to avoid
    the refcount leak.
    
    Signed-off-by: Peng Wu <wupeng58@huawei.com>
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Link: https://lore.kernel.org/r/20220428230356.69418-1-linus.walleij@linaro.org'
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ASoC: dapm: Don't fold register value changes into notifications [+ + +]
Author: Mark Brown <broonie@kernel.org>
Date:   Thu Apr 28 17:18:32 2022 +0100

    ASoC: dapm: Don't fold register value changes into notifications
    
    [ Upstream commit ad685980469b9f9b99d4d6ea05f4cb8f57cb2234 ]
    
    DAPM tracks and reports the value presented to the user from DAPM controls
    separately to the register value, these may diverge during initialisation
    or when an autodisable control is in use.
    
    When writing DAPM controls we currently report that a change has occurred
    if either the DAPM value or the value stored in the register has changed,
    meaning that if the two are out of sync we may appear to report a spurious
    event to userspace. Since we use this folded in value for nothing other
    than the value reported to userspace simply drop the folding in of the
    register change.
    
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Link: https://lore.kernel.org/r/20220428161833.3690050-1-broonie@kernel.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed May 11 10:58:03 2022 +0400

    ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe
    
    [ Upstream commit 41cd312dfe980af869c3503b4d38e62ed20dd3b7 ]
    
    of_find_i2c_device_by_node() takes a reference,
    In error paths, we should call put_device() to drop
    the reference to aviod refount leak.
    
    Fixes: 81e8e4926167 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Fabio Estevam <festevam@gmail.com>
    Link: https://lore.kernel.org/r/20220511065803.3957-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: fsl_sai: Fix FSL_SAI_xDR/xFR definition [+ + +]
Author: Shengjiu Wang <shengjiu.wang@nxp.com>
Date:   Mon May 23 13:44:21 2022 +0800

    ASoC: fsl_sai: Fix FSL_SAI_xDR/xFR definition
    
    [ Upstream commit e4dd748dc87cf431af7b3954963be0d9f6150217 ]
    
    There are multiple xDR and xFR registers, the index is
    from 0 to 7. FSL_SAI_xDR and FSL_SAI_xFR is abandoned,
    replace them with FSL_SAI_xDR0 and FSL_SAI_xFR0.
    
    Fixes: 4f7a0728b530 ("ASoC: fsl_sai: Add support for SAI new version")
    Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
    Link: https://lore.kernel.org/r/1653284661-18964-1-git-send-email-shengjiu.wang@nxp.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: max98357a: remove dependency on GPIOLIB [+ + +]
Author: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date:   Tue May 17 12:26:46 2022 -0500

    ASoC: max98357a: remove dependency on GPIOLIB
    
    [ Upstream commit 21ca3274333f5c1cbbf9d91e5b33f4f2463859b2 ]
    
    commit dcc2c012c7691 ("ASoC: Fix gpiolib dependencies") removed a
    series of unnecessary dependencies on GPIOLIB when the gpio was
    optional.
    
    A similar simplification seems valid for max98357a, so remove the
    dependency as well. This will avoid the following warning
    
       WARNING: unmet direct dependencies detected for SND_SOC_MAX98357A
         Depends on [n]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && GPIOLIB [=n]
         Selected by [y]:
         - SND_SOC_INTEL_SOF_CS42L42_MACH [=y] && SOUND [=y] && !UML &&
           SND [=y] && SND_SOC [=y] && SND_SOC_INTEL_MACH [=y] &&
           (SND_SOC_SOF_HDA_LINK [=y] || SND_SOC_SOF_BAYTRAIL [=n]) && I2C
           [=y] && ACPI [=y] && SND_HDA_CODEC_HDMI [=y] &&
           SND_SOC_SOF_HDA_AUDIO_CODEC [=y] && (MFD_INTEL_LPSS [=y] ||
           COMPILE_TEST [=n])
    
    Reported-by: kernel test robot <yujie.liu@intel.com>
    Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
    Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
    Link: https://lore.kernel.org/r/20220517172647.468244-2-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: mediatek: Fix error handling in mt8173_max98090_dev_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon Apr 4 09:29:01 2022 +0000

    ASoC: mediatek: Fix error handling in mt8173_max98090_dev_probe
    
    [ Upstream commit 4f4e0454e226de3bf4efd7e7924d1edc571c52d5 ]
    
    Call of_node_put(platform_node) to avoid refcount leak in
    the error path.
    
    Fixes: 94319ba10eca ("ASoC: mediatek: Use platform_of_node for machine drivers")
    Fixes: 493433785df0 ("ASoC: mediatek: mt8173: fix device_node leak")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Link: https://lore.kernel.org/r/20220404092903.26725-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: mediatek: Fix missing of_node_put in mt2701_wm8960_machine_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon Apr 4 09:35:25 2022 +0000

    ASoC: mediatek: Fix missing of_node_put in mt2701_wm8960_machine_probe
    
    [ Upstream commit 05654431a18fe24e5e46a375d98904134628a102 ]
    
    This node pointer is returned by of_parse_phandle() with
    refcount incremented in this function.
    Calling of_node_put() to avoid the refcount leak.
    
    Fixes: 8625c1dbd876 ("ASoC: mediatek: Add mt2701-wm8960 machine driver")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220404093526.30004-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: mxs-saif: Fix refcount leak in mxs_saif_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed May 11 17:37:22 2022 +0400

    ASoC: mxs-saif: Fix refcount leak in mxs_saif_probe
    
    [ Upstream commit 2be84f73785fa9ed6443e3c5b158730266f1c2ee ]
    
    of_parse_phandle() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when done.
    
    Fixes: 08641c7c74dd ("ASoC: mxs: add device tree support for mxs-saif")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220511133725.39039-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: rk3328: fix disabling mclk on pclk probe failure [+ + +]
Author: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Date:   Wed Apr 27 19:23:11 2022 +0200

    ASoC: rk3328: fix disabling mclk on pclk probe failure
    
    [ Upstream commit dd508e324cdde1c06ace08a8143fa50333a90703 ]
    
    If preparing/enabling the pclk fails, the probe function should
    unprepare and disable the previously prepared and enabled mclk,
    which it doesn't do. This commit rectifies this.
    
    Fixes: c32759035ad2 ("ASoC: rockchip: support ACODEC for rk3328")
    Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
    Reviewed-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
    Link: https://lore.kernel.org/r/20220427172310.138638-1-frattaroli.nicolas@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: rt5514: Fix event generation for "DSP Voice Wake Up" control [+ + +]
Author: Mark Brown <broonie@kernel.org>
Date:   Thu Apr 28 17:24:44 2022 +0100

    ASoC: rt5514: Fix event generation for "DSP Voice Wake Up" control
    
    commit 4213ff556740bb45e2d9ff0f50d056c4e7dd0921 upstream.
    
    The driver has a custom put function for "DSP Voice Wake Up" which does
    not generate event notifications on change, instead returning 0. Since we
    already exit early in the case that there is no change this can be fixed
    by unconditionally returning 1 at the end of the function.
    
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20220428162444.3883147-1-broonie@kernel.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ASoC: rt5645: Fix errorenous cleanup order [+ + +]
Author: Lin Ma <linma@zju.edu.cn>
Date:   Mon May 16 17:20:35 2022 +0800

    ASoC: rt5645: Fix errorenous cleanup order
    
    [ Upstream commit 2def44d3aec59e38d2701c568d65540783f90f2f ]
    
    There is a logic error when removing rt5645 device as the function
    rt5645_i2c_remove() first cancel the &rt5645->jack_detect_work and
    delete the &rt5645->btn_check_timer latter. However, since the timer
    handler rt5645_btn_check_callback() will re-queue the jack_detect_work,
    this cleanup order is buggy.
    
    That is, once the del_timer_sync in rt5645_i2c_remove is concurrently
    run with the rt5645_btn_check_callback, the canceled jack_detect_work
    will be rescheduled again, leading to possible use-after-free.
    
    This patch fix the issue by placing the del_timer_sync function before
    the cancel_delayed_work_sync.
    
    Signed-off-by: Lin Ma <linma@zju.edu.cn>
    Link: https://lore.kernel.org/r/20220516092035.28283-1-linma@zju.edu.cn
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: tscs454: Add endianness flag in snd_soc_component_driver [+ + +]
Author: Charles Keepax <ckeepax@opensource.cirrus.com>
Date:   Wed May 4 18:08:52 2022 +0100

    ASoC: tscs454: Add endianness flag in snd_soc_component_driver
    
    [ Upstream commit ff69ec96b87dccb3a29edef8cec5d4fefbbc2055 ]
    
    The endianness flag is used on the CODEC side to specify an
    ambivalence to endian, typically because it is lost over the hardware
    link. This device receives audio over an I2S DAI and as such should
    have endianness applied.
    
    A fixup is also required to use the width directly rather than relying
    on the format in hw_params, now both little and big endian would be
    supported. It is worth noting this changes the behaviour of S24_LE to
    use a word length of 24 rather than 32. This would appear to be a
    correction since the fact S24_LE is stored as 32 bits should not be
    presented over the bus.
    
    Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
    Link: https://lore.kernel.org/r/20220504170905.332415-26-ckeepax@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ASoC: wm2000: fix missing clk_disable_unprepare() on error in wm2000_anc_transition() [+ + +]
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Sat May 14 17:10:53 2022 +0800

    ASoC: wm2000: fix missing clk_disable_unprepare() on error in wm2000_anc_transition()
    
    [ Upstream commit be2af740e2a9c7134f2d8ab4f104006e110b13de ]
    
    Fix the missing clk_disable_unprepare() before return
    from wm2000_anc_transition() in the error handling case.
    
    Fixes: 514cfd6dd725 ("ASoC: wm2000: Integrate with clock API")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
    Link: https://lore.kernel.org/r/20220514091053.686416-1-yangyingliang@huawei.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files [+ + +]
Author: Sergey Shtylyov <s.shtylyov@omp.ru>
Date:   Wed Jun 8 22:51:07 2022 +0300

    ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
    
    commit 72aad489f992871e908ff6d9055b26c6366fb864 upstream.
    
    The {dma|pio}_mode sysfs files are incorrectly documented as having a
    list of the supported DMA/PIO transfer modes, while the corresponding
    fields of the *struct* ata_device hold the transfer mode IDs, not masks.
    
    To match these docs, the {dma|pio}_mode (and even xfer_mode!) sysfs
    files are handled by the ata_bitfield_name_match() macro which leads to
    reading such kind of nonsense from them:
    
    $ cat /sys/class/ata_device/dev3.0/pio_mode
    XFER_UDMA_7, XFER_UDMA_6, XFER_UDMA_5, XFER_UDMA_4, XFER_MW_DMA_4,
    XFER_PIO_6, XFER_PIO_5, XFER_PIO_4, XFER_PIO_3, XFER_PIO_2, XFER_PIO_1,
    XFER_PIO_0
    
    Using the correct ata_bitfield_name_search() macro fixes that:
    
    $ cat /sys/class/ata_device/dev3.0/pio_mode
    XFER_PIO_4
    
    While fixing the file documentation, somewhat reword the {dma|pio}_mode
    file doc and add a note about being mostly useful for PATA devices to
    the xfer_mode file doc...
    
    Fixes: d9027470b886 ("[libata] Add ATA transport class")
    Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
    Cc: stable@vger.kernel.org
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed Jun 1 12:59:26 2022 +0400

    ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe
    
    [ Upstream commit 10d6bdf532902be1d8aa5900b3c03c5671612aa2 ]
    
    of_find_device_by_node() takes reference, we should use put_device()
    to release it when not need anymore.
    Add missing put_device() to avoid refcount leak.
    
    Fixes: 43f01da0f279 ("MIPS/OCTEON/ata: Convert pata_octeon_cf.c to use device tree.")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ath9k: fix ar9003_get_eepmisc [+ + +]
Author: Wenli Looi <wlooi@ucalgary.ca>
Date:   Sun Mar 20 17:30:08 2022 -0600

    ath9k: fix ar9003_get_eepmisc
    
    [ Upstream commit 9aaff3864b603408c02c629957ae8d8ff5d5a4f2 ]
    
    The current implementation is reading the wrong eeprom type.
    
    Fixes: d8ec2e2a63e8 ("ath9k: Add an eeprom_ops callback for retrieving the eepmisc value")
    Signed-off-by: Wenli Looi <wlooi@ucalgary.ca>
    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/20220320233010.123106-5-wlooi@ucalgary.ca
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ath9k: fix QCA9561 PA bias level [+ + +]
Author: Thibaut VARÈNE <hacks+kernel@slashdirt.org>
Date:   Sun Apr 17 16:51:45 2022 +0200

    ath9k: fix QCA9561 PA bias level
    
    [ Upstream commit e999a5da28a0e0f7de242d841ef7d5e48f4646ae ]
    
    This patch fixes an invalid TX PA DC bias level on QCA9561, which
    results in a very low output power and very low throughput as devices
    are further away from the AP (compared to other 2.4GHz APs).
    
    This patch was suggested by Felix Fietkau, who noted[1]:
    "The value written to that register is wrong, because while the mask
    definition AR_CH0_TOP2_XPABIASLVL uses a different value for 9561, the
    shift definition AR_CH0_TOP2_XPABIASLVL_S is hardcoded to 12, which is
    wrong for 9561."
    
    In real life testing, without this patch the 2.4GHz throughput on
    Yuncore XD3200 is around 10Mbps sitting next to the AP, and closer to
    practical maximum with the patch applied.
    
    [1] https://lore.kernel.org/all/91c58969-c60e-2f41-00ac-737786d435ae@nbd.name
    
    Signed-off-by: Thibaut VARÈNE <hacks+kernel@slashdirt.org>
    Acked-by: Felix Fietkau <nbd@nbd.name>
    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/20220417145145.1847-1-hacks+kernel@slashdirt.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ath9k_htc: fix potential out of bounds access with invalid rxstatus->rs_keyix [+ + +]
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Sat Apr 9 09:12:25 2022 +0300

    ath9k_htc: fix potential out of bounds access with invalid rxstatus->rs_keyix
    
    [ Upstream commit 2dc509305cf956381532792cb8dceef2b1504765 ]
    
    The "rxstatus->rs_keyix" eventually gets passed to test_bit() so we need to
    ensure that it is within the bitmap.
    
    drivers/net/wireless/ath/ath9k/common.c:46 ath9k_cmn_rx_accept()
    error: passing untrusted data 'rx_stats->rs_keyix' to 'test_bit()'
    
    Fixes: 4ed1a8d4a257 ("ath9k_htc: use ath9k_cmn_rx_accept")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.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/20220409061225.GA5447@kili
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
b43: Fix assigning negative value to unsigned variable [+ + +]
Author: Haowen Bai <baihaowen@meizu.com>
Date:   Fri Mar 25 18:15:15 2022 +0800

    b43: Fix assigning negative value to unsigned variable
    
    [ Upstream commit 11800d893b38e0e12d636c170c1abc19c43c730c ]
    
    fix warning reported by smatch:
    drivers/net/wireless/broadcom/b43/phy_n.c:585 b43_nphy_adjust_lna_gain_table()
    warn: assigning (-2) to unsigned variable '*(lna_gain[0])'
    
    Signed-off-by: Haowen Bai <baihaowen@meizu.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/1648203315-28093-1-git-send-email-baihaowen@meizu.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
b43legacy: Fix assigning negative value to unsigned variable [+ + +]
Author: Haowen Bai <baihaowen@meizu.com>
Date:   Fri Mar 25 18:17:13 2022 +0800

    b43legacy: Fix assigning negative value to unsigned variable
    
    [ Upstream commit 3f6b867559b3d43a7ce1b4799b755e812fc0d503 ]
    
    fix warning reported by smatch:
    drivers/net/wireless/broadcom/b43legacy/phy.c:1181 b43legacy_phy_lo_b_measure()
    warn: assigning (-772) to unsigned variable 'fval'
    
    Signed-off-by: Haowen Bai <baihaowen@meizu.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/1648203433-8736-1-git-send-email-baihaowen@meizu.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
bfq: Avoid merging queues with different parents [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Tue Jun 7 11:15:09 2022 +0200

    bfq: Avoid merging queues with different parents
    
    commit c1cee4ab36acef271be9101590756ed0c0c374d9 upstream.
    
    It can happen that the parent of a bfqq changes between the moment we
    decide two queues are worth to merge (and set bic->stable_merge_bfqq)
    and the moment bfq_setup_merge() is called. This can happen e.g. because
    the process submitted IO for a different cgroup and thus bfqq got
    reparented. It can even happen that the bfqq we are merging with has
    parent cgroup that is already offline and going to be destroyed in which
    case the merge can lead to use-after-free issues such as:
    
    BUG: KASAN: use-after-free in __bfq_deactivate_entity+0x9cb/0xa50
    Read of size 8 at addr ffff88800693c0c0 by task runc:[2:INIT]/10544
    
    CPU: 0 PID: 10544 Comm: runc:[2:INIT] Tainted: G            E     5.15.2-0.g5fb85fd-default #1 openSUSE Tumbleweed (unreleased) f1f3b891c72369aebecd2e43e4641a6358867c70
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a-rebuilt.opensuse.org 04/01/2014
    Call Trace:
     <IRQ>
     dump_stack_lvl+0x46/0x5a
     print_address_description.constprop.0+0x1f/0x140
     ? __bfq_deactivate_entity+0x9cb/0xa50
     kasan_report.cold+0x7f/0x11b
     ? __bfq_deactivate_entity+0x9cb/0xa50
     __bfq_deactivate_entity+0x9cb/0xa50
     ? update_curr+0x32f/0x5d0
     bfq_deactivate_entity+0xa0/0x1d0
     bfq_del_bfqq_busy+0x28a/0x420
     ? resched_curr+0x116/0x1d0
     ? bfq_requeue_bfqq+0x70/0x70
     ? check_preempt_wakeup+0x52b/0xbc0
     __bfq_bfqq_expire+0x1a2/0x270
     bfq_bfqq_expire+0xd16/0x2160
     ? try_to_wake_up+0x4ee/0x1260
     ? bfq_end_wr_async_queues+0xe0/0xe0
     ? _raw_write_unlock_bh+0x60/0x60
     ? _raw_spin_lock_irq+0x81/0xe0
     bfq_idle_slice_timer+0x109/0x280
     ? bfq_dispatch_request+0x4870/0x4870
     __hrtimer_run_queues+0x37d/0x700
     ? enqueue_hrtimer+0x1b0/0x1b0
     ? kvm_clock_get_cycles+0xd/0x10
     ? ktime_get_update_offsets_now+0x6f/0x280
     hrtimer_interrupt+0x2c8/0x740
    
    Fix the problem by checking that the parent of the two bfqqs we are
    merging in bfq_setup_merge() is the same.
    
    Link: https://lore.kernel.org/linux-block/20211125172809.GC19572@quack2.suse.cz/
    CC: stable@vger.kernel.org
    Fixes: 430a67f9d616 ("block, bfq: merge bursts of newly-created queues")
    Tested-by: "yukuai (C)" <yukuai3@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220401102752.8599-2-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bfq: Drop pointless unlock-lock pair [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Tue Jun 7 11:15:10 2022 +0200

    bfq: Drop pointless unlock-lock pair
    
    commit fc84e1f941b91221092da5b3102ec82da24c5673 upstream.
    
    In bfq_insert_request() we unlock bfqd->lock only to call
    trace_block_rq_insert() and then lock bfqd->lock again. This is really
    pointless since tracing is disabled if we really care about performance
    and even if the tracepoint is enabled, it is a quick call.
    
    CC: stable@vger.kernel.org
    Tested-by: "yukuai (C)" <yukuai3@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220401102752.8599-5-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bfq: Get rid of __bio_blkcg() usage [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Tue Jun 7 11:15:12 2022 +0200

    bfq: Get rid of __bio_blkcg() usage
    
    commit 4e54a2493e582361adc3bfbf06c7d50d19d18837 upstream.
    
    BFQ usage of __bio_blkcg() is a relict from the past. Furthermore if bio
    would not be associated with any blkcg, the usage of __bio_blkcg() in
    BFQ is prone to races with the task being migrated between cgroups as
    __bio_blkcg() calls at different places could return different blkcgs.
    
    Convert BFQ to the new situation where bio->bi_blkg is initialized in
    bio_set_dev() and thus practically always valid. This allows us to save
    blkcg_gq lookup and noticeably simplify the code.
    
    CC: stable@vger.kernel.org
    Fixes: 0fe061b9f03c ("blkcg: fix ref count issue with bio_blkcg() using task_css")
    Tested-by: "yukuai (C)" <yukuai3@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220401102752.8599-8-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bfq: Make sure bfqg for which we are queueing requests is online [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Tue Jun 7 11:15:13 2022 +0200

    bfq: Make sure bfqg for which we are queueing requests is online
    
    commit 075a53b78b815301f8d3dd1ee2cd99554e34f0dd upstream.
    
    Bios queued into BFQ IO scheduler can be associated with a cgroup that
    was already offlined. This may then cause insertion of this bfq_group
    into a service tree. But this bfq_group will get freed as soon as last
    bio associated with it is completed leading to use after free issues for
    service tree users. Fix the problem by making sure we always operate on
    online bfq_group. If the bfq_group associated with the bio is not
    online, we pick the first online parent.
    
    CC: stable@vger.kernel.org
    Fixes: e21b7a0b9887 ("block, bfq: add full hierarchical scheduling and cgroups support")
    Tested-by: "yukuai (C)" <yukuai3@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220401102752.8599-9-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bfq: Remove pointless bfq_init_rq() calls [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Tue Jun 7 11:15:11 2022 +0200

    bfq: Remove pointless bfq_init_rq() calls
    
    commit 5f550ede5edf846ecc0067be1ba80514e6fe7f8e upstream.
    
    We call bfq_init_rq() from request merging functions where requests we
    get should have already gone through bfq_init_rq() during insert and
    anyway we want to do anything only if the request is already tracked by
    BFQ. So replace calls to bfq_init_rq() with RQ_BFQQ() instead to simply
    skip requests untracked by BFQ. We move bfq_init_rq() call in
    bfq_insert_request() a bit earlier to cover request merging and thus
    can transfer FIFO position in case of a merge.
    
    CC: stable@vger.kernel.org
    Tested-by: "yukuai (C)" <yukuai3@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220401102752.8599-6-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bfq: Split shared queues on move between cgroups [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Fri Apr 1 12:27:44 2022 +0200

    bfq: Split shared queues on move between cgroups
    
    commit 3bc5e683c67d94bd839a1da2e796c15847b51b69 upstream.
    
    When bfqq is shared by multiple processes it can happen that one of the
    processes gets moved to a different cgroup (or just starts submitting IO
    for different cgroup). In case that happens we need to split the merged
    bfqq as otherwise we will have IO for multiple cgroups in one bfqq and
    we will just account IO time to wrong entities etc.
    
    Similarly if the bfqq is scheduled to merge with another bfqq but the
    merge didn't happen yet, cancel the merge as it need not be valid
    anymore.
    
    CC: stable@vger.kernel.org
    Fixes: e21b7a0b9887 ("block, bfq: add full hierarchical scheduling and cgroups support")
    Tested-by: "yukuai (C)" <yukuai3@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220401102752.8599-3-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bfq: Track whether bfq_group is still online [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Fri Apr 1 12:27:48 2022 +0200

    bfq: Track whether bfq_group is still online
    
    commit 09f871868080c33992cd6a9b72a5ca49582578fa upstream.
    
    Track whether bfq_group is still online. We cannot rely on
    blkcg_gq->online because that gets cleared only after all policies are
    offlined and we need something that gets updated already under
    bfqd->lock when we are cleaning up our bfq_group to be able to guarantee
    that when we see online bfq_group, it will stay online while we are
    holding bfqd->lock lock.
    
    CC: stable@vger.kernel.org
    Tested-by: "yukuai (C)" <yukuai3@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220401102752.8599-7-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

bfq: Update cgroup information before merging bio [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Fri Apr 1 12:27:45 2022 +0200

    bfq: Update cgroup information before merging bio
    
    commit ea591cd4eb270393810e7be01feb8fde6a34fbbe upstream.
    
    When the process is migrated to a different cgroup (or in case of
    writeback just starts submitting bios associated with a different
    cgroup) bfq_merge_bio() can operate with stale cgroup information in
    bic. Thus the bio can be merged to a request from a different cgroup or
    it can result in merging of bfqqs for different cgroups or bfqqs of
    already dead cgroups and causing possible use-after-free issues. Fix the
    problem by updating cgroup information in bfq_merge_bio().
    
    CC: stable@vger.kernel.org
    Fixes: e21b7a0b9887 ("block, bfq: add full hierarchical scheduling and cgroups support")
    Tested-by: "yukuai (C)" <yukuai3@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220401102752.8599-4-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
binfmt_flat: do not stop relocating GOT entries prematurely on riscv [+ + +]
Author: Niklas Cassel <niklas.cassel@wdc.com>
Date:   Thu Apr 14 11:10:18 2022 +0200

    binfmt_flat: do not stop relocating GOT entries prematurely on riscv
    
    commit 6045ab5fea4c849153ebeb0acb532da5f29d69c4 upstream.
    
    bFLT binaries are usually created using elf2flt.
    
    The linker script used by elf2flt has defined the .data section like the
    following for the last 19 years:
    
    .data : {
            _sdata = . ;
            __data_start = . ;
            data_start = . ;
            *(.got.plt)
            *(.got)
            FILL(0) ;
            . = ALIGN(0x20) ;
            LONG(-1)
            . = ALIGN(0x20) ;
            ...
    }
    
    It places the .got.plt input section before the .got input section.
    The same is true for the default linker script (ld --verbose) on most
    architectures except x86/x86-64.
    
    The binfmt_flat loader should relocate all GOT entries until it encounters
    a -1 (the LONG(-1) in the linker script).
    
    The problem is that the .got.plt input section starts with a GOTPLT header
    (which has size 16 bytes on elf64-riscv and 8 bytes on elf32-riscv), where
    the first word is set to -1. See the binutils implementation for riscv [1].
    
    This causes the binfmt_flat loader to stop relocating GOT entries
    prematurely and thus causes the application to crash when running.
    
    Fix this by skipping the whole GOTPLT header, since the whole GOTPLT header
    is reserved for the dynamic linker.
    
    The GOTPLT header will only be skipped for bFLT binaries with flag
    FLAT_FLAG_GOTPIC set. This flag is unconditionally set by elf2flt if the
    supplied ELF binary has the symbol _GLOBAL_OFFSET_TABLE_ defined.
    ELF binaries without a .got input section should thus remain unaffected.
    
    Tested on RISC-V Canaan Kendryte K210 and RISC-V QEMU nommu_virt_defconfig.
    
    [1] https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elfnn-riscv.c;hb=binutils-2_38#l3275
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
    Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Link: https://lore.kernel.org/r/20220414091018.896737-1-niklas.cassel@wdc.com
    Fixed-by: kernel test robot <lkp@intel.com>
    Link: https://lore.kernel.org/lkml/202204182333.OIUOotK8-lkp@intel.com
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 
blk-iolatency: Fix inflight count imbalances and IO hangs on offline [+ + +]
Author: Tejun Heo <tj@kernel.org>
Date:   Fri May 13 20:55:45 2022 -1000

    blk-iolatency: Fix inflight count imbalances and IO hangs on offline
    
    commit 8a177a36da6c54c98b8685d4f914cb3637d53c0d upstream.
    
    iolatency needs to track the number of inflight IOs per cgroup. As this
    tracking can be expensive, it is disabled when no cgroup has iolatency
    configured for the device. To ensure that the inflight counters stay
    balanced, iolatency_set_limit() freezes the request_queue while manipulating
    the enabled counter, which ensures that no IO is in flight and thus all
    counters are zero.
    
    Unfortunately, iolatency_set_limit() isn't the only place where the enabled
    counter is manipulated. iolatency_pd_offline() can also dec the counter and
    trigger disabling. As this disabling happens without freezing the q, this
    can easily happen while some IOs are in flight and thus leak the counts.
    
    This can be easily demonstrated by turning on iolatency on an one empty
    cgroup while IOs are in flight in other cgroups and then removing the
    cgroup. Note that iolatency shouldn't have been enabled elsewhere in the
    system to ensure that removing the cgroup disables iolatency for the whole
    device.
    
    The following keeps flipping on and off iolatency on sda:
    
      echo +io > /sys/fs/cgroup/cgroup.subtree_control
      while true; do
          mkdir -p /sys/fs/cgroup/test
          echo '8:0 target=100000' > /sys/fs/cgroup/test/io.latency
          sleep 1
          rmdir /sys/fs/cgroup/test
          sleep 1
      done
    
    and there's concurrent fio generating direct rand reads:
    
      fio --name test --filename=/dev/sda --direct=1 --rw=randread \
          --runtime=600 --time_based --iodepth=256 --numjobs=4 --bs=4k
    
    while monitoring with the following drgn script:
    
      while True:
        for css in css_for_each_descendant_pre(prog['blkcg_root'].css.address_of_()):
            for pos in hlist_for_each(container_of(css, 'struct blkcg', 'css').blkg_list):
                blkg = container_of(pos, 'struct blkcg_gq', 'blkcg_node')
                pd = blkg.pd[prog['blkcg_policy_iolatency'].plid]
                if pd.value_() == 0:
                    continue
                iolat = container_of(pd, 'struct iolatency_grp', 'pd')
                inflight = iolat.rq_wait.inflight.counter.value_()
                if inflight:
                    print(f'inflight={inflight} {disk_name(blkg.q.disk).decode("utf-8")} '
                          f'{cgroup_path(css.cgroup).decode("utf-8")}')
        time.sleep(1)
    
    The monitoring output looks like the following:
    
      inflight=1 sda /user.slice
      inflight=1 sda /user.slice
      ...
      inflight=14 sda /user.slice
      inflight=13 sda /user.slice
      inflight=17 sda /user.slice
      inflight=15 sda /user.slice
      inflight=18 sda /user.slice
      inflight=17 sda /user.slice
      inflight=20 sda /user.slice
      inflight=19 sda /user.slice <- fio stopped, inflight stuck at 19
      inflight=19 sda /user.slice
      inflight=19 sda /user.slice
    
    If a cgroup with stuck inflight ends up getting throttled, the throttled IOs
    will never get issued as there's no completion event to wake it up leading
    to an indefinite hang.
    
    This patch fixes the bug by unifying enable handling into a work item which
    is automatically kicked off from iolatency_set_min_lat_nsec() which is
    called from both iolatency_set_limit() and iolatency_pd_offline() paths.
    Punting to a work item is necessary as iolatency_pd_offline() is called
    under spinlocks while freezing a request_queue requires a sleepable context.
    
    This also simplifies the code reducing LOC sans the comments and avoids the
    unnecessary freezes which were happening whenever a cgroup's latency target
    is newly set or cleared.
    
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Cc: Josef Bacik <josef@toxicpanda.com>
    Cc: Liu Bo <bo.liu@linux.alibaba.com>
    Fixes: 8c772a9bfc7c ("blk-iolatency: fix IO hang due to negative inflight counter")
    Cc: stable@vger.kernel.org # v5.0+
    Link: https://lore.kernel.org/r/Yn9ScX6Nx2qIiQQi@slm.duckdns.org
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
block: fix bio_clone_blkg_association() to associate with proper blkcg_gq [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Tue Jun 7 11:15:14 2022 +0200

    block: fix bio_clone_blkg_association() to associate with proper blkcg_gq
    
    commit 22b106e5355d6e7a9c3b5cb5ed4ef22ae585ea94 upstream.
    
    Commit d92c370a16cb ("block: really clone the block cgroup in
    bio_clone_blkg_association") changed bio_clone_blkg_association() to
    just clone bio->bi_blkg reference from source to destination bio. This
    is however wrong if the source and destination bios are against
    different block devices because struct blkcg_gq is different for each
    bdev-blkcg pair. This will result in IOs being accounted (and throttled
    as a result) multiple times against the same device (src bdev) while
    throttling of the other device (dst bdev) is ignored. In case of BFQ the
    inconsistency can even result in crashes in bfq_bic_update_cgroup().
    Fix the problem by looking up correct blkcg_gq for the cloned bio.
    
    Reported-by: Logan Gunthorpe <logang@deltatee.com>
    Reported-and-tested-by: Donald Buczek <buczek@molgen.mpg.de>
    Fixes: d92c370a16cb ("block: really clone the block cgroup in bio_clone_blkg_association")
    CC: stable@vger.kernel.org
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220602081242.7731-1-jack@suse.cz
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
Bluetooth: fix dangling sco_conn and use-after-free in sco_sock_timeout [+ + +]
Author: Ying Hsu <yinghsu@chromium.org>
Date:   Sat Mar 26 07:09:28 2022 +0000

    Bluetooth: fix dangling sco_conn and use-after-free in sco_sock_timeout
    
    [ Upstream commit 7aa1e7d15f8a5b65f67bacb100d8fc033b21efa2 ]
    
    Connecting the same socket twice consecutively in sco_sock_connect()
    could lead to a race condition where two sco_conn objects are created
    but only one is associated with the socket. If the socket is closed
    before the SCO connection is established, the timer associated with the
    dangling sco_conn object won't be canceled. As the sock object is being
    freed, the use-after-free problem happens when the timer callback
    function sco_sock_timeout() accesses the socket. Here's the call trace:
    
    dump_stack+0x107/0x163
    ? refcount_inc+0x1c/
    print_address_description.constprop.0+0x1c/0x47e
    ? refcount_inc+0x1c/0x7b
    kasan_report+0x13a/0x173
    ? refcount_inc+0x1c/0x7b
    check_memory_region+0x132/0x139
    refcount_inc+0x1c/0x7b
    sco_sock_timeout+0xb2/0x1ba
    process_one_work+0x739/0xbd1
    ? cancel_delayed_work+0x13f/0x13f
    ? __raw_spin_lock_init+0xf0/0xf0
    ? to_kthread+0x59/0x85
    worker_thread+0x593/0x70e
    kthread+0x346/0x35a
    ? drain_workqueue+0x31a/0x31a
    ? kthread_bind+0x4b/0x4b
    ret_from_fork+0x1f/0x30
    
    Link: https://syzkaller.appspot.com/bug?extid=2bef95d3ab4daa10155b
    Reported-by: syzbot+2bef95d3ab4daa10155b@syzkaller.appspotmail.com
    Fixes: e1dee2c1de2b ("Bluetooth: fix repeated calls to sco_sock_kill")
    Signed-off-by: Ying Hsu <yinghsu@chromium.org>
    Reviewed-by: Joseph Hwang <josephsih@chromium.org>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
bpf, arm64: Clear prog->jited_len along prog->jited [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue May 31 14:51:13 2022 -0700

    bpf, arm64: Clear prog->jited_len along prog->jited
    
    [ Upstream commit 10f3b29c65bb2fe0d47c2945cd0b4087be1c5218 ]
    
    syzbot reported an illegal copy_to_user() attempt
    from bpf_prog_get_info_by_fd() [1]
    
    There was no repro yet on this bug, but I think
    that commit 0aef499f3172 ("mm/usercopy: Detect vmalloc overruns")
    is exposing a prior bug in bpf arm64.
    
    bpf_prog_get_info_by_fd() looks at prog->jited_len
    to determine if the JIT image can be copied out to user space.
    
    My theory is that syzbot managed to get a prog where prog->jited_len
    has been set to 43, while prog->bpf_func has ben cleared.
    
    It is not clear why copy_to_user(uinsns, NULL, ulen) is triggering
    this particular warning.
    
    I thought find_vma_area(NULL) would not find a vm_struct.
    As we do not hold vmap_area_lock spinlock, it might be possible
    that the found vm_struct was garbage.
    
    [1]
    usercopy: Kernel memory exposure attempt detected from vmalloc (offset 792633534417210172, size 43)!
    kernel BUG at mm/usercopy.c:101!
    Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
    Modules linked in:
    CPU: 0 PID: 25002 Comm: syz-executor.1 Not tainted 5.18.0-syzkaller-10139-g8291eaafed36 #0
    Hardware name: linux,dummy-virt (DT)
    pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    pc : usercopy_abort+0x90/0x94 mm/usercopy.c:101
    lr : usercopy_abort+0x90/0x94 mm/usercopy.c:89
    sp : ffff80000b773a20
    x29: ffff80000b773a30 x28: faff80000b745000 x27: ffff80000b773b48
    x26: 0000000000000000 x25: 000000000000002b x24: 0000000000000000
    x23: 00000000000000e0 x22: ffff80000b75db67 x21: 0000000000000001
    x20: 000000000000002b x19: ffff80000b75db3c x18: 00000000fffffffd
    x17: 2820636f6c6c616d x16: 76206d6f72662064 x15: 6574636574656420
    x14: 74706d6574746120 x13: 2129333420657a69 x12: 73202c3237313031
    x11: 3237313434333533 x10: 3336323937207465 x9 : 657275736f707865
    x8 : ffff80000a30c550 x7 : ffff80000b773830 x6 : ffff80000b773830
    x5 : 0000000000000000 x4 : ffff00007fbbaa10 x3 : 0000000000000000
    x2 : 0000000000000000 x1 : f7ff000028fc0000 x0 : 0000000000000064
    Call trace:
     usercopy_abort+0x90/0x94 mm/usercopy.c:89
     check_heap_object mm/usercopy.c:186 [inline]
     __check_object_size mm/usercopy.c:252 [inline]
     __check_object_size+0x198/0x36c mm/usercopy.c:214
     check_object_size include/linux/thread_info.h:199 [inline]
     check_copy_size include/linux/thread_info.h:235 [inline]
     copy_to_user include/linux/uaccess.h:159 [inline]
     bpf_prog_get_info_by_fd.isra.0+0xf14/0xfdc kernel/bpf/syscall.c:3993
     bpf_obj_get_info_by_fd+0x12c/0x510 kernel/bpf/syscall.c:4253
     __sys_bpf+0x900/0x2150 kernel/bpf/syscall.c:4956
     __do_sys_bpf kernel/bpf/syscall.c:5021 [inline]
     __se_sys_bpf kernel/bpf/syscall.c:5019 [inline]
     __arm64_sys_bpf+0x28/0x40 kernel/bpf/syscall.c:5019
     __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
     invoke_syscall+0x48/0x114 arch/arm64/kernel/syscall.c:52
     el0_svc_common.constprop.0+0x44/0xec arch/arm64/kernel/syscall.c:142
     do_el0_svc+0xa0/0xc0 arch/arm64/kernel/syscall.c:206
     el0_svc+0x44/0xb0 arch/arm64/kernel/entry-common.c:624
     el0t_64_sync_handler+0x1ac/0x1b0 arch/arm64/kernel/entry-common.c:642
     el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:581
    Code: aa0003e3 d00038c0 91248000 97fff65f (d4210000)
    
    Fixes: db496944fdaa ("bpf: arm64: add JIT support for multi-function programs")
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Song Liu <songliubraving@fb.com>
    Link: https://lore.kernel.org/bpf/20220531215113.1100754-1-eric.dumazet@gmail.com
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
bpf: Fix excessive memory allocation in stack_map_alloc() [+ + +]
Author: Yuntao Wang <ytcoode@gmail.com>
Date:   Thu Apr 7 21:04:23 2022 +0800

    bpf: Fix excessive memory allocation in stack_map_alloc()
    
    [ Upstream commit b45043192b3e481304062938a6561da2ceea46a6 ]
    
    The 'n_buckets * (value_size + sizeof(struct stack_map_bucket))' part of the
    allocated memory for 'smap' is never used after the memlock accounting was
    removed, thus get rid of it.
    
    [ Note, Daniel:
    
    Commit b936ca643ade ("bpf: rework memlock-based memory accounting for maps")
    moved `cost += n_buckets * (value_size + sizeof(struct stack_map_bucket))`
    up and therefore before the bpf_map_area_alloc() allocation, sigh. In a later
    step commit c85d69135a91 ("bpf: move memory size checks to bpf_map_charge_init()"),
    and the overflow checks of `cost >= U32_MAX - PAGE_SIZE` moved into
    bpf_map_charge_init(). And then 370868107bf6 ("bpf: Eliminate rlimit-based
    memory accounting for stackmap maps") finally removed the bpf_map_charge_init().
    Anyway, the original code did the allocation same way as /after/ this fix. ]
    
    Fixes: b936ca643ade ("bpf: rework memlock-based memory accounting for maps")
    Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20220407130423.798386-1-ytcoode@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
btrfs: add "0x" prefix for unsupported optional features [+ + +]
Author: Qu Wenruo <wqu@suse.com>
Date:   Tue May 10 15:10:18 2022 +0800

    btrfs: add "0x" prefix for unsupported optional features
    
    commit d5321a0fa8bc49f11bea0b470800962c17d92d8f upstream.
    
    The following error message lack the "0x" obviously:
    
      cannot mount because of unsupported optional features (4000)
    
    Add the prefix to make it less confusing. This can happen on older
    kernels that try to mount a filesystem with newer features so it makes
    sense to backport to older trees.
    
    CC: stable@vger.kernel.org # 4.14+
    Reviewed-by: Nikolay Borisov <nborisov@suse.com>
    Signed-off-by: Qu Wenruo <wqu@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: repair super block num_devices automatically [+ + +]
Author: Qu Wenruo <wqu@suse.com>
Date:   Mon Feb 28 15:05:53 2022 +0800

    btrfs: repair super block num_devices automatically
    
    commit d201238ccd2f30b9bfcfadaeae0972e3a486a176 upstream.
    
    [BUG]
    There is a report that a btrfs has a bad super block num devices.
    
    This makes btrfs to reject the fs completely.
    
      BTRFS error (device sdd3): super_num_devices 3 mismatch with num_devices 2 found here
      BTRFS error (device sdd3): failed to read chunk tree: -22
      BTRFS error (device sdd3): open_ctree failed
    
    [CAUSE]
    During btrfs device removal, chunk tree and super block num devs are
    updated in two different transactions:
    
      btrfs_rm_device()
      |- btrfs_rm_dev_item(device)
      |  |- trans = btrfs_start_transaction()
      |  |  Now we got transaction X
      |  |
      |  |- btrfs_del_item()
      |  |  Now device item is removed from chunk tree
      |  |
      |  |- btrfs_commit_transaction()
      |     Transaction X got committed, super num devs untouched,
      |     but device item removed from chunk tree.
      |     (AKA, super num devs is already incorrect)
      |
      |- cur_devices->num_devices--;
      |- cur_devices->total_devices--;
      |- btrfs_set_super_num_devices()
         All those operations are not in transaction X, thus it will
         only be written back to disk in next transaction.
    
    So after the transaction X in btrfs_rm_dev_item() committed, but before
    transaction X+1 (which can be minutes away), a power loss happen, then
    we got the super num mismatch.
    
    This has been fixed by commit bbac58698a55 ("btrfs: remove device item
    and update super block in the same transaction").
    
    [FIX]
    Make the super_num_devices check less strict, converting it from a hard
    error to a warning, and reset the value to a correct one for the current
    or next transaction commit.
    
    As the number of device items is the critical information where the
    super block num_devices is only a cached value (and also useful for
    cross checking), it's safe to automatically update it. Other device
    related problems like missing device are handled after that and may
    require other means to resolve, like degraded mount. With this fix,
    potentially affected filesystems won't fail mount and require the manual
    repair by btrfs check.
    
    Reported-by: Luca Béla Palkovics <luca.bela.palkovics@gmail.com>
    Link: https://lore.kernel.org/linux-btrfs/CA+8xDSpvdm_U0QLBAnrH=zqDq_cWCOH5TiV46CKmp3igr44okQ@mail.gmail.com/
    CC: stable@vger.kernel.org # 4.14+
    Signed-off-by: Qu Wenruo <wqu@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>

 
bus: ti-sysc: Fix warnings for unbind for serial [+ + +]
Author: Tony Lindgren <tony@atomide.com>
Date:   Thu May 12 08:30:21 2022 +0300

    bus: ti-sysc: Fix warnings for unbind for serial
    
    [ Upstream commit c337125b8834f9719dfda0e40b25eaa266f1b8cf ]
    
    We can get "failed to disable" clock_unprepare warnings on unbind at least
    for the serial console device if the unbind is done before the device has
    been idled.
    
    As some devices are using deferred idle, we must check the status for
    pending idle work to idle the device.
    
    Fixes: 76f0f772e469 ("bus: ti-sysc: Improve handling for no-reset-on-init and no-idle-on-init")
    Cc: Romain Naour <romain.naour@smile.fr>
    Reviewed-by: Romain Naour <romain.naour@smile.fr>
    Signed-off-by: Tony Lindgren <tony@atomide.com>
    Link: https://lore.kernel.org/r/20220512053021.61650-1-tony@atomide.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
can: xilinx_can: mark bit timing constants as const [+ + +]
Author: Marc Kleine-Budde <mkl@pengutronix.de>
Date:   Thu Mar 17 21:29:07 2022 +0100

    can: xilinx_can: mark bit timing constants as const
    
    [ Upstream commit ae38fda02996d43d9fb09f16e81e0008704dd524 ]
    
    This patch marks the bit timing constants as const.
    
    Fixes: c223da689324 ("can: xilinx_can: Add support for CANFD FD frames")
    Link: https://lore.kernel.org/all/20220317203119.792552-1-mkl@pengutronix.de
    Cc: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>
    Cc: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
carl9170: tx: fix an incorrect use of list iterator [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Mon Mar 28 20:28:20 2022 +0800

    carl9170: tx: fix an incorrect use of list iterator
    
    commit 54a6f29522da3c914da30e50721dedf51046449a upstream.
    
    If the previous list_for_each_entry_continue_rcu() don't exit early
    (no goto hit inside the loop), the iterator 'cvif' after the loop
    will be a bogus pointer to an invalid structure object containing
    the HEAD (&ar->vif_list). As a result, the use of 'cvif' after that
    will lead to a invalid memory access (i.e., 'cvif->id': the invalid
    pointer dereference when return back to/after the callsite in the
    carl9170_update_beacon()).
    
    The original intention should have been to return the valid 'cvif'
    when found in list, NULL otherwise. So just return NULL when no
    entry found, to fix this bug.
    
    Cc: stable@vger.kernel.org
    Fixes: 1f1d9654e183c ("carl9170: refactor carl9170_update_beacon")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Acked-by: Christian Lamparter <chunkeey@gmail.com>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20220328122820.1004-1-xiam0nd.tong@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ceph: allow ceph.dir.rctime xattr to be updatable [+ + +]
Author: Venky Shankar <vshankar@redhat.com>
Date:   Thu Mar 10 09:34:19 2022 -0500

    ceph: allow ceph.dir.rctime xattr to be updatable
    
    [ Upstream commit d7a2dc523085f8b8c60548ceedc696934aefeb0e ]
    
    `rctime' has been a pain point in cephfs due to its buggy
    nature - inconsistent values reported and those sorts.
    Fixing rctime is non-trivial needing an overall redesign
    of the entire nested statistics infrastructure.
    
    As a workaround, PR
    
         http://github.com/ceph/ceph/pull/37938
    
    allows this extended attribute to be manually set. This allows
    users to "fixup" inconsistent rctime values. While this sounds
    messy, its probably the wisest approach allowing users/scripts
    to workaround buggy rctime values.
    
    The above PR enables Ceph MDS to allow manually setting
    rctime extended attribute with the corresponding user-land
    changes. We may as well allow the same to be done via kclient
    for parity.
    
    Signed-off-by: Venky Shankar <vshankar@redhat.com>
    Reviewed-by: Xiubo Li <xiubli@redhat.com>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
cifs: return errors during session setup during reconnects [+ + +]
Author: Shyam Prasad N <sprasad@microsoft.com>
Date:   Tue May 31 12:31:05 2022 +0000

    cifs: return errors during session setup during reconnects
    
    commit 8ea21823aa584b55ba4b861307093b78054b0c1b upstream.
    
    During reconnects, we check the return value from
    cifs_negotiate_protocol, and have handlers for both success
    and failures. But if that passes, and cifs_setup_session
    returns any errors other than -EACCES, we do not handle
    that. This fix adds a handler for that, so that we don't
    go ahead and try a tree_connect on a failed session.
    
    Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
    Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
    Cc: stable@vger.kernel.org
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

cifs: version operations for smb20 unneeded when legacy support disabled [+ + +]
Author: Steve French <stfrench@microsoft.com>
Date:   Wed Jun 1 22:08:46 2022 -0500

    cifs: version operations for smb20 unneeded when legacy support disabled
    
    [ Upstream commit 7ef93ffccd55fb0ba000ed16ef6a81cd7dee07b5 ]
    
    We should not be including unused smb20 specific code when legacy
    support is disabled (CONFIG_CIFS_ALLOW_INSECURE_LEGACY turned
    off).  For example smb2_operations and smb2_values aren't used
    in that case.  Over time we can move more and more SMB1/CIFS and SMB2.0
    code into the insecure legacy ifdefs
    
    Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
clocksource/drivers/oxnas-rps: Fix irq_of_parse_and_map() return value [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Fri Apr 22 12:41:01 2022 +0200

    clocksource/drivers/oxnas-rps: Fix irq_of_parse_and_map() return value
    
    [ Upstream commit 9c04a8ff03def4df3f81219ffbe1ec9b44ff5348 ]
    
    The irq_of_parse_and_map() returns 0 on failure, not a negative ERRNO.
    
    Fixes: 89355274e1f7 ("clocksource/drivers/oxnas-rps: Add Oxford Semiconductor RPS Dual Timer")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
    Link: https://lore.kernel.org/r/20220422104101.55754-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
clocksource/drivers/riscv: Events are stopped during CPU suspend [+ + +]
Author: Samuel Holland <samuel@sholland.org>
Date:   Sun May 8 20:21:21 2022 -0500

    clocksource/drivers/riscv: Events are stopped during CPU suspend
    
    [ Upstream commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d ]
    
    Some implementations of the SBI time extension depend on hart-local
    state (for example, CSRs) that are lost or hardware that is powered
    down when a CPU is suspended. To be safe, the clockevents driver
    cannot assume that timer IRQs will be received during CPU suspend.
    
    Fixes: 62b019436814 ("clocksource: new RISC-V SBI timer driver")
    Signed-off-by: Samuel Holland <samuel@sholland.org>
    Reviewed-by: Anup Patel <anup@brainfault.org>
    Link: https://lore.kernel.org/r/20220509012121.40031-1-samuel@sholland.org
    Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
clocksource/drivers/sp804: Avoid error on multiple instances [+ + +]
Author: Andre Przywara <andre.przywara@arm.com>
Date:   Fri May 6 17:25:22 2022 +0100

    clocksource/drivers/sp804: Avoid error on multiple instances
    
    [ Upstream commit a98399cbc1e05f7b977419f03905501d566cf54e ]
    
    When a machine sports more than one SP804 timer instance, we only bring
    up the first one, since multiple timers of the same kind are not useful
    to Linux. As this is intentional behaviour, we should not return an
    error message, as we do today:
    ===============
    [    0.000800] Failed to initialize '/bus@8000000/motherboard-bus@8000000/iofpga-bus@300000000/timer@120000': -22
    ===============
    
    Replace the -EINVAL return with a debug message and return 0 instead.
    
    Also we do not reach the init function anymore if the DT node is
    disabled (as this is now handled by OF_DECLARE), so remove the explicit
    check for that case.
    
    This fixes a long standing bogus error when booting ARM's fastmodels.
    
    Signed-off-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Robin Murphy <robin.murphy@arm.com>
    Link: https://lore.kernel.org/r/20220506162522.3675399-1-andre.przywara@arm.com
    Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier [+ + +]
Author: Guilherme G. Piccoli <gpiccoli@igalia.com>
Date:   Wed Apr 27 19:49:03 2022 -0300

    coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier
    
    [ Upstream commit 1adff542d67a2ed1120955cb219bfff8a9c53f59 ]
    
    The panic notifier infrastructure executes registered callbacks when
    a panic event happens - such callbacks are executed in atomic context,
    with interrupts and preemption disabled in the running CPU and all other
    CPUs disabled. That said, mutexes in such context are not a good idea.
    
    This patch replaces a regular mutex with a mutex_trylock safer approach;
    given the nature of the mutex used in the driver, it should be pretty
    uncommon being unable to acquire such mutex in the panic path, hence
    no functional change should be observed (and if it is, that would be
    likely a deadlock with the regular mutex).
    
    Fixes: 2227b7c74634 ("coresight: add support for CPU debug module")
    Cc: Leo Yan <leo.yan@linaro.org>
    Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
    Cc: Mike Leach <mike.leach@linaro.org>
    Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
    Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Link: https://lore.kernel.org/r/20220427224924.592546-10-gpiccoli@igalia.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
cpufreq: Fix possible race in cpufreq online error path [+ + +]
Author: Schspa Shi <schspa@gmail.com>
Date:   Thu Apr 21 03:15:41 2022 +0800

    cpufreq: Fix possible race in cpufreq online error path
    
    [ Upstream commit f346e96267cd76175d6c201b40f770c0116a8a04 ]
    
    When cpufreq online fails, the policy->cpus mask is not cleared and
    policy->rwsem is released too early, so the driver can be invoked
    via the cpuinfo_cur_freq sysfs attribute while its ->offline() or
    ->exit() callbacks are being run.
    
    Take policy->clk as an example:
    
    static int cpufreq_online(unsigned int cpu)
    {
      ...
      // policy->cpus != 0 at this time
      down_write(&policy->rwsem);
      ret = cpufreq_add_dev_interface(policy);
      up_write(&policy->rwsem);
    
      return 0;
    
    out_destroy_policy:
            for_each_cpu(j, policy->real_cpus)
                    remove_cpu_dev_symlink(policy, get_cpu_device(j));
        up_write(&policy->rwsem);
    ...
    out_exit_policy:
      if (cpufreq_driver->exit)
        cpufreq_driver->exit(policy);
          clk_put(policy->clk);
          // policy->clk is a wild pointer
    ...
                                        ^
                                        |
                                Another process access
                                __cpufreq_get
                                  cpufreq_verify_current_freq
                                    cpufreq_generic_get
                                      // acces wild pointer of policy->clk;
                                        |
                                        |
    out_offline_policy:                 |
      cpufreq_policy_free(policy);      |
        // deleted here, and will wait for no body reference
        cpufreq_policy_put_kobj(policy);
    }
    
    Address this by modifying cpufreq_online() to release policy->rwsem
    in the error path after the driver callbacks have run and to clear
    policy->cpus before releasing the semaphore.
    
    Fixes: 7106e02baed4 ("cpufreq: release policy->rwsem on error")
    Signed-off-by: Schspa Shi <schspa@gmail.com>
    [ rjw: Subject and changelog edits ]
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
crypto: cryptd - Protect per-CPU resource by disabling BH. [+ + +]
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:   Wed May 4 17:07:36 2022 +0200

    crypto: cryptd - Protect per-CPU resource by disabling BH.
    
    [ Upstream commit 91e8bcd7b4da182e09ea19a2c73167345fe14c98 ]
    
    The access to cryptd_queue::cpu_queue is synchronized by disabling
    preemption in cryptd_enqueue_request() and disabling BH in
    cryptd_queue_worker(). This implies that access is allowed from BH.
    
    If cryptd_enqueue_request() is invoked from preemptible context _and_
    soft interrupt then this can lead to list corruption since
    cryptd_enqueue_request() is not protected against access from
    soft interrupt.
    
    Replace get_cpu() in cryptd_enqueue_request() with local_bh_disable()
    to ensure BH is always disabled.
    Remove preempt_disable() from cryptd_queue_worker() since it is not
    needed because local_bh_disable() ensures synchronisation.
    
    Fixes: 254eff771441 ("crypto: cryptd - Per-CPU thread implementation...")
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

crypto: marvell/cesa - ECB does not IV [+ + +]
Author: Corentin Labbe <clabbe@baylibre.com>
Date:   Wed Apr 13 19:11:54 2022 +0000

    crypto: marvell/cesa - ECB does not IV
    
    [ Upstream commit 4ffa1763622ae5752961499588f3f8874315f974 ]
    
    The DES3 ECB has an IV size set but ECB does not need one.
    
    Fixes: 4ada483978237 ("crypto: marvell/cesa - add Triple-DES support")
    Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dax: fix cache flush on PMD-mapped pages [+ + +]
Author: Muchun Song <songmuchun@bytedance.com>
Date:   Thu Apr 28 23:16:09 2022 -0700

    dax: fix cache flush on PMD-mapped pages
    
    [ Upstream commit e583b5c472bd23d450e06f148dc1f37be74f7666 ]
    
    The flush_cache_page() only remove a PAGE_SIZE sized range from the cache.
    However, it does not cover the full pages in a THP except a head page.
    Replace it with flush_cache_range() to fix this issue.  This is just a
    documentation issue with the respect to properly documenting the expected
    usage of cache flushing before modifying the pmd.  However, in practice
    this is not a problem due to the fact that DAX is not available on
    architectures with virtually indexed caches per:
    
      commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches")
    
    Link: https://lkml.kernel.org/r/20220403053957.10770-3-songmuchun@bytedance.com
    Fixes: f729c8c9b24f ("dax: wrprotect pmd_t in dax_mapping_entry_mkclean")
    Signed-off-by: Muchun Song <songmuchun@bytedance.com>
    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Cc: Alistair Popple <apopple@nvidia.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Jan Kara <jack@suse.cz>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Ralph Campbell <rcampbell@nvidia.com>
    Cc: Ross Zwisler <zwisler@kernel.org>
    Cc: Xiongchun Duan <duanxiongchun@bytedance.com>
    Cc: Xiyu Yang <xiyuyang19@fudan.edu.cn>
    Cc: Yang Shi <shy828301@gmail.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dlm: fix missing lkb refcount handling [+ + +]
Author: Alexander Aring <aahringo@redhat.com>
Date:   Fri Apr 29 11:06:51 2022 -0400

    dlm: fix missing lkb refcount handling
    
    commit 1689c169134f4b5a39156122d799b7dca76d8ddb upstream.
    
    We always call hold_lkb(lkb) if we increment lkb->lkb_wait_count.
    So, we always need to call unhold_lkb(lkb) if we decrement
    lkb->lkb_wait_count. This patch will add missing unhold_lkb(lkb) if we
    decrement lkb->lkb_wait_count. In case of setting lkb->lkb_wait_count to
    zero we need to countdown until reaching zero and call unhold_lkb(lkb).
    The waiters list unhold_lkb(lkb) can be removed because it's done for
    the last lkb_wait_count decrement iteration as it's done in
    _remove_from_waiters().
    
    This issue was discovered by a dlm gfs2 test case which use excessively
    dlm_unlock(LKF_CANCEL) feature. Probably the lkb->lkb_wait_count value
    never reached above 1 if this feature isn't used and so it was not
    discovered before.
    
    The testcase ended in a rsb on the rsb keep data structure with a
    refcount of 1 but no lkb was associated with it, which is itself
    an invalid behaviour. A side effect of that was a condition in which
    the dlm was sending remove messages in a looping behaviour. With this
    patch that has not been reproduced.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Alexander Aring <aahringo@redhat.com>
    Signed-off-by: David Teigland <teigland@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

dlm: fix plock invalid read [+ + +]
Author: Alexander Aring <aahringo@redhat.com>
Date:   Mon Apr 4 16:06:30 2022 -0400

    dlm: fix plock invalid read
    
    commit 42252d0d2aa9b94d168241710a761588b3959019 upstream.
    
    This patch fixes an invalid read showed by KASAN. A unlock will allocate a
    "struct plock_op" and a followed send_op() will append it to a global
    send_list data structure. In some cases a followed dev_read() moves it
    to recv_list and dev_write() will cast it to "struct plock_xop" and access
    fields which are only available in those structures. At this point an
    invalid read happens by accessing those fields.
    
    To fix this issue the "callback" field is moved to "struct plock_op" to
    indicate that a cast to "plock_xop" is allowed and does the additional
    "plock_xop" handling if set.
    
    Example of the KASAN output which showed the invalid read:
    
    [ 2064.296453] ==================================================================
    [ 2064.304852] BUG: KASAN: slab-out-of-bounds in dev_write+0x52b/0x5a0 [dlm]
    [ 2064.306491] Read of size 8 at addr ffff88800ef227d8 by task dlm_controld/7484
    [ 2064.308168]
    [ 2064.308575] CPU: 0 PID: 7484 Comm: dlm_controld Kdump: loaded Not tainted 5.14.0+ #9
    [ 2064.310292] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
    [ 2064.311618] Call Trace:
    [ 2064.312218]  dump_stack_lvl+0x56/0x7b
    [ 2064.313150]  print_address_description.constprop.8+0x21/0x150
    [ 2064.314578]  ? dev_write+0x52b/0x5a0 [dlm]
    [ 2064.315610]  ? dev_write+0x52b/0x5a0 [dlm]
    [ 2064.316595]  kasan_report.cold.14+0x7f/0x11b
    [ 2064.317674]  ? dev_write+0x52b/0x5a0 [dlm]
    [ 2064.318687]  dev_write+0x52b/0x5a0 [dlm]
    [ 2064.319629]  ? dev_read+0x4a0/0x4a0 [dlm]
    [ 2064.320713]  ? bpf_lsm_kernfs_init_security+0x10/0x10
    [ 2064.321926]  vfs_write+0x17e/0x930
    [ 2064.322769]  ? __fget_light+0x1aa/0x220
    [ 2064.323753]  ksys_write+0xf1/0x1c0
    [ 2064.324548]  ? __ia32_sys_read+0xb0/0xb0
    [ 2064.325464]  do_syscall_64+0x3a/0x80
    [ 2064.326387]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    [ 2064.327606] RIP: 0033:0x7f807e4ba96f
    [ 2064.328470] Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 39 87 f8 ff 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 7c 87 f8 ff 48
    [ 2064.332902] RSP: 002b:00007ffd50cfe6e0 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
    [ 2064.334658] RAX: ffffffffffffffda RBX: 000055cc3886eb30 RCX: 00007f807e4ba96f
    [ 2064.336275] RDX: 0000000000000040 RSI: 00007ffd50cfe7e0 RDI: 0000000000000010
    [ 2064.337980] RBP: 00007ffd50cfe7e0 R08: 0000000000000000 R09: 0000000000000001
    [ 2064.339560] R10: 000055cc3886eb30 R11: 0000000000000293 R12: 000055cc3886eb80
    [ 2064.341237] R13: 000055cc3886eb00 R14: 000055cc3886f590 R15: 0000000000000001
    [ 2064.342857]
    [ 2064.343226] Allocated by task 12438:
    [ 2064.344057]  kasan_save_stack+0x1c/0x40
    [ 2064.345079]  __kasan_kmalloc+0x84/0xa0
    [ 2064.345933]  kmem_cache_alloc_trace+0x13b/0x220
    [ 2064.346953]  dlm_posix_unlock+0xec/0x720 [dlm]
    [ 2064.348811]  do_lock_file_wait.part.32+0xca/0x1d0
    [ 2064.351070]  fcntl_setlk+0x281/0xbc0
    [ 2064.352879]  do_fcntl+0x5e4/0xfe0
    [ 2064.354657]  __x64_sys_fcntl+0x11f/0x170
    [ 2064.356550]  do_syscall_64+0x3a/0x80
    [ 2064.358259]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    [ 2064.360745]
    [ 2064.361511] Last potentially related work creation:
    [ 2064.363957]  kasan_save_stack+0x1c/0x40
    [ 2064.365811]  __kasan_record_aux_stack+0xaf/0xc0
    [ 2064.368100]  call_rcu+0x11b/0xf70
    [ 2064.369785]  dlm_process_incoming_buffer+0x47d/0xfd0 [dlm]
    [ 2064.372404]  receive_from_sock+0x290/0x770 [dlm]
    [ 2064.374607]  process_recv_sockets+0x32/0x40 [dlm]
    [ 2064.377290]  process_one_work+0x9a8/0x16e0
    [ 2064.379357]  worker_thread+0x87/0xbf0
    [ 2064.381188]  kthread+0x3ac/0x490
    [ 2064.383460]  ret_from_fork+0x22/0x30
    [ 2064.385588]
    [ 2064.386518] Second to last potentially related work creation:
    [ 2064.389219]  kasan_save_stack+0x1c/0x40
    [ 2064.391043]  __kasan_record_aux_stack+0xaf/0xc0
    [ 2064.393303]  call_rcu+0x11b/0xf70
    [ 2064.394885]  dlm_process_incoming_buffer+0x47d/0xfd0 [dlm]
    [ 2064.397694]  receive_from_sock+0x290/0x770 [dlm]
    [ 2064.399932]  process_recv_sockets+0x32/0x40 [dlm]
    [ 2064.402180]  process_one_work+0x9a8/0x16e0
    [ 2064.404388]  worker_thread+0x87/0xbf0
    [ 2064.406124]  kthread+0x3ac/0x490
    [ 2064.408021]  ret_from_fork+0x22/0x30
    [ 2064.409834]
    [ 2064.410599] The buggy address belongs to the object at ffff88800ef22780
    [ 2064.410599]  which belongs to the cache kmalloc-96 of size 96
    [ 2064.416495] The buggy address is located 88 bytes inside of
    [ 2064.416495]  96-byte region [ffff88800ef22780, ffff88800ef227e0)
    [ 2064.422045] The buggy address belongs to the page:
    [ 2064.424635] page:00000000b6bef8bc refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xef22
    [ 2064.428970] flags: 0xfffffc0000200(slab|node=0|zone=1|lastcpupid=0x1fffff)
    [ 2064.432515] raw: 000fffffc0000200 ffffea0000d68b80 0000001400000014 ffff888001041780
    [ 2064.436110] raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
    [ 2064.439813] page dumped because: kasan: bad access detected
    [ 2064.442548]
    [ 2064.443310] Memory state around the buggy address:
    [ 2064.445988]  ffff88800ef22680: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
    [ 2064.449444]  ffff88800ef22700: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
    [ 2064.452941] >ffff88800ef22780: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc
    [ 2064.456383]                                                     ^
    [ 2064.459386]  ffff88800ef22800: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
    [ 2064.462788]  ffff88800ef22880: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
    [ 2064.466239] ==================================================================
    
    reproducer in python:
    
    import argparse
    import struct
    import fcntl
    import os
    
    parser = argparse.ArgumentParser()
    
    parser.add_argument('-f', '--file',
                        help='file to use fcntl, must be on dlm lock filesystem e.g. gfs2')
    
    args = parser.parse_args()
    
    f = open(args.file, 'wb+')
    
    lockdata = struct.pack('hhllhh', fcntl.F_WRLCK,0,0,0,0,0)
    fcntl.fcntl(f, fcntl.F_SETLK, lockdata)
    lockdata = struct.pack('hhllhh', fcntl.F_UNLCK,0,0,0,0,0)
    fcntl.fcntl(f, fcntl.F_SETLK, lockdata)
    
    Fixes: 586759f03e2e ("gfs2: nfs lock support for gfs2")
    Cc: stable@vger.kernel.org
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Alexander Aring <aahringo@redhat.com>
    Signed-off-by: David Teigland <teigland@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
dma-debug: change allocation mode from GFP_NOWAIT to GFP_ATIOMIC [+ + +]
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Tue May 10 13:17:32 2022 -0400

    dma-debug: change allocation mode from GFP_NOWAIT to GFP_ATIOMIC
    
    [ Upstream commit 84bc4f1dbbbb5f8aa68706a96711dccb28b518e5 ]
    
    We observed the error "cacheline tracking ENOMEM, dma-debug disabled"
    during a light system load (copying some files). The reason for this error
    is that the dma_active_cacheline radix tree uses GFP_NOWAIT allocation -
    so it can't access the emergency memory reserves and it fails as soon as
    anybody reaches the watermark.
    
    This patch changes GFP_NOWAIT to GFP_ATOMIC, so that it can access the
    emergency memory reserves.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dmaengine: stm32-mdma: remove GISR1 register [+ + +]
Author: Amelie Delaunay <amelie.delaunay@foss.st.com>
Date:   Wed May 4 17:53:20 2022 +0200

    dmaengine: stm32-mdma: remove GISR1 register
    
    [ Upstream commit 9d6a2d92e450926c483e45eaf426080a19219f4e ]
    
    GISR1 was described in a not up-to-date documentation when the stm32-mdma
    driver has been developed. This register has not been added in reference
    manual of STM32 SoC with MDMA, which have only 32 MDMA channels.
    So remove it from stm32-mdma driver.
    
    Fixes: a4ffb13c8946 ("dmaengine: Add STM32 MDMA driver")
    Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
    Link: https://lore.kernel.org/r/20220504155322.121431-2-amelie.delaunay@foss.st.com
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type [+ + +]
Author: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Date:   Tue May 10 12:42:40 2022 +0530

    dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type
    
    [ Upstream commit f9a9f43a62a04ec3183fb0da9226c7706eed0115 ]
    
    In zynqmp_dma_alloc/free_chan_resources functions there is a
    potential overflow in the below expressions.
    
    dma_alloc_coherent(chan->dev, (2 * chan->desc_size *
                       ZYNQMP_DMA_NUM_DESCS),
                       &chan->desc_pool_p, GFP_KERNEL);
    
    dma_free_coherent(chan->dev,(2 * ZYNQMP_DMA_DESC_SIZE(chan) *
                     ZYNQMP_DMA_NUM_DESCS),
                    chan->desc_pool_v, chan->desc_pool_p);
    
    The arguments desc_size and ZYNQMP_DMA_NUM_DESCS were 32 bit. Though
    this overflow condition is not observed but it is a potential problem
    in the case of 32-bit multiplication. Hence fix it by changing the
    desc_size data type to size_t.
    
    In addition to coverity fix it also reuse ZYNQMP_DMA_DESC_SIZE macro in
    dma_alloc_coherent API argument.
    
    Addresses-Coverity: Event overflow_before_widen.
    Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
    Link: https://lore.kernel.org/r/1652166762-18317-2-git-send-email-radhey.shyam.pandey@xilinx.com
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
docs/conf.py: Cope with removal of language=None in Sphinx 5.0.0 [+ + +]
Author: Akira Yokosawa <akiyks@gmail.com>
Date:   Wed Jun 1 23:34:06 2022 +0900

    docs/conf.py: Cope with removal of language=None in Sphinx 5.0.0
    
    commit 627f01eab93d8671d4e4afee9b148f9998d20e7c upstream.
    
    One of the changes in Sphinx 5.0.0 [1] says [sic]:
    
        5.0.0 final
    
         - #10474: language does not accept None as it value.
           The default value of language becomes to 'en' now.
    
    [1]: https://www.sphinx-doc.org/en/master/changes.html#release-5-0-0-released-may-30-2022
    
    It results in a new warning from Sphinx 5.0.0 [sic]:
    
        WARNING: Invalid configuration value found: 'language = None'.
        Update your configuration to a valid langauge code. Falling
        back to 'en' (English).
    
    Silence the warning by using 'en'.
    It works with all the Sphinx versions required for building
    kernel documentation (1.7.9 or later).
    
    Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
    Link: https://lore.kernel.org/r/bd0c2ddc-2401-03cb-4526-79ca664e1cbe@gmail.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drbd: fix duplicate array initializer [+ + +]
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed Apr 6 21:07:09 2022 +0200

    drbd: fix duplicate array initializer
    
    [ Upstream commit 33cb0917bbe241dd17a2b87ead63514c1b7e5615 ]
    
    There are two initializers for P_RETRY_WRITE:
    
    drivers/block/drbd/drbd_main.c:3676:22: warning: initialized field overwritten [-Woverride-init]
    
    Remove the first one since it was already ignored by the compiler
    and reorder the list to match the enum definition. As P_ZEROES had
    no entry, add that one instead.
    
    Fixes: 036b17eaab93 ("drbd: Receiving part for the PROTOCOL_UPDATE packet")
    Fixes: f31e583aa2c2 ("drbd: introduce P_ZEROES (REQ_OP_WRITE_ZEROES on the "wire")")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
    Link: https://lore.kernel.org/r/20220406190715.1938174-2-christoph.boehmwalder@linbit.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
driver core: fix deadlock in __device_attach [+ + +]
Author: Zhang Wensheng <zhangwensheng5@huawei.com>
Date:   Wed May 18 15:45:16 2022 +0800

    driver core: fix deadlock in __device_attach
    
    [ Upstream commit b232b02bf3c205b13a26dcec08e53baddd8e59ed ]
    
    In __device_attach function, The lock holding logic is as follows:
    ...
    __device_attach
    device_lock(dev)      // get lock dev
      async_schedule_dev(__device_attach_async_helper, dev); // func
        async_schedule_node
          async_schedule_node_domain(func)
            entry = kzalloc(sizeof(struct async_entry), GFP_ATOMIC);
            /* when fail or work limit, sync to execute func, but
               __device_attach_async_helper will get lock dev as
               well, which will lead to A-A deadlock.  */
            if (!entry || atomic_read(&entry_count) > MAX_WORK) {
              func;
            else
              queue_work_node(node, system_unbound_wq, &entry->work)
      device_unlock(dev)
    
    As shown above, when it is allowed to do async probes, because of
    out of memory or work limit, async work is not allowed, to do
    sync execute instead. it will lead to A-A deadlock because of
    __device_attach_async_helper getting lock dev.
    
    To fix the deadlock, move the async_schedule_dev outside device_lock,
    as we can see, in async_schedule_node_domain, the parameter of
    queue_work_node is system_unbound_wq, so it can accept concurrent
    operations. which will also not change the code logic, and will
    not lead to deadlock.
    
    Fixes: 765230b5f084 ("driver-core: add asynchronous probing support for drivers")
    Signed-off-by: Zhang Wensheng <zhangwensheng5@huawei.com>
    Link: https://lore.kernel.org/r/20220518074516.1225580-1-zhangwensheng5@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
driver: base: fix UAF when driver_attach failed [+ + +]
Author: Schspa Shi <schspa@gmail.com>
Date:   Fri May 13 19:24:44 2022 +0800

    driver: base: fix UAF when driver_attach failed
    
    [ Upstream commit 310862e574001a97ad02272bac0fd13f75f42a27 ]
    
    When driver_attach(drv); failed, the driver_private will be freed.
    But it has been added to the bus, which caused a UAF.
    
    To fix it, we need to delete it from the bus when failed.
    
    Fixes: 190888ac01d0 ("driver core: fix possible missing of device probe")
    Signed-off-by: Schspa Shi <schspa@gmail.com>
    Link: https://lore.kernel.org/r/20220513112444.45112-1-schspa@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drivers/base/node.c: fix compaction sysfs file leak [+ + +]
Author: Miaohe Lin <linmiaohe@huawei.com>
Date:   Thu Apr 28 23:16:06 2022 -0700

    drivers/base/node.c: fix compaction sysfs file leak
    
    [ Upstream commit da63dc84befaa9e6079a0bc363ff0eaa975f9073 ]
    
    Compaction sysfs file is created via compaction_register_node in
    register_node.  But we forgot to remove it in unregister_node.  Thus
    compaction sysfs file is leaked.  Using compaction_unregister_node to fix
    this issue.
    
    Link: https://lkml.kernel.org/r/20220401070905.43679-1-linmiaohe@huawei.com
    Fixes: ed4a6d7f0676 ("mm: compaction: add /sys trigger for per-node memory compaction")
    Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Rafael J. Wysocki <rafael@kernel.org>
    Cc: Mel Gorman <mel@csn.ul.ie>
    Cc: Minchan Kim <minchan.kim@gmail.com>
    Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drivers: staging: rtl8192e: Fix deadlock in rtllib_beacons_stop() [+ + +]
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Sun Apr 17 22:16:41 2022 +0800

    drivers: staging: rtl8192e: Fix deadlock in rtllib_beacons_stop()
    
    [ Upstream commit 9b6bdbd9337de3917945847bde262a34a87a6303 ]
    
    There is a deadlock in rtllib_beacons_stop(), which is shown
    below:
    
       (Thread 1)              |      (Thread 2)
                               | rtllib_send_beacon()
    rtllib_beacons_stop()      |  mod_timer()
     spin_lock_irqsave() //(1) |  (wait a time)
     ...                       | rtllib_send_beacon_cb()
     del_timer_sync()          |  spin_lock_irqsave() //(2)
     (wait timer to stop)      |  ...
    
    We hold ieee->beacon_lock in position (1) of thread 1 and
    use del_timer_sync() to wait timer to stop, but timer handler
    also need ieee->beacon_lock in position (2) of thread 2.
    As a result, rtllib_beacons_stop() will block forever.
    
    This patch extracts del_timer_sync() from the protection of
    spin_lock_irqsave(), which could let timer handler to obtain
    the needed lock.
    
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Link: https://lore.kernel.org/r/20220417141641.124388-1-duoming@zju.edu.cn
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drivers: staging: rtl8192u: Fix deadlock in ieee80211_beacons_stop() [+ + +]
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Sun Apr 17 21:54:07 2022 +0800

    drivers: staging: rtl8192u: Fix deadlock in ieee80211_beacons_stop()
    
    [ Upstream commit 806c7b53414934ba2a39449b31fd1a038e500273 ]
    
    There is a deadlock in ieee80211_beacons_stop(), which is shown below:
    
       (Thread 1)              |      (Thread 2)
                               | ieee80211_send_beacon()
    ieee80211_beacons_stop()   |  mod_timer()
     spin_lock_irqsave() //(1) |  (wait a time)
     ...                       | ieee80211_send_beacon_cb()
     del_timer_sync()          |  spin_lock_irqsave() //(2)
     (wait timer to stop)      |  ...
    
    We hold ieee->beacon_lock in position (1) of thread 1 and use
    del_timer_sync() to wait timer to stop, but timer handler
    also need ieee->beacon_lock in position (2) of thread 2.
    As a result, ieee80211_beacons_stop() will block forever.
    
    This patch extracts del_timer_sync() from the protection of
    spin_lock_irqsave(), which could let timer handler to obtain
    the needed lock.
    
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Link: https://lore.kernel.org/r/20220417135407.109536-1-duoming@zju.edu.cn
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drivers: tty: serial: Fix deadlock in sa1100_set_termios() [+ + +]
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Sun Apr 17 19:16:26 2022 +0800

    drivers: tty: serial: Fix deadlock in sa1100_set_termios()
    
    [ Upstream commit 62b2caef400c1738b6d22f636c628d9f85cd4c4c ]
    
    There is a deadlock in sa1100_set_termios(), which is shown
    below:
    
       (Thread 1)              |      (Thread 2)
                               | sa1100_enable_ms()
    sa1100_set_termios()       |  mod_timer()
     spin_lock_irqsave() //(1) |  (wait a time)
     ...                       | sa1100_timeout()
     del_timer_sync()          |  spin_lock_irqsave() //(2)
     (wait timer to stop)      |  ...
    
    We hold sport->port.lock in position (1) of thread 1 and
    use del_timer_sync() to wait timer to stop, but timer handler
    also need sport->port.lock in position (2) of thread 2. As a result,
    sa1100_set_termios() will block forever.
    
    This patch moves del_timer_sync() before spin_lock_irqsave()
    in order to prevent the deadlock.
    
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Link: https://lore.kernel.org/r/20220417111626.7802-1-duoming@zju.edu.cn
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drivers: usb: host: Fix deadlock in oxu_bus_suspend() [+ + +]
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Sun Apr 17 20:03:05 2022 +0800

    drivers: usb: host: Fix deadlock in oxu_bus_suspend()
    
    [ Upstream commit 4d378f2ae58138d4c55684e1d274e7dd94aa6524 ]
    
    There is a deadlock in oxu_bus_suspend(), which is shown below:
    
       (Thread 1)              |      (Thread 2)
                               | timer_action()
    oxu_bus_suspend()          |  mod_timer()
     spin_lock_irq() //(1)     |  (wait a time)
     ...                       | oxu_watchdog()
     del_timer_sync()          |  spin_lock_irq() //(2)
     (wait timer to stop)      |  ...
    
    We hold oxu->lock in position (1) of thread 1, and use
    del_timer_sync() to wait timer to stop, but timer handler
    also need oxu->lock in position (2) of thread 2. As a result,
    oxu_bus_suspend() will block forever.
    
    This patch extracts del_timer_sync() from the protection of
    spin_lock_irq(), which could let timer handler to obtain
    the needed lock.
    
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Link: https://lore.kernel.org/r/20220417120305.64577-1-duoming@zju.edu.cn
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/amd/pm: fix double free in si_parse_power_table() [+ + +]
Author: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
Date:   Tue Apr 19 10:37:19 2022 +0000

    drm/amd/pm: fix double free in si_parse_power_table()
    
    [ Upstream commit f3fa2becf2fc25b6ac7cf8d8b1a2e4a86b3b72bd ]
    
    In function si_parse_power_table(), array adev->pm.dpm.ps and its member
    is allocated. If the allocation of each member fails, the array itself
    is freed and returned with an error code. However, the array is later
    freed again in si_dpm_fini() function which is called when the function
    returns an error.
    
    This leads to potential double free of the array adev->pm.dpm.ps, as
    well as leak of its array members, since the members are not freed in
    the allocation function and the array is not nulled when freed.
    In addition adev->pm.dpm.num_ps, which keeps track of the allocated
    array member, is not updated until the member allocation is
    successfully finished, this could also lead to either use after free,
    or uninitialized variable access in si_dpm_fini().
    
    Fix this by postponing the free of the array until si_dpm_fini() and
    increment adev->pm.dpm.num_ps everytime the array member is allocated.
    
    Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/amd/pm: fix the compile warning [+ + +]
Author: Evan Quan <evan.quan@amd.com>
Date:   Mon Apr 25 10:16:46 2022 +0800

    drm/amd/pm: fix the compile warning
    
    [ Upstream commit 555238d92ac32dbad2d77ad2bafc48d17391990c ]
    
    Fix the compile warning below:
    drivers/gpu/drm/amd/amdgpu/../pm/legacy-dpm/kv_dpm.c:1641
    kv_get_acp_boot_level() warn: always true condition '(table->entries[i]->clk >= 0) => (0-u32max >= 0)'
    
    Reported-by: kernel test robot <lkp@intel.com>
    CC: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Evan Quan <evan.quan@amd.com>
    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/cs: make commands with 0 chunks illegal behaviour. [+ + +]
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon May 23 10:24:18 2022 +1000

    drm/amdgpu/cs: make commands with 0 chunks illegal behaviour.
    
    commit 31ab27b14daaa75541a415c6794d6f3567fea44a upstream.
    
    Submitting a cs with 0 chunks, causes an oops later, found trying
    to execute the wrong userspace driver.
    
    MESA_LOADER_DRIVER_OVERRIDE=v3d glxinfo
    
    [172536.665184] BUG: kernel NULL pointer dereference, address: 00000000000001d8
    [172536.665188] #PF: supervisor read access in kernel mode
    [172536.665189] #PF: error_code(0x0000) - not-present page
    [172536.665191] PGD 6712a0067 P4D 6712a0067 PUD 5af9ff067 PMD 0
    [172536.665195] Oops: 0000 [#1] SMP NOPTI
    [172536.665197] CPU: 7 PID: 2769838 Comm: glxinfo Tainted: P           O      5.10.81 #1-NixOS
    [172536.665199] Hardware name: To be filled by O.E.M. To be filled by O.E.M./CROSSHAIR V FORMULA-Z, BIOS 2201 03/23/2015
    [172536.665272] RIP: 0010:amdgpu_cs_ioctl+0x96/0x1ce0 [amdgpu]
    [172536.665274] Code: 75 18 00 00 4c 8b b2 88 00 00 00 8b 46 08 48 89 54 24 68 49 89 f7 4c 89 5c 24 60 31 d2 4c 89 74 24 30 85 c0 0f 85 c0 01 00 00 <48> 83 ba d8 01 00 00 00 48 8b b4 24 90 00 00 00 74 16 48 8b 46 10
    [172536.665276] RSP: 0018:ffffb47c0e81bbe0 EFLAGS: 00010246
    [172536.665277] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
    [172536.665278] RDX: 0000000000000000 RSI: ffffb47c0e81be28 RDI: ffffb47c0e81bd68
    [172536.665279] RBP: ffff936524080010 R08: 0000000000000000 R09: ffffb47c0e81be38
    [172536.665281] R10: ffff936524080010 R11: ffff936524080000 R12: ffffb47c0e81bc40
    [172536.665282] R13: ffffb47c0e81be28 R14: ffff9367bc410000 R15: ffffb47c0e81be28
    [172536.665283] FS:  00007fe35e05d740(0000) GS:ffff936c1edc0000(0000) knlGS:0000000000000000
    [172536.665284] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [172536.665286] CR2: 00000000000001d8 CR3: 0000000532e46000 CR4: 00000000000406e0
    [172536.665287] Call Trace:
    [172536.665322]  ? amdgpu_cs_find_mapping+0x110/0x110 [amdgpu]
    [172536.665332]  drm_ioctl_kernel+0xaa/0xf0 [drm]
    [172536.665338]  drm_ioctl+0x201/0x3b0 [drm]
    [172536.665369]  ? amdgpu_cs_find_mapping+0x110/0x110 [amdgpu]
    [172536.665372]  ? selinux_file_ioctl+0x135/0x230
    [172536.665399]  amdgpu_drm_ioctl+0x49/0x80 [amdgpu]
    [172536.665403]  __x64_sys_ioctl+0x83/0xb0
    [172536.665406]  do_syscall_64+0x33/0x40
    [172536.665409]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2018
    Signed-off-by: Dave Airlie <airlied@redhat.com>
    Cc: stable@vger.kernel.org
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/amdgpu/ucode: Remove firmware load type check in amdgpu_ucode_free_bo [+ + +]
Author: Alice Wong <shiwei.wong@amd.com>
Date:   Mon May 2 11:40:18 2022 -0400

    drm/amdgpu/ucode: Remove firmware load type check in amdgpu_ucode_free_bo
    
    [ Upstream commit ab0cd4a9ae5b4679b714d8dbfedc0901fecdce9f ]
    
    When psp_hw_init failed, it will set the load_type to AMDGPU_FW_LOAD_DIRECT.
    During amdgpu_device_ip_fini, amdgpu_ucode_free_bo checks that load_type is
    AMDGPU_FW_LOAD_DIRECT and skips deallocating fw_buf causing memory leak.
    Remove load_type check in amdgpu_ucode_free_bo.
    
    Signed-off-by: Alice Wong <shiwei.wong@amd.com>
    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/bridge: adv7511: clean up CEC adapter when probe fails [+ + +]
Author: Lucas Stach <l.stach@pengutronix.de>
Date:   Mon Mar 21 11:47:05 2022 +0100

    drm/bridge: adv7511: clean up CEC adapter when probe fails
    
    [ Upstream commit 7ed2b0dabf7a22874cb30f8878df239ef638eb53 ]
    
    When the probe routine fails we also need to clean up the
    CEC adapter registered in adv7511_cec_init().
    
    Fixes: 3b1b975003e4 ("drm: adv7511/33: add HDMI CEC support")
    Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
    Reviewed-by: Robert Foss <robert.foss@linaro.org>
    Signed-off-by: Robert Foss <robert.foss@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220321104705.2804423-1-l.stach@pengutronix.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX [+ + +]
Author: Brian Norris <briannorris@chromium.org>
Date:   Tue Mar 1 18:11:38 2022 -0800

    drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
    
    commit 8fb6c44fe8468f92ac7b8bbfcca4404a4e88645f upstream.
    
    If the display is not enable()d, then we aren't holding a runtime PM
    reference here. Thus, it's easy to accidentally cause a hang, if user
    space is poking around at /dev/drm_dp_aux0 at the "wrong" time.
    
    Let's get a runtime PM reference, and check that we "see" the panel.
    Don't force any panel power-up, etc., because that can be intrusive, and
    that's not what other drivers do (see
    drivers/gpu/drm/bridge/ti-sn65dsi86.c and
    drivers/gpu/drm/bridge/parade-ps8640.c.)
    
    Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code")
    Cc: <stable@vger.kernel.org>
    Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
    Signed-off-by: Brian Norris <briannorris@chromium.org>
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Signed-off-by: Douglas Anderson <dianders@chromium.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220301181107.v4.1.I773a08785666ebb236917b0c8e6c05e3de471e75@changeid
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drm/bridge: Fix error handling in analogix_dp_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed Apr 20 01:16:40 2022 +0000

    drm/bridge: Fix error handling in analogix_dp_probe
    
    [ Upstream commit 9f15930bb2ef9f031d62ffc49629cbae89137733 ]
    
    In the error handling path, the clk_prepare_enable() function
    call should be balanced by a corresponding 'clk_disable_unprepare()'
    call, as already done in the remove function.
    
    Fixes: 3424e3a4f844 ("drm: bridge: analogix/dp: split exynos dp driver to bridge directory")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Robert Foss <robert.foss@linaro.org>
    Signed-off-by: Robert Foss <robert.foss@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220420011644.25730-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/edid: fix invalid EDID extension block filtering [+ + +]
Author: Jani Nikula <jani.nikula@intel.com>
Date:   Wed Mar 30 20:04:26 2022 +0300

    drm/edid: fix invalid EDID extension block filtering
    
    [ Upstream commit 3aefc722ff52076407203b6af9713de567993adf ]
    
    The invalid EDID block filtering uses the number of valid EDID
    extensions instead of all EDID extensions for looping the extensions in
    the copy. This is fine, by coincidence, if all the invalid blocks are at
    the end of the EDID. However, it's completely broken if there are
    invalid extensions in the middle; the invalid blocks are included and
    valid blocks are excluded.
    
    Fix it by modifying the base block after, not before, the copy.
    
    Fixes: 14544d0937bf ("drm/edid: Only print the bad edid when aborting")
    Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Signed-off-by: Jani Nikula <jani.nikula@intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220330170426.349248-1-jani.nikula@intel.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/etnaviv: check for reaped mapping in etnaviv_iommu_unmap_gem [+ + +]
Author: Lucas Stach <l.stach@pengutronix.de>
Date:   Wed Mar 23 17:08:22 2022 +0100

    drm/etnaviv: check for reaped mapping in etnaviv_iommu_unmap_gem
    
    commit e168c25526cd0368af098095c2ded4a008007e1b upstream.
    
    When the mapping is already reaped the unmap must be a no-op, as we
    would otherwise try to remove the mapping twice, corrupting the involved
    data structures.
    
    Cc: stable@vger.kernel.org # 5.4
    Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
    Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
    Tested-by: Guido Günther <agx@sigxcpu.org>
    Acked-by: Guido Günther <agx@sigxcpu.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/komeda: Fix an undefined behavior bug in komeda_plane_add() [+ + +]
Author: Zhou Qingyang <zhou1615@umn.edu>
Date:   Wed Dec 1 11:37:03 2021 +0800

    drm/komeda: Fix an undefined behavior bug in komeda_plane_add()
    
    [ Upstream commit f5e284bb74ab296f98122673c7ecd22028b2c200 ]
    
    In komeda_plane_add(), komeda_get_layer_fourcc_list() is assigned to
    formats and used in drm_universal_plane_init().
    drm_universal_plane_init() passes formats to
    __drm_universal_plane_init(). __drm_universal_plane_init() further
    passes formats to memcpy() as src parameter, which could lead to an
    undefined behavior bug on failure of komeda_get_layer_fourcc_list().
    
    Fix this bug by adding a check of formats.
    
    This bug was found by a static analyzer. The analysis employs
    differential checking to identify inconsistent security operations
    (e.g., checks or kfrees) between two code paths and confirms that the
    inconsistent operations are not recovered in the current function or
    the callers, so they constitute bugs.
    
    Note that, as a bug found by static analysis, it can be a false
    positive or hard to trigger. Multiple researchers have cross-reviewed
    the bug.
    
    Builds with CONFIG_DRM_KOMEDA=m show no new warnings,
    and our static analyzer no longer warns about this code.
    
    Fixes: 61f1c4a8ab75 ("drm/komeda: Attach komeda_dev to DRM-KMS")
    Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
    Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
    Link: https://lore.kernel.org/dri-devel/20211201033704.32054-1-zhou1615@umn.edu
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/komeda: return early if drm_universal_plane_init() fails. [+ + +]
Author: Liviu Dudau <liviu.dudau@arm.com>
Date:   Thu Dec 2 17:00:33 2021 +0000

    drm/komeda: return early if drm_universal_plane_init() fails.
    
    [ Upstream commit c8f76c37cc3668ee45e081e76a15f24a352ebbdd ]
    
    If drm_universal_plane_init() fails early we jump to the common cleanup code
    that calls komeda_plane_destroy() which in turn could access the uninitalised
    drm_plane and crash. Return early if an error is detected without going through
    the common code.
    
    Reported-by: Steven Price <steven.price@arm.com>
    Reviewed-by: Steven Price <steven.price@arm.com>
    Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
    Link: https://lore.kernel.org/dri-devel/20211203100946.2706922-1-liviu.dudau@arm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/mediatek: Fix mtk_cec_mask() [+ + +]
Author: Miles Chen <miles.chen@mediatek.com>
Date:   Wed Mar 16 07:23:00 2022 +0800

    drm/mediatek: Fix mtk_cec_mask()
    
    [ Upstream commit 2c5d69b0a141e1e98febe3111e6f4fd8420493a5 ]
    
    In current implementation, mtk_cec_mask() writes val into target register
    and ignores the mask. After talking to our hdmi experts, mtk_cec_mask()
    should read a register, clean only mask bits, and update (val | mask) bits
    to the register.
    
    Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20220315232301.2434-1-miles.chen@mediatek.com/
    Fixes: 8f83f26891e1 ("drm/mediatek: Add HDMI support")
    Signed-off-by: Miles Chen <miles.chen@mediatek.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
    Cc: Zhiqiang Lin <zhiqiang.lin@mediatek.com>
    Cc: CK Hu <ck.hu@mediatek.com>
    Cc: Matthias Brugger <matthias.bgg@gmail.com>
    Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/a6xx: Fix refcount leak in a6xx_gpu_init [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Thu May 12 16:19:50 2022 +0400

    drm/msm/a6xx: Fix refcount leak in a6xx_gpu_init
    
    [ Upstream commit c56de483093d7ad0782327f95dda7da97bc4c315 ]
    
    of_parse_phandle() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    
    a6xx_gmu_init() passes the node to of_find_device_by_node()
    and of_dma_configure(), of_find_device_by_node() will takes its
    reference, of_dma_configure() doesn't need the node after usage.
    
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: 4b565ca5a2cb ("drm/msm: Add A6XX device support")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Akhil P Oommen <quic_akhilpo@quicinc.com>
    Link: https://lore.kernel.org/r/20220512121955.56937-1-linmq006@gmail.com
    Signed-off-by: Rob Clark <robdclark@chromium.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/disp/dpu1: set vbif hw config to NULL to avoid use after memory free during pm runtime resume [+ + +]
Author: Vinod Polimera <quic_vpolimer@quicinc.com>
Date:   Mon Apr 25 08:56:53 2022 +0530

    drm/msm/disp/dpu1: set vbif hw config to NULL to avoid use after memory free during pm runtime resume
    
    [ Upstream commit fa5186b279ecf44b14fb435540d2065be91cb1ed ]
    
    BUG: Unable to handle kernel paging request at virtual address 006b6b6b6b6b6be3
    
    Call trace:
      dpu_vbif_init_memtypes+0x40/0xb8
      dpu_runtime_resume+0xcc/0x1c0
      pm_generic_runtime_resume+0x30/0x44
      __genpd_runtime_resume+0x68/0x7c
      genpd_runtime_resume+0x134/0x258
      __rpm_callback+0x98/0x138
      rpm_callback+0x30/0x88
      rpm_resume+0x36c/0x49c
      __pm_runtime_resume+0x80/0xb0
      dpu_core_irq_uninstall+0x30/0xb0
      dpu_irq_uninstall+0x18/0x24
      msm_drm_uninit+0xd8/0x16c
    
    Fixes: 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")
    Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/483255/
    Link: https://lore.kernel.org/r/1650857213-30075-1-git-send-email-quic_vpolimer@quicinc.com
    [DB: fixed Fixes tag]
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/dsi: fix error checks and return values for DSI xmit functions [+ + +]
Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date:   Sat Apr 2 02:11:04 2022 +0300

    drm/msm/dsi: fix error checks and return values for DSI xmit functions
    
    [ Upstream commit f0e7e9ed379c012c4d6b09a09b868accc426223c ]
    
    As noticed by Dan ([1] an the followup thread) there are multiple issues
    with the return values for MSM DSI command transmission callback. In
    the error case it can easily return a positive value when it should
    have returned a proper error code.
    
    This commits attempts to fix these issues both in TX and in RX paths.
    
    [1]: https://lore.kernel.org/linux-arm-msm/20211001123617.GH2283@kili/
    
    Fixes: a689554ba6ed ("drm/msm: Initial add DSI connector support")
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Tested-by: Marijn Suijten <marijn.suijten@somainline.org>
    Patchwork: https://patchwork.freedesktop.org/patch/480501/
    Link: https://lore.kernel.org/r/20220401231104.967193-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/hdmi: check return value after calling platform_get_resource_byname() [+ + +]
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Fri Apr 22 11:22:27 2022 +0800

    drm/msm/hdmi: check return value after calling platform_get_resource_byname()
    
    [ Upstream commit a36e506711548df923ceb7ec9f6001375be799a5 ]
    
    It will cause null-ptr-deref if platform_get_resource_byname() returns NULL,
    we need check the return value.
    
    Fixes: c6a57a50ad56 ("drm/msm/hdmi: add hdmi hdcp support (V3)")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/482992/
    Link: https://lore.kernel.org/r/20220422032227.2991553-1-yangyingliang@huawei.com
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/hdmi: fix error check return value of irq_of_parse_and_map() [+ + +]
Author: Lv Ruyi <lv.ruyi@zte.com.cn>
Date:   Mon Apr 25 09:18:31 2022 +0000

    drm/msm/hdmi: fix error check return value of irq_of_parse_and_map()
    
    [ Upstream commit 03371e4fbdeb7f596cbceacb59e474248b6d95ac ]
    
    The irq_of_parse_and_map() function returns 0 on failure, and does not
    return a negative value anyhow, so never enter this conditional branch.
    
    Fixes: f6a8eaca0ea1 ("drm/msm/mdp5: use irqdomains")
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
    Reviewed-by: Stephen Boyd <swboyd@chromium.org>
    Patchwork: https://patchwork.freedesktop.org/patch/483294/
    Link: https://lore.kernel.org/r/20220425091831.3500487-1-lv.ruyi@zte.com.cn
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm/mdp5: Return error code in mdp5_mixer_release when deadlock is detected [+ + +]
Author: Jessica Zhang <quic_jesszhan@quicinc.com>
Date:   Thu May 5 14:40:51 2022 -0700

    drm/msm/mdp5: Return error code in mdp5_mixer_release when deadlock is detected
    
    [ Upstream commit ca75f6f7c6f89365e40f10f641b15981b1f07c31 ]
    
    There is a possibility for mdp5_get_global_state to return
    -EDEADLK when acquiring the modeset lock, but currently global_state in
    mdp5_mixer_release doesn't check for if an error is returned.
    
    To avoid a NULL dereference error, let's have mdp5_mixer_release
    check if an error is returned and propagate that error.
    
    Reported-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
    Signed-off-by: Jessica Zhang <quic_jesszhan@quicinc.com>
    Fixes: 7907a0d77cb4 ("drm/msm/mdp5: Use the new private_obj state")
    Reviewed-by: Rob Clark <robdclark@gmail.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/485181/
    Link: https://lore.kernel.org/r/20220505214051.155-2-quic_jesszhan@quicinc.com
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/msm/mdp5: Return error code in mdp5_pipe_release when deadlock is detected [+ + +]
Author: Jessica Zhang <quic_jesszhan@quicinc.com>
Date:   Thu May 5 14:40:50 2022 -0700

    drm/msm/mdp5: Return error code in mdp5_pipe_release when deadlock is detected
    
    [ Upstream commit d59be579fa932c46b908f37509f319cbd4ca9a68 ]
    
    mdp5_get_global_state runs the risk of hitting a -EDEADLK when acquiring
    the modeset lock, but currently mdp5_pipe_release doesn't check for if
    an error is returned. Because of this, there is a possibility of
    mdp5_pipe_release hitting a NULL dereference error.
    
    To avoid this, let's have mdp5_pipe_release check if
    mdp5_get_global_state returns an error and propogate that error.
    
    Changes since v1:
    - Separated declaration and initialization of *new_state to avoid
      compiler warning
    - Fixed some spelling mistakes in commit message
    
    Changes since v2:
    - Return 0 in case where hwpipe is NULL as this is considered normal
      behavior
    - Added 2nd patch in series to fix a similar NULL dereference issue in
      mdp5_mixer_release
    
    Reported-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
    Signed-off-by: Jessica Zhang <quic_jesszhan@quicinc.com>
    Fixes: 7907a0d77cb4 ("drm/msm/mdp5: Use the new private_obj state")
    Reviewed-by: Rob Clark <robdclark@gmail.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/485179/
    Link: https://lore.kernel.org/r/20220505214051.155-1-quic_jesszhan@quicinc.com
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/msm: return an error pointer in msm_gem_prime_get_sg_table() [+ + +]
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu May 5 13:28:05 2022 +0300

    drm/msm: return an error pointer in msm_gem_prime_get_sg_table()
    
    [ Upstream commit cf575e31611eb6dccf08fad02e57e35b2187704d ]
    
    The msm_gem_prime_get_sg_table() needs to return error pointers on
    error.  This is called from drm_gem_map_dma_buf() and returning a
    NULL will lead to a crash in that function.
    
    Fixes: ac45146733b0 ("drm/msm: fix msm_gem_prime_get_sg_table()")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/485023/
    Link: https://lore.kernel.org/r/YnOmtS5tfENywR9m@kili
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/nouveau/clk: Fix an incorrect NULL check on list iterator [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Sun Mar 27 15:58:24 2022 +0800

    drm/nouveau/clk: Fix an incorrect NULL check on list iterator
    
    commit 1c3b2a27def609473ed13b1cd668cb10deab49b4 upstream.
    
    The bug is here:
            if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
                    return cstate;
    
    The list iterator value 'cstate' will *always* be set and non-NULL
    by list_for_each_entry_from_reverse(), so it is incorrect to assume
    that the iterator value will be unchanged if the list is empty or no
    element is found (In fact, it will be a bogus pointer to an invalid
    structure object containing the HEAD). Also it missed a NULL check
    at callsite and may lead to invalid memory access after that.
    
    To fix this bug, just return 'encoder' when found, otherwise return
    NULL. And add the NULL check.
    
    Cc: stable@vger.kernel.org
    Fixes: 1f7f3d91ad38a ("drm/nouveau/clk: Respect voltage limits in nvkm_cstate_prog")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Reviewed-by: Lyude Paul <lyude@redhat.com>
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220327075824.11806-1-xiam0nd.tong@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
drm/plane: Move range check for format_count earlier [+ + +]
Author: Steven Price <steven.price@arm.com>
Date:   Fri Dec 3 10:28:15 2021 +0000

    drm/plane: Move range check for format_count earlier
    
    [ Upstream commit 4b674dd69701c2e22e8e7770c1706a69f3b17269 ]
    
    While the check for format_count > 64 in __drm_universal_plane_init()
    shouldn't be hit (it's a WARN_ON), in its current position it will then
    leak the plane->format_types array and fail to call
    drm_mode_object_unregister() leaking the modeset identifier. Move it to
    the start of the function to avoid allocating those resources in the
    first place.
    
    Signed-off-by: Steven Price <steven.price@arm.com>
    Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
    Link: https://lore.kernel.org/dri-devel/20211203102815.38624-1-steven.price@arm.com/
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/radeon: fix a possible null pointer dereference [+ + +]
Author: Gong Yuanjun <ruc_gongyuanjun@163.com>
Date:   Tue May 17 17:57:00 2022 +0800

    drm/radeon: fix a possible null pointer dereference
    
    [ Upstream commit a2b28708b645c5632dc93669ab06e97874c8244f ]
    
    In radeon_fp_native_mode(), the return value of drm_mode_duplicate()
    is assigned to mode, which will lead to a NULL pointer dereference
    on failure of drm_mode_duplicate(). Add a check to avoid npd.
    
    The failure status of drm_cvt_mode() on the other path is checked too.
    
    Signed-off-by: Gong Yuanjun <ruc_gongyuanjun@163.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/rockchip: vop: fix possible null-ptr-deref in vop_bind() [+ + +]
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Fri Apr 22 11:28:54 2022 +0800

    drm/rockchip: vop: fix possible null-ptr-deref in vop_bind()
    
    [ Upstream commit f8c242908ad15bbd604d3bcb54961b7d454c43f8 ]
    
    It will cause null-ptr-deref in resource_size(), if platform_get_resource()
    returns NULL, move calling resource_size() after devm_ioremap_resource() that
    will check 'res' to avoid null-ptr-deref.
    
    Fixes: 2048e3286f34 ("drm: rockchip: Add basic drm driver")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Signed-off-by: Heiko Stuebner <heiko@sntech.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220422032854.2995175-1-yangyingliang@huawei.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/vc4: txp: Don't set TXP_VSTART_AT_EOF [+ + +]
Author: Maxime Ripard <maxime@cerno.tech>
Date:   Mon Mar 28 17:36:55 2022 +0200

    drm/vc4: txp: Don't set TXP_VSTART_AT_EOF
    
    [ Upstream commit 234998df929f14d00cbf2f1e81a7facb69fd9266 ]
    
    The TXP_VSTART_AT_EOF will generate a second VSTART signal to the HVS.
    However, the HVS waits for VSTART to enable the FIFO and will thus start
    filling the FIFO before the start of the frame.
    
    This leads to corruption at the beginning of the first frame, and
    content from the previous frame at the beginning of the next frames.
    
    Since one VSTART is enough, let's get rid of it.
    
    Fixes: 008095e065a8 ("drm/vc4: Add support for the transposer block")
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
    Link: https://lore.kernel.org/r/20220328153659.2382206-3-maxime@cerno.tech
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm/vc4: txp: Force alpha to be 0xff if it's disabled [+ + +]
Author: Maxime Ripard <maxime@cerno.tech>
Date:   Mon Mar 28 17:36:56 2022 +0200

    drm/vc4: txp: Force alpha to be 0xff if it's disabled
    
    [ Upstream commit 5453343a88ede8b12812fced81ecd24cb888ccc3 ]
    
    If we use a format that has padding instead of the alpha component (such
    as XRGB8888), it appears that the Transposer will fill the padding to 0,
    disregarding what was stored in the input buffer padding.
    
    This leads to issues with IGT, since it will set the padding to 0xff,
    but will then compare the CRC of the two frames which will thus fail.
    Another nice side effect is that it is now possible to just use the
    buffer as ARGB.
    
    Fixes: 008095e065a8 ("drm/vc4: Add support for the transposer block")
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
    Link: https://lore.kernel.org/r/20220328153659.2382206-4-maxime@cerno.tech
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes [+ + +]
Author: Liu Zixian <liuzixian4@huawei.com>
Date:   Tue Mar 22 17:17:30 2022 +0800

    drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes
    
    [ Upstream commit 194d250cdc4a40ccbd179afd522a9e9846957402 ]
    
    drm_cvt_mode may return NULL and we should check it.
    
    This bug is found by syzkaller:
    
    FAULT_INJECTION stacktrace:
    [  168.567394] FAULT_INJECTION: forcing a failure.
    name failslab, interval 1, probability 0, space 0, times 1
    [  168.567403] CPU: 1 PID: 6425 Comm: syz Kdump: loaded Not tainted 4.19.90-vhulk2201.1.0.h1035.kasan.eulerosv2r10.aarch64 #1
    [  168.567406] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
    [  168.567408] Call trace:
    [  168.567414]  dump_backtrace+0x0/0x310
    [  168.567418]  show_stack+0x28/0x38
    [  168.567423]  dump_stack+0xec/0x15c
    [  168.567427]  should_fail+0x3ac/0x3d0
    [  168.567437]  __should_failslab+0xb8/0x120
    [  168.567441]  should_failslab+0x28/0xc0
    [  168.567445]  kmem_cache_alloc_trace+0x50/0x640
    [  168.567454]  drm_mode_create+0x40/0x90
    [  168.567458]  drm_cvt_mode+0x48/0xc78
    [  168.567477]  virtio_gpu_conn_get_modes+0xa8/0x140 [virtio_gpu]
    [  168.567485]  drm_helper_probe_single_connector_modes+0x3a4/0xd80
    [  168.567492]  drm_mode_getconnector+0x2e0/0xa70
    [  168.567496]  drm_ioctl_kernel+0x11c/0x1d8
    [  168.567514]  drm_ioctl+0x558/0x6d0
    [  168.567522]  do_vfs_ioctl+0x160/0xf30
    [  168.567525]  ksys_ioctl+0x98/0xd8
    [  168.567530]  __arm64_sys_ioctl+0x50/0xc8
    [  168.567536]  el0_svc_common+0xc8/0x320
    [  168.567540]  el0_svc_handler+0xf8/0x160
    [  168.567544]  el0_svc+0x10/0x218
    
    KASAN stacktrace:
    [  168.567561] BUG: KASAN: null-ptr-deref in virtio_gpu_conn_get_modes+0xb4/0x140 [virtio_gpu]
    [  168.567565] Read of size 4 at addr 0000000000000054 by task syz/6425
    [  168.567566]
    [  168.567571] CPU: 1 PID: 6425 Comm: syz Kdump: loaded Not tainted 4.19.90-vhulk2201.1.0.h1035.kasan.eulerosv2r10.aarch64 #1
    [  168.567573] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
    [  168.567575] Call trace:
    [  168.567578]  dump_backtrace+0x0/0x310
    [  168.567582]  show_stack+0x28/0x38
    [  168.567586]  dump_stack+0xec/0x15c
    [  168.567591]  kasan_report+0x244/0x2f0
    [  168.567594]  __asan_load4+0x58/0xb0
    [  168.567607]  virtio_gpu_conn_get_modes+0xb4/0x140 [virtio_gpu]
    [  168.567612]  drm_helper_probe_single_connector_modes+0x3a4/0xd80
    [  168.567617]  drm_mode_getconnector+0x2e0/0xa70
    [  168.567621]  drm_ioctl_kernel+0x11c/0x1d8
    [  168.567624]  drm_ioctl+0x558/0x6d0
    [  168.567628]  do_vfs_ioctl+0x160/0xf30
    [  168.567632]  ksys_ioctl+0x98/0xd8
    [  168.567636]  __arm64_sys_ioctl+0x50/0xc8
    [  168.567641]  el0_svc_common+0xc8/0x320
    [  168.567645]  el0_svc_handler+0xf8/0x160
    [  168.567649]  el0_svc+0x10/0x218
    
    Signed-off-by: Liu Zixian <liuzixian4@huawei.com>
    Link: http://patchwork.freedesktop.org/patch/msgid/20220322091730.1653-1-liuzixian4@huawei.com
    Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
drm: fix EDID struct for old ARM OABI format [+ + +]
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sat May 28 11:08:48 2022 -0700

    drm: fix EDID struct for old ARM OABI format
    
    [ Upstream commit 47f15561b69e226bfc034e94ff6dbec51a4662af ]
    
    When building the kernel for arm with the "-mabi=apcs-gnu" option, gcc
    will force alignment of all structures and unions to a word boundary
    (see also STRUCTURE_SIZE_BOUNDARY and the "-mstructure-size-boundary=XX"
    option if you're a gcc person), even when the members of said structures
    do not want or need said alignment.
    
    This completely messes up the structure alignment of 'struct edid' on
    those targets, because even though all the embedded structures are
    marked with "__attribute__((packed))", the unions that contain them are
    not.
    
    This was exposed by commit f1e4c916f97f ("drm/edid: add EDID block count
    and size helpers"), but the bug is pre-existing.  That commit just made
    the structure layout problem cause a build failure due to the addition
    of the
    
            BUILD_BUG_ON(sizeof(*edid) != EDID_LENGTH);
    
    sanity check in drivers/gpu/drm/drm_edid.c:edid_block_data().
    
    This legacy union alignment should probably not be used in the first
    place, but we can fix the layout by adding the packed attribute to the
    union entries even when each member is already packed and it shouldn't
    matter in a sane build environment.
    
    You can see this issue with a trivial test program:
    
      union {
            struct {
                    char c[5];
            };
            struct {
                    char d;
                    unsigned e;
            } __attribute__((packed));
      } a = { "1234" };
    
    where building this with a normal "gcc -S" will result in the expected
    5-byte size of said union:
    
            .type   a, @object
            .size   a, 5
    
    but with an ARM compiler and the old ABI:
    
        arm-linux-gnu-gcc -mabi=apcs-gnu -mfloat-abi=soft -S t.c
    
    you get
    
            .type   a, %object
            .size   a, 8
    
    instead, because even though each member of the union is packed, the
    union itself still gets aligned.
    
    This was reported by Sudip for the spear3xx_defconfig target.
    
    Link: https://lore.kernel.org/lkml/YpCUzStDnSgQLNFN@debian/
    Reported-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Maxime Ripard <mripard@kernel.org>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: David Airlie <airlied@linux.ie>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm: imx: fix compiler warning with gcc-12 [+ + +]
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Wed Jun 8 16:59:29 2022 -0700

    drm: imx: fix compiler warning with gcc-12
    
    [ Upstream commit 7aefd8b53815274f3ef398d370a3c9b27dd9f00c ]
    
    Gcc-12 correctly warned about this code using a non-NULL pointer as a
    truth value:
    
      drivers/gpu/drm/imx/ipuv3-crtc.c: In function ‘ipu_crtc_disable_planes’:
      drivers/gpu/drm/imx/ipuv3-crtc.c:72:21: error: the comparison will always evaluate as ‘true’ for the address of ‘plane’ will never be NULL [-Werror=address]
         72 |                 if (&ipu_crtc->plane[1] && plane == &ipu_crtc->plane[1]->base)
            |                     ^
    
    due to the extraneous '&' address-of operator.
    
    Philipp Zabel points out that The mistake had no adverse effect since
    the following condition doesn't actually dereference the NULL pointer,
    but the intent of the code was obviously to check for it, not to take
    the address of the member.
    
    Fixes: eb8c88808c83 ("drm/imx: add deferred plane disabling")
    Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm: mali-dp: potential dereference of null pointer [+ + +]
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Tue Dec 14 18:08:37 2021 +0800

    drm: mali-dp: potential dereference of null pointer
    
    [ Upstream commit 73c3ed7495c67b8fbdc31cf58e6ca8757df31a33 ]
    
    The return value of kzalloc() needs to be checked.
    To avoid use of null pointer '&state->base' in case of the
    failure of alloc.
    
    Fixes: 99665d072183 ("drm: mali-dp: add malidp_crtc_state struct")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Reviewed-by: Brian Starkey <brian.starkey@arm.com>
    Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211214100837.46912-1-jiasheng@iscas.ac.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm: msm: fix error check return value of irq_of_parse_and_map() [+ + +]
Author: Lv Ruyi <lv.ruyi@zte.com.cn>
Date:   Sun Apr 24 03:19:59 2022 +0000

    drm: msm: fix error check return value of irq_of_parse_and_map()
    
    [ Upstream commit b9e4f1d2b505df8e2439b63e67afaa287c1c43e2 ]
    
    The irq_of_parse_and_map() function returns 0 on failure, and does not
    return an negative value.
    
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/483175/
    Link: https://lore.kernel.org/r/20220424031959.3172406-1-lv.ruyi@zte.com.cn
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

drm: msm: fix possible memory leak in mdp5_crtc_cursor_set() [+ + +]
Author: Hangyu Hua <hbh25y@gmail.com>
Date:   Mon May 9 14:11:25 2022 +0800

    drm: msm: fix possible memory leak in mdp5_crtc_cursor_set()
    
    [ Upstream commit 947a844bb3ebff0f4736d244d792ce129f6700d7 ]
    
    drm_gem_object_lookup will call drm_gem_object_get inside. So cursor_bo
    needs to be put when msm_gem_get_and_pin_iova fails.
    
    Fixes: e172d10a9c4a ("drm/msm/mdp5: Add hardware cursor support")
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Link: https://lore.kernel.org/r/20220509061125.18585-1-hbh25y@gmail.com
    Signed-off-by: Rob Clark <robdclark@chromium.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
dt-bindings: gpio: altera: correct interrupt-cells [+ + +]
Author: Dinh Nguyen <dinguyen@kernel.org>
Date:   Wed May 11 12:54:46 2022 -0500

    dt-bindings: gpio: altera: correct interrupt-cells
    
    commit 3a21c3ac93aff7b4522b152399df8f6a041df56d upstream.
    
    update documentation to correctly state the interrupt-cells to be 2.
    
    Cc: stable@vger.kernel.org
    Fixes: 4fd9bbc6e071 ("drivers/gpio: Altera soft IP GPIO driver devicetree binding")
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
efi: Add missing prototype for efi_capsule_setup_info [+ + +]
Author: Jan Kiszka <jan.kiszka@siemens.com>
Date:   Fri Mar 4 07:36:37 2022 +0100

    efi: Add missing prototype for efi_capsule_setup_info
    
    [ Upstream commit aa480379d8bdb33920d68acfd90f823c8af32578 ]
    
    Fixes "no previous declaration for 'efi_capsule_setup_info'" warnings
    under W=1.
    
    Fixes: 2959c95d510c ("efi/capsule: Add support for Quark security header")
    Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
    Link: https://lore.kernel.org/r/c28d3f86-dd72-27d1-e2c2-40971b8da6bd@siemens.com
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

efi: Do not import certificates from UEFI Secure Boot for T2 Macs [+ + +]
Author: Aditya Garg <gargaditya08@live.com>
Date:   Fri Apr 15 17:02:46 2022 +0000

    efi: Do not import certificates from UEFI Secure Boot for T2 Macs
    
    commit 155ca952c7ca19aa32ecfb7373a32bbc2e1ec6eb upstream.
    
    On Apple T2 Macs, when Linux attempts to read the db and dbx efi variables
    at early boot to load UEFI Secure Boot certificates, a page fault occurs
    in Apple firmware code and EFI runtime services are disabled with the
    following logs:
    
    [Firmware Bug]: Page fault caused by firmware at PA: 0xffffb1edc0068000
    WARNING: CPU: 3 PID: 104 at arch/x86/platform/efi/quirks.c:735 efi_crash_gracefully_on_page_fault+0x50/0xf0
    (Removed some logs from here)
    Call Trace:
     <TASK>
     page_fault_oops+0x4f/0x2c0
     ? search_bpf_extables+0x6b/0x80
     ? search_module_extables+0x50/0x80
     ? search_exception_tables+0x5b/0x60
     kernelmode_fixup_or_oops+0x9e/0x110
     __bad_area_nosemaphore+0x155/0x190
     bad_area_nosemaphore+0x16/0x20
     do_kern_addr_fault+0x8c/0xa0
     exc_page_fault+0xd8/0x180
     asm_exc_page_fault+0x1e/0x30
    (Removed some logs from here)
     ? __efi_call+0x28/0x30
     ? switch_mm+0x20/0x30
     ? efi_call_rts+0x19a/0x8e0
     ? process_one_work+0x222/0x3f0
     ? worker_thread+0x4a/0x3d0
     ? kthread+0x17a/0x1a0
     ? process_one_work+0x3f0/0x3f0
     ? set_kthread_struct+0x40/0x40
     ? ret_from_fork+0x22/0x30
     </TASK>
    ---[ end trace 1f82023595a5927f ]---
    efi: Froze efi_rts_wq and disabled EFI Runtime Services
    integrity: Couldn't get size: 0x8000000000000015
    integrity: MODSIGN: Couldn't get UEFI db list
    efi: EFI Runtime Services are disabled!
    integrity: Couldn't get size: 0x8000000000000015
    integrity: Couldn't get UEFI dbx list
    integrity: Couldn't get size: 0x8000000000000015
    integrity: Couldn't get mokx list
    integrity: Couldn't get size: 0x80000000
    
    So we avoid reading these UEFI variables and thus prevent the crash.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Aditya Garg <gargaditya08@live.com>
    Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
    Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
eth: tg3: silence the GCC 12 array-bounds warning [+ + +]
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Fri May 20 12:56:05 2022 -0700

    eth: tg3: silence the GCC 12 array-bounds warning
    
    [ Upstream commit 9dec850fd7c210a04b4707df8e6c95bfafdd6a4b ]
    
    GCC 12 currently generates a rather inconsistent warning:
    
    drivers/net/ethernet/broadcom/tg3.c:17795:51: warning: array subscript 5 is above array bounds of ‘struct tg3_napi[5]’ [-Warray-bounds]
    17795 |                 struct tg3_napi *tnapi = &tp->napi[i];
          |                                           ~~~~~~~~^~~
    
    i is guaranteed < tp->irq_max which in turn is either 1 or 5.
    There are more loops like this one in the driver, but strangely
    GCC 12 dislikes only this single one.
    
    Silence this silliness for now.
    
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ext4: avoid cycles in directory h-tree [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Wed May 18 11:33:29 2022 +0200

    ext4: avoid cycles in directory h-tree
    
    commit 3ba733f879c2a88910744647e41edeefbc0d92b2 upstream.
    
    A maliciously corrupted filesystem can contain cycles in the h-tree
    stored inside a directory. That can easily lead to the kernel corrupting
    tree nodes that were already verified under its hands while doing a node
    split and consequently accessing unallocated memory. Fix the problem by
    verifying traversed block numbers are unique.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220518093332.13986-2-jack@suse.cz
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ext4: fix bug_on in ext4_writepages [+ + +]
Author: Ye Bin <yebin10@huawei.com>
Date:   Mon May 16 20:26:34 2022 +0800

    ext4: fix bug_on in ext4_writepages
    
    commit ef09ed5d37b84d18562b30cf7253e57062d0db05 upstream.
    
    we got issue as follows:
    EXT4-fs error (device loop0): ext4_mb_generate_buddy:1141: group 0, block bitmap and bg descriptor inconsistent: 25 vs 31513 free cls
    ------------[ cut here ]------------
    kernel BUG at fs/ext4/inode.c:2708!
    invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
    CPU: 2 PID: 2147 Comm: rep Not tainted 5.18.0-rc2-next-20220413+ #155
    RIP: 0010:ext4_writepages+0x1977/0x1c10
    RSP: 0018:ffff88811d3e7880 EFLAGS: 00010246
    RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffff88811c098000
    RDX: 0000000000000000 RSI: ffff88811c098000 RDI: 0000000000000002
    RBP: ffff888128140f50 R08: ffffffffb1ff6387 R09: 0000000000000000
    R10: 0000000000000007 R11: ffffed10250281ea R12: 0000000000000001
    R13: 00000000000000a4 R14: ffff88811d3e7bb8 R15: ffff888128141028
    FS:  00007f443aed9740(0000) GS:ffff8883aef00000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000020007200 CR3: 000000011c2a4000 CR4: 00000000000006e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     <TASK>
     do_writepages+0x130/0x3a0
     filemap_fdatawrite_wbc+0x83/0xa0
     filemap_flush+0xab/0xe0
     ext4_alloc_da_blocks+0x51/0x120
     __ext4_ioctl+0x1534/0x3210
     __x64_sys_ioctl+0x12c/0x170
     do_syscall_64+0x3b/0x90
    
    It may happen as follows:
    1. write inline_data inode
    vfs_write
      new_sync_write
        ext4_file_write_iter
          ext4_buffered_write_iter
            generic_perform_write
              ext4_da_write_begin
                ext4_da_write_inline_data_begin -> If inline data size too
                small will allocate block to write, then mapping will has
                dirty page
                    ext4_da_convert_inline_data_to_extent ->clear EXT4_STATE_MAY_INLINE_DATA
    2. fallocate
    do_vfs_ioctl
      ioctl_preallocate
        vfs_fallocate
          ext4_fallocate
            ext4_convert_inline_data
              ext4_convert_inline_data_nolock
                ext4_map_blocks -> fail will goto restore data
                ext4_restore_inline_data
                  ext4_create_inline_data
                  ext4_write_inline_data
                  ext4_set_inode_state -> set inode EXT4_STATE_MAY_INLINE_DATA
    3. writepages
    __ext4_ioctl
      ext4_alloc_da_blocks
        filemap_flush
          filemap_fdatawrite_wbc
            do_writepages
              ext4_writepages
                if (ext4_has_inline_data(inode))
                  BUG_ON(ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA))
    
    The root cause of this issue is we destory inline data until call
    ext4_writepages under delay allocation mode.  But there maybe already
    convert from inline to extent.  To solve this issue, we call
    filemap_flush first..
    
    Cc: stable@kernel.org
    Signed-off-by: Ye Bin <yebin10@huawei.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220516122634.1690462-1-yebin10@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ext4: fix use-after-free in ext4_rename_dir_prepare [+ + +]
Author: Ye Bin <yebin10@huawei.com>
Date:   Thu Apr 14 10:52:23 2022 +0800

    ext4: fix use-after-free in ext4_rename_dir_prepare
    
    commit 0be698ecbe4471fcad80e81ec6a05001421041b3 upstream.
    
    We got issue as follows:
    EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue
    ext4_get_first_dir_block: bh->b_data=0xffff88810bee6000 len=34478
    ext4_get_first_dir_block: *parent_de=0xffff88810beee6ae bh->b_data=0xffff88810bee6000
    ext4_rename_dir_prepare: [1] parent_de=0xffff88810beee6ae
    ==================================================================
    BUG: KASAN: use-after-free in ext4_rename_dir_prepare+0x152/0x220
    Read of size 4 at addr ffff88810beee6ae by task rep/1895
    
    CPU: 13 PID: 1895 Comm: rep Not tainted 5.10.0+ #241
    Call Trace:
     dump_stack+0xbe/0xf9
     print_address_description.constprop.0+0x1e/0x220
     kasan_report.cold+0x37/0x7f
     ext4_rename_dir_prepare+0x152/0x220
     ext4_rename+0xf44/0x1ad0
     ext4_rename2+0x11c/0x170
     vfs_rename+0xa84/0x1440
     do_renameat2+0x683/0x8f0
     __x64_sys_renameat+0x53/0x60
     do_syscall_64+0x33/0x40
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x7f45a6fc41c9
    RSP: 002b:00007ffc5a470218 EFLAGS: 00000246 ORIG_RAX: 0000000000000108
    RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f45a6fc41c9
    RDX: 0000000000000005 RSI: 0000000020000180 RDI: 0000000000000005
    RBP: 00007ffc5a470240 R08: 00007ffc5a470160 R09: 0000000020000080
    R10: 00000000200001c0 R11: 0000000000000246 R12: 0000000000400bb0
    R13: 00007ffc5a470320 R14: 0000000000000000 R15: 0000000000000000
    
    The buggy address belongs to the page:
    page:00000000440015ce refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x10beee
    flags: 0x200000000000000()
    raw: 0200000000000000 ffffea00043ff4c8 ffffea0004325608 0000000000000000
    raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff88810beee580: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
     ffff88810beee600: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
    >ffff88810beee680: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                      ^
     ffff88810beee700: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
     ffff88810beee780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
    ==================================================================
    Disabling lock debugging due to kernel taint
    ext4_rename_dir_prepare: [2] parent_de->inode=3537895424
    ext4_rename_dir_prepare: [3] dir=0xffff888124170140
    ext4_rename_dir_prepare: [4] ino=2
    ext4_rename_dir_prepare: ent->dir->i_ino=2 parent=-757071872
    
    Reason is first directory entry which 'rec_len' is 34478, then will get illegal
    parent entry. Now, we do not check directory entry after read directory block
    in 'ext4_get_first_dir_block'.
    To solve this issue, check directory entry in 'ext4_get_first_dir_block'.
    
    [ Trigger an ext4_error() instead of just warning if the directory is
      missing a '.' or '..' entry.   Also make sure we return an error code
      if the file system is corrupted.  -TYT ]
    
    Signed-off-by: Ye Bin <yebin10@huawei.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220414025223.4113128-1-yebin10@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ext4: fix warning in ext4_handle_inode_extension [+ + +]
Author: Ye Bin <yebin10@huawei.com>
Date:   Sat Mar 26 14:53:51 2022 +0800

    ext4: fix warning in ext4_handle_inode_extension
    
    commit f4534c9fc94d22383f187b9409abb3f9df2e3db3 upstream.
    
    We got issue as follows:
    EXT4-fs error (device loop0) in ext4_reserve_inode_write:5741: Out of memory
    EXT4-fs error (device loop0): ext4_setattr:5462: inode #13: comm syz-executor.0: mark_inode_dirty error
    EXT4-fs error (device loop0) in ext4_setattr:5519: Out of memory
    EXT4-fs error (device loop0): ext4_ind_map_blocks:595: inode #13: comm syz-executor.0: Can't allocate blocks for non-extent mapped inodes with bigalloc
    ------------[ cut here ]------------
    WARNING: CPU: 1 PID: 4361 at fs/ext4/file.c:301 ext4_file_write_iter+0x11c9/0x1220
    Modules linked in:
    CPU: 1 PID: 4361 Comm: syz-executor.0 Not tainted 5.10.0+ #1
    RIP: 0010:ext4_file_write_iter+0x11c9/0x1220
    RSP: 0018:ffff924d80b27c00 EFLAGS: 00010282
    RAX: ffffffff815a3379 RBX: 0000000000000000 RCX: 000000003b000000
    RDX: ffff924d81601000 RSI: 00000000000009cc RDI: 00000000000009cd
    RBP: 000000000000000d R08: ffffffffbc5a2c6b R09: 0000902e0e52a96f
    R10: ffff902e2b7c1b40 R11: ffff902e2b7c1b40 R12: 000000000000000a
    R13: 0000000000000001 R14: ffff902e0e52aa10 R15: ffffffffffffff8b
    FS:  00007f81a7f65700(0000) GS:ffff902e3bc80000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffffffffff600400 CR3: 000000012db88001 CR4: 00000000003706e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     do_iter_readv_writev+0x2e5/0x360
     do_iter_write+0x112/0x4c0
     do_pwritev+0x1e5/0x390
     __x64_sys_pwritev2+0x7e/0xa0
     do_syscall_64+0x37/0x50
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Above issue may happen as follows:
    Assume
    inode.i_size=4096
    EXT4_I(inode)->i_disksize=4096
    
    step 1: set inode->i_isize = 8192
    ext4_setattr
      if (attr->ia_size != inode->i_size)
        EXT4_I(inode)->i_disksize = attr->ia_size;
        rc = ext4_mark_inode_dirty
           ext4_reserve_inode_write
              ext4_get_inode_loc
                __ext4_get_inode_loc
                  sb_getblk --> return -ENOMEM
       ...
       if (!error)  ->will not update i_size
         i_size_write(inode, attr->ia_size);
    Now:
    inode.i_size=4096
    EXT4_I(inode)->i_disksize=8192
    
    step 2: Direct write 4096 bytes
    ext4_file_write_iter
     ext4_dio_write_iter
       iomap_dio_rw ->return error
     if (extend)
       ext4_handle_inode_extension
         WARN_ON_ONCE(i_size_read(inode) < EXT4_I(inode)->i_disksize);
    ->Then trigger warning.
    
    To solve above issue, if mark inode dirty failed in ext4_setattr just
    set 'EXT4_I(inode)->i_disksize' with old value.
    
    Signed-off-by: Ye Bin <yebin10@huawei.com>
    Link: https://lore.kernel.org/r/20220326065351.761952-1-yebin10@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ext4: reject the 'commit' option on ext2 filesystems [+ + +]
Author: Eric Biggers <ebiggers@google.com>
Date:   Tue May 10 11:32:32 2022 -0700

    ext4: reject the 'commit' option on ext2 filesystems
    
    [ Upstream commit cb8435dc8ba33bcafa41cf2aa253794320a3b8df ]
    
    The 'commit' option is only applicable for ext3 and ext4 filesystems,
    and has never been accepted by the ext2 filesystem driver, so the ext4
    driver shouldn't allow it on ext2 filesystems.
    
    This fixes a failure in xfstest ext4/053.
    
    Fixes: 8dc0aa8cf0f7 ("ext4: check incompatible mount options while mounting ext2/3")
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Ritesh Harjani <ritesh.list@gmail.com>
    Reviewed-by: Lukas Czerner <lczerner@redhat.com>
    Link: https://lore.kernel.org/r/20220510183232.172615-1-ebiggers@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ext4: verify dir block before splitting it [+ + +]
Author: Jan Kara <jack@suse.cz>
Date:   Wed May 18 11:33:28 2022 +0200

    ext4: verify dir block before splitting it
    
    commit 46c116b920ebec58031f0a78c5ea9599b0d2a371 upstream.
    
    Before splitting a directory block verify its directory entries are sane
    so that the splitting code does not access memory it should not.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220518093332.13986-1-jack@suse.cz
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
extcon: Modify extcon device to be created after driver data is set [+ + +]
Author: bumwoo lee <bw365.lee@samsung.com>
Date:   Wed Apr 27 12:00:05 2022 +0900

    extcon: Modify extcon device to be created after driver data is set
    
    [ Upstream commit 5dcc2afe716d69f5112ce035cb14f007461ff189 ]
    
    Currently, someone can invoke the sysfs such as state_show()
    intermittently before dev_set_drvdata() is done.
    And it can be a cause of kernel Oops because of edev is Null at that time.
    So modified the driver registration to after setting drviver data.
    
    - Oops's backtrace.
    
    Backtrace:
    [<c067865c>] (state_show) from [<c05222e8>] (dev_attr_show)
    [<c05222c0>] (dev_attr_show) from [<c02c66e0>] (sysfs_kf_seq_show)
    [<c02c6648>] (sysfs_kf_seq_show) from [<c02c496c>] (kernfs_seq_show)
    [<c02c4938>] (kernfs_seq_show) from [<c025e2a0>] (seq_read)
    [<c025e11c>] (seq_read) from [<c02c50a0>] (kernfs_fop_read)
    [<c02c5064>] (kernfs_fop_read) from [<c0231cac>] (__vfs_read)
    [<c0231c5c>] (__vfs_read) from [<c0231ee0>] (vfs_read)
    [<c0231e34>] (vfs_read) from [<c0232464>] (ksys_read)
    [<c02323f0>] (ksys_read) from [<c02324fc>] (sys_read)
    [<c02324e4>] (sys_read) from [<c00091d0>] (__sys_trace_return)
    
    Signed-off-by: bumwoo lee <bw365.lee@samsung.com>
    Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
f2fs: don't need inode lock for system hidden quota [+ + +]
Author: Jaegeuk Kim <jaegeuk@kernel.org>
Date:   Thu May 5 17:40:25 2022 -0700

    f2fs: don't need inode lock for system hidden quota
    
    commit 6213f5d4d23c50d393a31dc8e351e63a1fd10dbe upstream.
    
    Let's avoid false-alarmed lockdep warning.
    
    [   58.914674] [T1501146] -> #2 (&sb->s_type->i_mutex_key#20){+.+.}-{3:3}:
    [   58.915975] [T1501146] system_server:        down_write+0x7c/0xe0
    [   58.916738] [T1501146] system_server:        f2fs_quota_sync+0x60/0x1a8
    [   58.917563] [T1501146] system_server:        block_operations+0x16c/0x43c
    [   58.918410] [T1501146] system_server:        f2fs_write_checkpoint+0x114/0x318
    [   58.919312] [T1501146] system_server:        f2fs_issue_checkpoint+0x178/0x21c
    [   58.920214] [T1501146] system_server:        f2fs_sync_fs+0x48/0x6c
    [   58.920999] [T1501146] system_server:        f2fs_do_sync_file+0x334/0x738
    [   58.921862] [T1501146] system_server:        f2fs_sync_file+0x30/0x48
    [   58.922667] [T1501146] system_server:        __arm64_sys_fsync+0x84/0xf8
    [   58.923506] [T1501146] system_server:        el0_svc_common.llvm.12821150825140585682+0xd8/0x20c
    [   58.924604] [T1501146] system_server:        do_el0_svc+0x28/0xa0
    [   58.925366] [T1501146] system_server:        el0_svc+0x24/0x38
    [   58.926094] [T1501146] system_server:        el0_sync_handler+0x88/0xec
    [   58.926920] [T1501146] system_server:        el0_sync+0x1b4/0x1c0
    
    [   58.927681] [T1501146] -> #1 (&sbi->cp_global_sem){+.+.}-{3:3}:
    [   58.928889] [T1501146] system_server:        down_write+0x7c/0xe0
    [   58.929650] [T1501146] system_server:        f2fs_write_checkpoint+0xbc/0x318
    [   58.930541] [T1501146] system_server:        f2fs_issue_checkpoint+0x178/0x21c
    [   58.931443] [T1501146] system_server:        f2fs_sync_fs+0x48/0x6c
    [   58.932226] [T1501146] system_server:        sync_filesystem+0xac/0x130
    [   58.933053] [T1501146] system_server:        generic_shutdown_super+0x38/0x150
    [   58.933958] [T1501146] system_server:        kill_block_super+0x24/0x58
    [   58.934791] [T1501146] system_server:        kill_f2fs_super+0xcc/0x124
    [   58.935618] [T1501146] system_server:        deactivate_locked_super+0x90/0x120
    [   58.936529] [T1501146] system_server:        deactivate_super+0x74/0xac
    [   58.937356] [T1501146] system_server:        cleanup_mnt+0x128/0x168
    [   58.938150] [T1501146] system_server:        __cleanup_mnt+0x18/0x28
    [   58.938944] [T1501146] system_server:        task_work_run+0xb8/0x14c
    [   58.939749] [T1501146] system_server:        do_notify_resume+0x114/0x1e8
    [   58.940595] [T1501146] system_server:        work_pending+0xc/0x5f0
    
    [   58.941375] [T1501146] -> #0 (&sbi->gc_lock){+.+.}-{3:3}:
    [   58.942519] [T1501146] system_server:        __lock_acquire+0x1270/0x2868
    [   58.943366] [T1501146] system_server:        lock_acquire+0x114/0x294
    [   58.944169] [T1501146] system_server:        down_write+0x7c/0xe0
    [   58.944930] [T1501146] system_server:        f2fs_issue_checkpoint+0x13c/0x21c
    [   58.945831] [T1501146] system_server:        f2fs_sync_fs+0x48/0x6c
    [   58.946614] [T1501146] system_server:        f2fs_do_sync_file+0x334/0x738
    [   58.947472] [T1501146] system_server:        f2fs_ioc_commit_atomic_write+0xc8/0x14c
    [   58.948439] [T1501146] system_server:        __f2fs_ioctl+0x674/0x154c
    [   58.949253] [T1501146] system_server:        f2fs_ioctl+0x54/0x88
    [   58.950018] [T1501146] system_server:        __arm64_sys_ioctl+0xa8/0x110
    [   58.950865] [T1501146] system_server:        el0_svc_common.llvm.12821150825140585682+0xd8/0x20c
    [   58.951965] [T1501146] system_server:        do_el0_svc+0x28/0xa0
    [   58.952727] [T1501146] system_server:        el0_svc+0x24/0x38
    [   58.953454] [T1501146] system_server:        el0_sync_handler+0x88/0xec
    [   58.954279] [T1501146] system_server:        el0_sync+0x1b4/0x1c0
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

f2fs: fix deadloop in foreground GC [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Wed May 4 14:09:22 2022 +0800

    f2fs: fix deadloop in foreground GC
    
    commit cfd66bb715fd11fde3338d0660cffa1396adc27d upstream.
    
    As Yanming reported in bugzilla:
    
    https://bugzilla.kernel.org/show_bug.cgi?id=215914
    
    The root cause is: in a very small sized image, it's very easy to
    exceed threshold of foreground GC, if we calculate free space and
    dirty data based on section granularity, in corner case,
    has_not_enough_free_secs() will always return true, result in
    deadloop in f2fs_gc().
    
    So this patch refactors has_not_enough_free_secs() as below to fix
    this issue:
    1. calculate needed space based on block granularity, and separate
    all blocks to two parts, section part, and block part, comparing
    section part to free section, and comparing block part to free space
    in openned log.
    2. account F2FS_DIRTY_NODES, F2FS_DIRTY_IMETA and F2FS_DIRTY_DENTS
    as node block consumer;
    3. account F2FS_DIRTY_DENTS as data block consumer;
    
    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan <yanming@tju.edu.cn>
    Signed-off-by: Chao Yu <chao.yu@oppo.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

f2fs: fix dereference of stale list iterator after loop body [+ + +]
Author: Jakob Koschel <jakobkoschel@gmail.com>
Date:   Fri Apr 1 00:34:14 2022 +0200

    f2fs: fix dereference of stale list iterator after loop body
    
    [ Upstream commit 2aaf51dd39afb6d01d13f1e6fe20b684733b37d5 ]
    
    The list iterator variable will be a bogus pointer if no break was hit.
    Dereferencing it (cur->page in this case) could load an out-of-bounds/undefined
    value making it unsafe to use that in the comparision to determine if the
    specific element was found.
    
    Since 'cur->page' *can* be out-ouf-bounds it cannot be guaranteed that
    by chance (or intention of an attacker) it matches the value of 'page'
    even though the correct element was not found.
    
    This is fixed by using a separate list iterator variable for the loop
    and only setting the original variable if a suitable element was found.
    Then determing if the element was found is simply checking if the
    variable is set.
    
    Fixes: 8c242db9b8c0 ("f2fs: fix stale ATOMIC_WRITTEN_PAGE private pointer")
    Signed-off-by: Jakob Koschel <jakobkoschel@gmail.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 fallocate to use file_modified to update permissions consistently [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Tue May 17 11:37:23 2022 +0800

    f2fs: fix fallocate to use file_modified to update permissions consistently
    
    commit 958ed92922028ec67f504dcdc72bfdfd0f43936a upstream.
    
    This patch tries to fix permission consistency issue as all other
    mainline filesystems.
    
    Since the initial introduction of (posix) fallocate back at the turn of
    the century, it has been possible to use this syscall to change the
    user-visible contents of files.  This can happen by extending the file
    size during a preallocation, or through any of the newer modes (punch,
    zero, collapse, insert range).  Because the call can be used to change
    file contents, we should treat it like we do any other modification to a
    file -- update the mtime, and drop set[ug]id privileges/capabilities.
    
    The VFS function file_modified() does all this for us if pass it a
    locked inode, so let's make fallocate drop permissions correctly.
    
    Cc: stable@kernel.org
    Signed-off-by: Chao Yu <chao.yu@oppo.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

f2fs: fix to avoid f2fs_bug_on() in dec_valid_node_count() [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Wed Apr 27 01:06:02 2022 +0800

    f2fs: fix to avoid f2fs_bug_on() in dec_valid_node_count()
    
    commit 4d17e6fe9293d57081ffdc11e1cf313e25e8fd9e upstream.
    
    As Yanming reported in bugzilla:
    
    https://bugzilla.kernel.org/show_bug.cgi?id=215897
    
    I have encountered a bug in F2FS file system in kernel v5.17.
    
    The kernel should enable CONFIG_KASAN=y and CONFIG_KASAN_INLINE=y. You can
    reproduce the bug by running the following commands:
    
    The kernel message is shown below:
    
    kernel BUG at fs/f2fs/f2fs.h:2511!
    Call Trace:
     f2fs_remove_inode_page+0x2a2/0x830
     f2fs_evict_inode+0x9b7/0x1510
     evict+0x282/0x4e0
     do_unlinkat+0x33a/0x540
     __x64_sys_unlinkat+0x8e/0xd0
     do_syscall_64+0x3b/0x90
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    The root cause is: .total_valid_block_count or .total_valid_node_count
    could fuzzed to zero, then once dec_valid_node_count() was called, it
    will cause BUG_ON(), this patch fixes to print warning info and set
    SBI_NEED_FSCK into CP instead of panic.
    
    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan <yanming@tju.edu.cn>
    Signed-off-by: Chao Yu <chao.yu@oppo.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

f2fs: fix to clear dirty inode in f2fs_evict_inode() [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Sat Apr 30 21:19:24 2022 +0800

    f2fs: fix to clear dirty inode in f2fs_evict_inode()
    
    commit f2db71053dc0409fae785096ad19cce4c8a95af7 upstream.
    
    As Yanming reported in bugzilla:
    
    https://bugzilla.kernel.org/show_bug.cgi?id=215904
    
    The kernel message is shown below:
    
    kernel BUG at fs/f2fs/inode.c:825!
    Call Trace:
     evict+0x282/0x4e0
     __dentry_kill+0x2b2/0x4d0
     shrink_dentry_list+0x17c/0x4f0
     shrink_dcache_parent+0x143/0x1e0
     do_one_tree+0x9/0x30
     shrink_dcache_for_umount+0x51/0x120
     generic_shutdown_super+0x5c/0x3a0
     kill_block_super+0x90/0xd0
     kill_f2fs_super+0x225/0x310
     deactivate_locked_super+0x78/0xc0
     cleanup_mnt+0x2b7/0x480
     task_work_run+0xc8/0x150
     exit_to_user_mode_prepare+0x14a/0x150
     syscall_exit_to_user_mode+0x1d/0x40
     do_syscall_64+0x48/0x90
    
    The root cause is: inode node and dnode node share the same nid,
    so during f2fs_evict_inode(), dnode node truncation will invalidate
    its NAT entry, so when truncating inode node, it fails due to
    invalid NAT entry, result in inode is still marked as dirty, fix
    this issue by clearing dirty for inode and setting SBI_NEED_FSCK
    flag in filesystem.
    
    output from dump.f2fs:
    [print_node_info: 354] Node ID [0xf:15] is inode
    i_nid[0]                                [0x       f : 15]
    
    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan <yanming@tju.edu.cn>
    Signed-off-by: Chao Yu <chao.yu@oppo.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

f2fs: fix to do sanity check on block address in f2fs_do_zero_range() [+ + +]
Author: Chao Yu <chao@kernel.org>
Date:   Wed Apr 27 17:51:40 2022 +0800

    f2fs: fix to do sanity check on block address in f2fs_do_zero_range()
    
    commit 25f8236213a91efdf708b9d77e9e51b6fc3e141c upstream.
    
    As Yanming reported in bugzilla:
    
    https://bugzilla.kernel.org/show_bug.cgi?id=215894
    
    I have encountered a bug in F2FS file system in kernel v5.17.
    
    I have uploaded the system call sequence as case.c, and a fuzzed image can
    be found in google net disk
    
    The kernel should enable CONFIG_KASAN=y and CONFIG_KASAN_INLINE=y. You can
    reproduce the bug by running the following commands:
    
    kernel BUG at fs/f2fs/segment.c:2291!
    Call Trace:
     f2fs_invalidate_blocks+0x193/0x2d0
     f2fs_fallocate+0x2593/0x4a70
     vfs_fallocate+0x2a5/0xac0
     ksys_fallocate+0x35/0x70
     __x64_sys_fallocate+0x8e/0xf0
     do_syscall_64+0x3b/0x90
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    The root cause is, after image was fuzzed, block mapping info in inode
    will be inconsistent with SIT table, so in f2fs_fallocate(), it will cause
    panic when updating SIT with invalid blkaddr.
    
    Let's fix the issue by adding sanity check on block address before updating
    SIT table with it.
    
    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan <yanming@tju.edu.cn>
    Signed-off-by: Chao Yu <chao.yu@oppo.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

f2fs: remove WARN_ON in f2fs_is_valid_blkaddr [+ + +]
Author: Dongliang Mu <mudongliangabcd@gmail.com>
Date:   Fri Apr 15 21:19:02 2022 +0800

    f2fs: remove WARN_ON in f2fs_is_valid_blkaddr
    
    [ Upstream commit dc2f78e2d4cc844a1458653d57ce1b54d4a29f21 ]
    
    Syzbot triggers two WARNs in f2fs_is_valid_blkaddr and
    __is_bitmap_valid. For example, in f2fs_is_valid_blkaddr,
    if type is DATA_GENERIC_ENHANCE or DATA_GENERIC_ENHANCE_READ,
    it invokes WARN_ON if blkaddr is not in the right range.
    The call trace is as follows:
    
     f2fs_get_node_info+0x45f/0x1070
     read_node_page+0x577/0x1190
     __get_node_page.part.0+0x9e/0x10e0
     __get_node_page
     f2fs_get_node_page+0x109/0x180
     do_read_inode
     f2fs_iget+0x2a5/0x58b0
     f2fs_fill_super+0x3b39/0x7ca0
    
    Fix these two WARNs by replacing WARN_ON with dump_stack.
    
    Reported-by: syzbot+763ae12a2ede1d99d4dc@syzkaller.appspotmail.com
    Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
    Reviewed-by: Chao Yu <chao@kernel.org>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
fat: add ratelimit to fat*_ent_bread() [+ + +]
Author: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Date:   Fri Apr 29 14:38:02 2022 -0700

    fat: add ratelimit to fat*_ent_bread()
    
    [ Upstream commit 183c3237c928109d2008c0456dff508baf692b20 ]
    
    fat*_ent_bread() can be the cause of too many report on I/O error path.
    So use fat_msg_ratelimit() instead.
    
    Link: https://lkml.kernel.org/r/87bkxogfeq.fsf@mail.parknet.co.jp
    Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
    Reported-by: qianfan <qianfanguijin@163.com>
    Tested-by: qianfan <qianfanguijin@163.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
fbcon: Consistently protect deferred_takeover with console_lock() [+ + +]
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Tue Apr 5 23:03:31 2022 +0200

    fbcon: Consistently protect deferred_takeover with console_lock()
    
    [ Upstream commit 43553559121ca90965b572cf8a1d6d0fd618b449 ]
    
    This shouldn't be a problem in practice since until we've actually
    taken over the console there's nothing we've registered with the
    console/vt subsystem, so the exit/unbind path that check this can't
    do the wrong thing. But it's confusing, so fix it by moving it a tad
    later.
    
    Acked-by: Sam Ravnborg <sam@ravnborg.org>
    Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: Du Cheng <ducheng2@gmail.com>
    Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Cc: Claudio Suarez <cssk@net-c.es>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220405210335.3434130-14-daniel.vetter@ffwll.ch
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
firmware: arm_scmi: Fix list protocols enumeration in the base protocol [+ + +]
Author: Cristian Marussi <cristian.marussi@arm.com>
Date:   Wed Mar 30 16:05:32 2022 +0100

    firmware: arm_scmi: Fix list protocols enumeration in the base protocol
    
    [ Upstream commit 8009120e0354a67068e920eb10dce532391361d0 ]
    
    While enumerating protocols implemented by the SCMI platform using
    BASE_DISCOVER_LIST_PROTOCOLS, the number of returned protocols is
    currently validated in an improper way since the check employs a sum
    between unsigned integers that could overflow and cause the check itself
    to be silently bypassed if the returned value 'loop_num_ret' is big
    enough.
    
    Fix the validation avoiding the addition.
    
    Link: https://lore.kernel.org/r/20220330150551.2573938-4-cristian.marussi@arm.com
    Fixes: b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol")
    Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed May 11 11:14:19 2022 +0400

    firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle
    
    [ Upstream commit 660ba678f9998aca6db74f2dd912fa5124f0fa31 ]
    
    kobject_init_and_add() takes reference even when it fails.
    According to the doc of kobject_init_and_add()
    
       If this function returns an error, kobject_put() must be called to
       properly clean up the memory associated with the object.
    
    Fix this issue by calling kobject_put().
    
    Fixes: 948af1f0bbc8 ("firmware: Basic dmi-sysfs support")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220511071421.9769-1-linmq006@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

firmware: stratix10-svc: fix a missing check on list iterator [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Thu Apr 14 11:56:09 2022 +0800

    firmware: stratix10-svc: fix a missing check on list iterator
    
    [ Upstream commit 5a0793ac66ac0e254d292f129a4d6c526f9f2aff ]
    
    The bug is here:
            pmem->vaddr = NULL;
    
    The list iterator 'pmem' will point to a bogus position containing
    HEAD if the list is empty or no element is found. This case must
    be checked before any use of the iterator, otherwise it will
    lead to a invalid memory access.
    
    To fix this bug, just gen_pool_free/set NULL/list_del() and return
    when found, otherwise list_del HEAD and return;
    
    Fixes: 7ca5ce896524f ("firmware: add Intel Stratix10 service layer driver")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Link: https://lore.kernel.org/r/20220414035609.2239-1-xiam0nd.tong@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
fs-writeback: writeback_sb_inodes:Recalculate 'wrote' according skipped pages [+ + +]
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Tue May 10 21:38:05 2022 +0800

    fs-writeback: writeback_sb_inodes:Recalculate 'wrote' according skipped pages
    
    commit 68f4c6eba70df70a720188bce95c85570ddfcc87 upstream.
    
    Commit 505a666ee3fc ("writeback: plug writeback in wb_writeback() and
    writeback_inodes_wb()") has us holding a plug during wb_writeback, which
    may cause a potential ABBA dead lock:
    
        wb_writeback                fat_file_fsync
    blk_start_plug(&plug)
    for (;;) {
      iter i-1: some reqs have been added into plug->mq_list  // LOCK A
      iter i:
        progress = __writeback_inodes_wb(wb, work)
        . writeback_sb_inodes // fat's bdev
        .   __writeback_single_inode
        .   . generic_writepages
        .   .   __block_write_full_page
        .   .   . .             __generic_file_fsync
        .   .   . .               sync_inode_metadata
        .   .   . .                 writeback_single_inode
        .   .   . .                   __writeback_single_inode
        .   .   . .                     fat_write_inode
        .   .   . .                       __fat_write_inode
        .   .   . .                         sync_dirty_buffer       // fat's bdev
        .   .   . .                           lock_buffer(bh)       // LOCK B
        .   .   . .                             submit_bh
        .   .   . .                               blk_mq_get_tag    // LOCK A
        .   .   . trylock_buffer(bh)  // LOCK B
        .   .   .   redirty_page_for_writepage
        .   .   .     wbc->pages_skipped++
        .   .   --wbc->nr_to_write
        .   wrote += write_chunk - wbc.nr_to_write  // wrote > 0
        .   requeue_inode
        .     redirty_tail_locked
        if (progress)    // progress > 0
          continue;
      iter i+1:
          queue_io
          // similar process with iter i, infinite for-loop !
    }
    blk_finish_plug(&plug)   // flush plug won't be called
    
    Above process triggers a hungtask like:
    [  399.044861] INFO: task bb:2607 blocked for more than 30 seconds.
    [  399.046824]       Not tainted 5.18.0-rc1-00005-gefae4d9eb6a2-dirty
    [  399.051539] task:bb              state:D stack:    0 pid: 2607 ppid:
    2426 flags:0x00004000
    [  399.051556] Call Trace:
    [  399.051570]  __schedule+0x480/0x1050
    [  399.051592]  schedule+0x92/0x1a0
    [  399.051602]  io_schedule+0x22/0x50
    [  399.051613]  blk_mq_get_tag+0x1d3/0x3c0
    [  399.051640]  __blk_mq_alloc_requests+0x21d/0x3f0
    [  399.051657]  blk_mq_submit_bio+0x68d/0xca0
    [  399.051674]  __submit_bio+0x1b5/0x2d0
    [  399.051708]  submit_bio_noacct+0x34e/0x720
    [  399.051718]  submit_bio+0x3b/0x150
    [  399.051725]  submit_bh_wbc+0x161/0x230
    [  399.051734]  __sync_dirty_buffer+0xd1/0x420
    [  399.051744]  sync_dirty_buffer+0x17/0x20
    [  399.051750]  __fat_write_inode+0x289/0x310
    [  399.051766]  fat_write_inode+0x2a/0xa0
    [  399.051783]  __writeback_single_inode+0x53c/0x6f0
    [  399.051795]  writeback_single_inode+0x145/0x200
    [  399.051803]  sync_inode_metadata+0x45/0x70
    [  399.051856]  __generic_file_fsync+0xa3/0x150
    [  399.051880]  fat_file_fsync+0x1d/0x80
    [  399.051895]  vfs_fsync_range+0x40/0xb0
    [  399.051929]  __x64_sys_fsync+0x18/0x30
    
    In my test, 'need_resched()' (which is imported by 590dca3a71 "fs-writeback:
    unplug before cond_resched in writeback_sb_inodes") in function
    'writeback_sb_inodes()' seldom comes true, unless cond_resched() is deleted
    from write_cache_pages().
    
    Fix it by correcting wrote number according number of skipped pages
    in writeback_sb_inodes().
    
    Goto Link to find a reproducer.
    
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=215837
    Cc: stable@vger.kernel.org # v4.3
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Link: https://lore.kernel.org/r/20220510133805.1988292-1-chengzhihao1@huawei.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
fs: jfs: fix possible NULL pointer dereference in dbFree() [+ + +]
Author: Zixuan Fu <r33s3n6@gmail.com>
Date:   Mon Apr 11 18:45:34 2022 +0800

    fs: jfs: fix possible NULL pointer dereference in dbFree()
    
    [ Upstream commit 0d4837fdb796f99369cf7691d33de1b856bcaf1f ]
    
    In our fault-injection testing, the variable "nblocks" in dbFree() can be
    zero when kmalloc_array() fails in dtSearch(). In this case, the variable
     "mp" in dbFree() would be NULL and then it is dereferenced in
    "write_metapage(mp)".
    
    The failure log is listed as follows:
    
    [   13.824137] BUG: kernel NULL pointer dereference, address: 0000000000000020
    ...
    [   13.827416] RIP: 0010:dbFree+0x5f7/0x910 [jfs]
    [   13.834341] Call Trace:
    [   13.834540]  <TASK>
    [   13.834713]  txFreeMap+0x7b4/0xb10 [jfs]
    [   13.835038]  txUpdateMap+0x311/0x650 [jfs]
    [   13.835375]  jfs_lazycommit+0x5f2/0xc70 [jfs]
    [   13.835726]  ? sched_dynamic_update+0x1b0/0x1b0
    [   13.836092]  kthread+0x3c2/0x4a0
    [   13.836355]  ? txLockFree+0x160/0x160 [jfs]
    [   13.836763]  ? kthread_unuse_mm+0x160/0x160
    [   13.837106]  ret_from_fork+0x1f/0x30
    [   13.837402]  </TASK>
    ...
    
    This patch adds a NULL check of "mp" before "write_metapage(mp)" is called.
    
    Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
    Signed-off-by: Zixuan Fu <r33s3n6@gmail.com>
    Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
fsnotify: fix wrong lockdep annotations [+ + +]
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Fri Apr 22 15:03:14 2022 +0300

    fsnotify: fix wrong lockdep annotations
    
    [ Upstream commit 623af4f538b5df9b416e1b82f720af7371b4c771 ]
    
    Commit 6960b0d909cd ("fsnotify: change locking order") changed some
    of the mark_mutex locks in direct reclaim path to use:
      mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING);
    
    This change is explained:
     "...It uses nested locking to avoid deadlock in case we do the final
      iput() on an inode which still holds marks and thus would take the
      mutex again when calling fsnotify_inode_delete() in destroy_inode()."
    
    The problem is that the mutex_lock_nested() is not a nested lock at
    all. In fact, it has the opposite effect of preventing lockdep from
    warning about a very possible deadlock.
    
    Due to these wrong annotations, a deadlock that was introduced with
    nfsd filecache in kernel v5.4 went unnoticed in v5.4.y for over two
    years until it was reported recently by Khazhismel Kumykov, only to
    find out that the deadlock was already fixed in kernel v5.5.
    
    Fix the wrong lockdep annotations.
    
    Cc: Khazhismel Kumykov <khazhy@google.com>
    Fixes: 6960b0d909cd ("fsnotify: change locking order")
    Link: https://lore.kernel.org/r/20220321112310.vpr7oxro2xkz5llh@quack3.lan/
    Link: https://lore.kernel.org/r/20220422120327.3459282-4-amir73il@gmail.com
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
gma500: fix an incorrect NULL check on list iterator [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Sun Mar 27 13:20:28 2022 +0800

    gma500: fix an incorrect NULL check on list iterator
    
    commit bdef417d84536715145f6dc9cc3275c46f26295a upstream.
    
    The bug is here:
            return crtc;
    
    The list iterator value 'crtc' will *always* be set and non-NULL by
    list_for_each_entry(), so it is incorrect to assume that the iterator
    value will be NULL if the list is empty or no element is found.
    
    To fix the bug, return 'crtc' when found, otherwise return NULL.
    
    Cc: stable@vger.kernel.org
    fixes: 89c78134cc54d ("gma500: Add Poulsbo support")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220327052028.2013-1-xiam0nd.tong@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
HID: bigben: fix slab-out-of-bounds Write in bigben_probe [+ + +]
Author: Dongliang Mu <mudongliangabcd@gmail.com>
Date:   Fri May 6 15:24:25 2022 +0800

    HID: bigben: fix slab-out-of-bounds Write in bigben_probe
    
    [ Upstream commit fc4ef9d5724973193bfa5ebed181dba6de3a56db ]
    
    There is a slab-out-of-bounds Write bug in hid-bigbenff driver.
    The problem is the driver assumes the device must have an input but
    some malicious devices violate this assumption.
    
    Fix this by checking hid_device's input is non-empty before its usage.
    
    Reported-by: syzkaller <syzkaller@googlegroups.com>
    Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

HID: elan: Fix potential double free in elan_input_configured [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Sat Apr 16 07:37:21 2022 +0000

    HID: elan: Fix potential double free in elan_input_configured
    
    [ Upstream commit 1af20714fedad238362571620be0bd690ded05b6 ]
    
    'input' is a managed resource allocated with devm_input_allocate_device(),
    so there is no need to call input_free_device() explicitly or
    there will be a double free.
    
    According to the doc of devm_input_allocate_device():
     * Managed input devices do not need to be explicitly unregistered or
     * freed as it will be done automatically when owner device unbinds from
     * its driver (or binding fails).
    
    Fixes: b7429ea53d6c ("HID: elan: Fix memleak in elan_input_configured")
    Fixes: 9a6a4193d65b ("HID: Add driver for USB ELAN Touchpad")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

HID: hid-led: fix maximum brightness for Dream Cheeky [+ + +]
Author: Jonathan Teh <jonathan.teh@outlook.com>
Date:   Sun Mar 13 19:48:18 2022 +0000

    HID: hid-led: fix maximum brightness for Dream Cheeky
    
    [ Upstream commit 116c3f4a78ebe478d5ad5a038baf931e93e7d748 ]
    
    Increase maximum brightness for Dream Cheeky to 63. Emperically
    determined based on testing in kernel 4.4 on this device:
    
    Bus 003 Device 002: ID 1d34:0004 Dream Cheeky Webmail Notifier
    
    Fixes: 6c7ad07e9e05 ("HID: migrate USB LED driver from usb misc to hid")
    Signed-off-by: Jonathan Teh <jonathan.teh@outlook.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
hugetlb: fix huge_pmd_unshare address update [+ + +]
Author: Mike Kravetz <mike.kravetz@oracle.com>
Date:   Tue May 24 13:50:03 2022 -0700

    hugetlb: fix huge_pmd_unshare address update
    
    commit 48381273f8734d28ef56a5bdf1966dd8530111bc upstream.
    
    The routine huge_pmd_unshare() is passed a pointer to an address
    associated with an area which may be unshared.  If unshare is successful
    this address is updated to 'optimize' callers iterating over huge page
    addresses.  For the optimization to work correctly, address should be
    updated to the last huge page in the unmapped/unshared area.  However, in
    the common case where the passed address is PUD_SIZE aligned, the address
    is incorrectly updated to the address of the preceding huge page.  That
    wastes CPU cycles as the unmapped/unshared range is scanned twice.
    
    Link: https://lkml.kernel.org/r/20220524205003.126184-1-mike.kravetz@oracle.com
    Fixes: 39dde65c9940 ("shared page table for hugetlb page")
    Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
    Acked-by: Muchun Song <songmuchun@bytedance.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
hwmon: Make chip parameter for with_info API mandatory [+ + +]
Author: Guenter Roeck <linux@roeck-us.net>
Date:   Wed May 11 06:22:51 2022 -0700

    hwmon: Make chip parameter for with_info API mandatory
    
    [ Upstream commit ddaefa209c4ac791c1262e97c9b2d0440c8ef1d5 ]
    
    Various attempts were made recently to "convert" the old
    hwmon_device_register() API to devm_hwmon_device_register_with_info()
    by just changing the function name without actually converting the
    driver. Prevent this from happening by making the 'chip' parameter of
    devm_hwmon_device_register_with_info() mandatory.
    
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
i2c: at91: Initialize dma_buf in at91_twi_xfer() [+ + +]
Author: Nathan Chancellor <nathan@kernel.org>
Date:   Thu May 5 08:27:38 2022 -0700

    i2c: at91: Initialize dma_buf in at91_twi_xfer()
    
    [ Upstream commit 6977262c2eee111645668fe9e235ef2f5694abf7 ]
    
    Clang warns:
    
      drivers/i2c/busses/i2c-at91-master.c:707:6: warning: variable 'dma_buf' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
              if (dev->use_dma) {
                  ^~~~~~~~~~~~
      drivers/i2c/busses/i2c-at91-master.c:717:27: note: uninitialized use occurs here
              i2c_put_dma_safe_msg_buf(dma_buf, m_start, !ret);
                                       ^~~~~~~
    
    Initialize dma_buf to NULL, as i2c_put_dma_safe_msg_buf() is a no-op
    when the first argument is NULL, which will work for the !dev->use_dma
    case.
    
    Fixes: 03fbb903c8bf ("i2c: at91: use dma safe buffers")
    Link: https://github.com/ClangBuiltLinux/linux/issues/1629
    Signed-off-by: Nathan Chancellor <nathan@kernel.org>
    Reviewed-by: Michael Walle <michael@walle.cc>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

i2c: at91: use dma safe buffers [+ + +]
Author: Michael Walle <michael@walle.cc>
Date:   Thu Apr 7 17:08:28 2022 +0200

    i2c: at91: use dma safe buffers
    
    [ Upstream commit 03fbb903c8bf7e53e101e8d9a7b261264317c411 ]
    
    The supplied buffer might be on the stack and we get the following error
    message:
    [    3.312058] at91_i2c e0070600.i2c: rejecting DMA map of vmalloc memory
    
    Use i2c_{get,put}_dma_safe_msg_buf() to get a DMA-able memory region if
    necessary.
    
    Fixes: 60937b2cdbf9 ("i2c: at91: add dma support")
    Signed-off-by: Michael Walle <michael@walle.cc>
    Reviewed-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

i2c: cadence: Increase timeout per message if necessary [+ + +]
Author: Lucas Tanure <tanureal@opensource.cirrus.com>
Date:   Wed Apr 13 10:14:10 2022 +0100

    i2c: cadence: Increase timeout per message if necessary
    
    [ Upstream commit 96789dce043f5bff8b7d62aa28d52a7c59403a84 ]
    
    Timeout as 1 second sets an upper limit on the length
    of the transfer executed, but there is no maximum length
    of a write or read message set in i2c_adapter_quirks for
    this controller.
    
    This upper limit affects devices that require sending
    large firmware blobs over I2C.
    
    To remove that limitation, calculate the minimal time
    necessary, plus some wiggle room, for every message and
    use it instead of the default one second, if more than
    one second.
    
    Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
    Acked-by: Michal Simek <michal.simek@xilinx.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
IB/rdmavt: add missing locks in rvt_ruc_loopback [+ + +]
Author: Niels Dossche <dossche.niels@gmail.com>
Date:   Mon Feb 28 20:51:44 2022 +0100

    IB/rdmavt: add missing locks in rvt_ruc_loopback
    
    [ Upstream commit 22cbc6c2681a0a4fe76150270426e763d52353a4 ]
    
    The documentation of the function rvt_error_qp says both r_lock and
    s_lock need to be held when calling that function.
    It also asserts using lockdep that both of those locks are held.
    rvt_error_qp is called form rvt_send_cq, which is called from
    rvt_qp_complete_swqe, which is called from rvt_send_complete, which is
    called from rvt_ruc_loopback in two places. Both of these places do not
    hold r_lock. Fix this by acquiring a spin_lock of r_lock in both of
    these places.
    The r_lock acquiring cannot be added in rvt_qp_complete_swqe because
    some of its other callers already have r_lock acquired.
    
    Link: https://lore.kernel.org/r/20220228195144.71946-1-dossche.niels@gmail.com
    Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
iio: adc: ad7124: Remove shift from scan_type [+ + +]
Author: Alexandru Tachici <alexandru.tachici@analog.com>
Date:   Tue Mar 22 12:50:24 2022 +0200

    iio: adc: ad7124: Remove shift from scan_type
    
    [ Upstream commit fe78ccf79b0e29fd6d8dc2e2c3b0dbeda4ce3ad8 ]
    
    The 24 bits data is stored in 32 bits in BE. There
    is no need to shift it. This confuses user-space apps.
    
    Fixes: b3af341bbd966 ("iio: adc: Add ad7124 support")
    Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
    Link: https://lore.kernel.org/r/20220322105029.86389-2-alexandru.tachici@analog.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

iio: adc: sc27xx: Fine tune the scale calibration values [+ + +]
Author: Cixi Geng <cixi.geng1@unisoc.com>
Date:   Tue Apr 19 22:24:54 2022 +0800

    iio: adc: sc27xx: Fine tune the scale calibration values
    
    [ Upstream commit 5a7a184b11c6910f47600ff5cbbee34168f701a8 ]
    
    Small adjustment the scale calibration value for the sc2731,
    use new name sc2731_[big|small]_scale_graph_calib, and remove
    the origin [big|small]_scale_graph_calib struct for unused.
    
    Fixes: 8ba0dbfd07a35 (iio: adc: sc27xx: Add ADC scale calibration)
    Signed-off-by: Cixi Geng <cixi.geng1@unisoc.com>
    Link: https://lore.kernel.org/r/20220419142458.884933-4-gengcixi@gmail.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

iio: adc: sc27xx: fix read big scale voltage not right [+ + +]
Author: Cixi Geng <cixi.geng1@unisoc.com>
Date:   Tue Apr 19 22:24:53 2022 +0800

    iio: adc: sc27xx: fix read big scale voltage not right
    
    [ Upstream commit ad930a75613282400179361e220e58b87386b8c7 ]
    
    Fix wrong configuration value of SC27XX_ADC_SCALE_MASK and
    SC27XX_ADC_SCALE_SHIFT by spec documetation.
    
    Fixes: 5df362a6cf49c (iio: adc: Add Spreadtrum SC27XX PMICs ADC support)
    Signed-off-by: Cixi Geng <cixi.geng1@unisoc.com>
    Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>
    Link: https://lore.kernel.org/r/20220419142458.884933-3-gengcixi@gmail.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

iio: adc: stmpe-adc: Fix wait_for_completion_timeout return value check [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Tue Apr 12 06:51:45 2022 +0000

    iio: adc: stmpe-adc: Fix wait_for_completion_timeout return value check
    
    [ Upstream commit d345b23200bcdbd2bd3582213d738c258b77718f ]
    
    wait_for_completion_timeout() returns unsigned long not long.
    it returns 0 if timed out, and positive if completed.
    The check for <= 0 is ambiguous and should be == 0 here
    indicating timeout which is the only error case
    
    Fixes: e813dde6f833 ("iio: stmpe-adc: Use wait_for_completion_timeout")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Philippe Schenker <philippe.schenker@toradex.com>
    Link: https://lore.kernel.org/r/20220412065150.14486-1-linmq006@gmail.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

iio: dummy: iio_simple_dummy: check the return value of kstrdup() [+ + +]
Author: Xiaoke Wang <xkernel.wang@foxmail.com>
Date:   Sat Mar 5 11:14:05 2022 +0800

    iio: dummy: iio_simple_dummy: check the return value of kstrdup()
    
    [ Upstream commit ba93642188a6fed754bf7447f638bc410e05a929 ]
    
    kstrdup() is also a memory allocation-related function, it returns NULL
    when some memory errors happen. So it is better to check the return
    value of it so to catch the memory error in time. Besides, there should
    have a kfree() to clear up the allocation if we get a failure later in
    this function to prevent memory leak.
    
    Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
    Link: https://lore.kernel.org/r/tencent_C920CFCC33B9CC1C63141FE1334A39FF8508@qq.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

iio: st_sensors: Add a local lock for protecting odr [+ + +]
Author: Miquel Raynal <miquel.raynal@bootlin.com>
Date:   Mon Feb 7 15:38:33 2022 +0100

    iio: st_sensors: Add a local lock for protecting odr
    
    [ Upstream commit 474010127e2505fc463236470908e1ff5ddb3578 ]
    
    Right now the (framework) mlock lock is (ab)used for multiple purposes:
    1- protecting concurrent accesses over the odr local cache
    2- avoid changing samplig frequency whilst buffer is running
    
    Let's start by handling situation #1 with a local lock.
    
    Suggested-by: Jonathan Cameron <jic23@kernel.org>
    Cc: Denis Ciocca <denis.ciocca@st.com>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/r/20220207143840.707510-7-miquel.raynal@bootlin.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
inotify: show inotify mask flags in proc fdinfo [+ + +]
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Fri Apr 22 15:03:12 2022 +0300

    inotify: show inotify mask flags in proc fdinfo
    
    [ Upstream commit a32e697cda27679a0327ae2cafdad8c7170f548f ]
    
    The inotify mask flags IN_ONESHOT and IN_EXCL_UNLINK are not "internal
    to kernel" and should be exposed in procfs fdinfo so CRIU can restore
    them.
    
    Fixes: 6933599697c9 ("inotify: hide internal kernel bits from fdinfo")
    Link: https://lore.kernel.org/r/20220422120327.3459282-2-amir73il@gmail.com
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Input: bcm5974 - set missing URB_NO_TRANSFER_DMA_MAP urb flag [+ + +]
Author: Mathias Nyman <mathias.nyman@linux.intel.com>
Date:   Tue Jun 7 12:11:33 2022 -0700

    Input: bcm5974 - set missing URB_NO_TRANSFER_DMA_MAP urb flag
    
    commit c42e65664390be7c1ef3838cd84956d3a2739d60 upstream.
    
    The bcm5974 driver does the allocation and dma mapping of the usb urb
    data buffer, but driver does not set the URB_NO_TRANSFER_DMA_MAP flag
    to let usb core know the buffer is already mapped.
    
    usb core tries to map the already mapped buffer, causing a warning:
    "xhci_hcd 0000:00:14.0: rejecting DMA map of vmalloc memory"
    
    Fix this by setting the URB_NO_TRANSFER_DMA_MAP, letting usb core
    know buffer is already mapped by bcm5974 driver
    
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Cc: stable@vger.kernel.org
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=215890
    Link: https://lore.kernel.org/r/20220606113636.588955-1-mathias.nyman@linux.intel.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Input: sparcspkr - fix refcount leak in bbc_beep_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon May 16 14:55:55 2022 -0700

    Input: sparcspkr - fix refcount leak in bbc_beep_probe
    
    [ Upstream commit c8994b30d71d64d5dcc9bc0edbfdf367171aa96f ]
    
    of_find_node_by_path() calls of_find_node_opts_by_path(),
    which returns a node pointer with refcount
    incremented, we should use of_node_put() on it when done.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: 9c1a5077fdca ("input: Rewrite sparcspkr device probing.")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220516081018.42728-1-linmq006@gmail.com
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Input: stmfts - do not leave device disabled in stmfts_input_open [+ + +]
Author: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date:   Wed May 25 09:51:08 2022 -0700

    Input: stmfts - do not leave device disabled in stmfts_input_open
    
    [ Upstream commit 5f76955ab1e43e5795a9631b22ca4f918a0ae986 ]
    
    The commit 26623eea0da3 attempted to deal with potential leak of runtime
    PM counter when opening the touchscreen device, however it ended up
    erroneously dropping the counter in the case of successfully enabling the
    device.
    
    Let's address this by using pm_runtime_resume_and_get() and then executing
    pm_runtime_put_sync() only when we fail to send "sense on" command to the
    device.
    
    Fixes: 26623eea0da3 ("Input: stmfts - fix reference leak in stmfts_input_open")
    Reported-by: Pavel Machek <pavel@denx.de>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
iomap: iomap_write_failed fix [+ + +]
Author: Andreas Gruenbacher <agruenba@redhat.com>
Date:   Thu May 5 18:19:13 2022 -0700

    iomap: iomap_write_failed fix
    
    [ Upstream commit b71450e2cc4b3c79f33c5bd276d152af9bd54f79 ]
    
    The @lend parameter of truncate_pagecache_range() should be the offset
    of the last byte of the hole, not the first byte beyond it.
    
    Fixes: ae259a9c8593 ("fs: introduce iomap infrastructure")
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Reviewed-by: Darrick J. Wong <djwong@kernel.org>
    Signed-off-by: Darrick J. Wong <djwong@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
iommu/amd: Increase timeout waiting for GA log enablement [+ + +]
Author: Joerg Roedel <jroedel@suse.de>
Date:   Fri May 20 12:22:14 2022 +0200

    iommu/amd: Increase timeout waiting for GA log enablement
    
    [ Upstream commit 42bb5aa043382f09bef2cc33b8431be867c70f8e ]
    
    On some systems it can take a long time for the hardware to enable the
    GA log of the AMD IOMMU. The current wait time is only 0.1ms, but
    testing showed that it can take up to 14ms for the GA log to enter
    running state after it has been enabled.
    
    Sometimes the long delay happens when booting the system, sometimes
    only on resume. Adjust the timeout accordingly to not print a warning
    when hardware takes a longer than usual.
    
    There has already been an attempt to fix this with commit
    
            9b45a7738eec ("iommu/amd: Fix loop timeout issue in iommu_ga_log_enable()")
    
    But that commit was based on some wrong math and did not fix the issue
    in all cases.
    
    Cc: "D. Ziegfeld" <dzigg@posteo.de>
    Cc: Jörg-Volker Peetz <jvpeetz@web.de>
    Fixes: 8bda0cfbdc1a ("iommu/amd: Detect and initialize guest vAPIC log")
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Link: https://lore.kernel.org/r/20220520102214.12563-1-joro@8bytes.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
iommu/mediatek: Add list_del in mtk_iommu_remove [+ + +]
Author: Yong Wu <yong.wu@mediatek.com>
Date:   Tue May 3 15:13:56 2022 +0800

    iommu/mediatek: Add list_del in mtk_iommu_remove
    
    [ Upstream commit ee55f75e4bcade81d253163641b63bef3e76cac4 ]
    
    Lack the list_del in the mtk_iommu_remove, and remove
    bus_set_iommu(*, NULL) since there may be several iommu HWs.
    we can not bus_set_iommu null when one iommu driver unbind.
    
    This could be a fix for mt2712 which support 2 M4U HW and list them.
    
    Fixes: 7c3a2ec02806 ("iommu/mediatek: Merge 2 M4U HWs into one iommu domain")
    Signed-off-by: Yong Wu <yong.wu@mediatek.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
    Link: https://lore.kernel.org/r/20220503071427.2285-6-yong.wu@mediatek.com
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
iommu/msm: Fix an incorrect NULL check on list iterator [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Sun May 1 21:28:23 2022 +0800

    iommu/msm: Fix an incorrect NULL check on list iterator
    
    commit 8b9ad480bd1dd25f4ff4854af5685fa334a2f57a upstream.
    
    The bug is here:
            if (!iommu || iommu->dev->of_node != spec->np) {
    
    The list iterator value 'iommu' will *always* be set and non-NULL by
    list_for_each_entry(), so it is incorrect to assume that the iterator
    value will be NULL if the list is empty or no element is found (in fact,
    it will point to a invalid structure object containing HEAD).
    
    To fix the bug, use a new value 'iter' as the list iterator, while use
    the old value 'iommu' as a dedicated variable to point to the found one,
    and remove the unneeded check for 'iommu->dev->of_node != spec->np'
    outside the loop.
    
    Cc: stable@vger.kernel.org
    Fixes: f78ebca8ff3d6 ("iommu/msm: Add support for generic master bindings")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Link: https://lore.kernel.org/r/20220501132823.12714-1-xiam0nd.tong@gmail.com
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ip_gre: test csum_start instead of transport header [+ + +]
Author: Willem de Bruijn <willemb@google.com>
Date:   Mon Jun 6 09:21:07 2022 -0400

    ip_gre: test csum_start instead of transport header
    
    [ Upstream commit 8d21e9963bec1aad2280cdd034c8993033ef2948 ]
    
    GRE with TUNNEL_CSUM will apply local checksum offload on
    CHECKSUM_PARTIAL packets.
    
    ipgre_xmit must validate csum_start after an optional skb_pull,
    else lco_csum may trigger an overflow. The original check was
    
            if (csum && skb_checksum_start(skb) < skb->data)
                    return -EINVAL;
    
    This had false positives when skb_checksum_start is undefined:
    when ip_summed is not CHECKSUM_PARTIAL. A discussed refinement
    was straightforward
    
            if (csum && skb->ip_summed == CHECKSUM_PARTIAL &&
                skb_checksum_start(skb) < skb->data)
                    return -EINVAL;
    
    But was eventually revised more thoroughly:
    - restrict the check to the only branch where needed, in an
      uncommon GRE path that uses header_ops and calls skb_pull.
    - test skb_transport_header, which is set along with csum_start
      in skb_partial_csum_set in the normal header_ops datapath.
    
    Turns out skbs can arrive in this branch without the transport
    header set, e.g., through BPF redirection.
    
    Revise the check back to check csum_start directly, and only if
    CHECKSUM_PARTIAL. Do leave the check in the updated location.
    Check field regardless of whether TUNNEL_CSUM is configured.
    
    Link: https://lore.kernel.org/netdev/YS+h%2FtqCJJiQei+W@shredder/
    Link: https://lore.kernel.org/all/20210902193447.94039-2-willemdebruijn.kernel@gmail.com/T/#u
    Fixes: 8a0ed250f911 ("ip_gre: validate csum_start only on pull")
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Willem de Bruijn <willemb@google.com>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
    Link: https://lore.kernel.org/r/20220606132107.3582565-1-willemdebruijn.kernel@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ipc/mqueue: use get_tree_nodev() in mqueue_get_tree() [+ + +]
Author: Waiman Long <longman@redhat.com>
Date:   Mon May 9 18:29:21 2022 -0700

    ipc/mqueue: use get_tree_nodev() in mqueue_get_tree()
    
    [ Upstream commit d60c4d01a98bc1942dba6e3adc02031f5519f94b ]
    
    When running the stress-ng clone benchmark with multiple testing threads,
    it was found that there were significant spinlock contention in sget_fc().
    The contended spinlock was the sb_lock.  It is under heavy contention
    because the following code in the critcal section of sget_fc():
    
      hlist_for_each_entry(old, &fc->fs_type->fs_supers, s_instances) {
          if (test(old, fc))
              goto share_extant_sb;
      }
    
    After testing with added instrumentation code, it was found that the
    benchmark could generate thousands of ipc namespaces with the
    corresponding number of entries in the mqueue's fs_supers list where the
    namespaces are the key for the search.  This leads to excessive time in
    scanning the list for a match.
    
    Looking back at the mqueue calling sequence leading to sget_fc():
    
      mq_init_ns()
      => mq_create_mount()
      => fc_mount()
      => vfs_get_tree()
      => mqueue_get_tree()
      => get_tree_keyed()
      => vfs_get_super()
      => sget_fc()
    
    Currently, mq_init_ns() is the only mqueue function that will indirectly
    call mqueue_get_tree() with a newly allocated ipc namespace as the key for
    searching.  As a result, there will never be a match with the exising ipc
    namespaces stored in the mqueue's fs_supers list.
    
    So using get_tree_keyed() to do an existing ipc namespace search is just a
    waste of time.  Instead, we could use get_tree_nodev() to eliminate the
    useless search.  By doing so, we can greatly reduce the sb_lock hold time
    and avoid the spinlock contention problem in case a large number of ipc
    namespaces are present.
    
    Of course, if the code is modified in the future to allow
    mqueue_get_tree() to be called with an existing ipc namespace instead of a
    new one, we will have to use get_tree_keyed() in this case.
    
    The following stress-ng clone benchmark command was run on a 2-socket
    48-core Intel system:
    
    ./stress-ng --clone 32 --verbose --oomable --metrics-brief -t 20
    
    The "bogo ops/s" increased from 5948.45 before patch to 9137.06 after
    patch. This is an increase of 54% in performance.
    
    Link: https://lkml.kernel.org/r/20220121172315.19652-1-longman@redhat.com
    Fixes: 935c6912b198 ("ipc: Convert mqueue fs to fs_context")
    Signed-off-by: Waiman Long <longman@redhat.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: David Howells <dhowells@redhat.com>
    Cc: Manfred Spraul <manfred@colorfullife.com>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ipmi: Fix pr_fmt to avoid compilation issues [+ + +]
Author: Corey Minyard <cminyard@mvista.com>
Date:   Fri Apr 15 07:23:32 2022 -0500

    ipmi: Fix pr_fmt to avoid compilation issues
    
    [ Upstream commit 2ebaf18a0b7fb764bba6c806af99fe868cee93de ]
    
    The was it was wouldn't work in some situations, simplify it.  What was
    there was unnecessary complexity.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Corey Minyard <cminyard@mvista.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Linux: ipmi:ssif: Check for NULL msg when handling events and messages [+ + +]
Author: Corey Minyard <cminyard@mvista.com>
Date:   Fri Apr 1 07:44:53 2022 -0500

    ipmi:ssif: Check for NULL msg when handling events and messages
    
    [ Upstream commit 7602b957e2404e5f98d9a40b68f1fd27f0028712 ]
    
    Even though it's not possible to get into the SSIF_GETTING_MESSAGES and
    SSIF_GETTING_EVENTS states without a valid message in the msg field,
    it's probably best to be defensive here and check and print a log, since
    that means something else went wrong.
    
    Also add a default clause to that switch statement to release the lock
    and print a log, in case the state variable gets messed up somehow.
    
    Reported-by: Haowen Bai <baihaowen@meizu.com>
    Signed-off-by: Corey Minyard <cminyard@mvista.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ipv6: Don't send rs packets to the interface of ARPHRD_TUNNEL [+ + +]
Author: jianghaoran <jianghaoran@kylinos.cn>
Date:   Fri Apr 29 13:38:02 2022 +0800

    ipv6: Don't send rs packets to the interface of ARPHRD_TUNNEL
    
    [ Upstream commit b52e1cce31ca721e937d517411179f9196ee6135 ]
    
    ARPHRD_TUNNEL interface can't process rs packets
    and will generate TX errors
    
    ex:
    ip tunnel add ethn mode ipip local 192.168.1.1 remote 192.168.1.2
    ifconfig ethn x.x.x.x
    
    ethn: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1480
            inet x.x.x.x  netmask 255.255.255.255  destination x.x.x.x
            inet6 fe80::5efe:ac1e:3cdb  prefixlen 64  scopeid 0x20<link>
            tunnel   txqueuelen 1000  (IPIP Tunnel)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 3  dropped 0 overruns 0  carrier 0  collisions 0
    
    Signed-off-by: jianghaoran <jianghaoran@kylinos.cn>
    Link: https://lore.kernel.org/r/20220429053802.246681-1-jianghaoran@kylinos.cn
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

ipv6: fix locking issues with loops over idev->addr_list [+ + +]
Author: Niels Dossche <dossche.niels@gmail.com>
Date:   Mon Apr 4 01:15:24 2022 +0200

    ipv6: fix locking issues with loops over idev->addr_list
    
    [ Upstream commit 51454ea42c1ab4e0c2828bb0d4d53957976980de ]
    
    idev->addr_list needs to be protected by idev->lock. However, it is not
    always possible to do so while iterating and performing actions on
    inet6_ifaddr instances. For example, multiple functions (like
    addrconf_{join,leave}_anycast) eventually call down to other functions
    that acquire the idev->lock. The current code temporarily unlocked the
    idev->lock during the loops, which can cause race conditions. Moving the
    locks up is also not an appropriate solution as the ordering of lock
    acquisition will be inconsistent with for example mc_lock.
    
    This solution adds an additional field to inet6_ifaddr that is used
    to temporarily add the instances to a temporary list while holding
    idev->lock. The temporary list can then be traversed without holding
    idev->lock. This change was done in two places. In addrconf_ifdown, the
    list_for_each_entry_safe variant of the list loop is also no longer
    necessary as there is no deletion within that specific loop.
    
    Suggested-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Link: https://lore.kernel.org/r/20220403231523.45843-1-dossche.niels@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ipw2x00: Fix potential NULL dereference in libipw_xmit() [+ + +]
Author: Haowen Bai <baihaowen@meizu.com>
Date:   Fri Apr 1 15:10:54 2022 +0800

    ipw2x00: Fix potential NULL dereference in libipw_xmit()
    
    [ Upstream commit e8366bbabe1d207cf7c5b11ae50e223ae6fc278b ]
    
    crypt and crypt->ops could be null, so we need to checking null
    before dereference
    
    Signed-off-by: Haowen Bai <baihaowen@meizu.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/1648797055-25730-1-git-send-email-baihaowen@meizu.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
irqchip/armada-370-xp: Do not touch Performance Counter Overflow on A375, A38x, A39x [+ + +]
Author: Pali Rohár <pali@kernel.org>
Date:   Mon Apr 25 13:37:05 2022 +0200

    irqchip/armada-370-xp: Do not touch Performance Counter Overflow on A375, A38x, A39x
    
    commit a3d66a76348daf559873f19afc912a2a7c2ccdaf upstream.
    
    Register ARMADA_370_XP_INT_FABRIC_MASK_OFFS is Armada 370 and XP specific
    and on new Armada platforms it has different meaning. It does not configure
    Performance Counter Overflow interrupt masking. So do not touch this
    register on non-A370/XP platforms (A375, A38x and A39x).
    
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Cc: stable@vger.kernel.org
    Fixes: 28da06dfd9e4 ("irqchip: armada-370-xp: Enable the PMU interrupts")
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20220425113706.29310-1-pali@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
irqchip/aspeed-i2c-ic: Fix irq_of_parse_and_map() return value [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Sat Apr 23 11:42:26 2022 +0200

    irqchip/aspeed-i2c-ic: Fix irq_of_parse_and_map() return value
    
    [ Upstream commit 50f0f26e7c8665763d0d7d3372dbcf191f94d077 ]
    
    The irq_of_parse_and_map() returns 0 on failure, not a negative ERRNO.
    
    Fixes: f48e699ddf70 ("irqchip/aspeed-i2c-ic: Add I2C IRQ controller for Aspeed")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20220423094227.33148-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
irqchip/exiu: Fix acknowledgment of edge triggered interrupts [+ + +]
Author: Daniel Thompson <daniel.thompson@linaro.org>
Date:   Tue May 3 14:45:41 2022 +0100

    irqchip/exiu: Fix acknowledgment of edge triggered interrupts
    
    [ Upstream commit 4efc851c36e389f7ed432edac0149acc5f94b0c7 ]
    
    Currently the EXIU uses the fasteoi interrupt flow that is configured by
    it's parent (irq-gic-v3.c). With this flow the only chance to clear the
    interrupt request happens during .irq_eoi() and (obviously) this happens
    after the interrupt handler has run. EXIU requires edge triggered
    interrupts to be acked prior to interrupt handling. Without this we
    risk incorrect interrupt dismissal when a new interrupt is delivered
    after the handler reads and acknowledges the peripheral but before the
    irq_eoi() takes place.
    
    Fix this by clearing the interrupt request from .irq_ack() if we are
    configured for edge triggered interrupts. This requires adopting the
    fasteoi-ack flow instead of the fasteoi to ensure the ack gets called.
    
    These changes have been tested using the power button on a
    Developerbox/SC2A11 combined with some hackery in gpio-keys so I can
    play with the different trigger mode [and an mdelay(500) so I can
    can check what happens on a double click in both modes].
    
    Fixes: 706cffc1b912 ("irqchip/exiu: Add support for Socionext Synquacer EXIU controller")
    Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
    Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20220503134541.2566457-1-daniel.thompson@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
irqchip: irq-xtensa-mx: fix initial IRQ affinity [+ + +]
Author: Max Filippov <jcmvbkbc@gmail.com>
Date:   Tue Apr 26 09:01:18 2022 -0700

    irqchip: irq-xtensa-mx: fix initial IRQ affinity
    
    commit a255ee29252066d621df5d6b420bf534c6ba5bc0 upstream.
    
    When irq-xtensa-mx chip is used in non-SMP configuration its
    irq_set_affinity callback is not called leaving IRQ affinity set empty.
    As a result IRQ delivery does not work in that configuration.
    Initialize IRQ affinity of the xtensa MX interrupt distributor to CPU 0
    for all external IRQ lines.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
iwlwifi: mvm: fix assert 1F04 upon reconfig [+ + +]
Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Date:   Tue May 17 12:05:09 2022 +0300

    iwlwifi: mvm: fix assert 1F04 upon reconfig
    
    commit 9d096e3d3061dbf4ee10e2b59fc2c06e05bdb997 upstream.
    
    When we reconfig we must not send the MAC_POWER command that relates to
    a MAC that was not yet added to the firmware.
    
    Ignore those in the iterator.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20220517120044.ed2ffc8ce732.If786e19512d0da4334a6382ea6148703422c7d7b@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ixgbe: fix bcast packets Rx on VF after promisc removal [+ + +]
Author: Olivier Matz <olivier.matz@6wind.com>
Date:   Wed Apr 6 11:52:51 2022 +0200

    ixgbe: fix bcast packets Rx on VF after promisc removal
    
    commit 803e9895ea2b0fe80bc85980ae2d7a7e44037914 upstream.
    
    After a VF requested to remove the promiscuous flag on an interface, the
    broadcast packets are not received anymore. This breaks some protocols
    like ARP.
    
    In ixgbe_update_vf_xcast_mode(), we should keep the IXGBE_VMOLR_BAM
    bit (Broadcast Accept) on promiscuous removal.
    
    This flag is already set by default in ixgbe_set_vmolr() on VF reset.
    
    Fixes: 8443c1a4b192 ("ixgbe, ixgbevf: Add new mbox API xcast mode")
    Cc: stable@vger.kernel.org
    Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
    Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ixgbe: fix unexpected VLAN Rx in promisc mode on VF [+ + +]
Author: Olivier Matz <olivier.matz@6wind.com>
Date:   Wed Apr 6 11:52:52 2022 +0200

    ixgbe: fix unexpected VLAN Rx in promisc mode on VF
    
    commit 7bb0fb7c63df95d6027dc50d6af3bc3bbbc25483 upstream.
    
    When the promiscuous mode is enabled on a VF, the IXGBE_VMOLR_VPE
    bit (VLAN Promiscuous Enable) is set. This means that the VF will
    receive packets whose VLAN is not the same than the VLAN of the VF.
    
    For instance, in this situation:
    
    ┌────────┐    ┌────────┐    ┌────────┐
    │        │    │        │    │        │
    │        │    │        │    │        │
    │     VF0├────┤VF1  VF2├────┤VF3     │
    │        │    │        │    │        │
    └────────┘    └────────┘    └────────┘
       VM1           VM2           VM3
    
    vf 0:  vlan 1000
    vf 1:  vlan 1000
    vf 2:  vlan 1001
    vf 3:  vlan 1001
    
    If we tcpdump on VF3, we see all the packets, even those transmitted
    on vlan 1000.
    
    This behavior prevents to bridge VF1 and VF2 in VM2, because it will
    create a loop: packets transmitted on VF1 will be received by VF2 and
    vice-versa, and bridged again through the software bridge.
    
    This patch remove the activation of VLAN Promiscuous when a VF enables
    the promiscuous mode. However, the IXGBE_VMOLR_UPE bit (Unicast
    Promiscuous) is kept, so that a VF receives all packets that has the
    same VLAN, whatever the destination MAC address.
    
    Fixes: 8443c1a4b192 ("ixgbe, ixgbevf: Add new mbox API xcast mode")
    Cc: stable@vger.kernel.org
    Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
    Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
jffs2: fix memory leak in jffs2_do_fill_super [+ + +]
Author: Baokun Li <libaokun1@huawei.com>
Date:   Tue Apr 12 17:38:16 2022 +0800

    jffs2: fix memory leak in jffs2_do_fill_super
    
    [ Upstream commit c14adb1cf70a984ed081c67e9d27bc3caad9537c ]
    
    If jffs2_iget() or d_make_root() in jffs2_do_fill_super() returns
    an error, we can observe the following kmemleak report:
    
    --------------------------------------------
    unreferenced object 0xffff888105a65340 (size 64):
      comm "mount", pid 710, jiffies 4302851558 (age 58.239s)
      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:
        [<ffffffff859c45e5>] kmem_cache_alloc_trace+0x475/0x8a0
        [<ffffffff86160146>] jffs2_sum_init+0x96/0x1a0
        [<ffffffff86140e25>] jffs2_do_mount_fs+0x745/0x2120
        [<ffffffff86149fec>] jffs2_do_fill_super+0x35c/0x810
        [<ffffffff8614aae9>] jffs2_fill_super+0x2b9/0x3b0
        [...]
    unreferenced object 0xffff8881bd7f0000 (size 65536):
      comm "mount", pid 710, jiffies 4302851558 (age 58.239s)
      hex dump (first 32 bytes):
        bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb  ................
        bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb  ................
      backtrace:
        [<ffffffff858579ba>] kmalloc_order+0xda/0x110
        [<ffffffff85857a11>] kmalloc_order_trace+0x21/0x130
        [<ffffffff859c2ed1>] __kmalloc+0x711/0x8a0
        [<ffffffff86160189>] jffs2_sum_init+0xd9/0x1a0
        [<ffffffff86140e25>] jffs2_do_mount_fs+0x745/0x2120
        [<ffffffff86149fec>] jffs2_do_fill_super+0x35c/0x810
        [<ffffffff8614aae9>] jffs2_fill_super+0x2b9/0x3b0
        [...]
    --------------------------------------------
    
    This is because the resources allocated in jffs2_sum_init() are not
    released. Call jffs2_sum_exit() to release these resources to solve
    the problem.
    
    Fixes: e631ddba5887 ("[JFFS2] Add erase block summary support (mount time improvement)")
    Signed-off-by: Baokun Li <libaokun1@huawei.com>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Kconfig: add config option for asm goto w/ outputs [+ + +]
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Fri Feb 14 14:18:11 2020 -0800

    Kconfig: add config option for asm goto w/ outputs
    
    commit 587f17018a2c6c414e41a312b002faaef60cf423 upstream.
    
    This allows C code to make use of compilers with support for output
    variables along the fallthrough path via preprocessor define:
    
      CONFIG_CC_HAS_ASM_GOTO_OUTPUT
    
    [ This is not used anywhere yet, and currently released compilers don't
      support this yet, but it's coming, and I have some local experimental
      patches to take advantage of it when it does   - Linus ]
    
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Wed Feb 2 00:49:41 2022 +0000

    Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug
    
    commit 1aa0e8b144b6474c4914439d232d15bfe883636b upstream.
    
    Add a config option to guard (future) usage of asm_volatile_goto() that
    includes "tied outputs", i.e. "+" constraints that specify both an input
    and output parameter.  clang-13 has a bug[1] that causes compilation of
    such inline asm to fail, and KVM wants to use a "+m" constraint to
    implement a uaccess form of CMPXCHG[2].  E.g. the test code fails with
    
      <stdin>:1:29: error: invalid operand in inline asm: '.long (${1:l}) - .'
      int foo(int *x) { asm goto (".long (%l[bar]) - .\n": "+m"(*x) ::: bar); return *x; bar: return 0; }
                                ^
      <stdin>:1:29: error: unknown token in expression
      <inline asm>:1:9: note: instantiated into assembly here
              .long () - .
                     ^
      2 errors generated.
    
    on clang-13, but passes on gcc (with appropriate asm goto support).  The
    bug is fixed in clang-14, but won't be backported to clang-13 as the
    changes are too invasive/risky.
    
    gcc also had a similar bug[3], fixed in gcc-11, where gcc failed to
    account for its behavior of assigning two numbers to tied outputs (one
    for input, one for output) when evaluating symbolic references.
    
    [1] https://github.com/ClangBuiltLinux/linux/issues/1512
    [2] https://lore.kernel.org/all/YfMruK8%2F1izZ2VHS@google.com
    [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98096
    
    Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20220202004945.2540433-2-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
kernfs: Separate kernfs_pr_cont_buf and rename_lock. [+ + +]
Author: Hao Luo <haoluo@google.com>
Date:   Mon May 16 12:09:51 2022 -0700

    kernfs: Separate kernfs_pr_cont_buf and rename_lock.
    
    [ Upstream commit 1a702dc88e150487c9c173a249b3d236498b9183 ]
    
    Previously the protection of kernfs_pr_cont_buf was piggy backed by
    rename_lock, which means that pr_cont() needs to be protected under
    rename_lock. This can cause potential circular lock dependencies.
    
    If there is an OOM, we have the following call hierarchy:
    
     -> cpuset_print_current_mems_allowed()
       -> pr_cont_cgroup_name()
         -> pr_cont_kernfs_name()
    
    pr_cont_kernfs_name() will grab rename_lock and call printk. So we have
    the following lock dependencies:
    
     kernfs_rename_lock -> console_sem
    
    Sometimes, printk does a wakeup before releasing console_sem, which has
    the dependence chain:
    
     console_sem -> p->pi_lock -> rq->lock
    
    Now, imagine one wants to read cgroup_name under rq->lock, for example,
    printing cgroup_name in a tracepoint in the scheduler code. They will
    be holding rq->lock and take rename_lock:
    
     rq->lock -> kernfs_rename_lock
    
    Now they will deadlock.
    
    A prevention to this circular lock dependency is to separate the
    protection of pr_cont_buf from rename_lock. In principle, rename_lock
    is to protect the integrity of cgroup name when copying to buf. Once
    pr_cont_buf has got its content, rename_lock can be dropped. So it's
    safe to drop rename_lock after kernfs_name_locked (and
    kernfs_path_from_node_locked) and rely on a dedicated pr_cont_lock
    to protect pr_cont_buf.
    
    Acked-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Hao Luo <haoluo@google.com>
    Link: https://lore.kernel.org/r/20220516190951.3144144-1-haoluo@google.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
KVM: nVMX: Leave most VM-Exit info fields unmodified on failed VM-Entry [+ + +]
Author: Sean Christopherson <seanjc@google.com>
Date:   Thu Apr 7 00:23:14 2022 +0000

    KVM: nVMX: Leave most VM-Exit info fields unmodified on failed VM-Entry
    
    [ Upstream commit c3634d25fbee88e2368a8e0903ae0d0670eb9e71 ]
    
    Don't modify vmcs12 exit fields except EXIT_REASON and EXIT_QUALIFICATION
    when performing a nested VM-Exit due to failed VM-Entry.  Per the SDM,
    only the two aformentioned fields are filled and "All other VM-exit
    information fields are unmodified".
    
    Fixes: 4704d0befb07 ("KVM: nVMX: Exiting from L2 to L1")
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20220407002315.78092-3-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Linux: Linux 5.4.198 [+ + +]
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue Jun 14 18:12:03 2022 +0200

    Linux 5.4.198
    
    Link: https://lore.kernel.org/r/20220613094928.482772422@linuxfoundation.org
    Tested-by: Florian Fainelli <f.fainelli@gmail.com>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
lkdtm/usercopy: Expand size of "out of frame" object [+ + +]
Author: Kees Cook <keescook@chromium.org>
Date:   Wed Feb 16 12:15:03 2022 -0800

    lkdtm/usercopy: Expand size of "out of frame" object
    
    [ Upstream commit f387e86d3a74407bdd9c5815820ac9d060962840 ]
    
    To be sufficiently out of range for the usercopy test to see the lifetime
    mismatch, expand the size of the "bad" buffer, which will let it be
    beyond current_stack_pointer regardless of stack growth direction.
    Paired with the recent addition of stack depth checking under
    CONFIG_HARDENED_USERCOPY=y, this will correctly start tripping again.
    
    Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
    Link: https://lore.kernel.org/lkml/762faf1b-0443-5ddf-4430-44a20cf2ec4d@collabora.com/
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
m68k: math-emu: Fix dependencies of math emulation support [+ + +]
Author: Geert Uytterhoeven <geert@linux-m68k.org>
Date:   Fri May 13 14:50:28 2022 +0200

    m68k: math-emu: Fix dependencies of math emulation support
    
    [ Upstream commit ed6bc6bf0a7d75e80eb1df883c09975ebb74e590 ]
    
    If CONFIG_M54xx=y, CONFIG_MMU=y, and CONFIG_M68KFPU_EMU=y:
    
        {standard input}:272: Error: invalid instruction for this architecture; needs 68000 or higher (68000 [68ec000, 68hc000, 68hc001, 68008, 68302, 68306, 68307, 68322, 68356], 68010, 68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060], cpu32 [68330, 68331, 68332, 68333, 68334, 68336, 68340, 68341, 68349, 68360], fidoa [fido]) -- statement `sub.b %d1,%d3' ignored
        {standard input}:609: Error: invalid instruction for this architecture; needs 68020 or higher (68020 [68k, 68ec020], 68030 [68ec030], 68040 [68ec040], 68060 [68ec060]) -- statement `bfextu 4(%a1){%d0,#8},%d0' ignored
        {standard input}:752: Error: operands mismatch -- statement `mulu.l 4(%a0),%d3:%d0' ignored
        {standard input}:1155: Error: operands mismatch -- statement `divu.l %d0,%d3:%d7' ignored
    
    The math emulation support code is intended for 68020 and higher, and
    uses several instructions or instruction modes not available on coldfire
    or 68000.
    
    Originally, the dependency of M68KFPU_EMU on MMU was fine, as MMU
    support was only available on 68020 or higher.  But this assumption
    was broken by the introduction of MMU support for M547x and M548x.
    
    Drop the dependency on MMU, as the code should work fine on 68020 and up
    without MMU (which are not yet supported by Linux, though).
    Add dependencies on M68KCLASSIC (to rule out Coldfire) and FPU (kernel
    has some type of floating-point support --- be it hardware or software
    emulated, to rule out anything below 68020).
    
    Fixes: 1f7034b9616e6f14 ("m68k: allow ColdFire 547x and 548x CPUs to be built with MMU enabled")
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Reviewed-by: Greg Ungerer <gerg@linux-m68k.org>
    Link: https://lore.kernel.org/r/18c34695b7c95107f60ccca82a4ff252f3edf477.1652446117.git.geert@linux-m68k.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
m68knommu: fix undefined reference to `_init_sp' [+ + +]
Author: Greg Ungerer <gerg@linux-m68k.org>
Date:   Fri May 13 17:27:39 2022 +1000

    m68knommu: fix undefined reference to `_init_sp'
    
    [ Upstream commit a71b9e66fee47c59b3ec34e652b5c23bc6550794 ]
    
    When configuring a nommu classic m68k system enabling the uboot parameter
    passing support (CONFIG_UBOOT) will produce the following compile error:
    
       m68k-linux-ld: arch/m68k/kernel/uboot.o: in function `process_uboot_commandline':
       uboot.c:(.init.text+0x32): undefined reference to `_init_sp'
    
    The logic to support this option is only used on ColdFire based platforms
    (in its head.S startup code). So make the selection of this option
    depend on building for a ColdFire based platform.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

m68knommu: set ZERO_PAGE() to the allocated zeroed page [+ + +]
Author: Greg Ungerer <gerg@linux-m68k.org>
Date:   Wed Apr 20 23:27:47 2022 +1000

    m68knommu: set ZERO_PAGE() to the allocated zeroed page
    
    [ Upstream commit dc068f46217970d9516f16cd37972a01d50dc055 ]
    
    The non-MMU m68k pagetable ZERO_PAGE() macro is being set to the
    somewhat non-sensical value of "virt_to_page(0)". The zeroth page
    is not in any way guaranteed to be a page full of "0". So the result
    is that ZERO_PAGE() will almost certainly contain random values.
    
    We already allocate a real "empty_zero_page" in the mm setup code shared
    between MMU m68k and non-MMU m68k. It is just not hooked up to the
    ZERO_PAGE() macro for the non-MMU m68k case.
    
    Fix ZERO_PAGE() to use the allocated "empty_zero_page" pointer.
    
    I am not aware of any specific issues caused by the old code.
    
    Link: https://lore.kernel.org/linux-m68k/2a462b23-5b8e-bbf4-ec7d-778434a3b9d7@google.com/T/#t
    Reported-by: Hugh Dickens <hughd@google.com>
    Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mac80211: upgrade passive scan to active scan on DFS channels after beacon rx [+ + +]
Author: Felix Fietkau <nbd@nbd.name>
Date:   Wed Apr 20 12:49:07 2022 +0200

    mac80211: upgrade passive scan to active scan on DFS channels after beacon rx
    
    commit b041b7b9de6e1d4362de855ab90f9d03ef323edd upstream.
    
    In client mode, we can't connect to hidden SSID APs or SSIDs not advertised
    in beacons on DFS channels, since we're forced to passive scan. Fix this by
    sending out a probe request immediately after the first beacon, if active
    scan was requested by the user.
    
    Cc: stable@vger.kernel.org
    Reported-by: Catrinel Catrinescu <cc@80211.de>
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/20220420104907.36275-1-nbd@nbd.name
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
macintosh/via-pmu: Fix build failure when CONFIG_INPUT is disabled [+ + +]
Author: Finn Thain <fthain@linux-m68k.org>
Date:   Thu Apr 7 20:11:32 2022 +1000

    macintosh/via-pmu: Fix build failure when CONFIG_INPUT is disabled
    
    [ Upstream commit 86ce436e30d86327c9f5260f718104ae7b21f506 ]
    
    drivers/macintosh/via-pmu-event.o: In function `via_pmu_event':
    via-pmu-event.c:(.text+0x44): undefined reference to `input_event'
    via-pmu-event.c:(.text+0x68): undefined reference to `input_event'
    via-pmu-event.c:(.text+0x94): undefined reference to `input_event'
    via-pmu-event.c:(.text+0xb8): undefined reference to `input_event'
    drivers/macintosh/via-pmu-event.o: In function `via_pmu_event_init':
    via-pmu-event.c:(.init.text+0x20): undefined reference to `input_allocate_device'
    via-pmu-event.c:(.init.text+0xc4): undefined reference to `input_register_device'
    via-pmu-event.c:(.init.text+0xd4): undefined reference to `input_free_device'
    make[1]: *** [Makefile:1155: vmlinux] Error 1
    make: *** [Makefile:350: __build_one_by_one] Error 2
    
    Don't call into the input subsystem unless CONFIG_INPUT is built-in.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Finn Thain <fthain@linux-m68k.org>
    Tested-by: Randy Dunlap <rdunlap@infradead.org>
    Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Acked-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/5edbe76ce68227f71e09af4614cc4c1bd61c7ec8.1649326292.git.fthain@linux-m68k.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
macintosh: via-pmu and via-cuda need RTC_LIB [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Sun Apr 10 09:10:35 2022 -0700

    macintosh: via-pmu and via-cuda need RTC_LIB
    
    [ Upstream commit 9a9c5ff5fff87eb1a43db0d899473554e408fd7b ]
    
    Fix build when RTC_LIB is not set/enabled.
    Eliminates these build errors:
    
    m68k-linux-ld: drivers/macintosh/via-pmu.o: in function `pmu_set_rtc_time':
    drivers/macintosh/via-pmu.c:1769: undefined reference to `rtc_tm_to_time64'
    m68k-linux-ld: drivers/macintosh/via-cuda.o: in function `cuda_set_rtc_time':
    drivers/macintosh/via-cuda.c:797: undefined reference to `rtc_tm_to_time64'
    
    Fixes: 0792a2c8e0bb ("macintosh: Use common code to access RTC")
    Reported-by: kernel test robot <lkp@intel.com>
    Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220410161035.592-1-rdunlap@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mailbox: forward the hrtimer if not queued and under a lock [+ + +]
Author: Björn Ardö <bjorn.ardo@axis.com>
Date:   Thu Mar 31 09:01:15 2022 +0200

    mailbox: forward the hrtimer if not queued and under a lock
    
    [ Upstream commit bca1a1004615efe141fd78f360ecc48c60bc4ad5 ]
    
    This reverts commit c7dacf5b0f32957b24ef29df1207dc2cd8307743,
    "mailbox: avoid timer start from callback"
    
    The previous commit was reverted since it lead to a race that
    caused the hrtimer to not be started at all. The check for
    hrtimer_active() in msg_submit() will return true if the
    callback function txdone_hrtimer() is currently running. This
    function could return HRTIMER_NORESTART and then the timer
    will not be restarted, and also msg_submit() will not start
    the timer. This will lead to a message actually being submitted
    but no timer will start to check for its compleation.
    
    The original fix that added checking hrtimer_active() was added to
    avoid a warning with hrtimer_forward. Looking in the kernel
    another solution to avoid this warning is to check hrtimer_is_queued()
    before calling hrtimer_forward_now() instead. This however requires a
    lock so the timer is not started by msg_submit() inbetween this check
    and the hrtimer_forward() call.
    
    Fixes: c7dacf5b0f32 ("mailbox: avoid timer start from callback")
    Signed-off-by: Björn Ardö <bjorn.ardo@axis.com>
    Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
md/bitmap: don't set sb values if can't pass sanity check [+ + +]
Author: Heming Zhao <heming.zhao@suse.com>
Date:   Fri Apr 1 10:13:16 2022 +0800

    md/bitmap: don't set sb values if can't pass sanity check
    
    [ Upstream commit e68cb83a57a458b01c9739e2ad9cb70b04d1e6d2 ]
    
    If bitmap area contains invalid data, kernel will crash then mdadm
    triggers "Segmentation fault".
    This is cluster-md speical bug. In non-clustered env, mdadm will
    handle broken metadata case. In clustered array, only kernel space
    handles bitmap slot info. But even this bug only happened in clustered
    env, current sanity check is wrong, the code should be changed.
    
    How to trigger: (faulty injection)
    
    dd if=/dev/zero bs=1M count=1 oflag=direct of=/dev/sda
    dd if=/dev/zero bs=1M count=1 oflag=direct of=/dev/sdb
    mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sda /dev/sdb
    mdadm -Ss
    echo aaa > magic.txt
     == below modifying slot 2 bitmap data ==
    dd if=magic.txt of=/dev/sda seek=16384 bs=1 count=3 <== destroy magic
    dd if=/dev/zero of=/dev/sda seek=16436 bs=1 count=4 <== ZERO chunksize
    mdadm -A /dev/md0 /dev/sda /dev/sdb
     == kernel crashes. mdadm outputs "Segmentation fault" ==
    
    Reason of kernel crash:
    
    In md_bitmap_read_sb (called by md_bitmap_create), bad bitmap magic didn't
    block chunksize assignment, and zero value made DIV_ROUND_UP_SECTOR_T()
    trigger "divide error".
    
    Crash log:
    
    kernel: md: md0 stopped.
    kernel: md/raid1:md0: not clean -- starting background reconstruction
    kernel: md/raid1:md0: active with 2 out of 2 mirrors
    kernel: dlm: ... ...
    kernel: md-cluster: Joined cluster 44810aba-38bb-e6b8-daca-bc97a0b254aa slot 1
    kernel: md0: invalid bitmap file superblock: bad magic
    kernel: md_bitmap_copy_from_slot can't get bitmap from slot 2
    kernel: md-cluster: Could not gather bitmaps from slot 2
    kernel: divide error: 0000 [#1] SMP NOPTI
    kernel: CPU: 0 PID: 1603 Comm: mdadm Not tainted 5.14.6-1-default
    kernel: Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
    kernel: RIP: 0010:md_bitmap_create+0x1d1/0x850 [md_mod]
    kernel: RSP: 0018:ffffc22ac0843ba0 EFLAGS: 00010246
    kernel: ... ...
    kernel: Call Trace:
    kernel:  ? dlm_lock_sync+0xd0/0xd0 [md_cluster 77fe..7a0]
    kernel:  md_bitmap_copy_from_slot+0x2c/0x290 [md_mod 24ea..d3a]
    kernel:  load_bitmaps+0xec/0x210 [md_cluster 77fe..7a0]
    kernel:  md_bitmap_load+0x81/0x1e0 [md_mod 24ea..d3a]
    kernel:  do_md_run+0x30/0x100 [md_mod 24ea..d3a]
    kernel:  md_ioctl+0x1290/0x15a0 [md_mod 24ea....d3a]
    kernel:  ? mddev_unlock+0xaa/0x130 [md_mod 24ea..d3a]
    kernel:  ? blkdev_ioctl+0xb1/0x2b0
    kernel:  block_ioctl+0x3b/0x40
    kernel:  __x64_sys_ioctl+0x7f/0xb0
    kernel:  do_syscall_64+0x59/0x80
    kernel:  ? exit_to_user_mode_prepare+0x1ab/0x230
    kernel:  ? syscall_exit_to_user_mode+0x18/0x40
    kernel:  ? do_syscall_64+0x69/0x80
    kernel:  entry_SYSCALL_64_after_hwframe+0x44/0xae
    kernel: RIP: 0033:0x7f4a15fa722b
    kernel: ... ...
    kernel: ---[ end trace 8afa7612f559c868 ]---
    kernel: RIP: 0010:md_bitmap_create+0x1d1/0x850 [md_mod]
    
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>
    Signed-off-by: Heming Zhao <heming.zhao@suse.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
md/raid0: Ignore RAID0 layout if the second zone has only one device [+ + +]
Author: Pascal Hambourg <pascal@plouf.fr.eu.org>
Date:   Wed Apr 13 08:53:56 2022 +0200

    md/raid0: Ignore RAID0 layout if the second zone has only one device
    
    commit ea23994edc4169bd90d7a9b5908c6ccefd82fa40 upstream.
    
    The RAID0 layout is irrelevant if all members have the same size so the
    array has only one zone. It is *also* irrelevant if the array has two
    zones and the second zone has only one device, for example if the array
    has two members of different sizes.
    
    So in that case it makes sense to allow assembly even when the layout is
    undefined, like what is done when the array has only one zone.
    
    Reviewed-by: NeilBrown <neilb@suse.de>
    Signed-off-by: Pascal Hambourg <pascal@plouf.fr.eu.org>
    Signed-off-by: Song Liu <song@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
md: bcache: check the return value of kzalloc() in detached_dev_do_request() [+ + +]
Author: Jia-Ju Bai <baijiaju1990@gmail.com>
Date:   Fri May 27 23:28:18 2022 +0800

    md: bcache: check the return value of kzalloc() in detached_dev_do_request()
    
    commit 40f567bbb3b0639d2ec7d1c6ad4b1b018f80cf19 upstream.
    
    The function kzalloc() in detached_dev_do_request() can fail, so its
    return value should be checked.
    
    Fixes: bc082a55d25c ("bcache: fix inaccurate io state for detached bcache devices")
    Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
    Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
    Signed-off-by: Coly Li <colyli@suse.de>
    Link: https://lore.kernel.org/r/20220527152818.27545-4-colyli@suse.de
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

md: fix an incorrect NULL check in does_sb_need_changing [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Fri Apr 8 16:37:28 2022 +0800

    md: fix an incorrect NULL check in does_sb_need_changing
    
    commit fc8738343eefc4ea8afb6122826dea48eacde514 upstream.
    
    The bug is here:
            if (!rdev)
    
    The list iterator value 'rdev' will *always* be set and non-NULL
    by rdev_for_each(), so it is incorrect to assume that the iterator
    value will be NULL if the list is empty or no element found.
    Otherwise it will bypass the NULL check and lead to invalid memory
    access passing the check.
    
    To fix the bug, use a new variable 'iter' as the list iterator,
    while using the original variable 'rdev' as a dedicated pointer to
    point to the found element.
    
    Cc: stable@vger.kernel.org
    Fixes: 2aa82191ac36 ("md-cluster: Perform a lazy update")
    Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Acked-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

md: fix an incorrect NULL check in md_reload_sb [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Fri Apr 8 16:47:15 2022 +0800

    md: fix an incorrect NULL check in md_reload_sb
    
    commit 64c54d9244a4efe9bc6e9c98e13c4bbb8bb39083 upstream.
    
    The bug is here:
            if (!rdev || rdev->desc_nr != nr) {
    
    The list iterator value 'rdev' will *always* be set and non-NULL
    by rdev_for_each_rcu(), so it is incorrect to assume that the
    iterator value will be NULL if the list is empty or no element
    found (In fact, it will be a bogus pointer to an invalid struct
    object containing the HEAD). Otherwise it will bypass the check
    and lead to invalid memory access passing the check.
    
    To fix the bug, use a new variable 'iter' as the list iterator,
    while using the original variable 'pdev' as a dedicated pointer to
    point to the found element.
    
    Cc: stable@vger.kernel.org
    Fixes: 70bcecdb1534 ("md-cluster: Improve md_reload_sb to be less error prone")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

md: protect md_unregister_thread from reentrancy [+ + +]
Author: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Date:   Fri Apr 29 16:49:09 2022 +0800

    md: protect md_unregister_thread from reentrancy
    
    [ Upstream commit 1e267742283a4b5a8ca65755c44166be27e9aa0f ]
    
    Generally, the md_unregister_thread is called with reconfig_mutex, but
    raid_message in dm-raid doesn't hold reconfig_mutex to unregister thread,
    so md_unregister_thread can be called simulitaneously from two call sites
    in theory.
    
    Then after previous commit which remove the protection of reconfig_mutex
    for md_unregister_thread completely, the potential issue could be worse
    than before.
    
    Let's take pers_lock at the beginning of function to ensure reentrancy.
    
    Reported-by: Donald Buczek <buczek@molgen.mpg.de>
    Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
    Signed-off-by: Song Liu <song@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
media: aspeed: Fix an error handling path in aspeed_video_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sun Mar 6 19:08:07 2022 +0100

    media: aspeed: Fix an error handling path in aspeed_video_probe()
    
    [ Upstream commit 310fda622bbd38be17fb444f7f049b137af3bc0d ]
    
    A dma_free_coherent() call is missing in the error handling path of the
    probe, as already done in the remove function.
    
    In fact, this call is included in aspeed_video_free_buf(). So use the
    latter both in the error handling path of the probe and in the remove
    function.
    It is easier to see the relation with aspeed_video_alloc_buf() this way.
    
    Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    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: cec-adap.c: fix is_configuring state [+ + +]
Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:   Fri May 6 09:43:25 2022 +0200

    media: cec-adap.c: fix is_configuring state
    
    [ Upstream commit 59267fc34f4900dcd2ec3295f6be04b79aee2186 ]
    
    If an adapter is trying to claim a free logical address then it is
    in the 'is_configuring' state. If during that process the cable is
    disconnected (HPD goes low, which in turn invalidates the physical
    address), then cec_adap_unconfigure() is called, and that set the
    is_configuring boolean to false, even though the thread that's
    trying to claim an LA is still running.
    
    Don't touch the is_configuring bool in cec_adap_unconfigure(), it
    will eventually be cleared by the thread. By making that change
    the cec_config_log_addr() function also had to change: it was
    aborting if is_configuring became false (since that is what
    cec_adap_unconfigure() did), but that no longer works. Instead
    check if the physical address is invalid. That is a much
    more appropriate check anyway.
    
    This fixes a bug where the the adapter could be disabled even
    though the device was still configuring. This could cause POLL
    transmits to time out.
    
    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: coda: Add more H264 levels for CODA960 [+ + +]
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Wed Apr 6 21:23:43 2022 +0100

    media: coda: Add more H264 levels for CODA960
    
    commit eb2fd187abc878a2dfad46902becb74963473c7d upstream.
    
    Add H264 level 1.0, 4.1, 4.2 to the list of supported formats.
    While the hardware does not fully support these levels, it does support
    most of them. The constraints on frame size and pixel formats already
    cover the limitation.
    
    This fixes negotiation of level on GStreamer 1.17.1.
    
    Cc: stable@vger.kernel.org
    Fixes: 42a68012e67c2 ("media: coda: add read-only h.264 decoder profile/level controls")
    Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
    Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
    Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
    Signed-off-by: Fabio Estevam <festevam@denx.de>
    Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

media: coda: Fix reported H264 profile [+ + +]
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Wed Apr 6 21:23:42 2022 +0100

    media: coda: Fix reported H264 profile
    
    commit 7110c08ea71953a7fc342f0b76046f72442cf26c upstream.
    
    The CODA960 manual states that ASO/FMO features of baseline are not
    supported, so for this reason this driver should only report
    constrained baseline support.
    
    This fixes negotiation issue with constrained baseline content
    on GStreamer 1.17.1.
    
    ASO/FMO features are unsupported for the encoder and untested for the
    decoder because there is currently no userspace support. Neither GStreamer
    parsers nor FFMPEG parsers support ASO/FMO.
    
    Cc: stable@vger.kernel.org
    Fixes: 42a68012e67c2 ("media: coda: add read-only h.264 decoder profile/level controls")
    Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
    Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
    Tested-by: Pascal Speck <kernel@iktek.de>
    Signed-off-by: Fabio Estevam <festevam@denx.de>
    Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

media: coda: limit frame interval enumeration to supported encoder frame sizes [+ + +]
Author: Philipp Zabel <p.zabel@pengutronix.de>
Date:   Tue Apr 26 11:15:55 2022 +0200

    media: coda: limit frame interval enumeration to supported encoder frame sizes
    
    [ Upstream commit 67e33dd957880879e785cfea83a3aa24bd5c5577 ]
    
    Let VIDIOC_ENUM_FRAMEINTERVALS return -EINVAL if userspace queries
    frame intervals for frame sizes unsupported by the encoder. Fixes the
    following v4l2-compliance failure:
    
                    fail: v4l2-test-formats.cpp(123): found frame intervals for invalid size 47x16
                    fail: v4l2-test-formats.cpp(282): node->codec_mask & STATEFUL_ENCODER
            test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL
    
    [hverkuil: drop incorrect 'For decoder devices, return -ENOTTY.' in the commit log]
    
    Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
    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: cx25821: Fix the warning when removing the module [+ + +]
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Sun Apr 10 08:44:09 2022 +0100

    media: cx25821: Fix the warning when removing the module
    
    [ Upstream commit 2203436a4d24302871617373a7eb21bc17e38762 ]
    
    When removing the module, we will get the following warning:
    
    [   14.746697] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'cx25821[1]'
    [   14.747449] WARNING: CPU: 4 PID: 368 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
    [   14.751611] RIP: 0010:remove_proc_entry+0x389/0x3f0
    [   14.759589] Call Trace:
    [   14.759792]  <TASK>
    [   14.759975]  unregister_irq_proc+0x14c/0x170
    [   14.760340]  irq_free_descs+0x94/0xe0
    [   14.760640]  mp_unmap_irq+0xb6/0x100
    [   14.760937]  acpi_unregister_gsi_ioapic+0x27/0x40
    [   14.761334]  acpi_pci_irq_disable+0x1d3/0x320
    [   14.761688]  pci_disable_device+0x1ad/0x380
    [   14.762027]  ? _raw_spin_unlock_irqrestore+0x2d/0x60
    [   14.762442]  ? cx25821_shutdown+0x20/0x9f0 [cx25821]
    [   14.762848]  cx25821_finidev+0x48/0xc0 [cx25821]
    [   14.763242]  pci_device_remove+0x92/0x240
    
    Fix this by freeing the irq before call pci_disable_device().
    
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.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: exynos4-is: Change clk_disable to clk_disable_unprepare [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Fri Mar 18 12:01:01 2022 +0100

    media: exynos4-is: Change clk_disable to clk_disable_unprepare
    
    [ Upstream commit 9fadab72a6916c7507d7fedcd644859eef995078 ]
    
    The corresponding API for clk_prepare_enable is clk_disable_unprepare,
    other than clk_disable.
    
    Fix this by changing clk_disable to clk_disable_unprepare.
    
    Fixes: b4155d7d5b2c ("[media] exynos4-is: Ensure fimc-is clocks are not enabled until properly configured")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.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: exynos4-is: Fix compile warning [+ + +]
Author: Kwanghoon Son <k.son@samsung.com>
Date:   Wed Apr 27 03:16:45 2022 +0200

    media: exynos4-is: Fix compile warning
    
    [ Upstream commit e080f5c1f2b6d02c02ee5d674e0e392ccf63bbaf ]
    
    Declare static on function 'fimc_isp_video_device_unregister'.
    
    When VIDEO_EXYNOS4_ISP_DMA_CAPTURE=n, compiler warns about
    warning: no previous prototype for function [-Wmissing-prototypes]
    
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Kwanghoon Son <k.son@samsung.com>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: ov7670: remove ov7670_power_off from ov7670_remove [+ + +]
Author: Dongliang Mu <mudongliangabcd@gmail.com>
Date:   Fri Apr 22 10:54:05 2022 +0200

    media: ov7670: remove ov7670_power_off from ov7670_remove
    
    [ Upstream commit 5bf19572e31375368f19edd2dbb2e0789518bb99 ]
    
    In ov7670_probe, it always invokes ov7670_power_off() no matter
    the execution is successful or failed. So we cannot invoke it
    agiain in ov7670_remove().
    
    Fix this by removing ov7670_power_off from ov7670_remove.
    
    Fixes: 030f9f682e66 ("media: ov7670: control clock along with power")
    Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: pci: cx23885: Fix the error handling in cx23885_initdev() [+ + +]
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Sun Apr 10 08:34:41 2022 +0100

    media: pci: cx23885: Fix the error handling in cx23885_initdev()
    
    [ Upstream commit e8123311cf06d7dae71e8c5fe78e0510d20cd30b ]
    
    When the driver fails to call the dma_set_mask(), the driver will get
    the following splat:
    
    [   55.853884] BUG: KASAN: use-after-free in __process_removed_driver+0x3c/0x240
    [   55.854486] Read of size 8 at addr ffff88810de60408 by task modprobe/590
    [   55.856822] Call Trace:
    [   55.860327]  __process_removed_driver+0x3c/0x240
    [   55.861347]  bus_for_each_dev+0x102/0x160
    [   55.861681]  i2c_del_driver+0x2f/0x50
    
    This is because the driver has initialized the i2c related resources
    in cx23885_dev_setup() but not released them in error handling, fix this
    bug by modifying the error path that jumps after failing to call the
    dma_set_mask().
    
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.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: pvrusb2: fix array-index-out-of-bounds in pvr2_i2c_core_init [+ + +]
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Fri Apr 15 23:24:48 2022 +0200

    media: pvrusb2: fix array-index-out-of-bounds in pvr2_i2c_core_init
    
    [ Upstream commit 471bec68457aaf981add77b4f590d65dd7da1059 ]
    
    Syzbot reported that -1 is used as array index. The problem was in
    missing validation check.
    
    hdw->unit_number is initialized with -1 and then if init table walk fails
    this value remains unchanged. Since code blindly uses this member for
    array indexing adding sanity check is the easiest fix for that.
    
    hdw->workpoll initialization moved upper to prevent warning in
    __flush_work.
    
    Reported-and-tested-by: syzbot+1a247e36149ffd709a9b@syzkaller.appspotmail.com
    
    Fixes: d855497edbfb ("V4L/DVB (4228a): pvrusb2 to kernel 2.6.18")
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.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: st-delta: Fix PM disable depth imbalance in delta_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon Mar 7 09:08:59 2022 +0100

    media: st-delta: Fix PM disable depth imbalance in delta_probe
    
    [ Upstream commit 94e3dba710fe0afc772172305444250023fc2d30 ]
    
    The pm_runtime_enable will decrease power disable depth.
    If the probe fails, we should use pm_runtime_disable() to balance
    pm_runtime_enable().
    
    Fixes: f386509e4959 ("[media] st-delta: STiH4xx multi-format video decoder v4l2 driver")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Acked-by: Hugues Fruchet <hugues.fruchet@foss.st.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: uvcvideo: Fix missing check to determine if element is found in list [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Sat Mar 19 11:22:22 2022 +0100

    media: uvcvideo: Fix missing check to determine if element is found in list
    
    [ Upstream commit 261f33388c29f6f3c12a724e6d89172b7f6d5996 ]
    
    The list iterator will point to a bogus position containing HEAD if
    the list is empty or the element is not found in list. This case
    should be checked before any use of the iterator, otherwise it will
    lead to a invalid memory access. The missing check here is before
    "pin = iterm->id;", just add check here to fix the security bug.
    
    In addition, the list iterator value will *always* be set and non-NULL
    by list_for_each_entry(), so it is incorrect to assume that the iterator
    value will be NULL if the element is not found in list, considering
    the (mis)use here: "if (iterm == NULL".
    
    Use a new value 'it' as the list iterator, while use the old value
    'iterm' as a dedicated pointer to point to the found element, which
    1. can fix this bug, due to 'iterm' is NULL only if it's not found.
    2. do not need to change all the uses of 'iterm' after the loop.
    3. can also limit the scope of the list iterator 'it' *only inside*
       the traversal loop by simply declaring 'it' inside the loop in the
       future, as usage of the iterator outside of the list_for_each_entry
       is considered harmful. https://lkml.org/lkml/2022/2/17/1032
    
    Fixes: d5e90b7a6cd1c ("[media] uvcvideo: Move to video_ioctl2")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: venus: hfi: avoid null dereference in deinit [+ + +]
Author: Luca Weiss <luca.weiss@fairphone.com>
Date:   Fri Jan 14 11:02:26 2022 +0000

    media: venus: hfi: avoid null dereference in deinit
    
    [ Upstream commit 86594f6af867b5165d2ba7b5a71fae3a5961e56c ]
    
    If venus_probe fails at pm_runtime_put_sync the error handling first
    calls hfi_destroy and afterwards hfi_core_deinit. As hfi_destroy sets
    core->ops to NULL, hfi_core_deinit cannot call the core_deinit function
    anymore.
    
    Avoid this null pointer derefence by skipping the call when necessary.
    
    Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
    Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

media: vsp1: Fix offset calculation for plane cropping [+ + +]
Author: Michael Rodin <mrodin@de.adit-jv.com>
Date:   Tue Nov 23 12:50:36 2021 +0100

    media: vsp1: Fix offset calculation for plane cropping
    
    [ Upstream commit 5f25abec8f21b7527c1223a354d23c270befddb3 ]
    
    The vertical subsampling factor is currently not considered in the
    offset calculation for plane cropping done in rpf_configure_partition.
    This causes a distortion (shift of the color plane) when formats with
    the vsub factor larger than 1 are used (e.g. NV12, see
    vsp1_video_formats in vsp1_pipe.c). This commit considers vsub factor
    for all planes except plane 0 (luminance).
    
    Drop generalization of the offset calculation to reduce the binary size.
    
    Fixes: e5ad37b64de9 ("[media] v4l: vsp1: Add cropping support")
    Signed-off-by: Michael Rodin <mrodin@de.adit-jv.com>
    Signed-off-by: LUU HOAI <hoai.luu.ub@renesas.com>
    Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
    Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mfd: davinci_voicecodec: Fix possible null-ptr-deref davinci_vc_probe() [+ + +]
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Tue Apr 26 11:08:57 2022 +0800

    mfd: davinci_voicecodec: Fix possible null-ptr-deref davinci_vc_probe()
    
    [ Upstream commit 311242c7703df0da14c206260b7e855f69cb0264 ]
    
    It will cause null-ptr-deref when using 'res', if platform_get_resource()
    returns NULL, so move using 'res' after devm_ioremap_resource() that
    will check it to avoid null-ptr-deref.
    And use devm_platform_get_and_ioremap_resource() to simplify code.
    
    Fixes: b5e29aa880be ("mfd: davinci_voicecodec: Remove pointless #include")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Link: https://lore.kernel.org/r/20220426030857.3539336-1-yangyingliang@huawei.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

mfd: ipaq-micro: Fix error check return value of platform_get_irq() [+ + +]
Author: Lv Ruyi <lv.ruyi@zte.com.cn>
Date:   Tue Apr 12 08:53:05 2022 +0000

    mfd: ipaq-micro: Fix error check return value of platform_get_irq()
    
    [ Upstream commit 3b49ae380ce1a3054e0c505dd9a356b82a5b48e8 ]
    
    platform_get_irq() return negative value on failure, so null check of
    irq is incorrect. Fix it by comparing whether it is less than zero.
    
    Fixes: dcc21cc09e3c ("mfd: Add driver for Atmel Microcontroller on iPaq h3xxx")
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Link: https://lore.kernel.org/r/20220412085305.2533030-1-lv.ruyi@zte.com.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mips: cpc: Fix refcount leak in mips_cpc_default_phys_base [+ + +]
Author: Gong Yuanjun <ruc_gongyuanjun@163.com>
Date:   Thu Apr 7 12:26:57 2022 +0800

    mips: cpc: Fix refcount leak in mips_cpc_default_phys_base
    
    [ Upstream commit 4107fa700f314592850e2c64608f6ede4c077476 ]
    
    Add the missing of_node_put() to release the refcount incremented
    by of_find_compatible_node().
    
    Signed-off-by: Gong Yuanjun <ruc_gongyuanjun@163.com>
    Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
MIPS: IP27: Remove incorrect `cpu_has_fpu' override [+ + +]
Author: Maciej W. Rozycki <macro@orcam.me.uk>
Date:   Sun May 1 23:14:16 2022 +0100

    MIPS: IP27: Remove incorrect `cpu_has_fpu' override
    
    commit 424c3781dd1cb401857585331eaaa425a13f2429 upstream.
    
    Remove unsupported forcing of `cpu_has_fpu' to 1, which makes the `nofpu'
    kernel parameter non-functional, and also causes a link error:
    
    ld: arch/mips/kernel/traps.o: in function `trap_init':
    ./arch/mips/include/asm/msa.h:(.init.text+0x348): undefined reference to `handle_fpe'
    ld: ./arch/mips/include/asm/msa.h:(.init.text+0x354): undefined reference to `handle_fpe'
    ld: ./arch/mips/include/asm/msa.h:(.init.text+0x360): undefined reference to `handle_fpe'
    
    where the CONFIG_MIPS_FP_SUPPORT configuration option has been disabled.
    
    Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
    Reported-by: Stephen Zhang <starzhangzsd@gmail.com>
    Fixes: 0ebb2f4159af ("MIPS: IP27: Update/restructure CPU overrides")
    Cc: stable@vger.kernel.org # v4.2+
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
misc: ocxl: fix possible double free in ocxl_file_register_afu [+ + +]
Author: Hangyu Hua <hbh25y@gmail.com>
Date:   Mon Apr 18 16:57:58 2022 +0800

    misc: ocxl: fix possible double free in ocxl_file_register_afu
    
    [ Upstream commit 950cf957fe34d40d63dfa3bf3968210430b6491e ]
    
    info_release() will be called in device_unregister() when info->dev's
    reference count is 0. So there is no need to call ocxl_afu_put() and
    kfree() again.
    
    Fix this by adding free_minor() and return to err_unregister error path.
    
    Fixes: 75ca758adbaf ("ocxl: Create a clear delineation between ocxl backend & frontend")
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220418085758.38145-1-hbh25y@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

misc: rtsx: set NULL intfdata when probe fails [+ + +]
Author: Shuah Khan <skhan@linuxfoundation.org>
Date:   Fri Apr 29 15:09:13 2022 -0600

    misc: rtsx: set NULL intfdata when probe fails
    
    [ Upstream commit f861d36e021e1ac4a0a2a1f6411d623809975d63 ]
    
    rtsx_usb_probe() doesn't call usb_set_intfdata() to null out the
    interface pointer when probe fails. This leaves a stale pointer.
    Noticed the missing usb_set_intfdata() while debugging an unrelated
    invalid DMA mapping problem.
    
    Fix it with a call to usb_set_intfdata(..., NULL).
    
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
    Link: https://lore.kernel.org/r/20220429210913.46804-1-skhan@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mlxsw: spectrum_dcb: Do not warn about priority changes [+ + +]
Author: Petr Machata <petrm@nvidia.com>
Date:   Wed May 4 09:29:05 2022 +0300

    mlxsw: spectrum_dcb: Do not warn about priority changes
    
    [ Upstream commit b6b584562cbe7dc357083459d6dd5b171e12cadb ]
    
    The idea behind the warnings is that the user would get warned in case when
    more than one priority is configured for a given DSCP value on a netdevice.
    
    The warning is currently wrong, because dcb_ieee_getapp_mask() returns
    the first matching entry, not all of them, and the warning will then claim
    that some priority is "current", when in fact it is not.
    
    But more importantly, the warning is misleading in general. Consider the
    following commands:
    
     # dcb app flush dev swp19 dscp-prio
     # dcb app add dev swp19 dscp-prio 24:3
     # dcb app replace dev swp19 dscp-prio 24:2
    
    The last command will issue the following warning:
    
     mlxsw_spectrum3 0000:07:00.0 swp19: Ignoring new priority 2 for DSCP 24 in favor of current value of 3
    
    The reason is that the "replace" command works by first adding the new
    value, and then removing all old values. This is the only way to make the
    replacement without causing the traffic to be prioritized to whatever the
    chip defaults to. The warning is issued in response to adding the new
    priority, and then no warning is shown when the old priority is removed.
    The upshot is that the canonical way to change traffic prioritization
    always produces a warning about ignoring the new priority, but what gets
    configured is in fact what the user intended.
    
    An option to just emit warning every time that the prioritization changes
    just to make it clear that it happened is obviously unsatisfactory.
    
    Therefore, in this patch, remove the warnings.
    
    Reported-by: Maksym Yaremchuk <maksymy@nvidia.com>
    Signed-off-by: Petr Machata <petrm@nvidia.com>
    Signed-off-by: Ido Schimmel <idosch@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mm, compaction: fast_find_migrateblock() should return pfn in the target zone [+ + +]
Author: Rei Yamamoto <yamamoto.rei@jp.fujitsu.com>
Date:   Fri May 13 16:48:57 2022 -0700

    mm, compaction: fast_find_migrateblock() should return pfn in the target zone
    
    commit bbe832b9db2e1ad21522f8f0bf02775fff8a0e0e upstream.
    
    At present, pages not in the target zone are added to cc->migratepages
    list in isolate_migratepages_block().  As a result, pages may migrate
    between nodes unintentionally.
    
    This would be a serious problem for older kernels without commit
    a984226f457f849e ("mm: memcontrol: remove the pgdata parameter of
    mem_cgroup_page_lruvec"), because it can corrupt the lru list by
    handling pages in list without holding proper lru_lock.
    
    Avoid returning a pfn outside the target zone in the case that it is
    not aligned with a pageblock boundary.  Otherwise
    isolate_migratepages_block() will handle pages not in the target zone.
    
    Link: https://lkml.kernel.org/r/20220511044300.4069-1-yamamoto.rei@jp.fujitsu.com
    Fixes: 70b44595eafe ("mm, compaction: use free lists to quickly locate a migration source")
    Signed-off-by: Rei Yamamoto <yamamoto.rei@jp.fujitsu.com>
    Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
    Acked-by: Mel Gorman <mgorman@techsingularity.net>
    Reviewed-by: Oscar Salvador <osalvador@suse.de>
    Cc: Don Dutile <ddutile@redhat.com>
    Cc: Wonhyuk Yang <vvghjk1234@gmail.com>
    Cc: Rei Yamamoto <yamamoto.rei@jp.fujitsu.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mmc: block: Fix CQE recovery reset success [+ + +]
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Tue May 31 20:19:22 2022 +0300

    mmc: block: Fix CQE recovery reset success
    
    commit a051246b786af7e4a9d9219cc7038a6e8a411531 upstream.
    
    The intention of the use of mmc_blk_reset_success() in
    mmc_blk_cqe_recovery() was to prevent repeated resets when retrying and
    getting the same error. However, that may not be the case - any amount
    of time and I/O may pass before another recovery is needed, in which
    case there would be no reason to deny it the opportunity to recover via
    a reset if necessary. CQE recovery is expected seldom and failure to
    recover (if the clear tasks command fails), even more seldom, so it is
    better to allow the reset always, which can be done by calling
    mmc_blk_reset_success() always.
    
    Fixes: 1e8e55b67030c6 ("mmc: block: Add CQE support")
    Cc: stable@vger.kernel.org
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Link: https://lore.kernel.org/r/20220531171922.76080-1-adrian.hunter@intel.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mmc: jz4740: Apply DMA engine limits to maximum segment size [+ + +]
Author: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Date:   Mon Apr 11 16:37:53 2022 +0100

    mmc: jz4740: Apply DMA engine limits to maximum segment size
    
    [ Upstream commit afadb04f1d6e74b18a253403f5274cde5e3fd7bd ]
    
    Do what is done in other DMA-enabled MMC host drivers (cf. host/mmci.c) and
    limit the maximum segment size based on the DMA engine's capabilities. This
    is needed to avoid warnings like the following with CONFIG_DMA_API_DEBUG=y.
    
    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 21 at kernel/dma/debug.c:1162 debug_dma_map_sg+0x2f4/0x39c
    DMA-API: jz4780-dma 13420000.dma-controller: mapping sg segment longer than device claims to support [len=98304] [max=65536]
    CPU: 0 PID: 21 Comm: kworker/0:1H Not tainted 5.18.0-rc1 #19
    Workqueue: kblockd blk_mq_run_work_fn
    Stack : 81575aec 00000004 80620000 80620000 80620000 805e7358 00000009 801537ac
            814c832c 806276e3 806e34b4 80620000 81575aec 00000001 81575ab8 09291444
            00000000 00000000 805e7358 81575958 ffffffea 8157596c 00000000 636f6c62
            6220646b 80387a70 0000000f 6d5f6b6c 80620000 00000000 81575ba4 00000009
            805e170c 80896640 00000001 00010000 00000000 00000000 00006098 806e0000
            ...
    Call Trace:
    [<80107670>] show_stack+0x84/0x120
    [<80528cd8>] __warn+0xb8/0xec
    [<80528d78>] warn_slowpath_fmt+0x6c/0xb8
    [<8016f1d4>] debug_dma_map_sg+0x2f4/0x39c
    [<80169d4c>] __dma_map_sg_attrs+0xf0/0x118
    [<8016a27c>] dma_map_sg_attrs+0x14/0x28
    [<804f66b4>] jz4740_mmc_prepare_dma_data+0x74/0xa4
    [<804f6714>] jz4740_mmc_pre_request+0x30/0x54
    [<804f4ff4>] mmc_blk_mq_issue_rq+0x6e0/0x7bc
    [<804f5590>] mmc_mq_queue_rq+0x220/0x2d4
    [<8038b2c0>] blk_mq_dispatch_rq_list+0x480/0x664
    [<80391040>] blk_mq_do_dispatch_sched+0x2dc/0x370
    [<80391468>] __blk_mq_sched_dispatch_requests+0xec/0x164
    [<80391540>] blk_mq_sched_dispatch_requests+0x44/0x94
    [<80387900>] __blk_mq_run_hw_queue+0xb0/0xcc
    [<80134c14>] process_one_work+0x1b8/0x264
    [<80134ff8>] worker_thread+0x2ec/0x3b8
    [<8013b13c>] kthread+0x104/0x10c
    [<80101dcc>] ret_from_kernel_thread+0x14/0x1c
    
    ---[ end trace 0000000000000000 ]---
    
    Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
    Link: https://lore.kernel.org/r/20220411153753.50443-1-aidanmacdonald.0x0@gmail.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
modpost: fix removing numeric suffixes [+ + +]
Author: Alexander Lobakin <alexandr.lobakin@intel.com>
Date:   Tue May 24 17:27:18 2022 +0200

    modpost: fix removing numeric suffixes
    
    [ Upstream commit b5beffa20d83c4e15306c991ffd00de0d8628338 ]
    
    With the `-z unique-symbol` linker flag or any similar mechanism,
    it is possible to trigger the following:
    
    ERROR: modpost: "param_set_uint.0" [vmlinux] is a static EXPORT_SYMBOL
    
    The reason is that for now the condition from remove_dot():
    
    if (m && (s[n + m] == '.' || s[n + m] == 0))
    
    which was designed to test if it's a dot or a '\0' after the suffix
    is never satisfied.
    This is due to that `s[n + m]` always points to the last digit of a
    numeric suffix, not on the symbol next to it (from a custom debug
    print added to modpost):
    
    param_set_uint.0, s[n + m] is '0', s[n + m + 1] is '\0'
    
    So it's off-by-one and was like that since 2014.
    
    Fix this for the sake of any potential upcoming features, but don't
    bother stable-backporting, as it's well hidden -- apart from that
    LD flag, it can be triggered only with GCC LTO which never landed
    upstream.
    
    Fixes: fcd38ed0ff26 ("scripts: modpost: fix compilation warning")
    Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
    Reviewed-by: Petr Mladek <pmladek@suse.com>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

modpost: fix undefined behavior of is_arm_mapping_symbol() [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Tue May 24 01:46:22 2022 +0900

    modpost: fix undefined behavior of is_arm_mapping_symbol()
    
    [ Upstream commit d6b732666a1bae0df3c3ae06925043bba34502b1 ]
    
    The return value of is_arm_mapping_symbol() is unpredictable when "$"
    is passed in.
    
    strchr(3) says:
      The strchr() and strrchr() functions return a pointer to the matched
      character or NULL if the character is not found. The terminating null
      byte is considered part of the string, so that if c is specified as
      '\0', these functions return a pointer to the terminator.
    
    When str[1] is '\0', strchr("axtd", str[1]) is not NULL, and str[2] is
    referenced (i.e. buffer overrun).
    
    Test code
    ---------
    
      char str1[] = "abc";
      char str2[] = "ab";
    
      strcpy(str1, "$");
      strcpy(str2, "$");
    
      printf("test1: %d\n", is_arm_mapping_symbol(str1));
      printf("test2: %d\n", is_arm_mapping_symbol(str2));
    
    Result
    ------
    
      test1: 0
      test2: 1
    
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
mtd: cfi_cmdset_0002: Move and rename chip_check/chip_ready/chip_good_for_write [+ + +]
Author: Tokunori Ikegami <ikegami.t@gmail.com>
Date:   Thu Mar 24 02:04:55 2022 +0900

    mtd: cfi_cmdset_0002: Move and rename chip_check/chip_ready/chip_good_for_write
    
    commit 083084df578a8bdb18334f69e7b32d690aaa3247 upstream.
    
    This is a preparation patch for the S29GL064N buffer writes fix. There
    is no functional change.
    
    Link: https://lore.kernel.org/r/b687c259-6413-26c9-d4c9-b3afa69ea124@pengutronix.de/
    Fixes: dfeae1073583("mtd: cfi_cmdset_0002: Change write buffer to check correct value")
    Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
    Cc: stable@vger.kernel.org
    Acked-by: Vignesh Raghavendra <vigneshr@ti.com>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/linux-mtd/20220323170458.5608-2-ikegami.t@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mtd: cfi_cmdset_0002: Use chip_ready() for write on S29GL064N [+ + +]
Author: Tokunori Ikegami <ikegami.t@gmail.com>
Date:   Thu Mar 24 02:04:56 2022 +0900

    mtd: cfi_cmdset_0002: Use chip_ready() for write on S29GL064N
    
    commit 0a8e98305f63deaf0a799d5cf5532cc83af035d1 upstream.
    
    Since commit dfeae1073583("mtd: cfi_cmdset_0002: Change write buffer to
    check correct value") buffered writes fail on S29GL064N. This is
    because, on S29GL064N, reads return 0xFF at the end of DQ polling for
    write completion, where as, chip_good() check expects actual data
    written to the last location to be returned post DQ polling completion.
    Fix is to revert to using chip_good() for S29GL064N which only checks
    for DQ lines to settle down to determine write completion.
    
    Link: https://lore.kernel.org/r/b687c259-6413-26c9-d4c9-b3afa69ea124@pengutronix.de/
    Fixes: dfeae1073583("mtd: cfi_cmdset_0002: Change write buffer to check correct value")
    Cc: stable@vger.kernel.org
    Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
    Acked-by: Vignesh Raghavendra <vigneshr@ti.com>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/linux-mtd/20220323170458.5608-3-ikegami.t@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue [+ + +]
Author: Niels Dossche <dossche.niels@gmail.com>
Date:   Mon Mar 21 23:55:16 2022 +0100

    mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue
    
    [ Upstream commit 3e12968f6d12a34b540c39cbd696a760cc4616f0 ]
    
    cfg80211_ch_switch_notify uses ASSERT_WDEV_LOCK to assert that
    net_device->ieee80211_ptr->mtx (which is the same as priv->wdev.mtx)
    is held during the function's execution.
    mwifiex_dfs_chan_sw_work_queue is one of its callers, which does not
    hold that lock, therefore violating the assertion.
    Add a lock around the call.
    
    Disclaimer:
    I am currently working on a static analyser to detect missing locks.
    This was a reported case. I manually verified the report by looking
    at the code, so that I do not send wrong information or patches.
    After concluding that this seems to be a true positive, I created
    this patch.
    However, as I do not in fact have this particular hardware,
    I was unable to test it.
    
    Reviewed-by: Brian Norris <briannorris@chromium.org>
    Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20220321225515.32113-1-dossche.niels@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nbd: call genl_unregister_family() first in nbd_cleanup() [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Sat May 21 15:37:44 2022 +0800

    nbd: call genl_unregister_family() first in nbd_cleanup()
    
    [ Upstream commit 06c4da89c24e7023ea448cadf8e9daf06a0aae6e ]
    
    Otherwise there may be race between module removal and the handling of
    netlink command, which can lead to the oops as shown below:
    
      BUG: kernel NULL pointer dereference, address: 0000000000000098
      Oops: 0002 [#1] SMP PTI
      CPU: 1 PID: 31299 Comm: nbd-client Tainted: G            E     5.14.0-rc4
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
      RIP: 0010:down_write+0x1a/0x50
      Call Trace:
       start_creating+0x89/0x130
       debugfs_create_dir+0x1b/0x130
       nbd_start_device+0x13d/0x390 [nbd]
       nbd_genl_connect+0x42f/0x748 [nbd]
       genl_family_rcv_msg_doit.isra.0+0xec/0x150
       genl_rcv_msg+0xe5/0x1e0
       netlink_rcv_skb+0x55/0x100
       genl_rcv+0x29/0x40
       netlink_unicast+0x1a8/0x250
       netlink_sendmsg+0x21b/0x430
       ____sys_sendmsg+0x2a4/0x2d0
       ___sys_sendmsg+0x81/0xc0
       __sys_sendmsg+0x62/0xb0
       __x64_sys_sendmsg+0x1f/0x30
       do_syscall_64+0x3b/0xc0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      Modules linked in: nbd(E-)
    
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Link: https://lore.kernel.org/r/20220521073749.3146892-2-yukuai3@huawei.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nbd: Fix hung on disconnect request if socket is closed before [+ + +]
Author: Xie Yongji <xieyongji@bytedance.com>
Date:   Tue Mar 22 16:06:39 2022 +0800

    nbd: Fix hung on disconnect request if socket is closed before
    
    [ Upstream commit 491bf8f236fdeec698fa6744993f1ecf3fafd1a5 ]
    
    When userspace closes the socket before sending a disconnect
    request, the following I/O requests will be blocked in
    wait_for_reconnect() until dead timeout. This will cause the
    following disconnect request also hung on blk_mq_quiesce_queue().
    That means we have no way to disconnect a nbd device if there
    are some I/O requests waiting for reconnecting until dead timeout.
    It's not expected. So let's wake up the thread waiting for
    reconnecting directly when a disconnect request is sent.
    
    Reported-by: Xu Jianhai <zero.xu@bytedance.com>
    Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Link: https://lore.kernel.org/r/20220322080639.142-1-xieyongji@bytedance.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nbd: fix io hung while disconnecting device [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Sat May 21 15:37:47 2022 +0800

    nbd: fix io hung while disconnecting device
    
    [ Upstream commit 09dadb5985023e27d4740ebd17e6fea4640110e5 ]
    
    In our tests, "qemu-nbd" triggers a io hung:
    
    INFO: task qemu-nbd:11445 blocked for more than 368 seconds.
          Not tainted 5.18.0-rc3-next-20220422-00003-g2176915513ca #884
    "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    task:qemu-nbd        state:D stack:    0 pid:11445 ppid:     1 flags:0x00000000
    Call Trace:
     <TASK>
     __schedule+0x480/0x1050
     ? _raw_spin_lock_irqsave+0x3e/0xb0
     schedule+0x9c/0x1b0
     blk_mq_freeze_queue_wait+0x9d/0xf0
     ? ipi_rseq+0x70/0x70
     blk_mq_freeze_queue+0x2b/0x40
     nbd_add_socket+0x6b/0x270 [nbd]
     nbd_ioctl+0x383/0x510 [nbd]
     blkdev_ioctl+0x18e/0x3e0
     __x64_sys_ioctl+0xac/0x120
     do_syscall_64+0x35/0x80
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    RIP: 0033:0x7fd8ff706577
    RSP: 002b:00007fd8fcdfebf8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
    RAX: ffffffffffffffda RBX: 0000000040000000 RCX: 00007fd8ff706577
    RDX: 000000000000000d RSI: 000000000000ab00 RDI: 000000000000000f
    RBP: 000000000000000f R08: 000000000000fbe8 R09: 000055fe497c62b0
    R10: 00000002aff20000 R11: 0000000000000246 R12: 000000000000006d
    R13: 0000000000000000 R14: 00007ffe82dc5e70 R15: 00007fd8fcdff9c0
    
    "qemu-ndb -d" will call ioctl 'NBD_DISCONNECT' first, however, following
    message was found:
    
    block nbd0: Send disconnect failed -32
    
    Which indicate that something is wrong with the server. Then,
    "qemu-nbd -d" will call ioctl 'NBD_CLEAR_SOCK', however ioctl can't clear
    requests after commit 2516ab1543fd("nbd: only clear the queue on device
    teardown"). And in the meantime, request can't complete through timeout
    because nbd_xmit_timeout() will always return 'BLK_EH_RESET_TIMER', which
    means such request will never be completed in this situation.
    
    Now that the flag 'NBD_CMD_INFLIGHT' can make sure requests won't
    complete multiple times, switch back to call nbd_clear_sock() in
    nbd_clear_sock_ioctl(), so that inflight requests can be cleared.
    
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Link: https://lore.kernel.org/r/20220521073749.3146892-5-yukuai3@huawei.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

nbd: fix race between nbd_alloc_config() and module removal [+ + +]
Author: Yu Kuai <yukuai3@huawei.com>
Date:   Sat May 21 15:37:45 2022 +0800

    nbd: fix race between nbd_alloc_config() and module removal
    
    [ Upstream commit c55b2b983b0fa012942c3eb16384b2b722caa810 ]
    
    When nbd module is being removing, nbd_alloc_config() may be
    called concurrently by nbd_genl_connect(), although try_module_get()
    will return false, but nbd_alloc_config() doesn't handle it.
    
    The race may lead to the leak of nbd_config and its related
    resources (e.g, recv_workq) and oops in nbd_read_stat() due
    to the unload of nbd module as shown below:
    
      BUG: kernel NULL pointer dereference, address: 0000000000000040
      Oops: 0000 [#1] SMP PTI
      CPU: 5 PID: 13840 Comm: kworker/u17:33 Not tainted 5.14.0+ #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
      Workqueue: knbd16-recv recv_work [nbd]
      RIP: 0010:nbd_read_stat.cold+0x130/0x1a4 [nbd]
      Call Trace:
       recv_work+0x3b/0xb0 [nbd]
       process_one_work+0x1ed/0x390
       worker_thread+0x4a/0x3d0
       kthread+0x12a/0x150
       ret_from_fork+0x22/0x30
    
    Fixing it by checking the return value of try_module_get()
    in nbd_alloc_config(). As nbd_alloc_config() may return ERR_PTR(-ENODEV),
    assign nbd->config only when nbd_alloc_config() succeeds to ensure
    the value of nbd->config is binary (valid or NULL).
    
    Also adding a debug message to check the reference counter
    of nbd_config during module removal.
    
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Yu Kuai <yukuai3@huawei.com>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Link: https://lore.kernel.org/r/20220521073749.3146892-3-yukuai3@huawei.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
net/mlx4_en: Fix wrong return value on ioctl EEPROM query failure [+ + +]
Author: Gal Pressman <gal@nvidia.com>
Date:   Mon Jun 6 14:57:18 2022 +0300

    net/mlx4_en: Fix wrong return value on ioctl EEPROM query failure
    
    [ Upstream commit f5826c8c9d57210a17031af5527056eefdc2b7eb ]
    
    The ioctl EEPROM query wrongly returns success on read failures, fix
    that by returning the appropriate error code.
    
    Fixes: 7202da8b7f71 ("ethtool, net/mlx4_en: Cable info, get_module_info/eeprom ethtool support")
    Signed-off-by: Gal Pressman <gal@nvidia.com>
    Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
    Link: https://lore.kernel.org/r/20220606115718.14233-1-tariqt@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
net/mlx5: Don't use already freed action pointer [+ + +]
Author: Leon Romanovsky <leon@kernel.org>
Date:   Tue May 24 15:59:27 2022 +0300

    net/mlx5: Don't use already freed action pointer
    
    [ Upstream commit 80b2bd737d0e833e6a2b77e482e5a714a79c86a4 ]
    
    The call to mlx5dr_action_destroy() releases "action" memory. That
    pointer is set to miss_action later and generates the following smatch
    error:
    
     drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c:53 set_miss_action()
     warn: 'action' was already freed.
    
    Make sure that the pointer is always valid by setting NULL after destroy.
    
    Fixes: 6a48faeeca10 ("net/mlx5: Add direct rule fs_cmd implementation")
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net/mlx5: fs, delete the FTE when there are no rules attached to it [+ + +]
Author: Mark Bloch <mbloch@nvidia.com>
Date:   Tue Mar 15 11:23:40 2022 +0000

    net/mlx5: fs, delete the FTE when there are no rules attached to it
    
    [ Upstream commit 7b0c6338597613f465d131bd939a51844a00455a ]
    
    When an FTE has no children is means all the rules where removed
    and the FTE can be deleted regardless of the dests_size value.
    While dests_size should be 0 when there are no children
    be extra careful not to leak memory or get firmware syndrome
    if the proper bookkeeping of dests_size wasn't done.
    
    Signed-off-by: Mark Bloch <mbloch@nvidia.com>
    Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net/mlx5: fs, fail conflicting actions [+ + +]
Author: Mark Bloch <mbloch@nvidia.com>
Date:   Mon May 30 10:46:59 2022 +0300

    net/mlx5: fs, fail conflicting actions
    
    [ Upstream commit 8fa5e7b20e01042b14f8cd684d2da9b638460c74 ]
    
    When combining two steering rules into one check
    not only do they share the same actions but those
    actions are also the same. This resolves an issue where
    when creating two different rules with the same match
    the actions are overwritten and one of the rules is deleted
    a FW syndrome can be seen in dmesg.
    
    mlx5_core 0000:03:00.0: mlx5_cmd_check:819:(pid 2105): DEALLOC_MODIFY_HEADER_CONTEXT(0x941) op_mod(0x0) failed, status bad resource state(0x9), syndrome (0x1ab444)
    
    Fixes: 0d235c3fabb7 ("net/mlx5: Add hash table to search FTEs in a flow-group")
    Signed-off-by: Mark Bloch <mbloch@nvidia.com>
    Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net/mlx5: Rearm the FW tracer after each tracer event [+ + +]
Author: Feras Daoud <ferasda@nvidia.com>
Date:   Sat Mar 19 21:47:48 2022 +0200

    net/mlx5: Rearm the FW tracer after each tracer event
    
    [ Upstream commit 8bf94e6414c9481bfa28269022688ab445d0081d ]
    
    The current design does not arm the tracer if traces are available before
    the tracer string database is fully loaded, leading to an unfunctional tracer.
    This fix will rearm the tracer every time the FW triggers tracer event
    regardless of the tracer strings database status.
    
    Fixes: c71ad41ccb0c ("net/mlx5: FW tracer, events handling")
    Signed-off-by: Feras Daoud <ferasda@nvidia.com>
    Signed-off-by: Roy Novich <royno@nvidia.com>
    Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
net/mlx5e: Update netdev features after changing XDP state [+ + +]
Author: Maxim Mikityanskiy <maximmi@nvidia.com>
Date:   Mon May 23 15:39:13 2022 +0300

    net/mlx5e: Update netdev features after changing XDP state
    
    [ Upstream commit f6279f113ad593971999c877eb69dc3d36a75894 ]
    
    Some features (LRO, HW GRO) conflict with XDP. If there is an attempt to
    enable such features while XDP is active, they will be set to `off
    [requested on]`. In order to activate these features after XDP is turned
    off, the driver needs to call netdev_update_features(). This commit adds
    this missing call after XDP state changes.
    
    Fixes: cf6e34c8c22f ("net/mlx5e: Properly block LRO when XDP is enabled")
    Fixes: b0617e7b3500 ("net/mlx5e: Properly block HW GRO when XDP is enabled")
    Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
net/smc: postpone sk_refcnt increment in connect() [+ + +]
Author: liuyacan <liuyacan@corp.netease.com>
Date:   Mon May 23 12:57:07 2022 +0800

    net/smc: postpone sk_refcnt increment in connect()
    
    [ Upstream commit 75c1edf23b95a9c66923d9269d8e86e4dbde151f ]
    
    Same trigger condition as commit 86434744. When setsockopt runs
    in parallel to a connect(), and switch the socket into fallback
    mode. Then the sk_refcnt is incremented in smc_connect(), but
    its state stay in SMC_INIT (NOT SMC_ACTIVE). This cause the
    corresponding sk_refcnt decrement in __smc_release() will not be
    performed.
    
    Fixes: 86434744fedf ("net/smc: add fallback check to connect()")
    Signed-off-by: liuyacan <liuyacan@corp.netease.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
net: altera: Fix refcount leak in altera_tse_mdio_create [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Tue Jun 7 08:11:43 2022 +0400

    net: altera: Fix refcount leak in altera_tse_mdio_create
    
    [ Upstream commit 11ec18b1d8d92b9df307d31950dcba0b3dd7283c ]
    
    Every iteration of for_each_child_of_node() decrements
    the reference count of the previous node.
    When break from a for_each_child_of_node() loop,
    we need to explicitly call of_node_put() on the child node when
    not need anymore.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220607041144.7553-1-linmq006@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: lantiq_gswip: Fix refcount leak in gswip_gphy_fw_list [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Sun Jun 5 11:23:34 2022 +0400

    net: dsa: lantiq_gswip: Fix refcount leak in gswip_gphy_fw_list
    
    [ Upstream commit 0737e018a05e2aa352828c52bdeed3b02cff2930 ]
    
    Every iteration of for_each_available_child_of_node() decrements
    the reference count of the previous node.
    when breaking early from a for_each_available_child_of_node() loop,
    we need to explicitly call of_node_put() on the gphy_fw_np.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: 14fceff4771e ("net: dsa: Add Lantiq / Intel DSA driver for vrx200")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220605072335.11257-1-linmq006@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Thu May 26 18:52:08 2022 +0400

    net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register
    
    [ Upstream commit 02ded5a173619b11728b8bf75a3fd995a2c1ff28 ]
    
    of_get_child_by_name() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when done.
    
    mv88e6xxx_mdio_register() pass the device node to of_mdiobus_register().
    We don't need the device node after it.
    
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: a3c53be55c95 ("net: dsa: mv88e6xxx: Support multiple MDIO busses")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Marek Behún <kabel@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_entry() [+ + +]
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu May 26 11:02:42 2022 +0300

    net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_entry()
    
    [ Upstream commit e7e7104e2d5ddf3806a28695670f21bef471f1e1 ]
    
    The "fsp->location" variable comes from user via ethtool_get_rxnfc().
    Check that it is valid to prevent an out of bounds read.
    
    Fixes: 7aab747e5563 ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: ipv6: unexport __init-annotated seg6_hmac_init() [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Mon Jun 6 13:53:55 2022 +0900

    net: ipv6: unexport __init-annotated seg6_hmac_init()
    
    [ Upstream commit 5801f064e35181c71857a80ff18af4dbec3c5f5c ]
    
    EXPORT_SYMBOL and __init is a bad combination because the .init.text
    section is freed up after the initialization. Hence, modules cannot
    use symbols annotated __init. The access to a freed symbol may end up
    with kernel panic.
    
    modpost used to detect it, but it has been broken for a decade.
    
    Recently, I fixed modpost so it started to warn it again, then this
    showed up in linux-next builds.
    
    There are two ways to fix it:
    
      - Remove __init
      - Remove EXPORT_SYMBOL
    
    I chose the latter for this case because the caller (net/ipv6/seg6.c)
    and the callee (net/ipv6/seg6_hmac.c) belong to the same module.
    It seems an internal function call in ipv6.ko.
    
    Fixes: bf355b8d2c30 ("ipv6: sr: add core files for SR HMAC support")
    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: mdio: unexport __init-annotated mdio_bus_init() [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Mon Jun 6 13:53:53 2022 +0900

    net: mdio: unexport __init-annotated mdio_bus_init()
    
    [ Upstream commit 35b42dce619701f1300fb8498dae82c9bb1f0263 ]
    
    EXPORT_SYMBOL and __init is a bad combination because the .init.text
    section is freed up after the initialization. Hence, modules cannot
    use symbols annotated __init. The access to a freed symbol may end up
    with kernel panic.
    
    modpost used to detect it, but it has been broken for a decade.
    
    Recently, I fixed modpost so it started to warn it again, then this
    showed up in linux-next builds.
    
    There are two ways to fix it:
    
      - Remove __init
      - Remove EXPORT_SYMBOL
    
    I chose the latter for this case because the only in-tree call-site,
    drivers/net/phy/phy_device.c is never compiled as modular.
    (CONFIG_PHYLIB is boolean)
    
    Fixes: 90eff9096c01 ("net: phy: Allow splitting MDIO bus/device support from PHYs")
    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
    Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: phy: micrel: Allow probing without .driver_data [+ + +]
Author: Fabio Estevam <festevam@denx.de>
Date:   Fri May 13 08:46:12 2022 -0300

    net: phy: micrel: Allow probing without .driver_data
    
    [ Upstream commit f2ef6f7539c68c6bd6c32323d8845ee102b7c450 ]
    
    Currently, if the .probe element is present in the phy_driver structure
    and the .driver_data is not, a NULL pointer dereference happens.
    
    Allow passing .probe without .driver_data by inserting NULL checks
    for priv->type.
    
    Signed-off-by: Fabio Estevam <festevam@denx.de>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Link: https://lore.kernel.org/r/20220513114613.762810-1-festevam@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: sched: add barrier to fix packet stuck problem for lockless qdisc [+ + +]
Author: Guoju Fang <gjfang@linux.alibaba.com>
Date:   Sat May 28 18:16:28 2022 +0800

    net: sched: add barrier to fix packet stuck problem for lockless qdisc
    
    [ Upstream commit 2e8728c955ce0624b958eee6e030a37aca3a5d86 ]
    
    In qdisc_run_end(), the spin_unlock() only has store-release semantic,
    which guarantees all earlier memory access are visible before it. But
    the subsequent test_bit() has no barrier semantics so may be reordered
    ahead of the spin_unlock(). The store-load reordering may cause a packet
    stuck problem.
    
    The concurrent operations can be described as below,
             CPU 0                      |          CPU 1
       qdisc_run_end()                  |     qdisc_run_begin()
              .                         |           .
     ----> /* may be reorderd here */   |           .
    |         .                         |           .
    |     spin_unlock()                 |         set_bit()
    |         .                         |         smp_mb__after_atomic()
     ---- test_bit()                    |         spin_trylock()
              .                         |          .
    
    Consider the following sequence of events:
        CPU 0 reorder test_bit() ahead and see MISSED = 0
        CPU 1 calls set_bit()
        CPU 1 calls spin_trylock() and return fail
        CPU 0 executes spin_unlock()
    
    At the end of the sequence, CPU 0 calls spin_unlock() and does nothing
    because it see MISSED = 0. The skb on CPU 1 has beed enqueued but no one
    take it, until the next cpu pushing to the qdisc (if ever ...) will
    notice and dequeue it.
    
    This patch fix this by adding one explicit barrier. As spin_unlock() and
    test_bit() ordering is a store-load ordering, a full memory barrier
    smp_mb() is needed here.
    
    Fixes: a90c57f2cedd ("net: sched: fix packet stuck problem for lockless qdisc")
    Signed-off-by: Guoju Fang <gjfang@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20220528101628.120193-1-gjfang@linux.alibaba.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: sched: fixed barrier to prevent skbuff sticking in qdisc backlog [+ + +]
Author: Vincent Ray <vray@kalrayinc.com>
Date:   Wed May 25 17:17:46 2022 -0700

    net: sched: fixed barrier to prevent skbuff sticking in qdisc backlog
    
    [ Upstream commit a54ce3703613e41fe1d98060b62ec09a3984dc28 ]
    
    In qdisc_run_begin(), smp_mb__before_atomic() used before test_bit()
    does not provide any ordering guarantee as test_bit() is not an atomic
    operation. This, added to the fact that the spin_trylock() call at
    the beginning of qdisc_run_begin() does not guarantee acquire
    semantics if it does not grab the lock, makes it possible for the
    following statement :
    
    if (test_bit(__QDISC_STATE_MISSED, &qdisc->state))
    
    to be executed before an enqueue operation called before
    qdisc_run_begin().
    
    As a result the following race can happen :
    
               CPU 1                             CPU 2
    
          qdisc_run_begin()               qdisc_run_begin() /* true */
            set(MISSED)                            .
          /* returns false */                      .
              .                            /* sees MISSED = 1 */
              .                            /* so qdisc not empty */
              .                            __qdisc_run()
              .                                    .
              .                              pfifo_fast_dequeue()
     ----> /* may be done here */                  .
    |         .                                clear(MISSED)
    |         .                                    .
    |         .                                smp_mb __after_atomic();
    |         .                                    .
    |         .                                /* recheck the queue */
    |         .                                /* nothing => exit   */
    |   enqueue(skb1)
    |         .
    |   qdisc_run_begin()
    |         .
    |     spin_trylock() /* fail */
    |         .
    |     smp_mb__before_atomic() /* not enough */
    |         .
     ---- if (test_bit(MISSED))
            return false;   /* exit */
    
    In the above scenario, CPU 1 and CPU 2 both try to grab the
    qdisc->seqlock at the same time. Only CPU 2 succeeds and enters the
    bypass code path, where it emits its skb then calls __qdisc_run().
    
    CPU1 fails, sets MISSED and goes down the traditionnal enqueue() +
    dequeue() code path. But when executing qdisc_run_begin() for the
    second time, after enqueuing its skbuff, it sees the MISSED bit still
    set (by itself) and consequently chooses to exit early without setting
    it again nor trying to grab the spinlock again.
    
    Meanwhile CPU2 has seen MISSED = 1, cleared it, checked the queue
    and found it empty, so it returned.
    
    At the end of the sequence, we end up with skb1 enqueued in the
    backlog, both CPUs out of __dev_xmit_skb(), the MISSED bit not set,
    and no __netif_schedule() called made. skb1 will now linger in the
    qdisc until somebody later performs a full __qdisc_run(). Associated
    to the bypass capacity of the qdisc, and the ability of the TCP layer
    to avoid resending packets which it knows are still in the qdisc, this
    can lead to serious traffic "holes" in a TCP connection.
    
    We fix this by replacing the smp_mb__before_atomic() / test_bit() /
    set_bit() / smp_mb__after_atomic() sequence inside qdisc_run_begin()
    by a single test_and_set_bit() call, which is more concise and
    enforces the needed memory barriers.
    
    Fixes: 89837eb4b246 ("net: sched: add barrier to ensure correct ordering for lockless qdisc")
    Signed-off-by: Vincent Ray <vray@kalrayinc.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Link: https://lore.kernel.org/r/20220526001746.2437669-1-eric.dumazet@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

net: xfrm: unexport __init-annotated xfrm4_protocol_init() [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Mon Jun 6 13:53:54 2022 +0900

    net: xfrm: unexport __init-annotated xfrm4_protocol_init()
    
    [ Upstream commit 4a388f08d8784af48f352193d2b72aaf167a57a1 ]
    
    EXPORT_SYMBOL and __init is a bad combination because the .init.text
    section is freed up after the initialization. Hence, modules cannot
    use symbols annotated __init. The access to a freed symbol may end up
    with kernel panic.
    
    modpost used to detect it, but it has been broken for a decade.
    
    Recently, I fixed modpost so it started to warn it again, then this
    showed up in linux-next builds.
    
    There are two ways to fix it:
    
      - Remove __init
      - Remove EXPORT_SYMBOL
    
    I chose the latter for this case because the only in-tree call-site,
    net/ipv4/xfrm4_policy.c is never compiled as modular.
    (CONFIG_XFRM is boolean)
    
    Fixes: 2f32b51b609f ("xfrm: Introduce xfrm_input_afinfo to access the the callbacks properly")
    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
netfilter: nat: really support inet nat without l3 address [+ + +]
Author: Florian Westphal <fw@strlen.de>
Date:   Wed Jun 1 10:47:35 2022 +0200

    netfilter: nat: really support inet nat without l3 address
    
    [ Upstream commit 282e5f8fe907dc3f2fbf9f2103b0e62ffc3a68a5 ]
    
    When no l3 address is given, priv->family is set to NFPROTO_INET and
    the evaluation function isn't called.
    
    Call it too so l4-only rewrite can work.
    Also add a test case for this.
    
    Fixes: a33f387ecd5aa ("netfilter: nft_nat: allow to specify layer 4 protocol NAT only")
    Reported-by: Yi Chen <yiche@redhat.com>
    Signed-off-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: disallow non-stateful expression in sets earlier [+ + +]
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Wed May 25 10:36:38 2022 +0200

    netfilter: nf_tables: disallow non-stateful expression in sets earlier
    
    commit 520778042ccca019f3ffa136dd0ca565c486cedd upstream.
    
    Since 3e135cd499bf ("netfilter: nft_dynset: dynamic stateful expression
    instantiation"), it is possible to attach stateful expressions to set
    elements.
    
    cd5125d8f518 ("netfilter: nf_tables: split set destruction in deactivate
    and destroy phase") introduces conditional destruction on the object to
    accomodate transaction semantics.
    
    nft_expr_init() calls expr->ops->init() first, then check for
    NFT_STATEFUL_EXPR, this stills allows to initialize a non-stateful
    lookup expressions which points to a set, which might lead to UAF since
    the set is not properly detached from the set->binding for this case.
    Anyway, this combination is non-sense from nf_tables perspective.
    
    This patch fixes this problem by checking for NFT_STATEFUL_EXPR before
    expr->ops->init() is called.
    
    The reporter provides a KASAN splat and a poc reproducer (similar to
    those autogenerated by syzbot to report use-after-free errors). It is
    unknown to me if they are using syzbot or if they use similar automated
    tool to locate the bug that they are reporting.
    
    For the record, this is the KASAN splat.
    
    [   85.431824] ==================================================================
    [   85.432901] BUG: KASAN: use-after-free in nf_tables_bind_set+0x81b/0xa20
    [   85.433825] Write of size 8 at addr ffff8880286f0e98 by task poc/776
    [   85.434756]
    [   85.434999] CPU: 1 PID: 776 Comm: poc Tainted: G        W         5.18.0+ #2
    [   85.436023] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
    
    Fixes: 0b2d8a7b638b ("netfilter: nf_tables: add helper functions for expression handling")
    Reported-and-tested-by: Aaron Adams <edg-e@nccgroup.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    [Ajay: Regenerated the patch for v5.4.y]
    Signed-off-by: Ajay Kaher <akaher@vmware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

netfilter: nf_tables: memleak flow rule from commit path [+ + +]
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Mon Jun 6 17:15:57 2022 +0200

    netfilter: nf_tables: memleak flow rule from commit path
    
    [ Upstream commit 9dd732e0bdf538b1b76dc7c157e2b5e560ff30d3 ]
    
    Abort path release flow rule object, however, commit path does not.
    Update code to destroy these objects before releasing the transaction.
    
    Fixes: c9626a2cbdb2 ("netfilter: nf_tables: add hardware offload support")
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx [+ + +]
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Wed May 18 19:57:33 2022 +0800

    NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx
    
    [ Upstream commit b413b0cb008646e9f24ce5253cb3cf7ee217aff6 ]
    
    There are sleep in atomic context bugs when the request to secure
    element of st21nfca is timeout. The root cause is that kzalloc and
    alloc_skb with GFP_KERNEL parameter and mutex_lock are called in
    st21nfca_se_wt_timeout which is a timer handler. The call tree shows
    the execution paths that could lead to bugs:
    
       (Interrupt context)
    st21nfca_se_wt_timeout
      nfc_hci_send_event
        nfc_hci_hcp_message_tx
          kzalloc(..., GFP_KERNEL) //may sleep
          alloc_skb(..., GFP_KERNEL) //may sleep
          mutex_lock() //may sleep
    
    This patch moves the operations that may sleep into a work item.
    The work item will run in another kernel thread which is in
    process context to execute the bottom half of the interrupt.
    So it could prevent atomic context from sleeping.
    
    Fixes: 2130fb97fecf ("NFC: st21nfca: Adding support for secure element")
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Link: https://lore.kernel.org/r/20220518115733.62111-1-duoming@zju.edu.cn
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

NFC: NULL out the dev->rfkill to prevent UAF [+ + +]
Author: Lin Ma <linma@zju.edu.cn>
Date:   Tue Apr 12 13:32:08 2022 +0800

    NFC: NULL out the dev->rfkill to prevent UAF
    
    [ Upstream commit 1b0e81416a24d6e9b8c2341e22e8bf48f8b8bfc9 ]
    
    Commit 3e3b5dfcd16a ("NFC: reorder the logic in nfc_{un,}register_device")
    assumes the device_is_registered() in function nfc_dev_up() will help
    to check when the rfkill is unregistered. However, this check only
    take effect when device_del(&dev->dev) is done in nfc_unregister_device().
    Hence, the rfkill object is still possible be dereferenced.
    
    The crash trace in latest kernel (5.18-rc2):
    
    [   68.760105] ==================================================================
    [   68.760330] BUG: KASAN: use-after-free in __lock_acquire+0x3ec1/0x6750
    [   68.760756] Read of size 8 at addr ffff888009c93018 by task fuzz/313
    [   68.760756]
    [   68.760756] CPU: 0 PID: 313 Comm: fuzz Not tainted 5.18.0-rc2 #4
    [   68.760756] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
    [   68.760756] Call Trace:
    [   68.760756]  <TASK>
    [   68.760756]  dump_stack_lvl+0x57/0x7d
    [   68.760756]  print_report.cold+0x5e/0x5db
    [   68.760756]  ? __lock_acquire+0x3ec1/0x6750
    [   68.760756]  kasan_report+0xbe/0x1c0
    [   68.760756]  ? __lock_acquire+0x3ec1/0x6750
    [   68.760756]  __lock_acquire+0x3ec1/0x6750
    [   68.760756]  ? lockdep_hardirqs_on_prepare+0x410/0x410
    [   68.760756]  ? register_lock_class+0x18d0/0x18d0
    [   68.760756]  lock_acquire+0x1ac/0x4f0
    [   68.760756]  ? rfkill_blocked+0xe/0x60
    [   68.760756]  ? lockdep_hardirqs_on_prepare+0x410/0x410
    [   68.760756]  ? mutex_lock_io_nested+0x12c0/0x12c0
    [   68.760756]  ? nla_get_range_signed+0x540/0x540
    [   68.760756]  ? _raw_spin_lock_irqsave+0x4e/0x50
    [   68.760756]  _raw_spin_lock_irqsave+0x39/0x50
    [   68.760756]  ? rfkill_blocked+0xe/0x60
    [   68.760756]  rfkill_blocked+0xe/0x60
    [   68.760756]  nfc_dev_up+0x84/0x260
    [   68.760756]  nfc_genl_dev_up+0x90/0xe0
    [   68.760756]  genl_family_rcv_msg_doit+0x1f4/0x2f0
    [   68.760756]  ? genl_family_rcv_msg_attrs_parse.constprop.0+0x230/0x230
    [   68.760756]  ? security_capable+0x51/0x90
    [   68.760756]  genl_rcv_msg+0x280/0x500
    [   68.760756]  ? genl_get_cmd+0x3c0/0x3c0
    [   68.760756]  ? lock_acquire+0x1ac/0x4f0
    [   68.760756]  ? nfc_genl_dev_down+0xe0/0xe0
    [   68.760756]  ? lockdep_hardirqs_on_prepare+0x410/0x410
    [   68.760756]  netlink_rcv_skb+0x11b/0x340
    [   68.760756]  ? genl_get_cmd+0x3c0/0x3c0
    [   68.760756]  ? netlink_ack+0x9c0/0x9c0
    [   68.760756]  ? netlink_deliver_tap+0x136/0xb00
    [   68.760756]  genl_rcv+0x1f/0x30
    [   68.760756]  netlink_unicast+0x430/0x710
    [   68.760756]  ? memset+0x20/0x40
    [   68.760756]  ? netlink_attachskb+0x740/0x740
    [   68.760756]  ? __build_skb_around+0x1f4/0x2a0
    [   68.760756]  netlink_sendmsg+0x75d/0xc00
    [   68.760756]  ? netlink_unicast+0x710/0x710
    [   68.760756]  ? netlink_unicast+0x710/0x710
    [   68.760756]  sock_sendmsg+0xdf/0x110
    [   68.760756]  __sys_sendto+0x19e/0x270
    [   68.760756]  ? __ia32_sys_getpeername+0xa0/0xa0
    [   68.760756]  ? fd_install+0x178/0x4c0
    [   68.760756]  ? fd_install+0x195/0x4c0
    [   68.760756]  ? kernel_fpu_begin_mask+0x1c0/0x1c0
    [   68.760756]  __x64_sys_sendto+0xd8/0x1b0
    [   68.760756]  ? lockdep_hardirqs_on+0xbf/0x130
    [   68.760756]  ? syscall_enter_from_user_mode+0x1d/0x50
    [   68.760756]  do_syscall_64+0x3b/0x90
    [   68.760756]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    [   68.760756] RIP: 0033:0x7f67fb50e6b3
    ...
    [   68.760756] RSP: 002b:00007f67fa91fe90 EFLAGS: 00000293 ORIG_RAX: 000000000000002c
    [   68.760756] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f67fb50e6b3
    [   68.760756] RDX: 000000000000001c RSI: 0000559354603090 RDI: 0000000000000003
    [   68.760756] RBP: 00007f67fa91ff00 R08: 00007f67fa91fedc R09: 000000000000000c
    [   68.760756] R10: 0000000000000000 R11: 0000000000000293 R12: 00007ffe824d496e
    [   68.760756] R13: 00007ffe824d496f R14: 00007f67fa120000 R15: 0000000000000003
    
    [   68.760756]  </TASK>
    [   68.760756]
    [   68.760756] Allocated by task 279:
    [   68.760756]  kasan_save_stack+0x1e/0x40
    [   68.760756]  __kasan_kmalloc+0x81/0xa0
    [   68.760756]  rfkill_alloc+0x7f/0x280
    [   68.760756]  nfc_register_device+0xa3/0x1a0
    [   68.760756]  nci_register_device+0x77a/0xad0
    [   68.760756]  nfcmrvl_nci_register_dev+0x20b/0x2c0
    [   68.760756]  nfcmrvl_nci_uart_open+0xf2/0x1dd
    [   68.760756]  nci_uart_tty_ioctl+0x2c3/0x4a0
    [   68.760756]  tty_ioctl+0x764/0x1310
    [   68.760756]  __x64_sys_ioctl+0x122/0x190
    [   68.760756]  do_syscall_64+0x3b/0x90
    [   68.760756]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    [   68.760756]
    [   68.760756] Freed by task 314:
    [   68.760756]  kasan_save_stack+0x1e/0x40
    [   68.760756]  kasan_set_track+0x21/0x30
    [   68.760756]  kasan_set_free_info+0x20/0x30
    [   68.760756]  __kasan_slab_free+0x108/0x170
    [   68.760756]  kfree+0xb0/0x330
    [   68.760756]  device_release+0x96/0x200
    [   68.760756]  kobject_put+0xf9/0x1d0
    [   68.760756]  nfc_unregister_device+0x77/0x190
    [   68.760756]  nfcmrvl_nci_unregister_dev+0x88/0xd0
    [   68.760756]  nci_uart_tty_close+0xdf/0x180
    [   68.760756]  tty_ldisc_kill+0x73/0x110
    [   68.760756]  tty_ldisc_hangup+0x281/0x5b0
    [   68.760756]  __tty_hangup.part.0+0x431/0x890
    [   68.760756]  tty_release+0x3a8/0xc80
    [   68.760756]  __fput+0x1f0/0x8c0
    [   68.760756]  task_work_run+0xc9/0x170
    [   68.760756]  exit_to_user_mode_prepare+0x194/0x1a0
    [   68.760756]  syscall_exit_to_user_mode+0x19/0x50
    [   68.760756]  do_syscall_64+0x48/0x90
    [   68.760756]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    This patch just add the null out of dev->rfkill to make sure such
    dereference cannot happen. This is safe since the device_lock() already
    protect the check/write from data race.
    
    Fixes: 3e3b5dfcd16a ("NFC: reorder the logic in nfc_{un,}register_device")
    Signed-off-by: Lin Ma <linma@zju.edu.cn>
    Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION [+ + +]
Author: Martin Faltesek <mfaltesek@google.com>
Date:   Mon Jun 6 21:57:27 2022 -0500

    nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION
    
    commit 77e5fe8f176a525523ae091d6fd0fbb8834c156d upstream.
    
    The first validation check for EVT_TRANSACTION has two different checks
    tied together with logical AND. One is a check for minimum packet length,
    and the other is for a valid aid_tag. If either condition is true (fails),
    then an error should be triggered.  The fix is to change && to ||.
    
    Fixes: 26fc6c7f02cb ("NFC: st21nfca: Add HCI transaction event support")
    Cc: stable@vger.kernel.org
    Signed-off-by: Martin Faltesek <mfaltesek@google.com>
    Reviewed-by: Guenter Roeck <groeck@chromium.org>
    Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling [+ + +]
Author: Martin Faltesek <mfaltesek@google.com>
Date:   Mon Jun 6 21:57:28 2022 -0500

    nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling
    
    commit 996419e0594abb311fb958553809f24f38e7abbe upstream.
    
    Error paths do not free previously allocated memory. Add devm_kfree() to
    those failure paths.
    
    Fixes: 26fc6c7f02cb ("NFC: st21nfca: Add HCI transaction event support")
    Fixes: 4fbcc1a4cb20 ("nfc: st21nfca: Fix potential buffer overflows in EVT_TRANSACTION")
    Cc: stable@vger.kernel.org
    Signed-off-by: Martin Faltesek <mfaltesek@google.com>
    Reviewed-by: Guenter Roeck <groeck@chromium.org>
    Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
nfp: only report pause frame configuration for physical device [+ + +]
Author: Yu Xiao <yu.xiao@corigine.com>
Date:   Fri May 27 20:24:24 2022 +0200

    nfp: only report pause frame configuration for physical device
    
    [ Upstream commit 0649e4d63420ebc8cbebef3e9d39e12ffc5eb9fa ]
    
    Only report pause frame configuration for physical device. Logical
    port of both PCI PF and PCI VF do not support it.
    
    Fixes: 9fdc5d85a8fe ("nfp: update ethtool reporting of pauseframe control")
    Signed-off-by: Yu Xiao <yu.xiao@corigine.com>
    Signed-off-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
NFS: Do not report EINTR/ERESTARTSYS as mapping errors [+ + +]
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat May 14 10:27:00 2022 -0400

    NFS: Do not report EINTR/ERESTARTSYS as mapping errors
    
    [ Upstream commit cea9ba7239dcc84175041174304c6cdeae3226e5 ]
    
    If the attempt to flush data was interrupted due to a local signal, then
    just requeue the writes back for I/O.
    
    Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

NFS: Do not report flush errors in nfs_write_end() [+ + +]
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat May 14 10:27:03 2022 -0400

    NFS: Do not report flush errors in nfs_write_end()
    
    [ Upstream commit d95b26650e86175e4a97698d89bc1626cd1df0c6 ]
    
    If we do flush cached writebacks in nfs_write_end() due to the imminent
    expiration of an RPCSEC_GSS session, then we should defer reporting any
    resulting errors until the calls to file_check_and_advance_wb_err() in
    nfs_file_write() and nfs_file_fsync().
    
    Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

NFS: Don't report errors from nfs_pageio_complete() more than once [+ + +]
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat May 14 10:27:04 2022 -0400

    NFS: Don't report errors from nfs_pageio_complete() more than once
    
    [ Upstream commit c5e483b77cc2edb318da152abe07e33006b975fd ]
    
    Since errors from nfs_pageio_complete() are already being reported
    through nfs_async_write_error(), we should not be returning them to the
    callers of do_writepages() as well. They will end up being reported
    through the generic mechanism instead.
    
    Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
NFSv4/pNFS: Do not fail I/O when we fail to allocate the pNFS layout [+ + +]
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat May 14 10:08:11 2022 -0400

    NFSv4/pNFS: Do not fail I/O when we fail to allocate the pNFS layout
    
    [ Upstream commit 3764a17e31d579cf9b4bd0a69894b577e8d75702 ]
    
    Commit 587f03deb69b caused pnfs_update_layout() to stop returning ENOMEM
    when the memory allocation fails, and hence causes it to fall back to
    trying to do I/O through the MDS. There is no guarantee that this will
    fare any better. If we're failing the pNFS layout allocation, then we
    should just redirty the page and retry later.
    
    Reported-by: Olga Kornievskaia <aglo@umich.edu>
    Fixes: 587f03deb69b ("pnfs: refactor send_layoutget")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
NFSv4: Don't hold the layoutget locks across multiple RPC calls [+ + +]
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Sat May 14 10:08:14 2022 -0400

    NFSv4: Don't hold the layoutget locks across multiple RPC calls
    
    [ Upstream commit 6949493884fe88500de4af182588e071cf1544ee ]
    
    When doing layoutget as part of the open() compound, we have to be
    careful to release the layout locks before we can call any further RPC
    calls, such as setattr(). The reason is that those calls could trigger
    a recall, which could deadlock.
    
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nl80211: show SSID for P2P_GO interfaces [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Mar 18 13:46:57 2022 +0100

    nl80211: show SSID for P2P_GO interfaces
    
    [ Upstream commit a75971bc2b8453630e9f85e0beaa4da8db8277a3 ]
    
    There's no real reason not to send the SSID to userspace
    when it requests information about P2P_GO, it is, in that
    respect, exactly the same as AP interfaces. Fix that.
    
    Fixes: 44905265bc15 ("nl80211: don't expose wdev->ssid for most interfaces")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Link: https://lore.kernel.org/r/20220318134656.14354ae223f0.Ia25e85a512281b92e1645d4160766a4b1a471597@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nodemask.h: fix compilation error with GCC12 [+ + +]
Author: Christophe de Dinechin <dinechin@redhat.com>
Date:   Thu Apr 14 17:08:54 2022 +0200

    nodemask.h: fix compilation error with GCC12
    
    commit 37462a920392cb86541650a6f4121155f11f1199 upstream.
    
    With gcc version 12.0.1 20220401 (Red Hat 12.0.1-0), building with
    defconfig results in the following compilation error:
    
    |   CC      mm/swapfile.o
    | mm/swapfile.c: In function `setup_swap_info':
    | mm/swapfile.c:2291:47: error: array subscript -1 is below array bounds
    |  of `struct plist_node[]' [-Werror=array-bounds]
    |  2291 |                                 p->avail_lists[i].prio = 1;
    |       |                                 ~~~~~~~~~~~~~~^~~
    | In file included from mm/swapfile.c:16:
    | ./include/linux/swap.h:292:27: note: while referencing `avail_lists'
    |   292 |         struct plist_node avail_lists[]; /*
    |       |                           ^~~~~~~~~~~
    
    This is due to the compiler detecting that the mask in
    node_states[__state] could theoretically be zero, which would lead to
    first_node() returning -1 through find_first_bit.
    
    I believe that the warning/error is legitimate.  I first tried adding a
    test to check that the node mask is not emtpy, since a similar test exists
    in the case where MAX_NUMNODES == 1.
    
    However, adding the if statement causes other warnings to appear in
    for_each_cpu_node_but, because it introduces a dangling else ambiguity.
    And unfortunately, GCC is not smart enough to detect that the added test
    makes the case where (node) == -1 impossible, so it still complains with
    the same message.
    
    This is why I settled on replacing that with a harmless, but relatively
    useless (node) >= 0 test.  Based on the warning for the dangling else, I
    also decided to fix the case where MAX_NUMNODES == 1 by moving the
    condition inside the for loop.  It will still only be tested once.  This
    ensures that the meaning of an else following for_each_node_mask or
    derivatives would not silently have a different meaning depending on the
    configuration.
    
    Link: https://lkml.kernel.org/r/20220414150855.2407137-3-dinechin@redhat.com
    Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
    Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Ben Segall <bsegall@google.com>
    Cc: "Michael S. Tsirkin" <mst@redhat.com>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
    Cc: Vincent Guittot <vincent.guittot@linaro.org>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
    Cc: Jason Wang <jasowang@redhat.com>
    Cc: Zhen Lei <thunder.leizhen@huawei.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
nodemask: Fix return values to be unsigned [+ + +]
Author: Kees Cook <keescook@chromium.org>
Date:   Wed May 18 13:52:23 2022 -0700

    nodemask: Fix return values to be unsigned
    
    [ Upstream commit 0dfe54071d7c828a02917b595456bfde1afdddc9 ]
    
    The nodemask routines had mixed return values that provided potentially
    signed return values that could never happen. This was leading to the
    compiler getting confusing about the range of possible return values
    (it was thinking things could be negative where they could not be). Fix
    all the nodemask routines that should be returning unsigned
    (or bool) values. Silences:
    
     mm/swapfile.c: In function ‘setup_swap_info’:
     mm/swapfile.c:2291:47: error: array subscript -1 is below array bounds of ‘struct plist_node[]’ [-Werror=array-bounds]
      2291 |                                 p->avail_lists[i].prio = 1;
           |                                 ~~~~~~~~~~~~~~^~~
     In file included from mm/swapfile.c:16:
     ./include/linux/swap.h:292:27: note: while referencing ‘avail_lists’
       292 |         struct plist_node avail_lists[]; /*
           |                           ^~~~~~~~~~~
    
    Reported-by: Christophe de Dinechin <dinechin@redhat.com>
    Link: https://lore.kernel.org/lkml/20220414150855.2407137-3-dinechin@redhat.com/
    Cc: Alexey Dobriyan <adobriyan@gmail.com>
    Cc: Yury Norov <yury.norov@gmail.com>
    Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Zhen Lei <thunder.leizhen@huawei.com>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nvdimm: Allow overwrite in the presence of disabled dimms [+ + +]
Author: Dan Williams <dan.j.williams@intel.com>
Date:   Thu Apr 28 15:47:46 2022 -0700

    nvdimm: Allow overwrite in the presence of disabled dimms
    
    [ Upstream commit bb7bf697fed58eae9d3445944e457ab0de4da54f ]
    
    It is not clear why the original implementation of overwrite support
    required the dimm driver to be active before overwrite could proceed. In
    fact that can lead to cases where the kernel retains an invalid cached
    copy of the labels from before the overwrite. Unfortunately the kernel
    has not only allowed that case, but enforced it.
    
    Going forward, allow for overwrite to happen while the label area is
    offline, and follow-on with updates to 'ndctl sanitize-dimm --overwrite'
    to trigger the label area invalidation by default.
    
    Cc: Vishal Verma <vishal.l.verma@intel.com>
    Cc: Dave Jiang <dave.jiang@intel.com>
    Cc: Ira Weiny <ira.weiny@intel.com>
    Cc: Jeff Moyer <jmoyer@redhat.com>
    Reported-by: Krzysztof Kensicki <krzysztof.kensicki@intel.com>
    Fixes: 7d988097c546 ("acpi/nfit, libnvdimm/security: Add security DSM overwrite support")
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
nvme-pci: fix a NULL pointer dereference in nvme_alloc_admin_tags [+ + +]
Author: Smith, Kyle Miller (Nimble Kernel) <kyles@hpe.com>
Date:   Fri Apr 22 14:40:32 2022 +0000

    nvme-pci: fix a NULL pointer dereference in nvme_alloc_admin_tags
    
    [ Upstream commit da42761181627e9bdc37d18368b827948a583929 ]
    
    In nvme_alloc_admin_tags, the admin_q can be set to an error (typically
    -ENOMEM) if the blk_mq_init_queue call fails to set up the queue, which
    is checked immediately after the call. However, when we return the error
    message up the stack, to nvme_reset_work the error takes us to
    nvme_remove_dead_ctrl()
      nvme_dev_disable()
       nvme_suspend_queue(&dev->queues[0]).
    
    Here, we only check that the admin_q is non-NULL, rather than not
    an error or NULL, and begin quiescing a queue that never existed, leading
    to bad / NULL pointer dereference.
    
    Signed-off-by: Kyle Smith <kyles@hpe.com>
    Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ocfs2: dlmfs: fix error handling of user_dlm_destroy_lock [+ + +]
Author: Junxiao Bi via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
Date:   Wed May 18 16:52:24 2022 -0700

    ocfs2: dlmfs: fix error handling of user_dlm_destroy_lock
    
    commit 863e0d81b6683c4cbc588ad831f560c90e494bef upstream.
    
    When user_dlm_destroy_lock failed, it didn't clean up the flags it set
    before exit.  For USER_LOCK_IN_TEARDOWN, if this function fails because of
    lock is still in used, next time when unlink invokes this function, it
    will return succeed, and then unlink will remove inode and dentry if lock
    is not in used(file closed), but the dlm lock is still linked in dlm lock
    resource, then when bast come in, it will trigger a panic due to
    user-after-free.  See the following panic call trace.  To fix this,
    USER_LOCK_IN_TEARDOWN should be reverted if fail.  And also error should
    be returned if USER_LOCK_IN_TEARDOWN is set to let user know that unlink
    fail.
    
    For the case of ocfs2_dlm_unlock failure, besides USER_LOCK_IN_TEARDOWN,
    USER_LOCK_BUSY is also required to be cleared.  Even though spin lock is
    released in between, but USER_LOCK_IN_TEARDOWN is still set, for
    USER_LOCK_BUSY, if before every place that waits on this flag,
    USER_LOCK_IN_TEARDOWN is checked to bail out, that will make sure no flow
    waits on the busy flag set by user_dlm_destroy_lock(), then we can
    simplely revert USER_LOCK_BUSY when ocfs2_dlm_unlock fails.  Fix
    user_dlm_cluster_lock() which is the only function not following this.
    
    [  941.336392] (python,26174,16):dlmfs_unlink:562 ERROR: unlink
    004fb0000060000b5a90b8c847b72e1, error -16 from destroy
    [  989.757536] ------------[ cut here ]------------
    [  989.757709] kernel BUG at fs/ocfs2/dlmfs/userdlm.c:173!
    [  989.757876] invalid opcode: 0000 [#1] SMP
    [  989.758027] Modules linked in: ksplice_2zhuk2jr_ib_ipoib_new(O)
    ksplice_2zhuk2jr(O) mptctl mptbase xen_netback xen_blkback xen_gntalloc
    xen_gntdev xen_evtchn cdc_ether usbnet mii ocfs2 jbd2 rpcsec_gss_krb5
    auth_rpcgss nfsv4 nfsv3 nfs_acl nfs fscache lockd grace ocfs2_dlmfs
    ocfs2_stack_o2cb ocfs2_dlm ocfs2_nodemanager ocfs2_stackglue configfs bnx2fc
    fcoe libfcoe libfc scsi_transport_fc sunrpc ipmi_devintf bridge stp llc
    rds_rdma rds bonding ib_sdp ib_ipoib rdma_ucm ib_ucm ib_uverbs ib_umad
    rdma_cm ib_cm iw_cm falcon_lsm_serviceable(PE) falcon_nf_netcontain(PE)
    mlx4_vnic falcon_kal(E) falcon_lsm_pinned_13402(E) mlx4_ib ib_sa ib_mad
    ib_core ib_addr xenfs xen_privcmd dm_multipath iTCO_wdt iTCO_vendor_support
    pcspkr sb_edac edac_core i2c_i801 lpc_ich mfd_core ipmi_ssif i2c_core ipmi_si
    ipmi_msghandler
    [  989.760686]  ioatdma sg ext3 jbd mbcache sd_mod ahci libahci ixgbe dca ptp
    pps_core vxlan udp_tunnel ip6_udp_tunnel megaraid_sas mlx4_core crc32c_intel
    be2iscsi bnx2i cnic uio cxgb4i cxgb4 cxgb3i libcxgbi ipv6 cxgb3 mdio
    libiscsi_tcp qla4xxx iscsi_boot_sysfs libiscsi scsi_transport_iscsi wmi
    dm_mirror dm_region_hash dm_log dm_mod [last unloaded:
    ksplice_2zhuk2jr_ib_ipoib_old]
    [  989.761987] CPU: 10 PID: 19102 Comm: dlm_thread Tainted: P           OE
    4.1.12-124.57.1.el6uek.x86_64 #2
    [  989.762290] Hardware name: Oracle Corporation ORACLE SERVER
    X5-2/ASM,MOTHERBOARD,1U, BIOS 30350100 06/17/2021
    [  989.762599] task: ffff880178af6200 ti: ffff88017f7c8000 task.ti:
    ffff88017f7c8000
    [  989.762848] RIP: e030:[<ffffffffc07d4316>]  [<ffffffffc07d4316>]
    __user_dlm_queue_lockres.part.4+0x76/0x80 [ocfs2_dlmfs]
    [  989.763185] RSP: e02b:ffff88017f7cbcb8  EFLAGS: 00010246
    [  989.763353] RAX: 0000000000000000 RBX: ffff880174d48008 RCX:
    0000000000000003
    [  989.763565] RDX: 0000000000120012 RSI: 0000000000000003 RDI:
    ffff880174d48170
    [  989.763778] RBP: ffff88017f7cbcc8 R08: ffff88021f4293b0 R09:
    0000000000000000
    [  989.763991] R10: ffff880179c8c000 R11: 0000000000000003 R12:
    ffff880174d48008
    [  989.764204] R13: 0000000000000003 R14: ffff880179c8c000 R15:
    ffff88021db7a000
    [  989.764422] FS:  0000000000000000(0000) GS:ffff880247480000(0000)
    knlGS:ffff880247480000
    [  989.764685] CS:  e033 DS: 0000 ES: 0000 CR0: 0000000080050033
    [  989.764865] CR2: ffff8000007f6800 CR3: 0000000001ae0000 CR4:
    0000000000042660
    [  989.765081] Stack:
    [  989.765167]  0000000000000003 ffff880174d48040 ffff88017f7cbd18
    ffffffffc07d455f
    [  989.765442]  ffff88017f7cbd88 ffffffff816fb639 ffff88017f7cbd38
    ffff8800361b5600
    [  989.765717]  ffff88021db7a000 ffff88021f429380 0000000000000003
    ffffffffc0453020
    [  989.765991] Call Trace:
    [  989.766093]  [<ffffffffc07d455f>] user_bast+0x5f/0xf0 [ocfs2_dlmfs]
    [  989.766287]  [<ffffffff816fb639>] ? schedule_timeout+0x169/0x2d0
    [  989.766475]  [<ffffffffc0453020>] ? o2dlm_lock_ast_wrapper+0x20/0x20
    [ocfs2_stack_o2cb]
    [  989.766738]  [<ffffffffc045303a>] o2dlm_blocking_ast_wrapper+0x1a/0x20
    [ocfs2_stack_o2cb]
    [  989.767010]  [<ffffffffc0864ec6>] dlm_do_local_bast+0x46/0xe0 [ocfs2_dlm]
    [  989.767217]  [<ffffffffc084f5cc>] ? dlm_lockres_calc_usage+0x4c/0x60
    [ocfs2_dlm]
    [  989.767466]  [<ffffffffc08501f1>] dlm_thread+0xa31/0x1140 [ocfs2_dlm]
    [  989.767662]  [<ffffffff816f78da>] ? __schedule+0x24a/0x810
    [  989.767834]  [<ffffffff816f78ce>] ? __schedule+0x23e/0x810
    [  989.768006]  [<ffffffff816f78da>] ? __schedule+0x24a/0x810
    [  989.768178]  [<ffffffff816f78ce>] ? __schedule+0x23e/0x810
    [  989.768349]  [<ffffffff816f78da>] ? __schedule+0x24a/0x810
    [  989.768521]  [<ffffffff816f78ce>] ? __schedule+0x23e/0x810
    [  989.768693]  [<ffffffff816f78da>] ? __schedule+0x24a/0x810
    [  989.768893]  [<ffffffff816f78ce>] ? __schedule+0x23e/0x810
    [  989.769067]  [<ffffffff816f78da>] ? __schedule+0x24a/0x810
    [  989.769241]  [<ffffffff810ce4d0>] ? wait_woken+0x90/0x90
    [  989.769411]  [<ffffffffc084f7c0>] ? dlm_kick_thread+0x80/0x80 [ocfs2_dlm]
    [  989.769617]  [<ffffffff810a8bbb>] kthread+0xcb/0xf0
    [  989.769774]  [<ffffffff816f78da>] ? __schedule+0x24a/0x810
    [  989.769945]  [<ffffffff816f78da>] ? __schedule+0x24a/0x810
    [  989.770117]  [<ffffffff810a8af0>] ? kthread_create_on_node+0x180/0x180
    [  989.770321]  [<ffffffff816fdaa1>] ret_from_fork+0x61/0x90
    [  989.770492]  [<ffffffff810a8af0>] ? kthread_create_on_node+0x180/0x180
    [  989.770689] Code: d0 00 00 00 f0 45 7d c0 bf 00 20 00 00 48 89 83 c0 00 00
    00 48 89 83 c8 00 00 00 e8 55 c1 8c c0 83 4b 04 10 48 83 c4 08 5b 5d c3 <0f>
    0b 0f 1f 84 00 00 00 00 00 55 48 89 e5 41 55 41 54 53 48 83
    [  989.771892] RIP  [<ffffffffc07d4316>]
    __user_dlm_queue_lockres.part.4+0x76/0x80 [ocfs2_dlmfs]
    [  989.772174]  RSP <ffff88017f7cbcb8>
    [  989.772704] ---[ end trace ebd1e38cebcc93a8 ]---
    [  989.772907] Kernel panic - not syncing: Fatal exception
    [  989.773173] Kernel Offset: disabled
    
    Link: https://lkml.kernel.org/r/20220518235224.87100-2-junxiao.bi@oracle.com
    Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
    Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
    Cc: Mark Fasheh <mark@fasheh.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Joseph Qi <jiangqi903@gmail.com>
    Cc: Changwei Ge <gechangwei@live.cn>
    Cc: Gang He <ghe@suse.com>
    Cc: Jun Piao <piaojun@huawei.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
of: overlay: do not break notify on NOTIFY_{OK|STOP} [+ + +]
Author: Nuno Sá <nuno.sa@analog.com>
Date:   Wed Apr 20 15:02:05 2022 +0200

    of: overlay: do not break notify on NOTIFY_{OK|STOP}
    
    [ Upstream commit 5f756a2eaa4436d7d3dc1e040147f5e992ae34b5 ]
    
    We should not break overlay notifications on NOTIFY_{OK|STOP}
    otherwise we might break on the first fragment. We should only stop
    notifications if a *real* errno is returned by one of the listeners.
    
    Fixes: a1d19bd4cf1fe ("of: overlay: pr_err from return NOTIFY_OK to overlay apply/remove")
    Signed-off-by: Nuno Sá <nuno.sa@analog.com>
    Signed-off-by: Rob Herring <robh@kernel.org>
    Link: https://lore.kernel.org/r/20220420130205.89435-1-nuno.sa@analog.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
openrisc: start CPU timer early in boot [+ + +]
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Sat Apr 23 21:11:41 2022 +0200

    openrisc: start CPU timer early in boot
    
    [ Upstream commit 516dd4aacd67a0f27da94f3fe63fe0f4dbab6e2b ]
    
    In order to measure the boot process, the timer should be switched on as
    early in boot as possible. As well, the commit defines the get_cycles
    macro, like the previous patches in this series, so that generic code is
    aware that it's implemented by the platform, as is done on other archs.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Jonas Bonn <jonas@southpole.se>
    Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
    Acked-by: Stafford Horne <shorne@gmail.com>
    Reported-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
PCI/PM: Fix bridge_d3_blacklist[] Elo i2 overwrite of Gigabyte X299 [+ + +]
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Thu May 26 16:52:23 2022 -0500

    PCI/PM: Fix bridge_d3_blacklist[] Elo i2 overwrite of Gigabyte X299
    
    commit 12068bb346db5776d0ec9bb4cd073f8427a1ac92 upstream.
    
    92597f97a40b ("PCI/PM: Avoid putting Elo i2 PCIe Ports in D3cold") omitted
    braces around the new Elo i2 entry, so it overwrote the existing Gigabyte
    X299 entry.  Add the appropriate braces.
    
    Found by:
    
      $ make W=1 drivers/pci/pci.o
        CC      drivers/pci/pci.o
      drivers/pci/pci.c:2974:12: error: initialized field overwritten [-Werror=override-init]
       2974 |   .ident = "Elo i2",
            |            ^~~~~~~~
    
    Link: https://lore.kernel.org/r/20220526221258.GA409855@bhelgaas
    Fixes: 92597f97a40b ("PCI/PM: Avoid putting Elo i2 PCIe Ports in D3cold")
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org  # v5.15+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
PCI: Avoid pci_dev_lock() AB/BA deadlock with sriov_numvfs_store() [+ + +]
Author: Yicong Yang <yangyicong@hisilicon.com>
Date:   Mon Apr 4 14:25:39 2022 +0800

    PCI: Avoid pci_dev_lock() AB/BA deadlock with sriov_numvfs_store()
    
    [ Upstream commit a91ee0e9fca9d7501286cfbced9b30a33e52740a ]
    
    The sysfs sriov_numvfs_store() path acquires the device lock before the
    config space access lock:
    
      sriov_numvfs_store
        device_lock                 # A (1) acquire device lock
        sriov_configure
          vfio_pci_sriov_configure  # (for example)
            vfio_pci_core_sriov_configure
              pci_disable_sriov
                sriov_disable
                  pci_cfg_access_lock
                    pci_wait_cfg    # B (4) wait for dev->block_cfg_access == 0
    
    Previously, pci_dev_lock() acquired the config space access lock before the
    device lock:
    
      pci_dev_lock
        pci_cfg_access_lock
          dev->block_cfg_access = 1 # B (2) set dev->block_cfg_access = 1
        device_lock                 # A (3) wait for device lock
    
    Any path that uses pci_dev_lock(), e.g., pci_reset_function(), may
    deadlock with sriov_numvfs_store() if the operations occur in the sequence
    (1) (2) (3) (4).
    
    Avoid the deadlock by reversing the order in pci_dev_lock() so it acquires
    the device lock before the config space access lock, the same as the
    sriov_numvfs_store() path.
    
    [bhelgaas: combined and adapted commit log from Jay Zhou's independent
    subsequent posting:
    https://lore.kernel.org/r/20220404062539.1710-1-jianjay.zhou@huawei.com]
    Link: https://lore.kernel.org/linux-pci/1583489997-17156-1-git-send-email-yangyicong@hisilicon.com/
    Also-posted-by: Jay Zhou <jianjay.zhou@huawei.com>
    Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: cadence: Fix find_first_zero_bit() limit [+ + +]
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Mar 15 09:58:29 2022 +0300

    PCI: cadence: Fix find_first_zero_bit() limit
    
    [ Upstream commit 0aa3a0937feeb91a0e4e438c3c063b749b194192 ]
    
    The ep->ob_region_map bitmap is a long and it has BITS_PER_LONG bits.
    
    Link: https://lore.kernel.org/r/20220315065829.GA13572@kili
    Fixes: 37dddf14f1ae ("PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: imx6: Fix PERST# start-up sequence [+ + +]
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Mon Apr 4 10:15:09 2022 +0200

    PCI: imx6: Fix PERST# start-up sequence
    
    [ Upstream commit a6809941c1f17f455db2cf4ca19c6d8c8746ec25 ]
    
    According to the PCIe standard the PERST# signal (reset-gpio in
    fsl,imx* compatible dts) should be kept asserted for at least 100 usec
    before the PCIe refclock is stable, should be kept asserted for at
    least 100 msec after the power rails are stable and the host should wait
    at least 100 msec after it is de-asserted before accessing the
    configuration space of any attached device.
    
    From PCIe CEM r2.0, sec 2.6.2
    
      T-PVPERL: Power stable to PERST# inactive - 100 msec
      T-PERST-CLK: REFCLK stable before PERST# inactive - 100 usec.
    
    From PCIe r5.0, sec 6.6.1
    
      With a Downstream Port that does not support Link speeds greater than
      5.0 GT/s, software must wait a minimum of 100 ms before sending a
      Configuration Request to the device immediately below that Port.
    
    Failure to do so could prevent PCIe devices to be working correctly,
    and this was experienced with real devices.
    
    Move reset assert to imx6_pcie_assert_core_reset(), this way we ensure
    that PERST# is asserted before enabling any clock, move de-assert to the
    end of imx6_pcie_deassert_core_reset() after the clock is enabled and
    deemed stable and add a new delay of 100 msec just afterward.
    
    Link: https://lore.kernel.org/all/20220211152550.286821-1-francesco.dolcini@toradex.com
    Link: https://lore.kernel.org/r/20220404081509.94356-1-francesco.dolcini@toradex.com
    Fixes: bb38919ec56e ("PCI: imx6: Add support for i.MX6 PCIe controller")
    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
    Acked-by: Richard Zhu <hongxing.zhu@nxp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

PCI: qcom: Fix runtime PM imbalance on probe errors [+ + +]
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Fri Apr 1 15:38:53 2022 +0200

    PCI: qcom: Fix runtime PM imbalance on probe errors
    
    commit 87d83b96c8d6c6c2d2096bd0bdba73bcf42b8ef0 upstream.
    
    Drop the leftover pm_runtime_disable() calls from the late probe error
    paths that would, for example, prevent runtime PM from being reenabled
    after a probe deferral.
    
    Link: https://lore.kernel.org/r/20220401133854.10421-2-johan+linaro@kernel.org
    Fixes: 6e5da6f7d824 ("PCI: qcom: Fix error handling in runtime PM support")
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Acked-by: Stanimir Varbanov <svarbanov@mm-sol.com>
    Cc: stable@vger.kernel.org      # 4.20
    Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

PCI: qcom: Fix unbalanced PHY init on probe errors [+ + +]
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Fri Apr 1 15:38:54 2022 +0200

    PCI: qcom: Fix unbalanced PHY init on probe errors
    
    commit 83013631f0f9961416abd812e228c8efbc2f6069 upstream.
    
    Undo the PHY initialisation (e.g. balance runtime PM) if host
    initialisation fails during probe.
    
    Link: https://lore.kernel.org/r/20220401133854.10421-3-johan+linaro@kernel.org
    Fixes: 82a823833f4e ("PCI: qcom: Add Qualcomm PCIe controller driver")
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Acked-by: Stanimir Varbanov <svarbanov@mm-sol.com>
    Cc: stable@vger.kernel.org      # 4.5
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

PCI: rockchip: Fix find_first_zero_bit() limit [+ + +]
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Mar 15 09:59:44 2022 +0300

    PCI: rockchip: Fix find_first_zero_bit() limit
    
    [ Upstream commit 096950e230b8d83645c7cf408b9f399f58c08b96 ]
    
    The ep->ob_region_map bitmap is a long and it has BITS_PER_LONG bits.
    
    Link: https://lore.kernel.org/r/20220315065944.GB13572@kili
    Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
pcmcia: db1xxx_ss: restrict to MIPS_DB1XXX boards [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Sun Jan 23 09:40:31 2022 -0800

    pcmcia: db1xxx_ss: restrict to MIPS_DB1XXX boards
    
    [ Upstream commit 3928cf08334ed895a31458cbebd8d4ec6d84c080 ]
    
    When the MIPS_ALCHEMY board selection is MIPS_XXS1500 instead of
    MIPS_DB1XXX, the PCMCIA driver 'db1xxx_ss' has build errors due
    to missing DB1XXX symbols. The PCMCIA driver should be restricted
    to MIPS_DB1XXX instead of MIPS_ALCHEMY to fix this build error.
    
    ERROR: modpost: "bcsr_read" [drivers/pcmcia/db1xxx_ss.ko] undefined!
    ERROR: modpost: "bcsr_mod" [drivers/pcmcia/db1xxx_ss.ko] undefined!
    
    Fixes: 42a4f17dc356 ("MIPS: Alchemy: remove SOC_AU1X00 in favor of MIPS_ALCHEMY")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Reported-by: kernel test robot <lkp@intel.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Cc: linux-mips@vger.kernel.org
    Acked-by: Manuel Lauss <manuel.lauss@gmail.com>
    Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf c2c: Fix sorting in percent_rmt_hitm_cmp() [+ + +]
Author: Leo Yan <leo.yan@linaro.org>
Date:   Mon May 30 16:42:53 2022 +0800

    perf c2c: Fix sorting in percent_rmt_hitm_cmp()
    
    [ Upstream commit b24192a17337abbf3f44aaa75e15df14a2d0016e ]
    
    The function percent_rmt_hitm_cmp() wrongly uses local HITMs for
    sorting remote HITMs.
    
    Since this function is to sort cache lines for remote HITMs, this patch
    changes to use 'rmt_hitm' field for correct sorting.
    
    Fixes: 9cb3500afc0980c5 ("perf c2c report: Add hitm/store percent related sort keys")
    Signed-off-by: Leo Yan <leo.yan@linaro.org>
    Acked-by: Namhyung Kim <namhyung@kernel.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Joe Mario <jmario@redhat.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: https://lore.kernel.org/r/20220530084253.750190-1-leo.yan@linaro.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

perf c2c: Use stdio interface if slang is not supported [+ + +]
Author: Leo Yan <leo.yan@linaro.org>
Date:   Thu May 26 22:54:00 2022 +0800

    perf c2c: Use stdio interface if slang is not supported
    
    [ Upstream commit c4040212bc97d16040712a410335f93bc94d2262 ]
    
    If the slang lib is not installed on the system, perf c2c tool disables TUI
    mode and roll back to use stdio mode;  but the flag 'c2c.use_stdio' is
    missed to set true and thus it wrongly applies UI quirks in the function
    ui_quirks().
    
    This commit forces to use stdio interface if slang is not supported, and
    it can avoid to apply the UI quirks and show the correct metric header.
    
    Before:
    
    =================================================
          Shared Cache Line Distribution Pareto
    =================================================
      -------------------------------------------------------------------------------
          0        0        0       99        0        0        0      0xaaaac17d6000
      -------------------------------------------------------------------------------
        0.00%    0.00%    6.06%    0.00%    0.00%    0.00%   0x20   N/A       0      0xaaaac17c25ac         0         0        43       375    18469         2  [.] 0x00000000000025ac  memstress         memstress[25ac]   0
        0.00%    0.00%   93.94%    0.00%    0.00%    0.00%   0x29   N/A       0      0xaaaac17c3e88         0         0       173       180      135         2  [.] 0x0000000000003e88  memstress         memstress[3e88]   0
    
    After:
    
    =================================================
          Shared Cache Line Distribution Pareto
    =================================================
      -------------------------------------------------------------------------------
          0        0        0       99        0        0        0      0xaaaac17d6000
      -------------------------------------------------------------------------------
               0.00%    0.00%    6.06%    0.00%    0.00%    0.00%                0x20   N/A       0      0xaaaac17c25ac         0         0        43       375    18469         2  [.] 0x00000000000025ac  memstress         memstress[25ac]   0
               0.00%    0.00%   93.94%    0.00%    0.00%    0.00%                0x29   N/A       0      0xaaaac17c3e88         0         0       173       180      135         2  [.] 0x0000000000003e88  memstress         memstress[3e88]   0
    
    Fixes: 5a1a99cd2e4e1557 ("perf c2c report: Add main TUI browser")
    Reported-by: Joe Mario <jmario@redhat.com>
    Signed-off-by: Leo Yan <leo.yan@linaro.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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>
    Link: http://lore.kernel.org/lkml/20220526145400.611249-1-leo.yan@linaro.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf jevents: Fix event syntax error caused by ExtSel [+ + +]
Author: Zhengjun Xing <zhengjun.xing@linux.intel.com>
Date:   Wed May 25 22:04:10 2022 +0800

    perf jevents: Fix event syntax error caused by ExtSel
    
    [ Upstream commit f4df0dbbe62ee8e4405a57b27ccd54393971c773 ]
    
    In the origin code, when "ExtSel" is 1, the eventcode will change to
    "eventcode |= 1 << 21”. For event “UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS",
    its "ExtSel" is "1", its eventcode will change from 0x1E to 0x20001E,
    but in fact the eventcode should <=0x1FF, so this will cause the parse
    fail:
    
      # perf stat -e "UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS" -a sleep 0.1
      event syntax error: '.._RxL_CREDITS_CONSUMED_VN0.DRS'
                                        \___ value too big for format, maximum is 511
    
    On the perf kernel side, the kernel assumes the valid bits are continuous.
    It will adjust the 0x100 (bit 8 for perf tool) to bit 21 in HW.
    
    DEFINE_UNCORE_FORMAT_ATTR(event_ext, event, "config:0-7,21");
    
    So the perf tool follows the kernel side and just set bit8 other than bit21.
    
    Fixes: fedb2b518239cbc0 ("perf jevents: Add support for parsing uncore json files")
    Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
    Signed-off-by: Xing Zhengjun <zhengjun.xing@linux.intel.com>
    Acked-by: Ian Rogers <irogers@google.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: https://lore.kernel.org/r/20220525140410.1706851-1-zhengjun.xing@linux.intel.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf tools: Add missing headers needed by util/data.h [+ + +]
Author: Yang Jihong <yangjihong1@huawei.com>
Date:   Fri Apr 29 17:05:39 2022 +0800

    perf tools: Add missing headers needed by util/data.h
    
    [ Upstream commit 4d27cf1d9de5becfa4d1efb2ea54dba1b9fc962a ]
    
    'struct perf_data' in util/data.h uses the "u64" data type, which is
    defined in "linux/types.h".
    
    If we only include util/data.h, the following compilation error occurs:
    
      util/data.h:38:3: error: unknown type name ‘u64’
         u64    version;
         ^~~
    
    Solution: include "linux/types.h." to add the needed type definitions.
    
    Fixes: 258031c017c353e8 ("perf header: Add DIR_FORMAT feature to describe directory data")
    Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@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>
    Link: https://lore.kernel.org/r/20220429090539.212448-1-yangjihong1@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf/amd/ibs: Use interrupt regs ip for stack unwinding [+ + +]
Author: Ravi Bangoria <ravi.bangoria@amd.com>
Date:   Fri Apr 29 10:44:41 2022 +0530

    perf/amd/ibs: Use interrupt regs ip for stack unwinding
    
    [ Upstream commit 3d47083b9ff46863e8374ad3bb5edb5e464c75f8 ]
    
    IbsOpRip is recorded when IBS interrupt is triggered. But there is
    a skid from the time IBS interrupt gets triggered to the time the
    interrupt is presented to the core. Meanwhile processor would have
    moved ahead and thus IbsOpRip will be inconsistent with rsp and rbp
    recorded as part of the interrupt regs. This causes issues while
    unwinding stack using the ORC unwinder as it needs consistent rip,
    rsp and rbp. Fix this by using rip from interrupt regs instead of
    IbsOpRip for stack unwinding.
    
    Fixes: ee9f8fce99640 ("x86/unwind: Add the ORC unwinder")
    Reported-by: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
    Suggested-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20220429051441.14251-1-ravi.bangoria@amd.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
perf/x86/intel: Fix event constraints for ICL [+ + +]
Author: Kan Liang <kan.liang@linux.intel.com>
Date:   Wed May 25 06:39:52 2022 -0700

    perf/x86/intel: Fix event constraints for ICL
    
    commit 86dca369075b3e310c3c0adb0f81e513c562b5e4 upstream.
    
    According to the latest event list, the event encoding 0x55
    INST_DECODED.DECODERS and 0x56 UOPS_DECODED.DEC0 are only available on
    the first 4 counters. Add them into the event constraints table.
    
    Fixes: 6017608936c1 ("perf/x86/intel: Add Icelake support")
    Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20220525133952.1660658-1-kan.liang@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
phy: qcom-qmp: fix pipe-clock imbalance on power-on failure [+ + +]
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Mon May 2 15:31:29 2022 +0200

    phy: qcom-qmp: fix pipe-clock imbalance on power-on failure
    
    [ Upstream commit 5e73b2d9867998278479ccc065a8a8227a5513ef ]
    
    Make sure to disable the pipe clock also if ufs-reset deassertion fails
    during power on.
    
    Note that the ufs-reset is asserted in qcom_qmp_phy_com_exit().
    
    Fixes: c9b589791fc1 ("phy: qcom: Utilize UFS reset controller")
    Cc: Evan Green <evgreen@chromium.org>
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Link: https://lore.kernel.org/r/20220502133130.4125-2-johan+linaro@kernel.org
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

phy: qcom-qmp: fix reset-controller leak on probe errors [+ + +]
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Wed Apr 27 08:32:42 2022 +0200

    phy: qcom-qmp: fix reset-controller leak on probe errors
    
    commit 4d2900f20edfe541f75756a00deeb2ffe7c66bc1 upstream.
    
    Make sure to release the lane reset controller in case of a late probe
    error (e.g. probe deferral).
    
    Note that due to the reset controller being defined in devicetree in
    "lane" child nodes, devm_reset_control_get_exclusive() cannot be used
    directly.
    
    Fixes: e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets")
    Cc: stable@vger.kernel.org      # 4.12
    Cc: Vivek Gautam <vivek.gautam@codeaurora.org>
    Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220427063243.32576-3-johan+linaro@kernel.org
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

phy: qcom-qmp: fix struct clk leak on probe errors [+ + +]
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Wed Apr 27 08:32:41 2022 +0200

    phy: qcom-qmp: fix struct clk leak on probe errors
    
    commit f0a4bc38a12f5a0cc5ad68670d9480e91e6a94df upstream.
    
    Make sure to release the pipe clock reference in case of a late probe
    error (e.g. probe deferral).
    
    Fixes: e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets")
    Cc: stable@vger.kernel.org      # 4.12
    Cc: Vivek Gautam <vivek.gautam@codeaurora.org>
    Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Link: https://lore.kernel.org/r/20220427063243.32576-2-johan+linaro@kernel.org
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
pinctrl: mvebu: Fix irq_of_parse_and_map() return value [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Fri Apr 22 12:53:38 2022 +0200

    pinctrl: mvebu: Fix irq_of_parse_and_map() return value
    
    [ Upstream commit 71bc7cf3be65bab441e03667cf215c557712976c ]
    
    The irq_of_parse_and_map() returns 0 on failure, not a negative ERRNO.
    
    Fixes: 2f227605394b ("pinctrl: armada-37xx: Add irqchip support")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Link: https://lore.kernel.org/r/20220422105339.78810-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
PM / devfreq: rk3399_dmc: Disable edev on remove() [+ + +]
Author: Brian Norris <briannorris@chromium.org>
Date:   Tue Mar 8 11:08:59 2022 -0800

    PM / devfreq: rk3399_dmc: Disable edev on remove()
    
    [ Upstream commit 2fccf9e6050e0e3b8b4cd275d41daf7f7fa22804 ]
    
    Otherwise we hit an unablanced enable-count when unbinding the DFI
    device:
    
    [ 1279.659119] ------------[ cut here ]------------
    [ 1279.659179] WARNING: CPU: 2 PID: 5638 at drivers/devfreq/devfreq-event.c:360 devfreq_event_remove_edev+0x84/0x8c
    ...
    [ 1279.659352] Hardware name: Google Kevin (DT)
    [ 1279.659363] pstate: 80400005 (Nzcv daif +PAN -UAO -TCO BTYPE=--)
    [ 1279.659371] pc : devfreq_event_remove_edev+0x84/0x8c
    [ 1279.659380] lr : devm_devfreq_event_release+0x1c/0x28
    ...
    [ 1279.659571] Call trace:
    [ 1279.659582]  devfreq_event_remove_edev+0x84/0x8c
    [ 1279.659590]  devm_devfreq_event_release+0x1c/0x28
    [ 1279.659602]  release_nodes+0x1cc/0x244
    [ 1279.659611]  devres_release_all+0x44/0x60
    [ 1279.659621]  device_release_driver_internal+0x11c/0x1ac
    [ 1279.659629]  device_driver_detach+0x20/0x2c
    [ 1279.659641]  unbind_store+0x7c/0xb0
    [ 1279.659650]  drv_attr_store+0x2c/0x40
    [ 1279.659663]  sysfs_kf_write+0x44/0x58
    [ 1279.659672]  kernfs_fop_write_iter+0xf4/0x190
    [ 1279.659684]  vfs_write+0x2b0/0x2e4
    [ 1279.659693]  ksys_write+0x80/0xec
    [ 1279.659701]  __arm64_sys_write+0x24/0x30
    [ 1279.659714]  el0_svc_common+0xf0/0x1d8
    [ 1279.659724]  do_el0_svc_compat+0x28/0x3c
    [ 1279.659738]  el0_svc_compat+0x10/0x1c
    [ 1279.659746]  el0_sync_compat_handler+0xa8/0xcc
    [ 1279.659758]  el0_sync_compat+0x188/0x1c0
    [ 1279.659768] ---[ end trace cec200e5094155b4 ]---
    
    Signed-off-by: Brian Norris <briannorris@chromium.org>
    Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/32: Fix overread/overwrite of thread_struct via ptrace [+ + +]
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Tue Jun 7 00:34:56 2022 +1000

    powerpc/32: Fix overread/overwrite of thread_struct via ptrace
    
    commit 8e1278444446fc97778a5e5c99bca1ce0bbc5ec9 upstream.
    
    The ptrace PEEKUSR/POKEUSR (aka PEEKUSER/POKEUSER) API allows a process
    to read/write registers of another process.
    
    To get/set a register, the API takes an index into an imaginary address
    space called the "USER area", where the registers of the process are
    laid out in some fashion.
    
    The kernel then maps that index to a particular register in its own data
    structures and gets/sets the value.
    
    The API only allows a single machine-word to be read/written at a time.
    So 4 bytes on 32-bit kernels and 8 bytes on 64-bit kernels.
    
    The way floating point registers (FPRs) are addressed is somewhat
    complicated, because double precision float values are 64-bit even on
    32-bit CPUs. That means on 32-bit kernels each FPR occupies two
    word-sized locations in the USER area. On 64-bit kernels each FPR
    occupies one word-sized location in the USER area.
    
    Internally the kernel stores the FPRs in an array of u64s, or if VSX is
    enabled, an array of pairs of u64s where one half of each pair stores
    the FPR. Which half of the pair stores the FPR depends on the kernel's
    endianness.
    
    To handle the different layouts of the FPRs depending on VSX/no-VSX and
    big/little endian, the TS_FPR() macro was introduced.
    
    Unfortunately the TS_FPR() macro does not take into account the fact
    that the addressing of each FPR differs between 32-bit and 64-bit
    kernels. It just takes the index into the "USER area" passed from
    userspace and indexes into the fp_state.fpr array.
    
    On 32-bit there are 64 indexes that address FPRs, but only 32 entries in
    the fp_state.fpr array, meaning the user can read/write 256 bytes past
    the end of the array. Because the fp_state sits in the middle of the
    thread_struct there are various fields than can be overwritten,
    including some pointers. As such it may be exploitable.
    
    It has also been observed to cause systems to hang or otherwise
    misbehave when using gdbserver, and is probably the root cause of this
    report which could not be easily reproduced:
      https://lore.kernel.org/linuxppc-dev/dc38afe9-6b78-f3f5-666b-986939e40fc6@keymile.com/
    
    Rather than trying to make the TS_FPR() macro even more complicated to
    fix the bug, or add more macros, instead add a special-case for 32-bit
    kernels. This is more obvious and hopefully avoids a similar bug
    happening again in future.
    
    Note that because 32-bit kernels never have VSX enabled the code doesn't
    need to consider TS_FPRWIDTH/OFFSET at all. Add a BUILD_BUG_ON() to
    ensure that 32-bit && VSX is never enabled.
    
    Fixes: 87fec0514f61 ("powerpc: PTRACE_PEEKUSR/PTRACE_POKEUSER of FPR registers in little endian builds")
    Cc: stable@vger.kernel.org # v3.13+
    Reported-by: Ariel Miculas <ariel.miculas@belden.com>
    Tested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220609133245.573565-1-mpe@ellerman.id.au
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
powerpc/4xx/cpm: Fix return value of __setup() handler [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Mon May 2 12:29:41 2022 -0700

    powerpc/4xx/cpm: Fix return value of __setup() handler
    
    [ Upstream commit 5bb99fd4090fe1acfdb90a97993fcda7f8f5a3d6 ]
    
    __setup() handlers should return 1 to obsolete_checksetup() in
    init/main.c to indicate that the boot option has been handled.
    
    A return of 0 causes the boot option/value to be listed as an Unknown
    kernel parameter and added to init's (limited) argument or environment
    strings.
    
    Also, error return codes don't mean anything to obsolete_checksetup() --
    only non-zero (usually 1) or zero. So return 1 from cpm_powersave_off().
    
    Fixes: d164f6d4f910 ("powerpc/4xx: Add suspend and idle support")
    Reported-by: Igor Zhbanov <izh1979@gmail.com>
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220502192941.20955-1-rdunlap@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/64: Only WARN if __pa()/__va() called with bad addresses [+ + +]
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Thu Apr 7 00:58:01 2022 +1000

    powerpc/64: Only WARN if __pa()/__va() called with bad addresses
    
    [ Upstream commit c4bce84d0bd3f396f702d69be2e92bbd8af97583 ]
    
    We added checks to __pa() / __va() to ensure they're only called with
    appropriate addresses. But using BUG_ON() is too strong, it means
    virt_addr_valid() will BUG when DEBUG_VIRTUAL is enabled.
    
    Instead switch them to warnings, arm64 does the same.
    
    Fixes: 4dd7554a6456 ("powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses")
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220406145802.538416-5-mpe@ellerman.id.au
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/8xx: export 'cpm_setbrg' for modules [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Thu Jan 21 17:08:19 2021 -0800

    powerpc/8xx: export 'cpm_setbrg' for modules
    
    [ Upstream commit 22f8e625ebabd7ed3185b82b44b4f12fc0402113 ]
    
    Fix missing export for a loadable module build:
    
    ERROR: modpost: "cpm_setbrg" [drivers/tty/serial/cpm_uart/cpm_uart.ko] undefined!
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Reported-by: kernel test robot <lkp@intel.com>
    [chleroy: Changed Fixes: tag]
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20210122010819.30986-1-rdunlap@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/fadump: Fix fadump to work with a different endian capture kernel [+ + +]
Author: Hari Bathini <hbathini@linux.ibm.com>
Date:   Wed Apr 21 23:20:52 2021 +0530

    powerpc/fadump: Fix fadump to work with a different endian capture kernel
    
    [ Upstream commit b74196af372f7cb4902179009265fe63ac81824f ]
    
    Dump capture would fail if capture kernel is not of the endianess as the
    production kernel, because the in-memory data structure (struct
    opal_fadump_mem_struct) shared across production kernel and capture
    kernel assumes the same endianess for both the kernels, which doesn't
    have to be true always. Fix it by having a well-defined endianess for
    struct opal_fadump_mem_struct.
    
    Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/161902744901.86147.14719228311655123526.stgit@hbathini
    Signed-off-by: Sasha Levin <sashal@kernel.org>

powerpc/fadump: fix PT_LOAD segment for boot memory area [+ + +]
Author: Hari Bathini <hbathini@linux.ibm.com>
Date:   Wed Apr 6 15:08:37 2022 +0530

    powerpc/fadump: fix PT_LOAD segment for boot memory area
    
    [ Upstream commit 15eb77f873255cf9f4d703b63cfbd23c46579654 ]
    
    Boot memory area is setup as separate PT_LOAD segment in the vmcore
    as it is moved by f/w, on crash, to a destination address provided by
    the kernel. Having separate PT_LOAD segment helps in handling the
    different physical address and offset for boot memory area in the
    vmcore.
    
    Commit ced1bf52f477 ("powerpc/fadump: merge adjacent memory ranges to
    reduce PT_LOAD segements") inadvertly broke this pre-condition for
    cases where some of the first kernel memory is available adjacent to
    boot memory area. This scenario is rare but possible when memory for
    fadump could not be reserved adjacent to boot memory area owing to
    memory hole or such. Reading memory from a vmcore exported in such
    scenario provides incorrect data.  Fix it by ensuring no other region
    is folded into boot memory area.
    
    Fixes: ced1bf52f477 ("powerpc/fadump: merge adjacent memory ranges to reduce PT_LOAD segements")
    Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220406093839.206608-2-hbathini@linux.ibm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/fsl_rio: Fix refcount leak in fsl_rio_setup [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Thu May 12 16:37:18 2022 +0400

    powerpc/fsl_rio: Fix refcount leak in fsl_rio_setup
    
    [ Upstream commit fcee96924ba1596ca80a6770b2567ca546f9a482 ]
    
    of_parse_phandle() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: abc3aeae3aaa ("fsl-rio: Add two ports and rapidio message units support")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220512123724.62931-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/idle: Fix return value of __setup() handler [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Mon May 2 12:29:25 2022 -0700

    powerpc/idle: Fix return value of __setup() handler
    
    [ Upstream commit b793a01000122d2bd133ba451a76cc135b5e162c ]
    
    __setup() handlers should return 1 to obsolete_checksetup() in
    init/main.c to indicate that the boot option has been handled.
    
    A return of 0 causes the boot option/value to be listed as an Unknown
    kernel parameter and added to init's (limited) argument or environment
    strings.
    
    Also, error return codes don't mean anything to obsolete_checksetup() --
    only non-zero (usually 1) or zero. So return 1 from powersave_off().
    
    Fixes: 302eca184fb8 ("[POWERPC] cell: use ppc_md->power_save instead of cbe_idle_loop")
    Reported-by: Igor Zhbanov <izh1979@gmail.com>
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220502192925.19954-1-rdunlap@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/iommu: Add missing of_node_put in iommu_init_early_dart [+ + +]
Author: Peng Wu <wupeng58@huawei.com>
Date:   Mon Apr 25 08:12:45 2022 +0000

    powerpc/iommu: Add missing of_node_put in iommu_init_early_dart
    
    [ Upstream commit 57b742a5b8945118022973e6416b71351df512fb ]
    
    The device_node pointer is returned by of_find_compatible_node
    with refcount incremented. We should use of_node_put() to avoid
    the refcount leak.
    
    Signed-off-by: Peng Wu <wupeng58@huawei.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220425081245.21705-1-wupeng58@huawei.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/perf: Fix the threshold compare group constraint for power9 [+ + +]
Author: Kajol Jain <kjain@linux.ibm.com>
Date:   Fri May 6 11:40:15 2022 +0530

    powerpc/perf: Fix the threshold compare group constraint for power9
    
    [ Upstream commit ab0cc6bbf0c812731c703ec757fcc3fc3a457a34 ]
    
    Thresh compare bits for a event is used to program thresh compare
    field in Monitor Mode Control Register A (MMCRA: 9-18 bits for power9).
    When scheduling events as a group, all events in that group should
    match value in threshold bits (like thresh compare, thresh control,
    thresh select). Otherwise event open for the sibling events should fail.
    But in the current code, incase thresh compare bits are not valid,
    we are not failing in group_constraint function which can result
    in invalid group schduling.
    
    Fix the issue by returning -1 incase event is threshold and threshold
    compare value is not valid.
    
    Thresh control bits in the event code is used to program thresh_ctl
    field in Monitor Mode Control Register A (MMCRA: 48-55). In below example,
    the scheduling of group events PM_MRK_INST_CMPL (873534401e0) and
    PM_THRESH_MET (8734340101ec) is expected to fail as both event
    request different thresh control bits and invalid thresh compare value.
    
    Result before the patch changes:
    
    [command]# perf stat -e "{r8735340401e0,r8734340101ec}" sleep 1
    
     Performance counter stats for 'sleep 1':
    
                11,048      r8735340401e0
                 1,967      r8734340101ec
    
           1.001354036 seconds time elapsed
    
           0.001421000 seconds user
           0.000000000 seconds sys
    
    Result after the patch changes:
    
    [command]# perf stat -e "{r8735340401e0,r8734340101ec}" sleep 1
    Error:
    The sys_perf_event_open() syscall returned with 22 (Invalid argument)
    for event (r8735340401e0).
    /bin/dmesg | grep -i perf may provide additional information.
    
    Fixes: 78a16d9fc1206 ("powerpc/perf: Avoid FAB_*_MATCH checks for power9")
    Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
    Reviewed-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220506061015.43916-2-kjain@linux.ibm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/powernv: fix missing of_node_put in uv_init() [+ + +]
Author: Lv Ruyi <lv.ruyi@zte.com.cn>
Date:   Thu Apr 7 09:00:43 2022 +0000

    powerpc/powernv: fix missing of_node_put in uv_init()
    
    [ Upstream commit 3ffa9fd471f57f365bc54fc87824c530422f64a5 ]
    
    of_find_compatible_node() returns node pointer with refcount incremented,
    use of_node_put() on it when done.
    
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220407090043.2491854-1-lv.ruyi@zte.com.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
powerpc/xics: fix refcount leak in icp_opal_init() [+ + +]
Author: Lv Ruyi <lv.ruyi@zte.com.cn>
Date:   Sat Apr 2 01:34:19 2022 +0000

    powerpc/xics: fix refcount leak in icp_opal_init()
    
    [ Upstream commit 5dd9e27ea4a39f7edd4bf81e9e70208e7ac0b7c9 ]
    
    The of_find_compatible_node() function returns a node pointer with
    refcount incremented, use of_node_put() on it when done.
    
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220402013419.2410298-1-lv.ruyi@zte.com.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
proc: fix dentry/inode overinstantiating under /proc/${pid}/net [+ + +]
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Mon May 9 18:29:19 2022 -0700

    proc: fix dentry/inode overinstantiating under /proc/${pid}/net
    
    [ Upstream commit 7055197705709c59b8ab77e6a5c7d46d61edd96e ]
    
    When a process exits, /proc/${pid}, and /proc/${pid}/net dentries are
    flushed.  However some leaf dentries like /proc/${pid}/net/arp_cache
    aren't.  That's because respective PDEs have proc_misc_d_revalidate() hook
    which returns 1 and leaves dentries/inodes in the LRU.
    
    Force revalidation/lookup on everything under /proc/${pid}/net by
    inheriting proc_net_dentry_ops.
    
    [akpm@linux-foundation.org: coding-style cleanups]
    Link: https://lkml.kernel.org/r/YjdVHgildbWO7diJ@localhost.localdomain
    Fixes: c6c75deda813 ("proc: fix lookup in /proc/net subdirectories after setns(2)")
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Reported-by: hui li <juanfengpy@gmail.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP [+ + +]
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Tue Apr 26 16:30:17 2022 -0500

    ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP
    
    commit c200e4bb44e80b343c09841e7caaaca0aac5e5fa upstream.
    
    User mode linux is the last user of the PT_DTRACE flag.  Using the flag to indicate
    single stepping is a little confusing and worse changing tsk->ptrace without locking
    could potentionally cause problems.
    
    So use a thread info flag with a better name instead of flag in tsk->ptrace.
    
    Remove the definition PT_DTRACE as uml is the last user.
    
    Cc: stable@vger.kernel.org
    Acked-by: Johannes Berg <johannes@sipsolutions.net>
    Tested-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: Oleg Nesterov <oleg@redhat.com>
    Link: https://lkml.kernel.org/r/20220505182645.497868-3-ebiederm@xmission.com
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP [+ + +]
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Tue Apr 26 16:45:37 2022 -0500

    ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP
    
    commit 4a3d2717d140401df7501a95e454180831a0c5af upstream.
    
    xtensa is the last user of the PT_SINGLESTEP flag.  Changing tsk->ptrace in
    user_enable_single_step and user_disable_single_step without locking could
    potentiallly cause problems.
    
    So use a thread info flag instead of a flag in tsk->ptrace.  Use TIF_SINGLESTEP
    that xtensa already had defined but unused.
    
    Remove the definitions of PT_SINGLESTEP and PT_BLOCKSTEP as they have no more users.
    
    Cc: stable@vger.kernel.org
    Acked-by: Max Filippov <jcmvbkbc@gmail.com>
    Tested-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: Oleg Nesterov <oleg@redhat.com>
    Link: https://lkml.kernel.org/r/20220505182645.497868-4-ebiederm@xmission.com
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
ptrace: Reimplement PTRACE_KILL by always sending SIGKILL [+ + +]
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Fri Apr 29 09:23:55 2022 -0500

    ptrace: Reimplement PTRACE_KILL by always sending SIGKILL
    
    commit 6a2d90ba027adba528509ffa27097cffd3879257 upstream.
    
    The current implementation of PTRACE_KILL is buggy and has been for
    many years as it assumes it's target has stopped in ptrace_stop.  At a
    quick skim it looks like this assumption has existed since ptrace
    support was added in linux v1.0.
    
    While PTRACE_KILL has been deprecated we can not remove it as
    a quick search with google code search reveals many existing
    programs calling it.
    
    When the ptracee is not stopped at ptrace_stop some fields would be
    set that are ignored except in ptrace_stop.  Making the userspace
    visible behavior of PTRACE_KILL a noop in those case.
    
    As the usual rules are not obeyed it is not clear what the
    consequences are of calling PTRACE_KILL on a running process.
    Presumably userspace does not do this as it achieves nothing.
    
    Replace the implementation of PTRACE_KILL with a simple
    send_sig_info(SIGKILL) followed by a return 0.  This changes the
    observable user space behavior only in that PTRACE_KILL on a process
    not stopped in ptrace_stop will also kill it.  As that has always
    been the intent of the code this seems like a reasonable change.
    
    Cc: stable@vger.kernel.org
    Reported-by: Al Viro <viro@zeniv.linux.org.uk>
    Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
    Tested-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: Oleg Nesterov <oleg@redhat.com>
    Link: https://lkml.kernel.org/r/20220505182645.497868-7-ebiederm@xmission.com
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
pwm: lp3943: Fix duty calculation in case period was clamped [+ + +]
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Fri Apr 8 17:22:38 2022 +0200

    pwm: lp3943: Fix duty calculation in case period was clamped
    
    [ Upstream commit 5e3b07ca5cc78cd4a987e78446849e41288d87cb ]
    
    The hardware only supports periods <= 1.6 ms and if a bigger period is
    requested it is clamped to 1.6 ms. In this case duty_cycle might be bigger
    than 1.6 ms and then the duty cycle register is written with a value
    bigger than LP3943_MAX_DUTY. So clamp duty_cycle accordingly.
    
    Fixes: af66b3c0934e ("pwm: Add LP3943 PWM driver")
    Signed-off-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>

 
RDMA/hfi1: Fix potential integer multiplication overflow errors [+ + +]
Author: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Date:   Fri May 20 14:37:12 2022 -0400

    RDMA/hfi1: Fix potential integer multiplication overflow errors
    
    commit f93e91a0372c922c20d5bee260b0f43b4b8a1bee upstream.
    
    When multiplying of different types, an overflow is possible even when
    storing the result in a larger type. This is because the conversion is
    done after the multiplication. So arithmetic overflow and thus in
    incorrect value is possible.
    
    Correct an instance of this in the inter packet delay calculation.  Fix by
    ensuring one of the operands is u64 which will promote the other to u64 as
    well ensuring no overflow.
    
    Cc: stable@vger.kernel.org
    Fixes: 7724105686e7 ("IB/hfi1: add driver files")
    Link: https://lore.kernel.org/r/20220520183712.48973.29855.stgit@awfm-01.cornelisnetworks.com
    Reviewed-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
    Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

RDMA/hfi1: Prevent panic when SDMA is disabled [+ + +]
Author: Douglas Miller <doug.miller@cornelisnetworks.com>
Date:   Fri May 20 14:37:06 2022 -0400

    RDMA/hfi1: Prevent panic when SDMA is disabled
    
    [ Upstream commit 629e052d0c98e46dde9f0824f0aa437f678d9b8f ]
    
    If the hfi1 module is loaded with HFI1_CAP_SDMA off, a call to
    hfi1_write_iter() will dereference a NULL pointer and panic. A typical
    stack frame is:
    
      sdma_select_user_engine [hfi1]
      hfi1_user_sdma_process_request [hfi1]
      hfi1_write_iter [hfi1]
      do_iter_readv_writev
      do_iter_write
      vfs_writev
      do_writev
      do_syscall_64
    
    The fix is to test for SDMA in hfi1_write_iter() and fail the I/O with
    EINVAL.
    
    Link: https://lore.kernel.org/r/20220520183706.48973.79803.stgit@awfm-01.cornelisnetworks.com
    Signed-off-by: Douglas Miller <doug.miller@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>

RDMA/hfi1: Prevent use of lock before it is initialized [+ + +]
Author: Douglas Miller <doug.miller@cornelisnetworks.com>
Date:   Fri May 20 14:37:01 2022 -0400

    RDMA/hfi1: Prevent use of lock before it is initialized
    
    [ Upstream commit 05c03dfd09c069c4ffd783b47b2da5dcc9421f2c ]
    
    If there is a failure during probe of hfi1 before the sdma_map_lock is
    initialized, the call to hfi1_free_devdata() will attempt to use a lock
    that has not been initialized. If the locking correctness validator is on
    then an INFO message and stack trace resembling the following may be seen:
    
      INFO: trying to register non-static key.
      The code is fine but needs lockdep annotation, or maybe
      you didn't initialize this object before use?
      turning off the locking correctness validator.
      Call Trace:
      register_lock_class+0x11b/0x880
      __lock_acquire+0xf3/0x7930
      lock_acquire+0xff/0x2d0
      _raw_spin_lock_irq+0x46/0x60
      sdma_clean+0x42a/0x660 [hfi1]
      hfi1_free_devdata+0x3a7/0x420 [hfi1]
      init_one+0x867/0x11a0 [hfi1]
      pci_device_probe+0x40e/0x8d0
    
    The use of sdma_map_lock in sdma_clean() is for freeing the sdma_map
    memory, and sdma_map is not allocated/initialized until after
    sdma_map_lock has been initialized. This code only needs to be run if
    sdma_map is not NULL, and so checking for that condition will avoid trying
    to use the lock before it is initialized.
    
    Fixes: 473291b3ea0e ("IB/hfi1: Fix for early release of sdma context")
    Fixes: 7724105686e7 ("IB/hfi1: add driver files")
    Link: https://lore.kernel.org/r/20220520183701.48973.72434.stgit@awfm-01.cornelisnetworks.com
    Reported-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Douglas Miller <doug.miller@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>

 
RDMA/rxe: Generate a completion for unsupported/invalid opcode [+ + +]
Author: Xiao Yang <yangx.jy@fujitsu.com>
Date:   Sun Apr 10 19:35:13 2022 +0800

    RDMA/rxe: Generate a completion for unsupported/invalid opcode
    
    commit 2f917af777011c88e977b9b9a5d00b280d3a59ce upstream.
    
    Current rxe_requester() doesn't generate a completion when processing an
    unsupported/invalid opcode. If rxe driver doesn't support a new opcode
    (e.g. RDMA Atomic Write) and RDMA library supports it, an application
    using the new opcode can reproduce this issue. Fix the issue by calling
    "goto err;".
    
    Fixes: 8700e3e7c485 ("Soft RoCE driver")
    Link: https://lore.kernel.org/r/20220410113513.27537-1-yangx.jy@fujitsu.com
    Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
regulator: core: Fix enable_count imbalance with EXCLUSIVE_GET [+ + +]
Author: Zev Weiss <zev@bewilderbeest.net>
Date:   Wed May 4 21:31:52 2022 -0700

    regulator: core: Fix enable_count imbalance with EXCLUSIVE_GET
    
    [ Upstream commit c3e3ca05dae37f8f74bb80358efd540911cbc2c8 ]
    
    Since the introduction of regulator->enable_count, a driver that did
    an exclusive get on an already-enabled regulator would end up with
    enable_count initialized to 0 but rdev->use_count initialized to 1.
    With that starting point the regulator is effectively stuck enabled,
    because if the driver attempted to disable it it would fail the
    enable_count underflow check in _regulator_handle_consumer_disable().
    
    The EXCLUSIVE_GET path in _regulator_get() now initializes
    enable_count along with rdev->use_count so that the regulator can be
    disabled without underflowing the former.
    
    Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
    Fixes: 5451781dadf85 ("regulator: core: Only count load for enabled consumers")
    Link: https://lore.kernel.org/r/20220505043152.12933-1-zev@bewilderbeest.net
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

regulator: pfuze100: Fix refcount leak in pfuze_parse_regulators_dt [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed May 11 15:35:05 2022 +0400

    regulator: pfuze100: Fix refcount leak in pfuze_parse_regulators_dt
    
    [ Upstream commit afaa7b933ef00a2d3262f4d1252087613fb5c06d ]
    
    of_node_get() returns a node with refcount incremented.
    Calling of_node_put() to drop the reference when not needed anymore.
    
    Fixes: 3784b6d64dc5 ("regulator: pfuze100: add pfuze100 regulator driver")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220511113506.45185-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Revert "cpufreq: Fix possible race in cpufreq online error path" [+ + +]
Author: Viresh Kumar <viresh.kumar@linaro.org>
Date:   Mon May 9 09:27:37 2022 +0530

    Revert "cpufreq: Fix possible race in cpufreq online error path"
    
    [ Upstream commit 85f0e42bd65d01b351d561efb38e584d4c596553 ]
    
    This reverts commit f346e96267cd76175d6c201b40f770c0116a8a04.
    
    The commit tried to fix a possible real bug but it made it even worse.
    The fix was simply buggy as now an error out to out_offline_policy or
    out_exit_policy will try to release a semaphore which was never taken in
    the first place. This works fine only if we failed late, i.e. via
    out_destroy_policy.
    
    Fixes: f346e96267cd ("cpufreq: Fix possible race in cpufreq online error path")
    Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process" [+ + +]
Author: Michal Kubecek <mkubecek@suse.cz>
Date:   Mon May 23 22:05:24 2022 +0200

    Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process"
    
    [ Upstream commit 9c90c9b3e50e16d03c7f87d63e9db373974781e0 ]
    
    This reverts commit 4dc2a5a8f6754492180741facf2a8787f2c415d7.
    
    A non-zero return value from pfkey_broadcast() does not necessarily mean
    an error occurred as this function returns -ESRCH when no registered
    listener received the message. In particular, a call with
    BROADCAST_PROMISC_ONLY flag and null one_sk argument can never return
    zero so that this commit in fact prevents processing any PF_KEY message.
    One visible effect is that racoon daemon fails to find encryption
    algorithms like aes and refuses to start.
    
    Excluding -ESRCH return value would fix this but it's not obvious that
    we really want to bail out here and most other callers of
    pfkey_broadcast() also ignore the return value. Also, as pointed out by
    Steffen Klassert, PF_KEY is kind of deprecated and newer userspace code
    should use netlink instead so that we should only disturb the code for
    really important fixes.
    
    v2: add a comment explaining why is the return value ignored
    
    Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rpmsg: qcom_smd: Fix irq_of_parse_and_map() return value [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Fri Apr 22 12:53:26 2022 +0200

    rpmsg: qcom_smd: Fix irq_of_parse_and_map() return value
    
    [ Upstream commit 1a358d35066487d228a68303d808bc4721c6b1b9 ]
    
    The irq_of_parse_and_map() returns 0 on failure, not a negative ERRNO.
    
    Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220422105326.78713-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

rpmsg: qcom_smd: Fix returning 0 if irq_of_parse_and_map() fails [+ + +]
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Sat Apr 23 11:39:32 2022 +0200

    rpmsg: qcom_smd: Fix returning 0 if irq_of_parse_and_map() fails
    
    [ Upstream commit 59d6f72f6f9c92fec8757d9e29527da828e9281f ]
    
    irq_of_parse_and_map() returns 0 on failure, so this should not be
    passed further as error return code.
    
    Fixes: 1a358d350664 ("rpmsg: qcom_smd: Fix irq_of_parse_and_map() return value")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220423093932.32136-1-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rtc: mt6397: check return value after calling platform_get_resource() [+ + +]
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Thu May 5 20:50:43 2022 +0800

    rtc: mt6397: check return value after calling platform_get_resource()
    
    [ Upstream commit d3b43eb505bffb8e4cdf6800c15660c001553fe6 ]
    
    It will cause null-ptr-deref if platform_get_resource() returns NULL,
    we need check the return value.
    
    Fixes: fc2979118f3f ("rtc: mediatek: Add MT6397 RTC driver")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20220505125043.1594771-1-yangyingliang@huawei.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rtl818x: Prevent using not initialized queues [+ + +]
Author: Alexander Wetzel <alexander@wetzel-home.de>
Date:   Fri Apr 22 16:52:28 2022 +0200

    rtl818x: Prevent using not initialized queues
    
    commit 746285cf81dc19502ab238249d75f5990bd2d231 upstream.
    
    Using not existing queues can panic the kernel with rtl8180/rtl8185 cards.
    Ignore the skb priority for those cards, they only have one tx queue. Pierre
    Asselin (pa@panix.com) reported the kernel crash in the Gentoo forum:
    
    https://forums.gentoo.org/viewtopic-t-1147832-postdays-0-postorder-asc-start-25.html
    
    He also confirmed that this patch fixes the issue. In summary this happened:
    
    After updating wpa_supplicant from 2.9 to 2.10 the kernel crashed with a
    "divide error: 0000" when connecting to an AP. Control port tx now tries to
    use IEEE80211_AC_VO for the priority, which wpa_supplicants starts to use in
    2.10.
    
    Since only the rtl8187se part of the driver supports QoS, the priority
    of the skb is set to IEEE80211_AC_BE (2) by mac80211 for rtl8180/rtl8185
    cards.
    
    rtl8180 is then unconditionally reading out the priority and finally crashes on
    drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c line 544 without this
    patch:
            idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries
    
    "ring->entries" is zero for rtl8180/rtl8185 cards, tx_ring[2] never got
    initialized.
    
    Cc: stable@vger.kernel.org
    Reported-by: pa@panix.com
    Tested-by: pa@panix.com
    Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20220422145228.7567-1-alexander@wetzel-home.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
rtlwifi: Use pr_warn instead of WARN_ONCE [+ + +]
Author: Dongliang Mu <mudongliangabcd@gmail.com>
Date:   Wed May 11 09:44:52 2022 +0800

    rtlwifi: Use pr_warn instead of WARN_ONCE
    
    [ Upstream commit ad732da434a2936128769216eddaece3b1af4588 ]
    
    This memory allocation failure can be triggered by fault injection or
    high pressure testing, resulting a WARN.
    
    Fix this by replacing WARN with pr_warn.
    
    Reported-by: syzkaller <syzkaller@googlegroups.com>
    Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20220511014453.1621366-1-dzm91@hust.edu.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
rxrpc: Don't let ack.previousPacket regress [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Sat May 21 09:03:24 2022 +0100

    rxrpc: Don't let ack.previousPacket regress
    
    [ Upstream commit 81524b6312535897707f2942695da1d359a5e56b ]
    
    The previousPacket field in the rx ACK packet should never go backwards -
    it's now the highest DATA sequence number received, not the last on
    received (it used to be used for out of sequence detection).
    
    Fixes: 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code")
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Marc Dionne <marc.dionne@auristor.com>
    cc: linux-afs@lists.infradead.org
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

rxrpc: Don't try to resend the request if we're receiving the reply [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Sat May 21 09:03:11 2022 +0100

    rxrpc: Don't try to resend the request if we're receiving the reply
    
    [ Upstream commit 114af61f88fbe34d641b13922d098ffec4c1be1b ]
    
    rxrpc has a timer to trigger resending of unacked data packets in a call.
    This is not cancelled when a client call switches to the receive phase on
    the basis that most calls don't last long enough for it to ever expire.
    However, if it *does* expire after we've started to receive the reply, we
    shouldn't then go into trying to retransmit or pinging the server to find
    out if an ack got lost.
    
    Fix this by skipping the resend code if we're into receiving the reply to a
    client call.
    
    Fixes: 17926a79320a ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both")
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: linux-afs@lists.infradead.org
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

rxrpc: Fix decision on when to generate an IDLE ACK [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Sat May 21 09:03:31 2022 +0100

    rxrpc: Fix decision on when to generate an IDLE ACK
    
    [ Upstream commit 9a3dedcf18096e8f7f22b8777d78c4acfdea1651 ]
    
    Fix the decision on when to generate an IDLE ACK by keeping a count of the
    number of packets we've received, but not yet soft-ACK'd, and the number of
    packets we've processed, but not yet hard-ACK'd, rather than trying to keep
    track of which DATA sequence numbers correspond to those points.
    
    We then generate an ACK when either counter exceeds 2.  The counters are
    both cleared when we transcribe the information into any sort of ACK packet
    for transmission.  IDLE and DELAY ACKs are skipped if both counters are 0
    (ie. no change).
    
    Fixes: 805b21b929e2 ("rxrpc: Send an ACK after every few DATA packets we receive")
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Marc Dionne <marc.dionne@auristor.com>
    cc: linux-afs@lists.infradead.org
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

rxrpc: Fix listen() setting the bar too high for the prealloc rings [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Sat May 21 09:03:04 2022 +0100

    rxrpc: Fix listen() setting the bar too high for the prealloc rings
    
    [ Upstream commit 88e22159750b0d55793302eeed8ee603f5c1a95c ]
    
    AF_RXRPC's listen() handler lets you set the backlog up to 32 (if you bump
    up the sysctl), but whilst the preallocation circular buffers have 32 slots
    in them, one of them has to be a dead slot because we're using CIRC_CNT().
    
    This means that listen(rxrpc_sock, 32) will cause an oops when the socket
    is closed because rxrpc_service_prealloc_one() allocated one too many calls
    and rxrpc_discard_prealloc() won't then be able to get rid of them because
    it'll think the ring is empty.  rxrpc_release_calls_on_socket() then tries
    to abort them, but oopses because call->peer isn't yet set.
    
    Fix this by setting the maximum backlog to RXRPC_BACKLOG_MAX - 1 to match
    the ring capacity.
    
     BUG: kernel NULL pointer dereference, address: 0000000000000086
     ...
     RIP: 0010:rxrpc_send_abort_packet+0x73/0x240 [rxrpc]
     Call Trace:
      <TASK>
      ? __wake_up_common_lock+0x7a/0x90
      ? rxrpc_notify_socket+0x8e/0x140 [rxrpc]
      ? rxrpc_abort_call+0x4c/0x60 [rxrpc]
      rxrpc_release_calls_on_socket+0x107/0x1a0 [rxrpc]
      rxrpc_release+0xc9/0x1c0 [rxrpc]
      __sock_release+0x37/0xa0
      sock_close+0x11/0x20
      __fput+0x89/0x240
      task_work_run+0x59/0x90
      do_exit+0x319/0xaa0
    
    Fixes: 00e907127e6f ("rxrpc: Preallocate peers, conns and calls for incoming service requests")
    Reported-by: Marc Dionne <marc.dionne@auristor.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: linux-afs@lists.infradead.org
    Link: https://lists.infradead.org/pipermail/linux-afs/2022-March/005079.html
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

rxrpc: Fix overlapping ACK accounting [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Sat May 21 09:03:18 2022 +0100

    rxrpc: Fix overlapping ACK accounting
    
    [ Upstream commit 8940ba3cfe4841928777fd45eaa92051522c7f0c ]
    
    Fix accidental overlapping of Rx-phase ACK accounting with Tx-phase ACK
    accounting through variables shared between the two.  call->acks_* members
    refer to ACKs received in the Tx phase and call->ackr_* members to ACKs
    sent/to be sent during the Rx phase.
    
    Fixes: 1a2391c30c0b ("rxrpc: Fix detection of out of order acks")
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Jeffrey Altman <jaltman@auristor.com>
    cc: Marc Dionne <marc.dionne@auristor.com>
    cc: linux-afs@lists.infradead.org
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

rxrpc: Return an error to sendmsg if call failed [+ + +]
Author: David Howells <dhowells@redhat.com>
Date:   Sat May 21 08:45:41 2022 +0100

    rxrpc: Return an error to sendmsg if call failed
    
    [ Upstream commit 4ba68c5192554876bd8c3afd904e3064d2915341 ]
    
    If at the end of rxrpc sendmsg() or rxrpc_kernel_send_data() the call that
    was being given data was aborted remotely or otherwise failed, return an
    error rather than returning the amount of data buffered for transmission.
    
    The call (presumably) did not complete, so there's not much point
    continuing with it.  AF_RXRPC considers it "complete" and so will be
    unwilling to do anything else with it - and won't send a notification for
    it, deeming the return from sendmsg sufficient.
    
    Not returning an error causes afs to incorrectly handle a StoreData
    operation that gets interrupted by a change of address due to NAT
    reconfiguration.
    
    This doesn't normally affect most operations since their request parameters
    tend to fit into a single UDP packet and afs_make_call() returns before the
    server responds; StoreData is different as it involves transmission of a
    lot of data.
    
    This can be triggered on a client by doing something like:
    
            dd if=/dev/zero of=/afs/example.com/foo bs=1M count=512
    
    at one prompt, and then changing the network address at another prompt,
    e.g.:
    
            ifconfig enp6s0 inet 192.168.6.2 && route add 192.168.6.1 dev enp6s0
    
    Tracing packets on an Auristor fileserver looks something like:
    
    192.168.6.1 -> 192.168.6.3  RX 107 ACK Idle  Seq: 0  Call: 4  Source Port: 7000  Destination Port: 7001
    192.168.6.3 -> 192.168.6.1  AFS (RX) 1482 FS Request: Unknown(64538) (64538)
    192.168.6.3 -> 192.168.6.1  AFS (RX) 1482 FS Request: Unknown(64538) (64538)
    192.168.6.1 -> 192.168.6.3  RX 107 ACK Idle  Seq: 0  Call: 4  Source Port: 7000  Destination Port: 7001
    <ARP exchange for 192.168.6.2>
    192.168.6.2 -> 192.168.6.1  AFS (RX) 1482 FS Request: Unknown(0) (0)
    192.168.6.2 -> 192.168.6.1  AFS (RX) 1482 FS Request: Unknown(0) (0)
    192.168.6.1 -> 192.168.6.2  RX 107 ACK Exceeds Window  Seq: 0  Call: 4  Source Port: 7000  Destination Port: 7001
    192.168.6.1 -> 192.168.6.2  RX 74 ABORT  Seq: 0  Call: 4  Source Port: 7000  Destination Port: 7001
    192.168.6.1 -> 192.168.6.2  RX 74 ABORT  Seq: 29321  Call: 4  Source Port: 7000  Destination Port: 7001
    
    The Auristor fileserver logs code -453 (RXGEN_SS_UNMARSHAL), but the abort
    code received by kafs is -5 (RX_PROTOCOL_ERROR) as the rx layer sees the
    condition and generates an abort first and the unmarshal error is a
    consequence of that at the application layer.
    
    Reported-by: Marc Dionne <marc.dionne@auristor.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: linux-afs@lists.infradead.org
    Link: http://lists.infradead.org/pipermail/linux-afs/2021-December/004810.html # v1
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
s390/crypto: fix scatterwalk_unmap() callers in AES-GCM [+ + +]
Author: Jann Horn <jannh@google.com>
Date:   Tue May 17 16:30:47 2022 +0200

    s390/crypto: fix scatterwalk_unmap() callers in AES-GCM
    
    [ Upstream commit bd52cd5e23f134019b23f0c389db0f9a436e4576 ]
    
    The argument of scatterwalk_unmap() is supposed to be the void* that was
    returned by the previous scatterwalk_map() call.
    The s390 AES-GCM implementation was instead passing the pointer to the
    struct scatter_walk.
    
    This doesn't actually break anything because scatterwalk_unmap() only uses
    its argument under CONFIG_HIGHMEM and ARCH_HAS_FLUSH_ON_KUNMAP.
    
    Fixes: bf7fa038707c ("s390/crypto: add s390 platform specific aes gcm support.")
    Signed-off-by: Jann Horn <jannh@google.com>
    Acked-by: Harald Freudenberger <freude@linux.ibm.com>
    Link: https://lore.kernel.org/r/20220517143047.3054498-1-jannh@google.com
    Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
s390/gmap: voluntarily schedule during key setting [+ + +]
Author: Christian Borntraeger <borntraeger@linux.ibm.com>
Date:   Mon May 30 11:27:05 2022 +0200

    s390/gmap: voluntarily schedule during key setting
    
    [ Upstream commit 6d5946274df1fff539a7eece458a43be733d1db8 ]
    
    With large and many guest with storage keys it is possible to create
    large latencies or stalls during initial key setting:
    
    rcu: INFO: rcu_sched self-detected stall on CPU
    rcu:   18-....: (2099 ticks this GP) idle=54e/1/0x4000000000000002 softirq=35598716/35598716 fqs=998
           (t=2100 jiffies g=155867385 q=20879)
    Task dump for CPU 18:
    CPU 1/KVM       R  running task        0 1030947 256019 0x06000004
    Call Trace:
    sched_show_task
    rcu_dump_cpu_stacks
    rcu_sched_clock_irq
    update_process_times
    tick_sched_handle
    tick_sched_timer
    __hrtimer_run_queues
    hrtimer_interrupt
    do_IRQ
    ext_int_handler
    ptep_zap_key
    
    The mmap lock is held during the page walking but since this is a
    semaphore scheduling is still possible. Same for the kvm srcu.
    To minimize overhead do this on every segment table entry or large page.
    
    Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
    Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
    Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
    Link: https://lore.kernel.org/r/20220530092706.11637-2-borntraeger@linux.ibm.com
    Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
    Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES [+ + +]
Author: Heiko Carstens <hca@linux.ibm.com>
Date:   Fri May 6 11:33:19 2022 +0200

    s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES
    
    [ Upstream commit 63678eecec57fc51b778be3da35a397931287170 ]
    
    gcc 12 does not (always) optimize away code that should only be generated
    if parameters are constant and within in a certain range. This depends on
    various obscure kernel config options, however in particular
    PROFILE_ALL_BRANCHES can trigger this compile error:
    
    In function ‘__atomic_add_const’,
        inlined from ‘__preempt_count_add.part.0’ at ./arch/s390/include/asm/preempt.h:50:3:
    ./arch/s390/include/asm/atomic_ops.h:80:9: error: impossible constraint in ‘asm’
       80 |         asm volatile(                                                   \
          |         ^~~
    
    Workaround this by simply disabling the optimization for
    PROFILE_ALL_BRANCHES, since the kernel will be so slow, that this
    optimization won't matter at all.
    
    Reported-by: Thomas Richter <tmricht@linux.ibm.com>
    Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
    Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
sched/fair: Fix cfs_rq_clock_pelt() for throttled cfs_rq [+ + +]
Author: Chengming Zhou <zhouchengming@bytedance.com>
Date:   Fri Apr 8 19:53:08 2022 +0800

    sched/fair: Fix cfs_rq_clock_pelt() for throttled cfs_rq
    
    [ Upstream commit 64eaf50731ac0a8c76ce2fedd50ef6652aabc5ff ]
    
    Since commit 23127296889f ("sched/fair: Update scale invariance of PELT")
    change to use rq_clock_pelt() instead of rq_clock_task(), we should also
    use rq_clock_pelt() for throttled_clock_task_time and throttled_clock_task
    accounting to get correct cfs_rq_clock_pelt() of throttled cfs_rq. And
    rename throttled_clock_task(_time) to be clock_pelt rather than clock_task.
    
    Fixes: 23127296889f ("sched/fair: Update scale invariance of PELT")
    Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Ben Segall <bsegall@google.com>
    Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
    Link: https://lore.kernel.org/r/20220408115309.81603-1-zhouchengming@bytedance.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
scripts/faddr2line: Fix overlapping text section failures [+ + +]
Author: Josh Poimboeuf <jpoimboe@kernel.org>
Date:   Thu May 12 12:05:27 2022 -0700

    scripts/faddr2line: Fix overlapping text section failures
    
    [ Upstream commit 1d1a0e7c5100d332583e20b40aa8c0a8ed3d7849 ]
    
    There have been some recent reports of faddr2line failures:
    
      $ scripts/faddr2line sound/soundcore.ko sound_devnode+0x5/0x35
      bad symbol size: base: 0x0000000000000000 end: 0x0000000000000000
    
      $ ./scripts/faddr2line vmlinux.o enter_from_user_mode+0x24
      bad symbol size: base: 0x0000000000005fe0 end: 0x0000000000005fe0
    
    The problem is that faddr2line is based on 'nm', which has a major
    limitation: it doesn't know how to distinguish between different text
    sections.  So if an offset exists in multiple text sections in the
    object, it may fail.
    
    Rewrite faddr2line to be section-aware, by basing it on readelf.
    
    Fixes: 67326666e2d4 ("scripts: add script for translating stack dump function offsets")
    Reported-by: Kaiwan N Billimoria <kaiwan.billimoria@gmail.com>
    Reported-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
    Link: https://lore.kernel.org/r/29ff99f86e3da965b6e46c1cc2d72ce6528c17c3.1652382321.git.jpoimboe@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
scripts/gdb: change kernel config dumping method [+ + +]
Author: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Date:   Fri Jun 10 15:14:57 2022 +0800

    scripts/gdb: change kernel config dumping method
    
    [ Upstream commit 1f7a6cf6b07c74a17343c2559cd5f5018a245961 ]
    
    MAGIC_START("IKCFG_ST") and MAGIC_END("IKCFG_ED") are moved out
    from the kernel_config_data variable.
    
    Thus, we parse kernel_config_data directly instead of considering
    offset of MAGIC_START and MAGIC_END.
    
    Fixes: 13610aa908dc ("kernel/configs: use .incbin directive to embed config_data.gz")
    Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
scsi: dc395x: Fix a missing check on list iterator [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Thu Apr 14 12:02:31 2022 +0800

    scsi: dc395x: Fix a missing check on list iterator
    
    commit 036a45aa587a10fa2abbd50fbd0f6c4cfc44f69f upstream.
    
    The bug is here:
    
            p->target_id, p->target_lun);
    
    The list iterator 'p' will point to a bogus position containing HEAD if the
    list is empty or no element is found. This case must be checked before any
    use of the iterator, otherwise it will lead to an invalid memory access.
    
    To fix this bug, add a check. Use a new variable 'iter' as the list
    iterator, and use the original variable 'p' as a dedicated pointer to point
    to the found element.
    
    Link: https://lore.kernel.org/r/20220414040231.2662-1-xiam0nd.tong@gmail.com
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Cc: stable@vger.kernel.org
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

scsi: fcoe: Fix Wstringop-overflow warnings in fcoe_wwn_from_mac() [+ + +]
Author: Gustavo A. R. Silva <gustavoars@kernel.org>
Date:   Thu Mar 3 17:55:21 2022 -0600

    scsi: fcoe: Fix Wstringop-overflow warnings in fcoe_wwn_from_mac()
    
    [ Upstream commit 54db804d5d7d36709d1ce70bde3b9a6c61b290b6 ]
    
    Fix the following Wstringop-overflow warnings when building with GCC-11:
    
    drivers/scsi/fcoe/fcoe.c: In function ‘fcoe_netdev_config’:
    drivers/scsi/fcoe/fcoe.c:744:32: warning: ‘fcoe_wwn_from_mac’ accessing 32 bytes in a region of size 6 [-Wstringop-overflow=]
      744 |                         wwnn = fcoe_wwn_from_mac(ctlr->ctl_src_addr, 1, 0);
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/scsi/fcoe/fcoe.c:744:32: note: referencing argument 1 of type ‘unsigned char *’
    In file included from drivers/scsi/fcoe/fcoe.c:36:
    ./include/scsi/libfcoe.h:252:5: note: in a call to function ‘fcoe_wwn_from_mac’
      252 | u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
          |     ^~~~~~~~~~~~~~~~~
    drivers/scsi/fcoe/fcoe.c:747:32: warning: ‘fcoe_wwn_from_mac’ accessing 32 bytes in a region of size 6 [-Wstringop-overflow=]
      747 |                         wwpn = fcoe_wwn_from_mac(ctlr->ctl_src_addr,
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      748 |                                                  2, 0);
          |                                                  ~~~~~
    drivers/scsi/fcoe/fcoe.c:747:32: note: referencing argument 1 of type ‘unsigned char *’
    In file included from drivers/scsi/fcoe/fcoe.c:36:
    ./include/scsi/libfcoe.h:252:5: note: in a call to function ‘fcoe_wwn_from_mac’
      252 | u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
          |     ^~~~~~~~~~~~~~~~~
      CC      drivers/scsi/bnx2fc/bnx2fc_io.o
    In function ‘bnx2fc_net_config’,
        inlined from ‘bnx2fc_if_create’ at drivers/scsi/bnx2fc/bnx2fc_fcoe.c:1543:7:
    drivers/scsi/bnx2fc/bnx2fc_fcoe.c:833:32: warning: ‘fcoe_wwn_from_mac’ accessing 32 bytes in a region of size 6 [-Wstringop-overflow=]
      833 |                         wwnn = fcoe_wwn_from_mac(ctlr->ctl_src_addr,
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      834 |                                                  1, 0);
          |                                                  ~~~~~
    drivers/scsi/bnx2fc/bnx2fc_fcoe.c: In function ‘bnx2fc_if_create’:
    drivers/scsi/bnx2fc/bnx2fc_fcoe.c:833:32: note: referencing argument 1 of type ‘unsigned char *’
    In file included from drivers/scsi/bnx2fc/bnx2fc.h:53,
                     from drivers/scsi/bnx2fc/bnx2fc_fcoe.c:17:
    ./include/scsi/libfcoe.h:252:5: note: in a call to function ‘fcoe_wwn_from_mac’
      252 | u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
          |     ^~~~~~~~~~~~~~~~~
    In function ‘bnx2fc_net_config’,
        inlined from ‘bnx2fc_if_create’ at drivers/scsi/bnx2fc/bnx2fc_fcoe.c:1543:7:
    drivers/scsi/bnx2fc/bnx2fc_fcoe.c:839:32: warning: ‘fcoe_wwn_from_mac’ accessing 32 bytes in a region of size 6 [-Wstringop-overflow=]
      839 |                         wwpn = fcoe_wwn_from_mac(ctlr->ctl_src_addr,
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      840 |                                                  2, 0);
          |                                                  ~~~~~
    drivers/scsi/bnx2fc/bnx2fc_fcoe.c: In function ‘bnx2fc_if_create’:
    drivers/scsi/bnx2fc/bnx2fc_fcoe.c:839:32: note: referencing argument 1 of type ‘unsigned char *’
    In file included from drivers/scsi/bnx2fc/bnx2fc.h:53,
                     from drivers/scsi/bnx2fc/bnx2fc_fcoe.c:17:
    ./include/scsi/libfcoe.h:252:5: note: in a call to function ‘fcoe_wwn_from_mac’
      252 | u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
          |     ^~~~~~~~~~~~~~~~~
    drivers/scsi/qedf/qedf_main.c: In function ‘__qedf_probe’:
    drivers/scsi/qedf/qedf_main.c:3520:30: warning: ‘fcoe_wwn_from_mac’ accessing 32 bytes in a region of size 6 [-Wstringop-overflow=]
     3520 |                 qedf->wwnn = fcoe_wwn_from_mac(qedf->mac, 1, 0);
          |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/scsi/qedf/qedf_main.c:3520:30: note: referencing argument 1 of type ‘unsigned char *’
    In file included from drivers/scsi/qedf/qedf.h:9,
                     from drivers/scsi/qedf/qedf_main.c:23:
    ./include/scsi/libfcoe.h:252:5: note: in a call to function ‘fcoe_wwn_from_mac’
      252 | u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
          |     ^~~~~~~~~~~~~~~~~
    drivers/scsi/qedf/qedf_main.c:3521:30: warning: ‘fcoe_wwn_from_mac’ accessing 32 bytes in a region of size 6 [-Wstringop-overflow=]
     3521 |                 qedf->wwpn = fcoe_wwn_from_mac(qedf->mac, 2, 0);
          |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/scsi/qedf/qedf_main.c:3521:30: note: referencing argument 1 of type ‘unsigned char *’
    In file included from drivers/scsi/qedf/qedf.h:9,
                     from drivers/scsi/qedf/qedf_main.c:23:
    ./include/scsi/libfcoe.h:252:5: note: in a call to function ‘fcoe_wwn_from_mac’
      252 | u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
          |     ^~~~~~~~~~~~~~~~~
    
    by changing the array size to the correct value of ETH_ALEN in the
    argument declaration.
    
    Also, fix a couple of checkpatch warnings:
    WARNING: function definition argument 'unsigned int' should also have an identifier name
    
    This helps with the ongoing efforts to globally enable
    -Wstringop-overflow.
    
    Link: https://github.com/KSPP/linux/issues/181
    Fixes: 85b4aa4926a5 ("[SCSI] fcoe: Fibre Channel over Ethernet")
    Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

scsi: megaraid: Fix error check return value of register_chrdev() [+ + +]
Author: Lv Ruyi <lv.ruyi@zte.com.cn>
Date:   Mon Apr 18 10:57:55 2022 +0000

    scsi: megaraid: Fix error check return value of register_chrdev()
    
    [ Upstream commit c5acd61dbb32b6bda0f3a354108f2b8dcb788985 ]
    
    If major equals 0, register_chrdev() returns an error code when it fails.
    This function dynamically allocates a major and returns its number on
    success, so we should use "< 0" to check it instead of "!".
    
    Link: https://lore.kernel.org/r/20220418105755.2558828-1-lv.ruyi@zte.com.cn
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

scsi: myrb: Fix up null pointer access on myrb_cleanup() [+ + +]
Author: Hannes Reinecke <hare@suse.de>
Date:   Mon May 23 14:02:44 2022 +0200

    scsi: myrb: Fix up null pointer access on myrb_cleanup()
    
    [ Upstream commit f9f0a46141e2e39bedb4779c88380d1b5f018c14 ]
    
    When myrb_probe() fails the callback might not be set, so we need to
    validate the 'disable_intr' callback in myrb_cleanup() to not cause a null
    pointer exception. And while at it do not call myrb_cleanup() if we cannot
    enable the PCI device at all.
    
    Link: https://lore.kernel.org/r/20220523120244.99515-1-hare@suse.de
    Reported-by: Zheyu Ma <zheyuma97@gmail.com>
    Tested-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

scsi: ufs: core: Exclude UECxx from SFR dump list [+ + +]
Author: Kiwoong Kim <kwmad.kim@samsung.com>
Date:   Thu Mar 31 10:24:05 2022 +0900

    scsi: ufs: core: Exclude UECxx from SFR dump list
    
    [ Upstream commit ef60031022eb6d972aac86ca26c98c33e1289436 ]
    
    Some devices may return invalid or zeroed data during an UIC error
    condition. In addition, reading these SFRs will clear them. This means the
    subsequent error handling will not be able to see them and therefore no
    error handling will be scheduled.
    
    Skip reading these SFRs in ufshcd_dump_regs().
    
    Link: https://lore.kernel.org/r/1648689845-33521-1-git-send-email-kwmad.kim@samsung.com
    Fixes: d67247566450 ("scsi: ufs: Use explicit access size in ufshcd_dump_regs")
    Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabled [+ + +]
Author: Manivannan Sadhasivam <mani@kernel.org>
Date:   Wed May 4 14:12:10 2022 +0530

    scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabled
    
    commit 8eecddfca30e1651dc1c74531ed5eef21dcce7e3 upstream.
    
    In ufs_qcom_dev_ref_clk_ctrl(), it was noted that the ref_clk needs to be
    stable for at least 1us. Even though there is wmb() to make sure the write
    gets "completed", there is no guarantee that the write actually reached the
    UFS device. There is a good chance that the write could be stored in a
    Write Buffer (WB). In that case, even though the CPU waits for 1us, the
    ref_clk might not be stable for that period.
    
    So lets do a readl() to make sure that the previous write has reached the
    UFS device before udelay().
    
    Also, the wmb() after writel_relaxed() is not really needed. Both writel()
    and readl() are ordered on all architectures and the CPU won't speculate
    instructions after readl() due to the in-built control dependency with read
    value on weakly ordered architectures. So it can be safely removed.
    
    Link: https://lore.kernel.org/r/20220504084212.11605-4-manivannan.sadhasivam@linaro.org
    Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations")
    Cc: stable@vger.kernel.org
    Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
sctp: read sk->sk_bound_dev_if once in sctp_rcv() [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri May 13 11:55:42 2022 -0700

    sctp: read sk->sk_bound_dev_if once in sctp_rcv()
    
    [ Upstream commit a20ea298071f46effa3aaf965bf9bb34c901db3f ]
    
    sctp_rcv() reads sk->sk_bound_dev_if twice while the socket
    is not locked. Another cpu could change this field under us.
    
    Fixes: 0fd9a65a76e8 ("[SCTP] Support SO_BINDTODEVICE socket option on incoming packets.")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Neil Horman <nhorman@tuxdriver.com>
    Cc: Vlad Yasevich <vyasevich@gmail.com>
    Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
selftests/bpf: fix btf_dump/btf_dump due to recent clang change [+ + +]
Author: Yonghong Song <yhs@fb.com>
Date:   Mon May 23 08:20:44 2022 -0700

    selftests/bpf: fix btf_dump/btf_dump due to recent clang change
    
    [ Upstream commit 4050764cbaa25760aab40857f723393c07898474 ]
    
    Latest llvm-project upstream had a change of behavior
    related to qualifiers on function return type ([1]).
    This caused selftests btf_dump/btf_dump failure.
    The following example shows what changed.
    
      $ cat t.c
      typedef const char * const (* const (* const fn_ptr_arr2_t[5])())(char * (*)(int));
      struct t {
        int a;
        fn_ptr_arr2_t l;
      };
      int foo(struct t *arg) {
        return arg->a;
      }
    
    Compiled with latest upstream llvm15,
      $ clang -O2 -g -target bpf -S -emit-llvm t.c
    The related generated debuginfo IR looks like:
      !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "fn_ptr_arr2_t", file: !1, line: 1, baseType: !17)
      !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 320, elements: !32)
      !18 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !19)
      !19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
      !20 = !DISubroutineType(types: !21)
      !21 = !{!22, null}
      !22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64)
      !23 = !DISubroutineType(types: !24)
      !24 = !{!25, !28}
      !25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !26, size: 64)
      !26 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !27)
      !27 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
    You can see two intermediate const qualifier to pointer are dropped in debuginfo IR.
    
    With llvm14, we have following debuginfo IR:
      !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "fn_ptr_arr2_t", file: !1, line: 1, baseType: !17)
      !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 320, elements: !34)
      !18 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !19)
      !19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
      !20 = !DISubroutineType(types: !21)
      !21 = !{!22, null}
      !22 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !23)
      !23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !24, size: 64)
      !24 = !DISubroutineType(types: !25)
      !25 = !{!26, !30}
      !26 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !27)
      !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64)
      !28 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !29)
      !29 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
    All const qualifiers are preserved.
    
    To adapt the selftest to both old and new llvm, this patch removed
    the intermediate const qualifier in const-to-ptr types, to make the
    test succeed again.
    
      [1] https://reviews.llvm.org/D125919
    
    Reported-by: Mykola Lysenko <mykolal@fb.com>
    Signed-off-by: Yonghong Song <yhs@fb.com>
    Link: https://lore.kernel.org/r/20220523152044.3905809-1-yhs@fb.com
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
serial: 8250_fintek: Check SER_RS485_RTS_* only with RS485 [+ + +]
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri May 13 16:46:43 2022 +0300

    serial: 8250_fintek: Check SER_RS485_RTS_* only with RS485
    
    [ Upstream commit af0179270977508df6986b51242825d7edd59caf ]
    
    SER_RS485_RTS_ON_SEND and SER_RS485_RTS_AFTER_SEND relate to behavior
    within RS485 operation. The driver checks if they have the same value
    which is not possible to realize with the hardware. The check is taken
    regardless of SER_RS485_ENABLED flag and -EINVAL is returned when the
    check fails, which creates problems.
    
    This check makes it unnecessarily complicated to turn RS485 mode off as
    simple zeroed serial_rs485 struct will trigger that equal values check.
    In addition, the driver itself memsets its rs485 structure to zero when
    RS485 is disabled but if userspace would try to make an TIOCSRS485
    ioctl() call with the very same struct, it would end up failing with
    -EINVAL which doesn't make much sense.
    
    Resolve the problem by moving the check inside SER_RS485_ENABLED block.
    
    Fixes: 7ecc77011c6f ("serial: 8250_fintek: Return -EINVAL on invalid configuration")
    Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/035c738-8ea5-8b17-b1d7-84a7b3aeaa51@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: digicolor-usart: Don't allow CS5-6 [+ + +]
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Thu May 19 11:18:01 2022 +0300

    serial: digicolor-usart: Don't allow CS5-6
    
    [ Upstream commit fd63031b8c0763addcecdefe0e0c59d49646204e ]
    
    Only CS7 and CS8 seem supported but CSIZE is not sanitized to CS8 in
    the default: block.
    
    Set CSIZE correctly so that userspace knows the effective value.
    Incorrect CSIZE also results in miscalculation of the frame bits in
    tty_get_char_size() or in its predecessor where the roughly the same
    code is directly within uart_update_timeout().
    
    Fixes: 5930cb3511df (serial: driver for Conexant Digicolor USART)
    Acked-by: Baruch Siach <baruch@tkos.co.il>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20220519081808.3776-3-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: meson: acquire port->lock in startup() [+ + +]
Author: John Ogness <john.ogness@linutronix.de>
Date:   Sun May 8 12:41:47 2022 +0206

    serial: meson: acquire port->lock in startup()
    
    [ Upstream commit 589f892ac8ef244e47c5a00ffd8605daa1eaef8e ]
    
    The uart_ops startup() callback is called without interrupts
    disabled and without port->lock locked, relatively late during the
    boot process (from the call path of console_on_rootfs()). If the
    device is a console, it was already previously registered and could
    be actively printing messages.
    
    Since the startup() callback is reading/writing registers used by
    the console write() callback (AML_UART_CONTROL), its access must
    be synchronized using the port->lock. Currently it is not.
    
    The startup() callback is the only function that explicitly enables
    interrupts. Without the synchronization, it is possible that
    interrupts become accidentally permanently disabled.
    
    CPU0                           CPU1
    meson_serial_console_write     meson_uart_startup
    --------------------------     ------------------
    spin_lock(port->lock)
    val = readl(AML_UART_CONTROL)
    uart_console_write()
                                   writel(INT_EN, AML_UART_CONTROL)
    writel(val, AML_UART_CONTROL)
    spin_unlock(port->lock)
    
    Add port->lock synchronization to meson_uart_startup() to avoid
    racing with meson_serial_console_write().
    
    Also add detailed comments to meson_uart_reset() explaining why it
    is *not* using port->lock synchronization.
    
    Link: https://lore.kernel.org/lkml/2a82eae7-a256-f70c-fd82-4e510750906e@samsung.com
    Fixes: ff7693d079e5 ("ARM: meson: serial: add MesonX SoC on-chip uart driver")
    Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Reviewed-by: Petr Mladek <pmladek@suse.com>
    Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
    Acked-by: Neil Armstrong <narmstrong@baylibre.com>
    Signed-off-by: John Ogness <john.ogness@linutronix.de>
    Link: https://lore.kernel.org/r/20220508103547.626355-1-john.ogness@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: msm_serial: disable interrupts in __msm_console_write() [+ + +]
Author: John Ogness <john.ogness@linutronix.de>
Date:   Fri May 6 23:39:24 2022 +0206

    serial: msm_serial: disable interrupts in __msm_console_write()
    
    [ Upstream commit aabdbb1b7a5819e18c403334a31fb0cc2c06ad41 ]
    
    __msm_console_write() assumes that interrupts are disabled, but
    with threaded console printers it is possible that the write()
    callback of the console is called with interrupts enabled.
    
    Explicitly disable interrupts using local_irq_save() to preserve
    the assumed context.
    
    Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Reviewed-by: Petr Mladek <pmladek@suse.com>
    Signed-off-by: John Ogness <john.ogness@linutronix.de>
    Link: https://lore.kernel.org/r/20220506213324.470461-1-john.ogness@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: pch: don't overwrite xmit->buf[0] by x_char [+ + +]
Author: Jiri Slaby <jirislaby@kernel.org>
Date:   Tue May 3 10:08:03 2022 +0200

    serial: pch: don't overwrite xmit->buf[0] by x_char
    
    commit d9f3af4fbb1d955bbaf872d9e76502f6e3e803cb upstream.
    
    When x_char is to be sent, the TX path overwrites whatever is in the
    circular buffer at offset 0 with x_char and sends it using
    pch_uart_hal_write(). I don't understand how this was supposed to work
    if xmit->buf[0] already contained some character. It must have been
    lost.
    
    Remove this whole pop_tx_x() concept and do the work directly in the
    callers. (Without printing anything using dev_dbg().)
    
    Cc: <stable@vger.kernel.org>
    Fixes: 3c6a483275f4 (Serial: EG20T: add PCH_UART driver)
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Link: https://lore.kernel.org/r/20220503080808.28332-1-jslaby@suse.cz
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

serial: rda-uart: Don't allow CS5-6 [+ + +]
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Thu May 19 11:18:02 2022 +0300

    serial: rda-uart: Don't allow CS5-6
    
    [ Upstream commit 098333a9c7d12bb3ce44c82f08b4d810c44d31b0 ]
    
    Only CS7 and CS8 are supported but CSIZE is not sanitized after
    fallthrough from CS5 or CS6 to CS7.
    
    Set CSIZE correctly so that userspace knows the effective value.
    Incorrect CSIZE also results in miscalculation of the frame bits in
    tty_get_char_size() or in its predecessor where the roughly the same
    code is directly within uart_update_timeout().
    
    Fixes: c10b13325ced (tty: serial: Add RDA8810PL UART driver)
    Cc: Manivannan Sadhasivam <mani@kernel.org>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20220519081808.3776-4-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: sh-sci: Don't allow CS5-6 [+ + +]
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Thu May 19 11:18:04 2022 +0300

    serial: sh-sci: Don't allow CS5-6
    
    [ Upstream commit 9b87162de8be26bf3156460b37deee6399fd0fcb ]
    
    Only CS7 and CS8 seem supported but CSIZE is not sanitized from
    CS5 or CS6 to CS8.
    
    Set CSIZE correctly so that userspace knows the effective value.
    Incorrect CSIZE also results in miscalculation of the frame bits in
    tty_get_char_size() or in its predecessor where the roughly the same
    code is directly within uart_update_timeout().
    
    Fixes: 1da177e4c3f4 (Linux-2.6.12-rc2)
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20220519081808.3776-6-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: sifive: Report actual baud base rather than fixed 115200 [+ + +]
Author: Maciej W. Rozycki <macro@orcam.me.uk>
Date:   Fri Apr 29 21:40:18 2022 +0100

    serial: sifive: Report actual baud base rather than fixed 115200
    
    [ Upstream commit 0a7ff843d507ce2cca2c3b7e169ee56e28133530 ]
    
    The base baud value reported is supposed to be the highest baud rate
    that can be set for a serial port.  The SiFive FU740-C000 SOC's on-chip
    UART supports baud rates of up to 1/16 of the input clock rate, which is
    the bus clock `tlclk'[1], often at 130MHz in the case of the HiFive
    Unmatched board.
    
    However the sifive UART driver reports a fixed value of 115200 instead:
    
    10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1, base_baud = 115200) is a SiFive UART v0
    10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 2, base_baud = 115200) is a SiFive UART v0
    
    even though we already support setting higher baud rates, e.g.:
    
    $ tty
    /dev/ttySIF1
    $ stty speed
    230400
    
    The baud base value is computed by the serial core by dividing the UART
    clock recorded in `struct uart_port' by 16, which is also the minimum
    value of the clock divider supported, so correct the baud base value
    reported by setting the UART clock recorded to the input clock rate
    rather than 115200:
    
    10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1, base_baud = 8125000) is a SiFive UART v0
    10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 2, base_baud = 8125000) is a SiFive UART v0
    
    References:
    
    [1] "SiFive FU740-C000 Manual", v1p3, SiFive, Inc., August 13, 2021,
        Section 16.9 "Baud Rate Divisor Register (div)", pp.143-144
    
    Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
    Fixes: 1f1496a923b6 ("riscv: Fix sifive serial driver")
    Link: https://lore.kernel.org/r/alpine.DEB.2.21.2204291656280.9383@angie.orcam.me.uk
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: sifive: Sanitize CSIZE and c_iflag [+ + +]
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Thu May 19 11:18:05 2022 +0300

    serial: sifive: Sanitize CSIZE and c_iflag
    
    [ Upstream commit c069d2756c01ed36121fae6a42c14fdf1325c71d ]
    
    Only CS8 is supported but CSIZE was not sanitized to CS8.
    
    Set CSIZE correctly so that userspace knows the effective value.
    Incorrect CSIZE also results in miscalculation of the frame bits in
    tty_get_char_size() or in its predecessor where the roughly the same
    code is directly within uart_update_timeout().
    
    Similarly, INPCK, PARMRK, and BRKINT are reported textually unsupported
    but were not cleared in termios c_iflag which is the machine-readable
    format.
    
    Fixes: 45c054d0815b (tty: serial: add driver for the SiFive UART)
    Cc: Paul Walmsley <paul.walmsley@sifive.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20220519081808.3776-7-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: st-asc: Sanitize CSIZE and correct PARENB for CS7 [+ + +]
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Thu May 19 11:18:06 2022 +0300

    serial: st-asc: Sanitize CSIZE and correct PARENB for CS7
    
    [ Upstream commit 52bb1cb7118564166b04d52387bd8403632f5190 ]
    
    Only CS7 and CS8 seem supported but CSIZE is not sanitized from CS5 or
    CS6 to CS8. In addition, ASC_CTL_MODE_7BIT_PAR suggests that CS7 has
    to have parity, thus add PARENB.
    
    Incorrect CSIZE results in miscalculation of the frame bits in
    tty_get_char_size() or in its predecessor where the roughly the same
    code is directly within uart_update_timeout().
    
    Fixes: c4b058560762 (serial:st-asc: Add ST ASC driver.)
    Cc: Srinivas Kandagatla <srinivas.kandagatla@st.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20220519081808.3776-8-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: stm32-usart: Correct CSIZE, bits, and parity [+ + +]
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Thu May 19 11:18:07 2022 +0300

    serial: stm32-usart: Correct CSIZE, bits, and parity
    
    [ Upstream commit 1deeda8d2877c18bc2b9eeee10dd6d2628852848 ]
    
    Add CSIZE sanitization for unsupported CSIZE configurations. In
    addition, if parity is asked for but CSx was unsupported, the sensible
    result is CS8+parity which requires setting USART_CR1_M0 like with 9
    bits.
    
    Incorrect CSIZE results in miscalculation of the frame bits in
    tty_get_char_size() or in its predecessor where the roughly the same
    code is directly within uart_update_timeout().
    
    Fixes: c8a9d043947b (serial: stm32: fix word length configuration)
    Cc: Erwan Le Ray <erwan.leray@st.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20220519081808.3776-9-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

serial: txx9: Don't allow CS5-6 [+ + +]
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Thu May 19 11:18:03 2022 +0300

    serial: txx9: Don't allow CS5-6
    
    [ Upstream commit 79ac88655dc0551e3571ad16bdabdbe65d61553e ]
    
    Only CS7 and CS8 are supported but CSIZE is not sanitized with
    CS5 or CS6 to CS8.
    
    Set CSIZE correctly so that userspace knows the effective value.
    Incorrect CSIZE also results in miscalculation of the frame bits in
    tty_get_char_size() or in its predecessor where the roughly the same
    code is directly within uart_update_timeout().
    
    Fixes: 1da177e4c3f4 (Linux-2.6.12-rc2)
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20220519081808.3776-5-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
soc: qcom: smp2p: Fix missing of_node_put() in smp2p_parse_ipc [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Tue Mar 8 07:19:42 2022 +0000

    soc: qcom: smp2p: Fix missing of_node_put() in smp2p_parse_ipc
    
    [ Upstream commit 8fd3f18ea31a398ecce4a6d3804433658678b0a3 ]
    
    The device_node pointer is returned by of_parse_phandle()  with refcount
    incremented. We should use of_node_put() on it when done.
    
    Fixes: 50e99641413e ("soc: qcom: smp2p: Qualcomm Shared Memory Point to Point")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220308071942.22942-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

soc: qcom: smsm: Fix missing of_node_put() in smsm_parse_ipc [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Tue Mar 8 07:36:48 2022 +0000

    soc: qcom: smsm: Fix missing of_node_put() in smsm_parse_ipc
    
    [ Upstream commit aad66a3c78da668f4506356c2fdb70b7a19ecc76 ]
    
    The device_node pointer is returned by of_parse_phandle()  with refcount
    incremented. We should use of_node_put() on it when done.
    
    Fixes: c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220308073648.24634-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

soc: rockchip: Fix refcount leak in rockchip_grf_init [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon May 16 11:20:10 2022 +0400

    soc: rockchip: Fix refcount leak in rockchip_grf_init
    
    [ Upstream commit 9b59588d8be91c96bfb0371e912ceb4f16315dbf ]
    
    of_find_matching_node_and_match returns a node pointer with refcount
    incremented, we should use of_node_put() on it when done.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: 4c58063d4258 ("soc: rockchip: add driver handling grf setup")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220516072013.19731-1-linmq006@gmail.com
    Signed-off-by: Heiko Stuebner <heiko@sntech.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
spi: img-spfi: Fix pm_runtime_get_sync() error checking [+ + +]
Author: Zheng Yongjun <zhengyongjun3@huawei.com>
Date:   Fri Apr 22 06:26:41 2022 +0000

    spi: img-spfi: Fix pm_runtime_get_sync() error checking
    
    [ Upstream commit cc470d55343056d6b2a5c32e10e0aad06f324078 ]
    
    If the device is already in a runtime PM enabled state
    pm_runtime_get_sync() will return 1, so a test for negative
    value should be used to check for errors.
    
    Fixes: deba25800a12b ("spi: Add driver for IMG SPFI controller")
    Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
    Link: https://lore.kernel.org/r/20220422062641.10486-1-zhengyongjun3@huawei.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

spi: spi-rspi: Remove setting {src,dst}_{addr,addr_width} based on DMA direction [+ + +]
Author: Biju Das <biju.das.jz@bp.renesas.com>
Date:   Mon Apr 11 18:31:15 2022 +0100

    spi: spi-rspi: Remove setting {src,dst}_{addr,addr_width} based on DMA direction
    
    [ Upstream commit 6f381481a5b236cb53d6de2c49c6ef83a4d0f432 ]
    
    The direction field in the DMA config is deprecated. The rspi driver
    sets {src,dst}_{addr,addr_width} based on the DMA direction and
    it results in dmaengine_slave_config() failure as RZ DMAC driver
    validates {src,dst}_addr_width values independent of DMA direction.
    
    This patch fixes the issue by passing both {src,dst}_{addr,addr_width}
    values independent of DMA direction.
    
    Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
    Suggested-by: Vinod Koul <vkoul@kernel.org>
    Reviewed-by: Vinod Koul <vkoul@kernel.org>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Link: https://lore.kernel.org/r/20220411173115.6619-1-biju.das.jz@bp.renesas.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

spi: spi-ti-qspi: Fix return value handling of wait_for_completion_timeout [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon Apr 11 11:10:33 2022 +0000

    spi: spi-ti-qspi: Fix return value handling of wait_for_completion_timeout
    
    [ Upstream commit 8b1ea69a63eb62f97cef63e6d816b64ed84e8760 ]
    
    wait_for_completion_timeout() returns unsigned long not int.
    It returns 0 if timed out, and positive if completed.
    The check for <= 0 is ambiguous and should be == 0 here
    indicating timeout which is the only error case.
    
    Fixes: 5720ec0a6d26 ("spi: spi-ti-qspi: Add DMA support for QSPI mmap read")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220411111034.24447-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

spi: stm32-qspi: Fix wait_cmd timeout in APM mode [+ + +]
Author: Patrice Chotard <patrice.chotard@foss.st.com>
Date:   Wed May 11 09:46:42 2022 +0200

    spi: stm32-qspi: Fix wait_cmd timeout in APM mode
    
    [ Upstream commit d83d89ea68b4726700fa87b22db075e4217e691c ]
    
    In APM mode, TCF and TEF flags are not set. To avoid timeout in
    stm32_qspi_wait_cmd(), don't check if TCF/TEF are set.
    
    Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
    Reported-by: eberhard.stoll@kontron.de
    Link: https://lore.kernel.org/r/20220511074644.558874-2-patrice.chotard@foss.st.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
staging: fieldbus: Fix the error handling path in anybuss_host_common_probe() [+ + +]
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Fri Apr 22 08:48:18 2022 +0200

    staging: fieldbus: Fix the error handling path in anybuss_host_common_probe()
    
    [ Upstream commit 7079b3483a17be2cfba64cbd4feb1b7ae07f1ea7 ]
    
    If device_register() fails, device_unregister() should not be called
    because it will free some resources that are not allocated.
    put_device() should be used instead.
    
    Fixes: 308ee87a2f1e ("staging: fieldbus: anybus-s: support HMS Anybus-S bus")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/5401a519608d6e1a4e7435c20f4f20b0c5c36c23.1650610082.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

staging: greybus: codecs: fix type confusion of list iterator variable [+ + +]
Author: Jakob Koschel <jakobkoschel@gmail.com>
Date:   Mon Mar 21 13:36:26 2022 +0100

    staging: greybus: codecs: fix type confusion of list iterator variable
    
    [ Upstream commit 84ef256550196bc06e6849a34224c998b45bd557 ]
    
    If the list does not exit early then data == NULL and 'module' does not
    point to a valid list element.
    Using 'module' in such a case is not valid and was therefore removed.
    
    Fixes: 6dd67645f22c ("greybus: audio: Use single codec driver registration")
    Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
    Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
    Reviewed-by: Mark Greer <mgreer@animalcreek.com>
    Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
    Link: https://lore.kernel.org/r/20220321123626.3068639-1-jakobkoschel@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

staging: rtl8712: fix uninit-value in r871xu_drv_init() [+ + +]
Author: Wang Cheng <wanngchenng@gmail.com>
Date:   Mon May 16 17:22:41 2022 +0800

    staging: rtl8712: fix uninit-value in r871xu_drv_init()
    
    [ Upstream commit 0458e5428e5e959d201a40ffe71d762a79ecedc4 ]
    
    When 'tmpU1b' returns from r8712_read8(padapter, EE_9346CR) is 0,
    'mac[6]' will not be initialized.
    
    BUG: KMSAN: uninit-value in r871xu_drv_init+0x2d54/0x3070 drivers/staging/rtl8712/usb_intf.c:541
     r871xu_drv_init+0x2d54/0x3070 drivers/staging/rtl8712/usb_intf.c:541
     usb_probe_interface+0xf19/0x1600 drivers/usb/core/driver.c:396
     really_probe+0x653/0x14b0 drivers/base/dd.c:596
     __driver_probe_device+0x3e9/0x530 drivers/base/dd.c:752
     driver_probe_device drivers/base/dd.c:782 [inline]
     __device_attach_driver+0x79f/0x1120 drivers/base/dd.c:899
     bus_for_each_drv+0x2d6/0x3f0 drivers/base/bus.c:427
     __device_attach+0x593/0x8e0 drivers/base/dd.c:970
     device_initial_probe+0x4a/0x60 drivers/base/dd.c:1017
     bus_probe_device+0x17b/0x3e0 drivers/base/bus.c:487
     device_add+0x1fff/0x26e0 drivers/base/core.c:3405
     usb_set_configuration+0x37e9/0x3ed0 drivers/usb/core/message.c:2170
     usb_generic_driver_probe+0x13c/0x300 drivers/usb/core/generic.c:238
     usb_probe_device+0x309/0x570 drivers/usb/core/driver.c:293
     really_probe+0x653/0x14b0 drivers/base/dd.c:596
     __driver_probe_device+0x3e9/0x530 drivers/base/dd.c:752
     driver_probe_device drivers/base/dd.c:782 [inline]
     __device_attach_driver+0x79f/0x1120 drivers/base/dd.c:899
     bus_for_each_drv+0x2d6/0x3f0 drivers/base/bus.c:427
     __device_attach+0x593/0x8e0 drivers/base/dd.c:970
     device_initial_probe+0x4a/0x60 drivers/base/dd.c:1017
     bus_probe_device+0x17b/0x3e0 drivers/base/bus.c:487
     device_add+0x1fff/0x26e0 drivers/base/core.c:3405
     usb_new_device+0x1b8e/0x2950 drivers/usb/core/hub.c:2566
     hub_port_connect drivers/usb/core/hub.c:5358 [inline]
     hub_port_connect_change drivers/usb/core/hub.c:5502 [inline]
     port_event drivers/usb/core/hub.c:5660 [inline]
     hub_event+0x58e3/0x89e0 drivers/usb/core/hub.c:5742
     process_one_work+0xdb6/0x1820 kernel/workqueue.c:2307
     worker_thread+0x10b3/0x21e0 kernel/workqueue.c:2454
     kthread+0x3c7/0x500 kernel/kthread.c:377
     ret_from_fork+0x1f/0x30
    
    Local variable mac created at:
     r871xu_drv_init+0x1771/0x3070 drivers/staging/rtl8712/usb_intf.c:394
     usb_probe_interface+0xf19/0x1600 drivers/usb/core/driver.c:396
    
    KMSAN: uninit-value in r871xu_drv_init
    https://syzkaller.appspot.com/bug?id=3cd92b1d85428b128503bfa7a250294c9ae00bd8
    
    Reported-by: <syzbot+6f5ecd144854c0d8580b@syzkaller.appspotmail.com>
    Tested-by: <syzbot+6f5ecd144854c0d8580b@syzkaller.appspotmail.com>
    Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Wang Cheng <wanngchenng@gmail.com>
    Link: https://lore.kernel.org/r/14c3886173dfa4597f0704547c414cfdbcd11d16.1652618244.git.wanngchenng@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

staging: rtl8712: fix uninit-value in usb_read8() and friends [+ + +]
Author: Wang Cheng <wanngchenng@gmail.com>
Date:   Mon May 16 17:22:23 2022 +0800

    staging: rtl8712: fix uninit-value in usb_read8() and friends
    
    [ Upstream commit d1b57669732d09da7e13ef86d058dab0cd57f6e0 ]
    
    When r8712_usbctrl_vendorreq() returns negative, 'data' in
    usb_read{8,16,32} will not be initialized.
    
    BUG: KMSAN: uninit-value in string_nocheck lib/vsprintf.c:643 [inline]
    BUG: KMSAN: uninit-value in string+0x4ec/0x6f0 lib/vsprintf.c:725
     string_nocheck lib/vsprintf.c:643 [inline]
     string+0x4ec/0x6f0 lib/vsprintf.c:725
     vsnprintf+0x2222/0x3650 lib/vsprintf.c:2806
     va_format lib/vsprintf.c:1704 [inline]
     pointer+0x18e6/0x1f70 lib/vsprintf.c:2443
     vsnprintf+0x1a9b/0x3650 lib/vsprintf.c:2810
     vprintk_store+0x537/0x2150 kernel/printk/printk.c:2158
     vprintk_emit+0x28b/0xab0 kernel/printk/printk.c:2256
     dev_vprintk_emit+0x5ef/0x6d0 drivers/base/core.c:4604
     dev_printk_emit+0x1dd/0x21f drivers/base/core.c:4615
     __dev_printk+0x3be/0x440 drivers/base/core.c:4627
     _dev_info+0x1ea/0x22f drivers/base/core.c:4673
     r871xu_drv_init+0x1929/0x3070 drivers/staging/rtl8712/usb_intf.c:401
     usb_probe_interface+0xf19/0x1600 drivers/usb/core/driver.c:396
     really_probe+0x6c7/0x1350 drivers/base/dd.c:621
     __driver_probe_device+0x3e9/0x530 drivers/base/dd.c:752
     driver_probe_device drivers/base/dd.c:782 [inline]
     __device_attach_driver+0x79f/0x1120 drivers/base/dd.c:899
     bus_for_each_drv+0x2d6/0x3f0 drivers/base/bus.c:427
     __device_attach+0x593/0x8e0 drivers/base/dd.c:970
     device_initial_probe+0x4a/0x60 drivers/base/dd.c:1017
     bus_probe_device+0x17b/0x3e0 drivers/base/bus.c:487
     device_add+0x1fff/0x26e0 drivers/base/core.c:3405
     usb_set_configuration+0x37e9/0x3ed0 drivers/usb/core/message.c:2170
     usb_generic_driver_probe+0x13c/0x300 drivers/usb/core/generic.c:238
     usb_probe_device+0x309/0x570 drivers/usb/core/driver.c:293
     really_probe+0x6c7/0x1350 drivers/base/dd.c:621
     __driver_probe_device+0x3e9/0x530 drivers/base/dd.c:752
     driver_probe_device drivers/base/dd.c:782 [inline]
     __device_attach_driver+0x79f/0x1120 drivers/base/dd.c:899
     bus_for_each_drv+0x2d6/0x3f0 drivers/base/bus.c:427
     __device_attach+0x593/0x8e0 drivers/base/dd.c:970
     device_initial_probe+0x4a/0x60 drivers/base/dd.c:1017
     bus_probe_device+0x17b/0x3e0 drivers/base/bus.c:487
     device_add+0x1fff/0x26e0 drivers/base/core.c:3405
     usb_new_device+0x1b91/0x2950 drivers/usb/core/hub.c:2566
     hub_port_connect drivers/usb/core/hub.c:5363 [inline]
     hub_port_connect_change drivers/usb/core/hub.c:5507 [inline]
     port_event drivers/usb/core/hub.c:5665 [inline]
     hub_event+0x58e3/0x89e0 drivers/usb/core/hub.c:5747
     process_one_work+0xdb6/0x1820 kernel/workqueue.c:2289
     worker_thread+0x10d0/0x2240 kernel/workqueue.c:2436
     kthread+0x3c7/0x500 kernel/kthread.c:376
     ret_from_fork+0x1f/0x30
    
    Local variable data created at:
     usb_read8+0x5d/0x130 drivers/staging/rtl8712/usb_ops.c:33
     r8712_read8+0xa5/0xd0 drivers/staging/rtl8712/rtl8712_io.c:29
    
    KMSAN: uninit-value in r871xu_drv_init
    https://syzkaller.appspot.com/bug?id=3cd92b1d85428b128503bfa7a250294c9ae00bd8
    
    Reported-by: <syzbot+6f5ecd144854c0d8580b@syzkaller.appspotmail.com>
    Tested-by: <syzbot+6f5ecd144854c0d8580b@syzkaller.appspotmail.com>
    Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Wang Cheng <wanngchenng@gmail.com>
    Link: https://lore.kernel.org/r/b9b7a6ee02c02aa28054f5cf16129977775f3cd9.1652618244.git.wanngchenng@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer() [+ + +]
Author: Chuck Lever <chuck.lever@oracle.com>
Date:   Tue Jun 7 16:47:52 2022 -0400

    SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()
    
    [ Upstream commit 6c254bf3b637dd4ef4f78eb78c7447419c0161d7 ]
    
    I found that NFSD's new NFSv3 READDIRPLUS XDR encoder was screwing up
    right at the end of the page array. xdr_get_next_encode_buffer() does
    not compute the value of xdr->end correctly:
    
     * The check to see if we're on the final available page in xdr->buf
       needs to account for the space consumed by @nbytes.
    
     * The new xdr->end value needs to account for the portion of @nbytes
       that is to be encoded into the previous buffer.
    
    Fixes: 2825a7f90753 ("nfsd4: allow encoding across page boundaries")
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
    Reviewed-by: NeilBrown <neilb@suse.de>
    Reviewed-by: J. Bruce Fields <bfields@fieldses.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tcp: fix tcp_mtup_probe_success vs wrong snd_cwnd [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri May 27 14:28:29 2022 -0700

    tcp: fix tcp_mtup_probe_success vs wrong snd_cwnd
    
    commit 11825765291a93d8e7f44230da67b9f607c777bf upstream.
    
    syzbot got a new report [1] finally pointing to a very old bug,
    added in initial support for MTU probing.
    
    tcp_mtu_probe() has checks about starting an MTU probe if
    tcp_snd_cwnd(tp) >= 11.
    
    But nothing prevents tcp_snd_cwnd(tp) to be reduced later
    and before the MTU probe succeeds.
    
    This bug would lead to potential zero-divides.
    
    Debugging added in commit 40570375356c ("tcp: add accessors
    to read/set tp->snd_cwnd") has paid off :)
    
    While we are at it, address potential overflows in this code.
    
    [1]
    WARNING: CPU: 1 PID: 14132 at include/net/tcp.h:1219 tcp_mtup_probe_success+0x366/0x570 net/ipv4/tcp_input.c:2712
    Modules linked in:
    CPU: 1 PID: 14132 Comm: syz-executor.2 Not tainted 5.18.0-syzkaller-07857-gbabf0bb978e3 #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    RIP: 0010:tcp_snd_cwnd_set include/net/tcp.h:1219 [inline]
    RIP: 0010:tcp_mtup_probe_success+0x366/0x570 net/ipv4/tcp_input.c:2712
    Code: 74 08 48 89 ef e8 da 80 17 f9 48 8b 45 00 65 48 ff 80 80 03 00 00 48 83 c4 30 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 aa b0 c5 f8 <0f> 0b e9 16 fe ff ff 48 8b 4c 24 08 80 e1 07 38 c1 0f 8c c7 fc ff
    RSP: 0018:ffffc900079e70f8 EFLAGS: 00010287
    RAX: ffffffff88c0f7f6 RBX: ffff8880756e7a80 RCX: 0000000000040000
    RDX: ffffc9000c6c4000 RSI: 0000000000031f9e RDI: 0000000000031f9f
    RBP: 0000000000000000 R08: ffffffff88c0f606 R09: ffffc900079e7520
    R10: ffffed101011226d R11: 1ffff1101011226c R12: 1ffff1100eadcf50
    R13: ffff8880756e72c0 R14: 1ffff1100eadcf89 R15: dffffc0000000000
    FS:  00007f643236e700(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007f1ab3f1e2a0 CR3: 0000000064fe7000 CR4: 00000000003506e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     <TASK>
     tcp_clean_rtx_queue+0x223a/0x2da0 net/ipv4/tcp_input.c:3356
     tcp_ack+0x1962/0x3c90 net/ipv4/tcp_input.c:3861
     tcp_rcv_established+0x7c8/0x1ac0 net/ipv4/tcp_input.c:5973
     tcp_v6_do_rcv+0x57b/0x1210 net/ipv6/tcp_ipv6.c:1476
     sk_backlog_rcv include/net/sock.h:1061 [inline]
     __release_sock+0x1d8/0x4c0 net/core/sock.c:2849
     release_sock+0x5d/0x1c0 net/core/sock.c:3404
     sk_stream_wait_memory+0x700/0xdc0 net/core/stream.c:145
     tcp_sendmsg_locked+0x111d/0x3fc0 net/ipv4/tcp.c:1410
     tcp_sendmsg+0x2c/0x40 net/ipv4/tcp.c:1448
     sock_sendmsg_nosec net/socket.c:714 [inline]
     sock_sendmsg net/socket.c:734 [inline]
     __sys_sendto+0x439/0x5c0 net/socket.c:2119
     __do_sys_sendto net/socket.c:2131 [inline]
     __se_sys_sendto net/socket.c:2127 [inline]
     __x64_sys_sendto+0xda/0xf0 net/socket.c:2127
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x46/0xb0
    RIP: 0033:0x7f6431289109
    Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 b8 ff ff ff f7 d8 64 89 01 48
    RSP: 002b:00007f643236e168 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
    RAX: ffffffffffffffda RBX: 00007f643139c100 RCX: 00007f6431289109
    RDX: 00000000d0d0c2ac RSI: 0000000020000080 RDI: 000000000000000a
    RBP: 00007f64312e308d R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000000
    R13: 00007fff372533af R14: 00007f643236e300 R15: 0000000000022000
    
    Fixes: 5d424d5a674f ("[TCP]: MTU probing")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Acked-by: Yuchung Cheng <ycheng@google.com>
    Acked-by: Neal Cardwell <ncardwell@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

tcp: tcp_rtx_synack() can be called from process context [+ + +]
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon May 30 14:37:13 2022 -0700

    tcp: tcp_rtx_synack() can be called from process context
    
    [ Upstream commit 0a375c822497ed6ad6b5da0792a12a6f1af10c0b ]
    
    Laurent reported the enclosed report [1]
    
    This bug triggers with following coditions:
    
    0) Kernel built with CONFIG_DEBUG_PREEMPT=y
    
    1) A new passive FastOpen TCP socket is created.
       This FO socket waits for an ACK coming from client to be a complete
       ESTABLISHED one.
    2) A socket operation on this socket goes through lock_sock()
       release_sock() dance.
    3) While the socket is owned by the user in step 2),
       a retransmit of the SYN is received and stored in socket backlog.
    4) At release_sock() time, the socket backlog is processed while
       in process context.
    5) A SYNACK packet is cooked in response of the SYN retransmit.
    6) -> tcp_rtx_synack() is called in process context.
    
    Before blamed commit, tcp_rtx_synack() was always called from BH handler,
    from a timer handler.
    
    Fix this by using TCP_INC_STATS() & NET_INC_STATS()
    which do not assume caller is in non preemptible context.
    
    [1]
    BUG: using __this_cpu_add() in preemptible [00000000] code: epollpep/2180
    caller is tcp_rtx_synack.part.0+0x36/0xc0
    CPU: 10 PID: 2180 Comm: epollpep Tainted: G           OE     5.16.0-0.bpo.4-amd64 #1  Debian 5.16.12-1~bpo11+1
    Hardware name: Supermicro SYS-5039MC-H8TRF/X11SCD-F, BIOS 1.7 11/23/2021
    Call Trace:
     <TASK>
     dump_stack_lvl+0x48/0x5e
     check_preemption_disabled+0xde/0xe0
     tcp_rtx_synack.part.0+0x36/0xc0
     tcp_rtx_synack+0x8d/0xa0
     ? kmem_cache_alloc+0x2e0/0x3e0
     ? apparmor_file_alloc_security+0x3b/0x1f0
     inet_rtx_syn_ack+0x16/0x30
     tcp_check_req+0x367/0x610
     tcp_rcv_state_process+0x91/0xf60
     ? get_nohz_timer_target+0x18/0x1a0
     ? lock_timer_base+0x61/0x80
     ? preempt_count_add+0x68/0xa0
     tcp_v4_do_rcv+0xbd/0x270
     __release_sock+0x6d/0xb0
     release_sock+0x2b/0x90
     sock_setsockopt+0x138/0x1140
     ? __sys_getsockname+0x7e/0xc0
     ? aa_sk_perm+0x3e/0x1a0
     __sys_setsockopt+0x198/0x1e0
     __x64_sys_setsockopt+0x21/0x30
     do_syscall_64+0x38/0xc0
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    Fixes: 168a8f58059a ("tcp: TCP Fast Open Server - main code path")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Laurent Fasnacht <laurent.fasnacht@proton.ch>
    Acked-by: Neal Cardwell <ncardwell@google.com>
    Link: https://lore.kernel.org/r/20220530213713.601888-1-eric.dumazet@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
thermal/drivers/broadcom: Fix potential NULL dereference in sr_thermal_probe [+ + +]
Author: Zheng Yongjun <zhengyongjun3@huawei.com>
Date:   Mon Apr 25 09:29:29 2022 +0000

    thermal/drivers/broadcom: Fix potential NULL dereference in sr_thermal_probe
    
    [ Upstream commit e20d136ec7d6f309989c447638365840d3424c8e ]
    
    platform_get_resource() may return NULL, add proper check to
    avoid potential NULL dereferencing.
    
    Fixes: 250e211057c72 ("thermal: broadcom: Add Stingray thermal driver")
    Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
    Link: https://lore.kernel.org/r/20220425092929.90412-1-zhengyongjun3@huawei.com
    Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator [+ + +]
Author: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Date:   Sun Mar 27 14:15:16 2022 +0800

    tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator
    
    commit 8b917cbe38e9b0d002492477a9fc2bfee2412ce4 upstream.
    
    The bug is here:
            if (!encoder) {
    
    The list iterator value 'encoder' will *always* be set and non-NULL
    by list_for_each_entry(), so it is incorrect to assume that the
    iterator value will be NULL if the list is empty or no element
    is found.
    
    To fix the bug, use a new variable 'iter' as the list iterator,
    while use the original variable 'encoder' as a dedicated pointer
    to point to the found element.
    
    Cc: stable@vger.kernel.org
    Fixes: ec9eab097a500 ("drm/tilcdc: Add drm bridge support for attaching drm bridge drivers")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
    Reviewed-by: Jyri Sarha <jyri.sarha@iki.fi>
    Tested-by: Jyri Sarha <jyri.sarha@iki.fi>
    Signed-off-by: Jyri Sarha <jyri.sarha@iki.fi>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220327061516.5076-1-xiam0nd.tong@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
tipc: check attribute length for bearer name [+ + +]
Author: Hoang Le <hoang.h.le@dektech.com.au>
Date:   Thu Jun 2 13:30:53 2022 +0700

    tipc: check attribute length for bearer name
    
    [ Upstream commit 7f36f798f89bf32c0164049cb0e3fd1af613d0bb ]
    
    syzbot reported uninit-value:
    =====================================================
    BUG: KMSAN: uninit-value in string_nocheck lib/vsprintf.c:644 [inline]
    BUG: KMSAN: uninit-value in string+0x4f9/0x6f0 lib/vsprintf.c:725
     string_nocheck lib/vsprintf.c:644 [inline]
     string+0x4f9/0x6f0 lib/vsprintf.c:725
     vsnprintf+0x2222/0x3650 lib/vsprintf.c:2806
     vprintk_store+0x537/0x2150 kernel/printk/printk.c:2158
     vprintk_emit+0x28b/0xab0 kernel/printk/printk.c:2256
     vprintk_default+0x86/0xa0 kernel/printk/printk.c:2283
     vprintk+0x15f/0x180 kernel/printk/printk_safe.c:50
     _printk+0x18d/0x1cf kernel/printk/printk.c:2293
     tipc_enable_bearer net/tipc/bearer.c:371 [inline]
     __tipc_nl_bearer_enable+0x2022/0x22a0 net/tipc/bearer.c:1033
     tipc_nl_bearer_enable+0x6c/0xb0 net/tipc/bearer.c:1042
     genl_family_rcv_msg_doit net/netlink/genetlink.c:731 [inline]
    
    - Do sanity check the attribute length for TIPC_NLA_BEARER_NAME.
    - Do not use 'illegal name' in printing message.
    
    Reported-by: syzbot+e820fdc8ce362f2dea51@syzkaller.appspotmail.com
    Fixes: cb30a63384bc ("tipc: refactor function tipc_enable_bearer()")
    Acked-by: Jon Maloy <jmaloy@redhat.com>
    Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
    Link: https://lore.kernel.org/r/20220602063053.5892-1-hoang.h.le@dektech.com.au
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tools/power turbostat: fix ICX DRAM power numbers [+ + +]
Author: Len Brown <len.brown@intel.com>
Date:   Thu Feb 10 21:06:56 2022 -0500

    tools/power turbostat: fix ICX DRAM power numbers
    
    [ Upstream commit 6397b6418935773a34b533b3348b03f4ce3d7050 ]
    
    ICX (and its duplicates) require special hard-coded DRAM RAPL units,
    rather than using the generic RAPL energy units.
    
    Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    Signed-off-by: Len Brown <len.brown@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tracing: Avoid adding tracer option before update_tracer_options [+ + +]
Author: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Date:   Tue Apr 26 20:24:06 2022 +0800

    tracing: Avoid adding tracer option before update_tracer_options
    
    [ Upstream commit ef9188bcc6ca1d8a2ad83e826b548e6820721061 ]
    
    To prepare for support asynchronous tracer_init_tracefs initcall,
    avoid calling create_trace_option_files before __update_tracer_options.
    Otherwise, create_trace_option_files will show warning because
    some tracers in trace_types list are already in tr->topts.
    
    For example, hwlat_tracer call register_tracer in late_initcall,
    and global_trace.dir is already created in tracing_init_dentry,
    hwlat_tracer will be put into tr->topts.
    Then if the __update_tracer_options is executed after hwlat_tracer
    registered, create_trace_option_files find that hwlat_tracer is
    already in tr->topts.
    
    Link: https://lkml.kernel.org/r/20220426122407.17042-2-mark-pk.tsai@mediatek.com
    
    Link: https://lore.kernel.org/lkml/20220322133339.GA32582@xsang-OptiPlex-9020/
    Reported-by: kernel test robot <oliver.sang@intel.com>
    Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

tracing: Fix potential double free in create_var_ref() [+ + +]
Author: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
Date:   Mon Apr 25 06:37:38 2022 +0000

    tracing: Fix potential double free in create_var_ref()
    
    commit 99696a2592bca641eb88cc9a80c90e591afebd0f upstream.
    
    In create_var_ref(), init_var_ref() is called to initialize the fields
    of variable ref_field, which is allocated in the previous function call
    to create_hist_field(). Function init_var_ref() allocates the
    corresponding fields such as ref_field->system, but frees these fields
    when the function encounters an error. The caller later calls
    destroy_hist_field() to conduct error handling, which frees the fields
    and the variable itself. This results in double free of the fields which
    are already freed in the previous function.
    
    Fix this by storing NULL to the corresponding fields when they are freed
    in init_var_ref().
    
    Link: https://lkml.kernel.org/r/20220425063739.3859998-1-keitasuzuki.park@sslab.ics.keio.ac.jp
    
    Fixes: 067fe038e70f ("tracing: Add variable reference handling to hist triggers")
    CC: stable@vger.kernel.org
    Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
    Reviewed-by: Tom Zanussi <zanussi@kernel.org>
    Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

tracing: Fix sleeping function called from invalid context on RT kernel [+ + +]
Author: Jun Miao <jun.miao@intel.com>
Date:   Tue Apr 19 09:39:10 2022 +0800

    tracing: Fix sleeping function called from invalid context on RT kernel
    
    [ Upstream commit 12025abdc8539ed9d5014e2d647a3fd1bd3de5cd ]
    
    When setting bootparams="trace_event=initcall:initcall_start tp_printk=1" in the
    cmdline, the output_printk() was called, and the spin_lock_irqsave() was called in the
    atomic and irq disable interrupt context suitation. On the PREEMPT_RT kernel,
    these locks are replaced with sleepable rt-spinlock, so the stack calltrace will
    be triggered.
    Fix it by raw_spin_lock_irqsave when PREEMPT_RT and "trace_event=initcall:initcall_start
    tp_printk=1" enabled.
    
     BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
     in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
     preempt_count: 2, expected: 0
     RCU nest depth: 0, expected: 0
     Preemption disabled at:
     [<ffffffff8992303e>] try_to_wake_up+0x7e/0xba0
     CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.17.1-rt17+ #19 34c5812404187a875f32bee7977f7367f9679ea7
     Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
     Call Trace:
      <TASK>
      dump_stack_lvl+0x60/0x8c
      dump_stack+0x10/0x12
      __might_resched.cold+0x11d/0x155
      rt_spin_lock+0x40/0x70
      trace_event_buffer_commit+0x2fa/0x4c0
      ? map_vsyscall+0x93/0x93
      trace_event_raw_event_initcall_start+0xbe/0x110
      ? perf_trace_initcall_finish+0x210/0x210
      ? probe_sched_wakeup+0x34/0x40
      ? ttwu_do_wakeup+0xda/0x310
      ? trace_hardirqs_on+0x35/0x170
      ? map_vsyscall+0x93/0x93
      do_one_initcall+0x217/0x3c0
      ? trace_event_raw_event_initcall_level+0x170/0x170
      ? push_cpu_stop+0x400/0x400
      ? cblist_init_generic+0x241/0x290
      kernel_init_freeable+0x1ac/0x347
      ? _raw_spin_unlock_irq+0x65/0x80
      ? rest_init+0xf0/0xf0
      kernel_init+0x1e/0x150
      ret_from_fork+0x22/0x30
      </TASK>
    
    Link: https://lkml.kernel.org/r/20220419013910.894370-1-jun.miao@intel.com
    
    Signed-off-by: Jun Miao <jun.miao@intel.com>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

tracing: incorrect isolate_mote_t cast in mm_vmscan_lru_isolate [+ + +]
Author: Vasily Averin <vasily.averin@linux.dev>
Date:   Wed May 11 12:46:53 2022 +0300

    tracing: incorrect isolate_mote_t cast in mm_vmscan_lru_isolate
    
    [ Upstream commit 2b132903de7124dd9a758be0c27562e91a510848 ]
    
    Fixes following sparse warnings:
    
      CHECK   mm/vmscan.c
    mm/vmscan.c: note: in included file (through
    include/trace/trace_events.h, include/trace/define_trace.h,
    include/trace/events/vmscan.h):
    ./include/trace/events/vmscan.h:281:1: sparse: warning:
     cast to restricted isolate_mode_t
    ./include/trace/events/vmscan.h:281:1: sparse: warning:
     restricted isolate_mode_t degrades to integer
    
    Link: https://lkml.kernel.org/r/e85d7ff2-fd10-53f8-c24e-ba0458439c1b@openvz.org
    Signed-off-by: Vasily Averin <vvs@openvz.org>
    Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
tty: Fix a possible resource leak in icom_probe [+ + +]
Author: Huang Guobin <huangguobin4@huawei.com>
Date:   Thu Mar 31 17:10:05 2022 +0800

    tty: Fix a possible resource leak in icom_probe
    
    [ Upstream commit ee157a79e7c82b01ae4c25de0ac75899801f322c ]
    
    When pci_read_config_dword failed, call pci_release_regions() and
    pci_disable_device() to recycle the resource previously allocated.
    
    Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
    Signed-off-by: Huang Guobin <huangguobin4@huawei.com>
    Link: https://lore.kernel.org/r/20220331091005.3290753-1-huangguobin4@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

tty: fix deadlock caused by calling printk() under tty_port->lock [+ + +]
Author: Qi Zheng <zhengqi.arch@bytedance.com>
Date:   Thu May 12 20:38:37 2022 -0700

    tty: fix deadlock caused by calling printk() under tty_port->lock
    
    [ Upstream commit 6b9dbedbe3499fef862c4dff5217cf91f34e43b3 ]
    
    pty_write() invokes kmalloc() which may invoke a normal printk() to print
    failure message.  This can cause a deadlock in the scenario reported by
    syz-bot below:
    
           CPU0              CPU1                    CPU2
           ----              ----                    ----
                             lock(console_owner);
                                                     lock(&port_lock_key);
      lock(&port->lock);
                             lock(&port_lock_key);
                                                     lock(&port->lock);
      lock(console_owner);
    
    As commit dbdda842fe96 ("printk: Add console owner and waiter logic to
    load balance console writes") said, such deadlock can be prevented by
    using printk_deferred() in kmalloc() (which is invoked in the section
    guarded by the port->lock).  But there are too many printk() on the
    kmalloc() path, and kmalloc() can be called from anywhere, so changing
    printk() to printk_deferred() is too complicated and inelegant.
    
    Therefore, this patch chooses to specify __GFP_NOWARN to kmalloc(), so
    that printk() will not be called, and this deadlock problem can be
    avoided.
    
    Syzbot reported the following lockdep error:
    
    ======================================================
    WARNING: possible circular locking dependency detected
    5.4.143-00237-g08ccc19a-dirty #10 Not tainted
    ------------------------------------------------------
    syz-executor.4/29420 is trying to acquire lock:
    ffffffff8aedb2a0 (console_owner){....}-{0:0}, at: console_trylock_spinning kernel/printk/printk.c:1752 [inline]
    ffffffff8aedb2a0 (console_owner){....}-{0:0}, at: vprintk_emit+0x2ca/0x470 kernel/printk/printk.c:2023
    
    but task is already holding lock:
    ffff8880119c9158 (&port->lock){-.-.}-{2:2}, at: pty_write+0xf4/0x1f0 drivers/tty/pty.c:120
    
    which lock already depends on the new lock.
    
    the existing dependency chain (in reverse order) is:
    
    -> #2 (&port->lock){-.-.}-{2:2}:
           __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
           _raw_spin_lock_irqsave+0x35/0x50 kernel/locking/spinlock.c:159
           tty_port_tty_get drivers/tty/tty_port.c:288 [inline]                     <-- lock(&port->lock);
           tty_port_default_wakeup+0x1d/0xb0 drivers/tty/tty_port.c:47
           serial8250_tx_chars+0x530/0xa80 drivers/tty/serial/8250/8250_port.c:1767
           serial8250_handle_irq.part.0+0x31f/0x3d0 drivers/tty/serial/8250/8250_port.c:1854
           serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1827 [inline]  <-- lock(&port_lock_key);
           serial8250_default_handle_irq+0xb2/0x220 drivers/tty/serial/8250/8250_port.c:1870
           serial8250_interrupt+0xfd/0x200 drivers/tty/serial/8250/8250_core.c:126
           __handle_irq_event_percpu+0x109/0xa50 kernel/irq/handle.c:156
           [...]
    
    -> #1 (&port_lock_key){-.-.}-{2:2}:
           __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
           _raw_spin_lock_irqsave+0x35/0x50 kernel/locking/spinlock.c:159
           serial8250_console_write+0x184/0xa40 drivers/tty/serial/8250/8250_port.c:3198
                                                                                    <-- lock(&port_lock_key);
           call_console_drivers kernel/printk/printk.c:1819 [inline]
           console_unlock+0x8cb/0xd00 kernel/printk/printk.c:2504
           vprintk_emit+0x1b5/0x470 kernel/printk/printk.c:2024                     <-- lock(console_owner);
           vprintk_func+0x8d/0x250 kernel/printk/printk_safe.c:394
           printk+0xba/0xed kernel/printk/printk.c:2084
           register_console+0x8b3/0xc10 kernel/printk/printk.c:2829
           univ8250_console_init+0x3a/0x46 drivers/tty/serial/8250/8250_core.c:681
           console_init+0x49d/0x6d3 kernel/printk/printk.c:2915
           start_kernel+0x5e9/0x879 init/main.c:713
           secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:241
    
    -> #0 (console_owner){....}-{0:0}:
           [...]
           lock_acquire+0x127/0x340 kernel/locking/lockdep.c:4734
           console_trylock_spinning kernel/printk/printk.c:1773 [inline]            <-- lock(console_owner);
           vprintk_emit+0x307/0x470 kernel/printk/printk.c:2023
           vprintk_func+0x8d/0x250 kernel/printk/printk_safe.c:394
           printk+0xba/0xed kernel/printk/printk.c:2084
           fail_dump lib/fault-inject.c:45 [inline]
           should_fail+0x67b/0x7c0 lib/fault-inject.c:144
           __should_failslab+0x152/0x1c0 mm/failslab.c:33
           should_failslab+0x5/0x10 mm/slab_common.c:1224
           slab_pre_alloc_hook mm/slab.h:468 [inline]
           slab_alloc_node mm/slub.c:2723 [inline]
           slab_alloc mm/slub.c:2807 [inline]
           __kmalloc+0x72/0x300 mm/slub.c:3871
           kmalloc include/linux/slab.h:582 [inline]
           tty_buffer_alloc+0x23f/0x2a0 drivers/tty/tty_buffer.c:175
           __tty_buffer_request_room+0x156/0x2a0 drivers/tty/tty_buffer.c:273
           tty_insert_flip_string_fixed_flag+0x93/0x250 drivers/tty/tty_buffer.c:318
           tty_insert_flip_string include/linux/tty_flip.h:37 [inline]
           pty_write+0x126/0x1f0 drivers/tty/pty.c:122                              <-- lock(&port->lock);
           n_tty_write+0xa7a/0xfc0 drivers/tty/n_tty.c:2356
           do_tty_write drivers/tty/tty_io.c:961 [inline]
           tty_write+0x512/0x930 drivers/tty/tty_io.c:1045
           __vfs_write+0x76/0x100 fs/read_write.c:494
           [...]
    
    other info that might help us debug this:
    
    Chain exists of:
      console_owner --> &port_lock_key --> &port->lock
    
    Link: https://lkml.kernel.org/r/20220511061951.1114-2-zhengqi.arch@bytedance.com
    Link: https://lkml.kernel.org/r/20220510113809.80626-2-zhengqi.arch@bytedance.com
    Fixes: b6da31b2c07c ("tty: Fix data race in tty_insert_flip_string_fixed_flag")
    Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
    Acked-by: Jiri Slaby <jirislaby@kernel.org>
    Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Akinobu Mita <akinobu.mita@gmail.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

tty: goldfish: Use tty_port_destroy() to destroy port [+ + +]
Author: Wang Weiyang <wangweiyang2@huawei.com>
Date:   Mon Mar 28 19:58:44 2022 +0800

    tty: goldfish: Use tty_port_destroy() to destroy port
    
    [ Upstream commit 507b05063d1b7a1fcb9f7d7c47586fc4f3508f98 ]
    
    In goldfish_tty_probe(), the port initialized through tty_port_init()
    should be destroyed in error paths.In goldfish_tty_remove(), qtty->port
    also should be destroyed or else might leak resources.
    
    Fix the above by calling tty_port_destroy().
    
    Fixes: 666b7793d4bf ("goldfish: tty driver")
    Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
    Signed-off-by: Wang Weiyang <wangweiyang2@huawei.com>
    Link: https://lore.kernel.org/r/20220328115844.86032-1-wangweiyang2@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

tty: serial: fsl_lpuart: fix potential bug when using both of_alias_get_id and ida_simple_get [+ + +]
Author: Sherry Sun <sherry.sun@nxp.com>
Date:   Mon Mar 21 19:22:11 2022 +0800

    tty: serial: fsl_lpuart: fix potential bug when using both of_alias_get_id and ida_simple_get
    
    [ Upstream commit f398e0aa325c61fa20903833a5b534ecb8e6e418 ]
    
    Now fsl_lpuart driver use both of_alias_get_id() and ida_simple_get() in
    .probe(), which has the potential bug. For example, when remove the
    lpuart7 alias in dts, of_alias_get_id() will return error, then call
    ida_simple_get() to allocate the id 0 for lpuart7, this may confilct
    with the lpuart4 which has alias 0.
    
        aliases {
            ...
            serial0 = &lpuart4;
            serial1 = &lpuart5;
            serial2 = &lpuart6;
            serial3 = &lpuart7;
        }
    
    So remove the ida_simple_get() in .probe(), return an error directly
    when calling of_alias_get_id() fails, which is consistent with other
    uart drivers behavior.
    
    Fixes: 3bc3206e1c0f ("serial: fsl_lpuart: Remove the alias node dependence")
    Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
    Link: https://lore.kernel.org/r/20220321112211.8895-1-sherry.sun@nxp.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

tty: serial: owl: Fix missing clk_disable_unprepare() in owl_uart_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon Mar 7 10:51:35 2022 +0000

    tty: serial: owl: Fix missing clk_disable_unprepare() in owl_uart_probe
    
    [ Upstream commit bcea0f547ec1a2ee44d429aaf0334633e386e67c ]
    
    Fix the missing clk_disable_unprepare() before return
    from owl_uart_probe() in the error handling case.
    
    Fixes: abf42d2f333b ("tty: serial: owl: add "much needed" clk_prepare_enable()")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220307105135.11698-1-linmq006@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

tty: synclink_gt: Fix null-pointer-dereference in slgt_clean() [+ + +]
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Sun Apr 10 19:48:14 2022 +0800

    tty: synclink_gt: Fix null-pointer-dereference in slgt_clean()
    
    [ Upstream commit 689ca31c542687709ba21ec2195c1fbce34fd029 ]
    
    When the driver fails at alloc_hdlcdev(), and then we remove the driver
    module, we will get the following splat:
    
    [   25.065966] general protection fault, probably for non-canonical address 0xdffffc0000000182: 0000 [#1] PREEMPT SMP KASAN PTI
    [   25.066914] KASAN: null-ptr-deref in range [0x0000000000000c10-0x0000000000000c17]
    [   25.069262] RIP: 0010:detach_hdlc_protocol+0x2a/0x3e0
    [   25.077709] Call Trace:
    [   25.077924]  <TASK>
    [   25.078108]  unregister_hdlc_device+0x16/0x30
    [   25.078481]  slgt_cleanup+0x157/0x9f0 [synclink_gt]
    
    Fix this by checking whether the 'info->netdev' is a null pointer first.
    
    Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Link: https://lore.kernel.org/r/20220410114814.3920474-1-zheyuma97@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
ubi: ubi_create_volume: Fix use-after-free when volume creation failed [+ + +]
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Tue May 10 20:31:26 2022 +0800

    ubi: ubi_create_volume: Fix use-after-free when volume creation failed
    
    [ Upstream commit 8c03a1c21d72210f81cb369cc528e3fde4b45411 ]
    
    There is an use-after-free problem for 'eba_tbl' in ubi_create_volume()'s
    error handling path:
    
      ubi_eba_replace_table(vol, eba_tbl)
        vol->eba_tbl = tbl
    out_mapping:
      ubi_eba_destroy_table(eba_tbl)   // Free 'eba_tbl'
    out_unlock:
      put_device(&vol->dev)
        vol_release
          kfree(tbl->entries)         // UAF
    
    Fix it by removing redundant 'eba_tbl' releasing.
    Fetch a reproducer in [Link].
    
    Fixes: 493cfaeaa0c9b ("mtd: utilize new cdev_device_add helper function")
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=215965
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
um: chan_user: Fix winch_tramp() return value [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri May 20 19:45:36 2022 +0200

    um: chan_user: Fix winch_tramp() return value
    
    commit 57ae0b67b747031bc41fb44643aa5344ab58607e upstream.
    
    The previous fix here was only partially correct, it did
    result in returning a proper error value in case of error,
    but it also clobbered the pid that we need to return from
    this function (not just zero for success).
    
    As a result, it returned 0 here, but later this is treated
    as a pid and used to kill the process, but since it's now
    0 we kill(0, SIGKILL), which makes UML kill itself rather
    than just the helper thread.
    
    Fix that and make it more obvious by using a separate
    variable for the pid.
    
    Fixes: ccf1236ecac4 ("um: fix error return code in winch_tramp()")
    Reported-and-tested-by: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

um: Fix out-of-bounds read in LDT setup [+ + +]
Author: Vincent Whitchurch <vincent.whitchurch@axis.com>
Date:   Mon May 23 16:04:03 2022 +0200

    um: Fix out-of-bounds read in LDT setup
    
    commit 2a4a62a14be1947fa945c5c11ebf67326381a568 upstream.
    
    syscall_stub_data() expects the data_count parameter to be the number of
    longs, not bytes.
    
     ==================================================================
     BUG: KASAN: stack-out-of-bounds in syscall_stub_data+0x70/0xe0
     Read of size 128 at addr 000000006411f6f0 by task swapper/1
    
     CPU: 0 PID: 1 Comm: swapper Not tainted 5.18.0+ #18
     Call Trace:
      show_stack.cold+0x166/0x2a7
      __dump_stack+0x3a/0x43
      dump_stack_lvl+0x1f/0x27
      print_report.cold+0xdb/0xf81
      kasan_report+0x119/0x1f0
      kasan_check_range+0x3a3/0x440
      memcpy+0x52/0x140
      syscall_stub_data+0x70/0xe0
      write_ldt_entry+0xac/0x190
      init_new_ldt+0x515/0x960
      init_new_context+0x2c4/0x4d0
      mm_init.constprop.0+0x5ed/0x760
      mm_alloc+0x118/0x170
      0x60033f48
      do_one_initcall+0x1d7/0x860
      0x60003e7b
      kernel_init+0x6e/0x3d4
      new_thread_handler+0x1e7/0x2c0
    
     The buggy address belongs to stack of task swapper/1
      and is located at offset 64 in frame:
      init_new_ldt+0x0/0x960
    
     This frame has 2 objects:
      [32, 40) 'addr'
      [64, 80) 'desc'
     ==================================================================
    
    Fixes: 858259cf7d1c443c83 ("uml: maintain own LDT entries")
    Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
usb: core: hcd: Add support for deferring roothub registration [+ + +]
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date:   Tue May 10 14:46:29 2022 +0530

    usb: core: hcd: Add support for deferring roothub registration
    
    commit a44623d9279086c89f631201d993aa332f7c9e66 upstream.
    
    It has been observed with certain PCIe USB cards (like Inateck connected
    to AM64 EVM or J7200 EVM) that as soon as the primary roothub is
    registered, port status change is handled even before xHC is running
    leading to cold plug USB devices not detected. For such cases, registering
    both the root hubs along with the second HCD is required. Add support for
    deferring roothub registration in usb_add_hcd(), so that both primary and
    secondary roothubs are registered along with the second HCD.
    
    This patch has been added and reverted earier as it triggered a race
    in usb device enumeration.
    That race is now fixed in 5.16-rc3, and in stable back to 5.4
    commit 6cca13de26ee ("usb: hub: Fix locking issues with address0_mutex")
    commit 6ae6dc22d2d1 ("usb: hub: Fix usb enumeration issue due to address0
    race")
    
    CC: stable@vger.kernel.org # 5.4+
    Suggested-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Tested-by: Chris Chiu <chris.chiu@canonical.com>
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    Link: https://lore.kernel.org/r/20220510091630.16564-2-kishon@ti.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

usb: dwc2: gadget: don't reset gadget's driver->bus [+ + +]
Author: Marek Szyprowski <m.szyprowski@samsung.com>
Date:   Thu May 5 12:46:18 2022 +0200

    usb: dwc2: gadget: don't reset gadget's driver->bus
    
    [ Upstream commit 3120aac6d0ecd9accf56894aeac0e265f74d3d5a ]
    
    UDC driver should not touch gadget's driver internals, especially it
    should not reset driver->bus. This wasn't harmful so far, but since
    commit fc274c1e9973 ("USB: gadget: Add a new bus for gadgets") gadget
    subsystem got it's own bus and messing with ->bus triggers the
    following NULL pointer dereference:
    
    dwc2 12480000.hsotg: bound driver g_ether
    8<--- cut here ---
    Unable to handle kernel NULL pointer dereference at virtual address 00000000
    [00000000] *pgd=00000000
    Internal error: Oops: 5 [#1] SMP ARM
    Modules linked in: ...
    CPU: 0 PID: 620 Comm: modprobe Not tainted 5.18.0-rc5-next-20220504 #11862
    Hardware name: Samsung Exynos (Flattened Device Tree)
    PC is at module_add_driver+0x44/0xe8
    LR is at sysfs_do_create_link_sd+0x84/0xe0
    ...
    Process modprobe (pid: 620, stack limit = 0x(ptrval))
    ...
     module_add_driver from bus_add_driver+0xf4/0x1e4
     bus_add_driver from driver_register+0x78/0x10c
     driver_register from usb_gadget_register_driver_owner+0x40/0xb4
     usb_gadget_register_driver_owner from do_one_initcall+0x44/0x1e0
     do_one_initcall from do_init_module+0x44/0x1c8
     do_init_module from load_module+0x19b8/0x1b9c
     load_module from sys_finit_module+0xdc/0xfc
     sys_finit_module from ret_fast_syscall+0x0/0x54
    Exception stack(0xf1771fa8 to 0xf1771ff0)
    ...
    dwc2 12480000.hsotg: new device is high-speed
    ---[ end trace 0000000000000000 ]---
    
    Fix this by removing driver->bus entry reset.
    
    Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Link: https://lore.kernel.org/r/20220505104618.22729-1-m.szyprowski@samsung.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: dwc3: pci: Fix pm_runtime_get_sync() error checking [+ + +]
Author: Zheng Yongjun <zhengyongjun3@huawei.com>
Date:   Fri Apr 22 06:26:52 2022 +0000

    usb: dwc3: pci: Fix pm_runtime_get_sync() error checking
    
    [ Upstream commit a03e2ddab8e735e2cc315609b297b300e9cc60d2 ]
    
    If the device is already in a runtime PM enabled state
    pm_runtime_get_sync() will return 1, so a test for negative
    value should be used to check for errors.
    
    Fixes: 8eed00b237a28 ("usb: dwc3: pci: Runtime resume child device from wq")
    Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
    Link: https://lore.kernel.org/r/20220422062652.10575-1-zhengyongjun3@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
USB: hcd-pci: Fully suspend across freeze/thaw cycle [+ + +]
Author: Evan Green <evgreen@chromium.org>
Date:   Thu Apr 21 10:39:27 2022 -0700

    USB: hcd-pci: Fully suspend across freeze/thaw cycle
    
    [ Upstream commit 63acaa8e9c65dc34dc249440216f8e977f5d2748 ]
    
    The documentation for the freeze() method says that it "should quiesce
    the device so that it doesn't generate IRQs or DMA". The unspoken
    consequence of not doing this is that MSIs aimed at non-boot CPUs may
    get fully lost if they're sent during the period where the target CPU is
    offline.
    
    The current callbacks for USB HCD do not fully quiesce interrupts,
    specifically on XHCI. Change to use the full suspend/resume flow for
    freeze/thaw to ensure interrupts are fully quiesced. This fixes issues
    where USB devices fail to thaw during hibernation because XHCI misses
    its interrupt and cannot recover.
    
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Evan Green <evgreen@chromium.org>
    Link: https://lore.kernel.org/r/20220421103751.v3.2.I8226c7fdae88329ef70957b96a39b346c69a914e@changeid
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

USB: host: isp116x: check return value after calling platform_get_resource() [+ + +]
Author: Zhen Ni <nizhen@uniontech.com>
Date:   Wed Mar 2 11:37:16 2022 +0800

    USB: host: isp116x: check return value after calling platform_get_resource()
    
    [ Upstream commit 134a3408c2d3f7e23eb0e4556e0a2d9f36c2614e ]
    
    It will cause null-ptr-deref if platform_get_resource() returns NULL,
    we need check the return value.
    
    Signed-off-by: Zhen Ni <nizhen@uniontech.com>
    Link: https://lore.kernel.org/r/20220302033716.31272-1-nizhen@uniontech.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
usb: musb: Fix missing of_node_put() in omap2430_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed Mar 9 11:10:33 2022 +0000

    usb: musb: Fix missing of_node_put() in omap2430_probe
    
    [ Upstream commit 424bef51fa530389b0b9008c9e144e40c10e8458 ]
    
    The device_node pointer is returned by of_parse_phandle() with refcount
    incremented. We should use of_node_put() on it when done.
    
    Fixes: 8934d3e4d0e7 ("usb: musb: omap2430: Don't use omap_get_control_dev()")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220309111033.24487-1-linmq006@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
USB: new quirk for Dell Gen 2 devices [+ + +]
Author: Monish Kumar R <monish.kumar.r@intel.com>
Date:   Fri May 20 18:30:44 2022 +0530

    USB: new quirk for Dell Gen 2 devices
    
    commit 97fa5887cf283bb75ffff5f6b2c0e71794c02400 upstream.
    
    Add USB_QUIRK_NO_LPM and USB_QUIRK_RESET_RESUME quirks for Dell usb gen
    2 device to not fail during enumeration.
    
    Found this bug on own testing
    
    Signed-off-by: Monish Kumar R <monish.kumar.r@intel.com>
    Cc: stable <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220520130044.17303-1-monish.kumar.r@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: serial: option: add Quectel BG95 modem [+ + +]
Author: Carl Yin(殷张成) <carl.yin@quectel.com>
Date:   Thu May 19 02:34:43 2022 +0000

    USB: serial: option: add Quectel BG95 modem
    
    commit 33b7af2f459df453feb0d44628d820c47fefe7a8 upstream.
    
    The BG95 modem has 3 USB configurations that are configurable via the AT
    command AT+QCFGEXT="usbnet",["ecm"|"modem"|"rmnet"] which make the modem
    enumerate with the following interfaces, respectively:
    
    "modem": Diag + GNSS + Modem + Modem
    "ecm"  : Diag + GNSS + Modem + ECM
    "rmnet": Diag + GNSS + Modem + QMI
             Don't support Full QMI messages (e.g WDS_START_NETWORK_INTERFACE)
    
    A detailed description of the USB configuration for each mode follows:
    
    +QCFGEXT: "usbnet","modem"
    --------------------------
    T:  Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#=  3 Spd=480  MxCh= 0
    D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
    P:  Vendor=2c7c ProdID=0700 Rev= 0.00
    S:  Manufacturer=Quectel, Incorporated
    S:  Product=Quectel LPWA Module
    S:  SerialNumber=884328a2
    C:* #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=500mA
    I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
    E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=fe Prot=ff Driver=option
    E:  Ad=85(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
    E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    
    +QCFGEXT: "usbnet","ecm"
    ------------------------
    T:  Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#=  4 Spd=480  MxCh= 0
    D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
    P:  Vendor=2c7c ProdID=0700 Rev= 0.00
    S:  Manufacturer=Quectel, Incorporated
    S:  Product=Quectel LPWA Module
    S:  SerialNumber=884328a2
    C:* #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr=500mA
    A:  FirstIf#= 3 IfCount= 2 Cls=02(comm.) Sub=00 Prot=00
    I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
    E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 3 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=cdc_ether
    E:  Ad=85(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
    I:  If#= 4 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether
    I:* If#= 4 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether
    E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    
    +QCFGEXT: "usbnet","rmnet"
    --------------------------
    T:  Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#=  4 Spd=480  MxCh= 0
    D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
    P:  Vendor=2c7c ProdID=0700 Rev= 0.00
    S:  Manufacturer=Quectel, Incorporated
    S:  Product=Quectel LPWA Module
    S:  SerialNumber=884328a2
    C:* #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=500mA
    I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
    E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
    E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
    E:  Ad=85(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
    E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
    
    Signed-off-by: Carl Yin <carl.yin@quectel.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

USB: storage: karma: fix rio_karma_init return [+ + +]
Author: Lin Ma <linma@zju.edu.cn>
Date:   Tue Apr 12 22:43:59 2022 +0800

    USB: storage: karma: fix rio_karma_init return
    
    [ Upstream commit b92ffb1eddd9a66a90defc556dcbf65a43c196c7 ]
    
    The function rio_karam_init() should return -ENOMEM instead of
    value 0 (USB_STOR_TRANSPORT_GOOD) when allocation fails.
    
    Similarly, it should return -EIO when rio_karma_send_command() fails.
    
    Fixes: dfe0d3ba20e8 ("USB Storage: add rio karma eject support")
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Lin Ma <linma@zju.edu.cn>
    Link: https://lore.kernel.org/r/20220412144359.28447-1-linma@zju.edu.cn
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
usb: usbip: add missing device lock on tweak configuration cmd [+ + +]
Author: Niels Dossche <dossche.niels@gmail.com>
Date:   Tue Apr 12 18:50:55 2022 +0200

    usb: usbip: add missing device lock on tweak configuration cmd
    
    [ Upstream commit d088fabace2ca337b275d1d4b36db4fe7771e44f ]
    
    The function documentation of usb_set_configuration says that its
    callers should hold the device lock. This lock is held for all
    callsites except tweak_set_configuration_cmd. The code path can be
    executed for example when attaching a remote USB device.
    The solution is to surround the call by the device lock.
    
    This bug was found using my experimental own-developed static analysis
    tool, which reported the missing lock on v5.17.2. I manually verified
    this bug report by doing code review as well. I runtime checked that
    the required lock is not held. I compiled and runtime tested this on
    x86_64 with a USB mouse. After applying this patch, my analyser no
    longer reports this potential bug.
    
    Fixes: 2c8c98158946 ("staging: usbip: let client choose device configuration")
    Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
    Link: https://lore.kernel.org/r/20220412165055.257113-1-dossche.niels@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

usb: usbip: fix a refcount leak in stub_probe() [+ + +]
Author: Hangyu Hua <hbh25y@gmail.com>
Date:   Tue Apr 12 10:02:57 2022 +0800

    usb: usbip: fix a refcount leak in stub_probe()
    
    [ Upstream commit 9ec4cbf1cc55d126759051acfe328d489c5d6e60 ]
    
    usb_get_dev() is called in stub_device_alloc(). When stub_probe() fails
    after that, usb_put_dev() needs to be called to release the reference.
    
    Fix this by moving usb_put_dev() to sdev_free error path handling.
    
    Find this by code review.
    
    Fixes: 3ff67445750a ("usbip: fix error handling in stub_probe()")
    Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Link: https://lore.kernel.org/r/20220412020257.9767-1-hbh25y@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
video: fbdev: clcdfb: Fix refcount leak in clcdfb_of_vram_setup [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Thu May 12 15:59:08 2022 +0400

    video: fbdev: clcdfb: Fix refcount leak in clcdfb_of_vram_setup
    
    [ Upstream commit b23789a59fa6f00e98a319291819f91fbba0deb8 ]
    
    of_parse_phandle() returns a node pointer with refcount incremented, we should
    use of_node_put() on it when not need anymore.  Add missing of_node_put() to
    avoid refcount leak.
    
    Fixes: d10715be03bd ("video: ARM CLCD: Add DT support")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

video: fbdev: pxa3xx-gcu: release the resources correctly in pxa3xx_gcu_probe/remove() [+ + +]
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Fri May 13 18:05:41 2022 +0800

    video: fbdev: pxa3xx-gcu: release the resources correctly in pxa3xx_gcu_probe/remove()
    
    [ Upstream commit d87ad457f7e1b8d2492ca5b1531eb35030a1cc8f ]
    
    In pxa3xx_gcu_probe(), the sequence of error lable is wrong, it will
    leads some resource leaked, so adjust the sequence to handle the error
    correctly, and if pxa3xx_gcu_add_buffer() fails, pxa3xx_gcu_free_buffers()
    need be called.
    In pxa3xx_gcu_remove(), add missing clk_disable_unpreprare().
    
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
virtio_blk: fix the discard_granularity and discard_alignment queue limits [+ + +]
Author: Christoph Hellwig <hch@lst.de>
Date:   Mon Apr 18 06:53:07 2022 +0200

    virtio_blk: fix the discard_granularity and discard_alignment queue limits
    
    [ Upstream commit 62952cc5bccd89b76d710de1d0b43244af0f2903 ]
    
    The discard_alignment queue limit is named a bit misleading means the
    offset into the block device at which the discard granularity starts.
    
    On the other hand the discard_sector_alignment from the virtio 1.1 looks
    similar to what Linux uses as discard granularity (even if not very well
    described):
    
      "discard_sector_alignment can be used by OS when splitting a request
       based on alignment. "
    
    And at least qemu does set it to the discard granularity.
    
    So stop setting the discard_alignment and use the virtio
    discard_sector_alignment to set the discard granularity.
    
    Fixes: 1f23816b8eb8 ("virtio_blk: add discard and write zeroes support")
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
    Link: https://lore.kernel.org/r/20220418045314.360785-5-hch@lst.de
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
vringh: Fix loop descriptors check in the indirect cases [+ + +]
Author: Xie Yongji <xieyongji@bytedance.com>
Date:   Thu May 5 18:09:10 2022 +0800

    vringh: Fix loop descriptors check in the indirect cases
    
    [ Upstream commit dbd29e0752286af74243cf891accf472b2f3edd8 ]
    
    We should use size of descriptor chain to test loop condition
    in the indirect case. And another statistical count is also introduced
    for indirect descriptors to avoid conflict with the statistical count
    of direct descriptors.
    
    Fixes: f87d0fbb5798 ("vringh: host-side implementation of virtio rings.")
    Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
    Signed-off-by: Fam Zheng <fam.zheng@bytedance.com>
    Message-Id: <20220505100910.137-1-xieyongji@bytedance.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Acked-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
watchdog: ts4800_wdt: Fix refcount leak in ts4800_wdt_probe [+ + +]
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed May 11 15:42:03 2022 +0400

    watchdog: ts4800_wdt: Fix refcount leak in ts4800_wdt_probe
    
    [ Upstream commit 5d24df3d690809952528e7a19a43d84bc5b99d44 ]
    
    of_parse_phandle() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when done.
    Add  missing of_node_put() in some error paths.
    
    Fixes: bf9006399939 ("watchdog: ts4800: add driver for TS-4800 watchdog")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20220511114203.47420-1-linmq006@gmail.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

watchdog: wdat_wdt: Stop watchdog when rebooting the system [+ + +]
Author: Liu Xinpeng <liuxp11@chinatelecom.cn>
Date:   Tue Apr 26 22:53:29 2022 +0800

    watchdog: wdat_wdt: Stop watchdog when rebooting the system
    
    [ Upstream commit 27fdf84510a1374748904db43f6755f912736d92 ]
    
    Executing reboot command several times on the machine "Dell
    PowerEdge R740", UEFI security detection stopped machine
    with the following prompt:
    
    UEFI0082: The system was reset due to a timeout from the watchdog
    timer. Check the System Event Log (SEL) or crash dumps from
    Operating Sysstem to identify the source that triggered the
    watchdog timer reset. Update the firmware or driver for the
    identified device.
    
    iDRAC has warning event: "The watchdog timer reset the system".
    
    This patch fixes this issue by adding the reboot notifier.
    
    Signed-off-by: Liu Xinpeng <liuxp11@chinatelecom.cn>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/1650984810-6247-3-git-send-email-liuxp11@chinatelecom.cn
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
wifi: mac80211: fix use-after-free in chanctx code [+ + +]
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Wed Jun 1 09:19:36 2022 +0200

    wifi: mac80211: fix use-after-free in chanctx code
    
    commit 2965c4cdf7ad9ce0796fac5e57debb9519ea721e upstream.
    
    In ieee80211_vif_use_reserved_context(), when we have an
    old context and the new context's replace_state is set to
    IEEE80211_CHANCTX_REPLACE_NONE, we free the old context
    in ieee80211_vif_use_reserved_reassign(). Therefore, we
    cannot check the old_ctx anymore, so we should set it to
    NULL after this point.
    
    However, since the new_ctx replace state is clearly not
    IEEE80211_CHANCTX_REPLACES_OTHER, we're not going to do
    anything else in this function and can just return to
    avoid accessing the freed old_ctx.
    
    Cc: stable@vger.kernel.org
    Fixes: 5bcae31d9cb1 ("mac80211: implement multi-vif in-place reservations")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20220601091926.df419d91b165.I17a9b3894ff0b8323ce2afdb153b101124c821e5@changeid
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 
x86/cpu: Elide KCSAN for cpu_has() and friends [+ + +]
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Mon May 2 12:15:23 2022 +0200

    x86/cpu: Elide KCSAN for cpu_has() and friends
    
    [ Upstream commit a6a5eb269f6f3a2fe392f725a8d9052190c731e2 ]
    
    As x86 uses the <asm-generic/bitops/instrumented-*.h> headers, the
    regular forms of all bitops are instrumented with explicit calls to
    KASAN and KCSAN checks. As these are explicit calls, these are not
    suppressed by the noinstr function attribute.
    
    This can result in calls to those check functions in noinstr code, which
    objtool warns about:
    
    vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
    vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __kcsan_check_access() leaves .noinstr.text section
    vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: call to __kcsan_check_access() leaves .noinstr.text section
    vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __kcsan_check_access() leaves .noinstr.text section
    
    Prevent this by using the arch_*() bitops, which are the underlying
    bitops without explciit instrumentation.
    
    [null: Changelog]
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20220502111216.290518605@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86/delay: Fix the wrong asm constraint in delay_loop() [+ + +]
Author: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Date:   Tue Mar 29 17:47:04 2022 +0700

    x86/delay: Fix the wrong asm constraint in delay_loop()
    
    [ Upstream commit b86eb74098a92afd789da02699b4b0dd3f73b889 ]
    
    The asm constraint does not reflect the fact that the asm statement can
    modify the value of the local variable loops. Which it does.
    
    Specifying the wrong constraint may lead to undefined behavior, it may
    clobber random stuff (e.g. local variable, important temporary value in
    regs, etc.). This is especially dangerous when the compiler decides to
    inline the function and since it doesn't know that the value gets
    modified, it might decide to use it from a register directly without
    reloading it.
    
    Change the constraint to "+a" to denote that the first argument is an
    input and an output argument.
    
      [ bp: Fix typo, massage commit message. ]
    
    Fixes: e01b70ef3eb3 ("x86: fix bug in arch/i386/lib/delay.c file, delay_loop function")
    Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/20220329104705.65256-2-ammarfaizi2@gnuweeb.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86/mm: Cleanup the control_va_addr_alignment() __setup handler [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Mon Mar 14 17:10:45 2022 -0700

    x86/mm: Cleanup the control_va_addr_alignment() __setup handler
    
    [ Upstream commit 1ef64b1e89e6d4018da46e08ffc32779a31160c7 ]
    
    Clean up control_va_addr_alignment():
    
    a. Make '=' required instead of optional (as documented).
    b. Print a warning if an invalid option value is used.
    c. Return 1 from the __setup handler when an invalid option value is
       used. This prevents the kernel from polluting init's (limited)
       environment space with the entire string.
    
    Fixes: dfb09f9b7ab0 ("x86, amd: Avoid cache aliasing penalties on AMD family 15h")
    Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
    Link: https://lore.kernel.org/r/20220315001045.7680-1-rdunlap@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86/pm: Fix false positive kmemleak report in msr_build_context() [+ + +]
Author: Matthieu Baerts <matthieu.baerts@tessares.net>
Date:   Sat Apr 23 20:24:10 2022 +0200

    x86/pm: Fix false positive kmemleak report in msr_build_context()
    
    [ Upstream commit b0b592cf08367719e1d1ef07c9f136e8c17f7ec3 ]
    
    Since
    
      e2a1256b17b1 ("x86/speculation: Restore speculation related MSRs during S3 resume")
    
    kmemleak reports this issue:
    
      unreferenced object 0xffff888009cedc00 (size 256):
        comm "swapper/0", pid 1, jiffies 4294693823 (age 73.764s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00  ........H.......
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          msr_build_context (include/linux/slab.h:621)
          pm_check_save_msr (arch/x86/power/cpu.c:520)
          do_one_initcall (init/main.c:1298)
          kernel_init_freeable (init/main.c:1370)
          kernel_init (init/main.c:1504)
          ret_from_fork (arch/x86/entry/entry_64.S:304)
    
    Reproducer:
    
      - boot the VM with a debug kernel config (see
        https://github.com/multipath-tcp/mptcp_net-next/issues/268)
      - wait ~1 minute
      - start a kmemleak scan
    
    The root cause here is alignment within the packed struct saved_context
    (from suspend_64.h). Kmemleak only searches for pointers that are
    aligned (see how pointers are scanned in kmemleak.c), but pahole shows
    that the saved_msrs struct member and all members after it in the
    structure are unaligned:
    
      struct saved_context {
        struct pt_regs             regs;                 /*     0   168 */
        /* --- cacheline 2 boundary (128 bytes) was 40 bytes ago --- */
        u16                        ds;                   /*   168     2 */
    
        ...
    
        u64                        misc_enable;          /*   232     8 */
        bool                       misc_enable_saved;    /*   240     1 */
    
       /* Note below odd offset values for the remainder of this struct */
    
        struct saved_msrs          saved_msrs;           /*   241    16 */
        /* --- cacheline 4 boundary (256 bytes) was 1 bytes ago --- */
        long unsigned int          efer;                 /*   257     8 */
        u16                        gdt_pad;              /*   265     2 */
        struct desc_ptr            gdt_desc;             /*   267    10 */
        u16                        idt_pad;              /*   277     2 */
        struct desc_ptr            idt;                  /*   279    10 */
        u16                        ldt;                  /*   289     2 */
        u16                        tss;                  /*   291     2 */
        long unsigned int          tr;                   /*   293     8 */
        long unsigned int          safety;               /*   301     8 */
        long unsigned int          return_address;       /*   309     8 */
    
        /* size: 317, cachelines: 5, members: 25 */
        /* last cacheline: 61 bytes */
      } __attribute__((__packed__));
    
    Move misc_enable_saved to the end of the struct declaration so that
    saved_msrs fits in before the cacheline 4 boundary.
    
    The comment above the saved_context declaration says to fix wakeup_64.S
    file and __save/__restore_processor_state() if the struct is modified:
    it looks like all the accesses in wakeup_64.S are done through offsets
    which are computed at build-time. Update that comment accordingly.
    
    At the end, the false positive kmemleak report is due to a limitation
    from kmemleak but it is always good to avoid unaligned members for
    optimisation purposes.
    
    Please note that it looks like this issue is not new, e.g.
    
      https://lore.kernel.org/all/9f1bb619-c4ee-21c4-a251-870bd4db04fa@lwfinger.net/
      https://lore.kernel.org/all/94e48fcd-1dbd-ebd2-4c91-f39941735909@molgen.mpg.de/
    
      [ bp: Massage + cleanup commit message. ]
    
    Fixes: 7a9c2dd08ead ("x86/pm: Introduce quirk framework to save/restore extra MSR registers around suspend/resume")
    Suggested-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://lore.kernel.org/r/20220426202138.498310-1-matthieu.baerts@tessares.net
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86/speculation: Add missing prototype for unpriv_ebpf_notify() [+ + +]
Author: Josh Poimboeuf <jpoimboe@kernel.org>
Date:   Mon Apr 25 16:40:02 2022 -0700

    x86/speculation: Add missing prototype for unpriv_ebpf_notify()
    
    [ Upstream commit 2147c438fde135d6c145a96e373d9348e7076f7f ]
    
    Fix the following warnings seen with "make W=1":
    
      kernel/sysctl.c:183:13: warning: no previous prototype for ‘unpriv_ebpf_notify’ [-Wmissing-prototypes]
        183 | void __weak unpriv_ebpf_notify(int new_state)
            |             ^~~~~~~~~~~~~~~~~~
    
      arch/x86/kernel/cpu/bugs.c:659:6: warning: no previous prototype for ‘unpriv_ebpf_notify’ [-Wmissing-prototypes]
        659 | void unpriv_ebpf_notify(int new_state)
            |      ^~~~~~~~~~~~~~~~~~
    
    Fixes: 44a3918c8245 ("x86/speculation: Include unprivileged eBPF status in Spectre v2 mitigation reporting")
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/5689d065f739602ececaee1e05e68b8644009608.1650930000.git.jpoimboe@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
x86: Fix return value of __setup handlers [+ + +]
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Sun Mar 13 18:27:25 2022 -0700

    x86: Fix return value of __setup handlers
    
    [ Upstream commit 12441ccdf5e2f5a01a46e344976cbbd3d46845c9 ]
    
    __setup() handlers should return 1 to obsolete_checksetup() in
    init/main.c to indicate that the boot option has been handled. A return
    of 0 causes the boot option/value to be listed as an Unknown kernel
    parameter and added to init's (limited) argument (no '=') or environment
    (with '=') strings. So return 1 from these x86 __setup handlers.
    
    Examples:
    
      Unknown kernel command line parameters "apicpmtimer
        BOOT_IMAGE=/boot/bzImage-517rc8 vdso=1 ring3mwait=disable", will be
        passed to user space.
    
      Run /sbin/init as init process
       with arguments:
         /sbin/init
         apicpmtimer
       with environment:
         HOME=/
         TERM=linux
         BOOT_IMAGE=/boot/bzImage-517rc8
         vdso=1
         ring3mwait=disable
    
    Fixes: 2aae950b21e4 ("x86_64: Add vDSO for x86-64 with gettimeofday/clock_gettime/getcpu")
    Fixes: 77b52b4c5c66 ("x86: add "debugpat" boot option")
    Fixes: e16fd002afe2 ("x86/cpufeature: Enable RING3MWAIT for Knights Landing")
    Fixes: b8ce33590687 ("x86_64: convert to clock events")
    Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
    Link: https://lore.kernel.org/r/20220314012725.26661-1-rdunlap@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
xen: unexport __init-annotated xen_xlate_map_ballooned_pages() [+ + +]
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Mon Jun 6 13:59:20 2022 +0900

    xen: unexport __init-annotated xen_xlate_map_ballooned_pages()
    
    [ Upstream commit dbac14a5a05ff8e1ce7c0da0e1f520ce39ec62ea ]
    
    EXPORT_SYMBOL and __init is a bad combination because the .init.text
    section is freed up after the initialization. Hence, modules cannot
    use symbols annotated __init. The access to a freed symbol may end up
    with kernel panic.
    
    modpost used to detect it, but it has been broken for a decade.
    
    Recently, I fixed modpost so it started to warn it again, then this
    showed up in linux-next builds.
    
    There are two ways to fix it:
    
      - Remove __init
      - Remove EXPORT_SYMBOL
    
    I chose the latter for this case because none of the in-tree call-sites
    (arch/arm/xen/enlighten.c, arch/x86/xen/grant-table.c) is compiled as
    modular.
    
    Fixes: 243848fc018c ("xen/grant-table: Move xlated_setup_gnttab_pages to common place")
    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
    Link: https://lore.kernel.org/r/20220606045920.4161881-1-masahiroy@kernel.org
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

 
xprtrdma: treat all calls not a bcall when bc_serv is NULL [+ + +]
Author: Kinglong Mee <kinglongmee@gmail.com>
Date:   Sun May 22 20:36:48 2022 +0800

    xprtrdma: treat all calls not a bcall when bc_serv is NULL
    
    [ Upstream commit 11270e7ca268e8d61b5d9e5c3a54bd1550642c9c ]
    
    When a rdma server returns a fault format reply, nfs v3 client may
    treats it as a bcall when bc service is not exist.
    
    The debug message at rpcrdma_bc_receive_call are,
    
    [56579.837169] RPC:       rpcrdma_bc_receive_call: callback XID
    00000001, length=20
    [56579.837174] RPC:       rpcrdma_bc_receive_call: 00 00 00 01 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 04
    
    After that, rpcrdma_bc_receive_call will meets NULL pointer as,
    
    [  226.057890] BUG: unable to handle kernel NULL pointer dereference at
    00000000000000c8
    ...
    [  226.058704] RIP: 0010:_raw_spin_lock+0xc/0x20
    ...
    [  226.059732] Call Trace:
    [  226.059878]  rpcrdma_bc_receive_call+0x138/0x327 [rpcrdma]
    [  226.060011]  __ib_process_cq+0x89/0x170 [ib_core]
    [  226.060092]  ib_cq_poll_work+0x26/0x80 [ib_core]
    [  226.060257]  process_one_work+0x1a7/0x360
    [  226.060367]  ? create_worker+0x1a0/0x1a0
    [  226.060440]  worker_thread+0x30/0x390
    [  226.060500]  ? create_worker+0x1a0/0x1a0
    [  226.060574]  kthread+0x116/0x130
    [  226.060661]  ? kthread_flush_work_fn+0x10/0x10
    [  226.060724]  ret_from_fork+0x35/0x40
    ...
    
    Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
    Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>