Changelog in Linux kernel 6.10.5

 
ACPI: battery: create alarm sysfs attribute atomically [+ + +]
Author: Thomas Weißschuh <[email protected]>
Date:   Sun Jun 9 09:27:16 2024 +0200

    ACPI: battery: create alarm sysfs attribute atomically
    
    [ Upstream commit a231eed10ed5a290129fda36ad7bcc263c53ff7d ]
    
    Let the power supply core register the attribute.
    This ensures that the attribute is created before the device is
    announced to userspace, avoid a race condition.
    
    Signed-off-by: Thomas Weißschuh <[email protected]>
    Signed-off-by: Rafael J. Wysocki <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ACPI: resource: Skip IRQ override on Asus Vivobook Pro N6506MJ [+ + +]
Author: Tamim Khan <[email protected]>
Date:   Sun Jul 7 20:05:50 2024 -0400

    ACPI: resource: Skip IRQ override on Asus Vivobook Pro N6506MJ
    
    [ Upstream commit e2e7f037b400aebbb3892d8010fb3d9cae6f426e ]
    
    Similar to other Asus Vivobooks, the Asus Vivobook Pro N6506MJ has a DSDT table
    that describes IRQ 1 as ActiveLow, whereas the kernel overrides it to Edge_High.
    This discrepancy prevents the internal keyboard from functioning properly. This
    patch resolves this issue by adding this laptop to the override table that prevents
    the kernel from overriding this IRQ.
    
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=218929
    Tested-by: Amber Connelly <[email protected]>
    Signed-off-by: Tamim Khan <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Rafael J. Wysocki <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ACPI: resource: Skip IRQ override on Asus Vivobook Pro N6506MU [+ + +]
Author: Tamim Khan <[email protected]>
Date:   Tue Jul 2 08:58:06 2024 -0400

    ACPI: resource: Skip IRQ override on Asus Vivobook Pro N6506MU
    
    [ Upstream commit dc41751f9e07889d078e3f06adb6e892c80b7c10 ]
    
    Like various other Asus laptops, the Asus Vivobook Pro N6506MV has a
    DSDT table that describes IRQ 1 as ActiveLow while the kernel is overriding
    it to Edge_High. This prevents the internal keyboard from working. This patch
    prevents this issue by adding this laptop to the override table that prevents
    the kernel from overriding this IRQ
    
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=218954
    Tested-by: Lefteris <[email protected]>
    Signed-off-by: Tamim Khan <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Rafael J. Wysocki <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ACPI: SBS: manage alarm sysfs attribute through psy core [+ + +]
Author: Thomas Weißschuh <[email protected]>
Date:   Sun Jun 9 13:13:28 2024 +0200

    ACPI: SBS: manage alarm sysfs attribute through psy core
    
    [ Upstream commit 6bad28cfc30988a845fb3f59a99f4b8a4ce8fe95 ]
    
    Let the power supply core register the attribute.
    
    This ensures that the attribute is created before the device is
    announced to userspace, avoiding a race condition.
    
    Signed-off-by: Thomas Weißschuh <[email protected]>
    Signed-off-by: Rafael J. Wysocki <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
af_unix: Don't retry after unix_state_lock_nested() in unix_stream_connect(). [+ + +]
Author: Kuniyuki Iwashima <[email protected]>
Date:   Thu Jun 20 13:56:15 2024 -0700

    af_unix: Don't retry after unix_state_lock_nested() in unix_stream_connect().
    
    [ Upstream commit 1ca27e0c8c13ac50a4acf9cdf77069e2d94a547d ]
    
    When a SOCK_(STREAM|SEQPACKET) socket connect()s to another one, we need
    to lock the two sockets to check their states in unix_stream_connect().
    
    We use unix_state_lock() for the server and unix_state_lock_nested() for
    client with tricky sk->sk_state check to avoid deadlock.
    
    The possible deadlock scenario are the following:
    
      1) Self connect()
      2) Simultaneous connect()
    
    The former is simple, attempt to grab the same lock, and the latter is
    AB-BA deadlock.
    
    After the server's unix_state_lock(), we check the server socket's state,
    and if it's not TCP_LISTEN, connect() fails with -EINVAL.
    
    Then, we avoid the former deadlock by checking the client's state before
    unix_state_lock_nested().  If its state is not TCP_LISTEN, we can make
    sure that the client and the server are not identical based on the state.
    
    Also, the latter deadlock can be avoided in the same way.  Due to the
    server sk->sk_state requirement, AB-BA deadlock could happen only with
    TCP_LISTEN sockets.  So, if the client's state is TCP_LISTEN, we can
    give up the second lock to avoid the deadlock.
    
      CPU 1                 CPU 2                  CPU 3
      connect(A -> B)       connect(B -> A)        listen(A)
      ---                   ---                    ---
      unix_state_lock(B)
      B->sk_state == TCP_LISTEN
      READ_ONCE(A->sk_state) == TCP_CLOSE
                                ^^^^^^^^^
                                ok, will lock A    unix_state_lock(A)
                 .--------------'                  WRITE_ONCE(A->sk_state, TCP_LISTEN)
                 |                                 unix_state_unlock(A)
                 |
                 |          unix_state_lock(A)
                 |          A->sk_sk_state == TCP_LISTEN
                 |          READ_ONCE(B->sk_state) == TCP_LISTEN
                 v                                    ^^^^^^^^^^
      unix_state_lock_nested(A)                       Don't lock B !!
    
    Currently, while checking the client's state, we also check if it's
    TCP_ESTABLISHED, but this is unlikely and can be checked after we know
    the state is not TCP_CLOSE.
    
    Moreover, if it happens after the second lock, we now jump to the restart
    label, but it's unlikely that the server is not found during the retry,
    so the jump is mostly to revist the client state check.
    
    Let's remove the retry logic and check the state against TCP_CLOSE first.
    
    Signed-off-by: Kuniyuki Iwashima <[email protected]>
    Signed-off-by: Paolo Abeni <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
ALSA: hda/hdmi: Yet more pin fix for HP EliteDesk 800 G4 [+ + +]
Author: Takashi Iwai <[email protected]>
Date:   Tue Aug 6 08:49:16 2024 +0200

    ALSA: hda/hdmi: Yet more pin fix for HP EliteDesk 800 G4
    
    commit 176fd1511dd9086ab4fa9323cb232177c6235288 upstream.
    
    HP EliteDesk 800 G4 (PCI SSID 103c:83e2) is another Kabylake machine
    where BIOS misses the HDMI pin initializations.  Add the quirk entry.
    
    Cc: <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Takashi Iwai <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

ALSA: hda/realtek: Add Framework Laptop 13 (Intel Core Ultra) to quirks [+ + +]
Author: Dustin L. Howett <[email protected]>
Date:   Tue Aug 6 21:33:51 2024 -0500

    ALSA: hda/realtek: Add Framework Laptop 13 (Intel Core Ultra) to quirks
    
    commit eb91c456f3714c336f0812dccab422ec0e72bde4 upstream.
    
    The Framework Laptop 13 (Intel Core Ultra) has an ALC285 that ships in a
    similar configuration to the ALC295 in previous models. It requires the
    same quirk for headset detection.
    
    Signed-off-by: Dustin L. Howett <[email protected]>
    Cc: <[email protected]>
    Link: https://patch.msgid.link/20240806-alsa-hda-realtek-add-framework-laptop-13-intel-core-ultra-to-quirks-v1-1-42d6ce2dbf14@howett.net
    Signed-off-by: Takashi Iwai <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

ALSA: hda: Add HP MP9 G4 Retail System AMS to force connect list [+ + +]
Author: Steven 'Steve' Kendall <[email protected]>
Date:   Tue Aug 6 00:08:24 2024 +0000

    ALSA: hda: Add HP MP9 G4 Retail System AMS to force connect list
    
    commit 7e1e206b99f4b3345aeb49d94584a420b7887f1d upstream.
    
    In recent HP UEFI firmware (likely v2.15 and above, tested on 2.27),
    these pins are incorrectly set for HDMI/DP audio. Tested on
    HP MP9 G4 Retail System AMS. Tested audio with two monitors connected
    via DisplayPort.
    
    Link: https://forum.manjaro.org/t/intel-cannon-lake-pch-cavs-conexant-cx20632-no-sound-at-hdmi-or-displayport/133494
    Link: https://bbs.archlinux.org/viewtopic.php?id=270523
    Signed-off-by: Steven 'Steve' Kendall <[email protected]>
    Cc: <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Takashi Iwai <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

ALSA: line6: Fix racy access to midibuf [+ + +]
Author: Takashi Iwai <[email protected]>
Date:   Mon Aug 5 15:01:28 2024 +0200

    ALSA: line6: Fix racy access to midibuf
    
    commit 15b7a03205b31bc5623378c190d22b7ff60026f1 upstream.
    
    There can be concurrent accesses to line6 midibuf from both the URB
    completion callback and the rawmidi API access.  This could be a cause
    of KMSAN warning triggered by syzkaller below (so put as reported-by
    here).
    
    This patch protects the midibuf call of the former code path with a
    spinlock for avoiding the possible races.
    
    Reported-by: [email protected]
    Closes: https://lore.kernel.org/[email protected]
    Cc: <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Takashi Iwai <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

ALSA: usb-audio: Re-add ScratchAmp quirk entries [+ + +]
Author: Takashi Iwai <[email protected]>
Date:   Thu Aug 8 10:18:01 2024 +0200

    ALSA: usb-audio: Re-add ScratchAmp quirk entries
    
    [ Upstream commit 03898691d42e0170e7d00f07cbe21ce0e9f3a8fa ]
    
    At the code refactoring of USB-audio quirk handling, I assumed that
    the quirk entries of Stanton ScratchAmp devices were only about the
    device name, and moved them completely into the rename table.
    But it seems that the device requires the quirk entry so that it's
    probed by the driver itself.
    
    This re-adds back the quirk entries of ScratchAmp, but in a
    minimalistic manner.
    
    Fixes: 5436f59bc5bc ("ALSA: usb-audio: Move device rename and profile quirks to an internal table")
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Takashi Iwai <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
arm64: cputype: Add Cortex-A720 definitions [+ + +]
Author: Mark Rutland <[email protected]>
Date:   Fri Aug 9 10:51:14 2024 +0100

    arm64: cputype: Add Cortex-A720 definitions
    
    [ Upstream commit add332c40328cf06fe35e4b3cde8ec315c4629e5 ]
    
    Add cputype definitions for Cortex-A720. These will be used for errata
    detection in subsequent patches.
    
    These values can be found in Table A-186 ("MIDR_EL1 bit descriptions")
    in issue 0002-05 of the Cortex-A720 TRM, which can be found at:
    
      https://developer.arm.com/documentation/102530/0002/?lang=en
    
    Signed-off-by: Mark Rutland <[email protected]>
    Cc: James Morse <[email protected]>
    Cc: Will Deacon <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Catalin Marinas <[email protected]>
    [ Mark: trivial backport ]
    Signed-off-by: Mark Rutland <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

arm64: cputype: Add Cortex-A725 definitions [+ + +]
Author: Mark Rutland <[email protected]>
Date:   Fri Aug 9 10:51:19 2024 +0100

    arm64: cputype: Add Cortex-A725 definitions
    
    [ Upstream commit 9ef54a384526911095db465e77acc1cb5266b32c ]
    
    Add cputype definitions for Cortex-A725. These will be used for errata
    detection in subsequent patches.
    
    These values can be found in the Cortex-A725 TRM:
    
      https://developer.arm.com/documentation/107652/0001/
    
    ... in table A-247 ("MIDR_EL1 bit descriptions").
    
    Signed-off-by: Mark Rutland <[email protected]>
    Cc: James Morse <[email protected]>
    Cc: Will Deacon <[email protected]>
    Reviewed-by: Anshuman Khandual <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Catalin Marinas <[email protected]>
    [ Mark: trivial backport ]
    Signed-off-by: Mark Rutland <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

arm64: cputype: Add Cortex-X1C definitions [+ + +]
Author: Mark Rutland <[email protected]>
Date:   Fri Aug 9 10:51:18 2024 +0100

    arm64: cputype: Add Cortex-X1C definitions
    
    [ Upstream commit 58d245e03c324d083a0ec3b9ab8ebd46ec9848d7 ]
    
    Add cputype definitions for Cortex-X1C. These will be used for errata
    detection in subsequent patches.
    
    These values can be found in the Cortex-X1C TRM:
    
      https://developer.arm.com/documentation/101968/0002/
    
    ... in section B2.107 ("MIDR_EL1, Main ID Register, EL1").
    
    Signed-off-by: Mark Rutland <[email protected]>
    Cc: James Morse <[email protected]>
    Cc: Will Deacon <[email protected]>
    Reviewed-by: Anshuman Khandual <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Catalin Marinas <[email protected]>
    [ Mark: trivial backport ]
    Signed-off-by: Mark Rutland <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

arm64: cputype: Add Cortex-X3 definitions [+ + +]
Author: Mark Rutland <[email protected]>
Date:   Fri Aug 9 10:51:13 2024 +0100

    arm64: cputype: Add Cortex-X3 definitions
    
    [ Upstream commit be5a6f238700f38b534456608588723fba96c5ab ]
    
    Add cputype definitions for Cortex-X3. These will be used for errata
    detection in subsequent patches.
    
    These values can be found in Table A-263 ("MIDR_EL1 bit descriptions")
    in issue 07 of the Cortex-X3 TRM, which can be found at:
    
      https://developer.arm.com/documentation/101593/0102/?lang=en
    
    Signed-off-by: Mark Rutland <[email protected]>
    Cc: James Morse <[email protected]>
    Cc: Will Deacon <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Catalin Marinas <[email protected]>
    [ Mark: trivial backport ]
    Signed-off-by: Mark Rutland <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

arm64: cputype: Add Cortex-X925 definitions [+ + +]
Author: Mark Rutland <[email protected]>
Date:   Fri Aug 9 10:51:15 2024 +0100

    arm64: cputype: Add Cortex-X925 definitions
    
    [ Upstream commit fd2ff5f0b320f418288e7a1f919f648fbc8a0dfc ]
    
    Add cputype definitions for Cortex-X925. These will be used for errata
    detection in subsequent patches.
    
    These values can be found in Table A-285 ("MIDR_EL1 bit descriptions")
    in issue 0001-05 of the Cortex-X925 TRM, which can be found at:
    
      https://developer.arm.com/documentation/102807/0001/?lang=en
    
    Signed-off-by: Mark Rutland <[email protected]>
    Cc: James Morse <[email protected]>
    Cc: Will Deacon <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Catalin Marinas <[email protected]>
    [ Mark: trivial backport ]
    Signed-off-by: Mark Rutland <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

arm64: dts: ti: k3-am62-verdin-dahlia: Keep CTRL_SLEEP_MOCI# regulator on [+ + +]
Author: Francesco Dolcini <[email protected]>
Date:   Wed Jul 31 07:48:04 2024 +0200

    arm64: dts: ti: k3-am62-verdin-dahlia: Keep CTRL_SLEEP_MOCI# regulator on
    
    commit 9438f970296f9c3a6dd340ae0ad01d2f056c88e6 upstream.
    
    This reverts commit 3935fbc87ddebea5439f3ab6a78b1e83e976bf88.
    
    CTRL_SLEEP_MOCI# is a signal that is defined for all the SoM
    implementing the Verdin family specification, this signal is supposed to
    control the power enable in the carrier board when the system is in deep
    sleep mode. However this is not possible with Texas Instruments AM62
    SoC, IOs output buffer is disabled in deep sleep and IOs are in
    tri-state mode.
    
    Given that we cannot properly control this pin, force it to be always
    high to minimize potential issues.
    
    Fixes: 3935fbc87dde ("arm64: dts: ti: k3-am62-verdin-dahlia: support sleep-moci")
    Cc:  <[email protected]>
    Link: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1361669/am625-gpio-output-state-in-deep-sleep/5244802
    Signed-off-by: Francesco Dolcini <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Nishanth Menon <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

arm64: errata: Expand speculative SSBS workaround [+ + +]
Author: Mark Rutland <[email protected]>
Date:   Fri Aug 9 10:51:17 2024 +0100

    arm64: errata: Expand speculative SSBS workaround
    
    [ Upstream commit 75b3c43eab594bfbd8184ec8ee1a6b820950819a ]
    
    A number of Arm Ltd CPUs suffer from errata whereby an MSR to the SSBS
    special-purpose register does not affect subsequent speculative
    instructions, permitting speculative store bypassing for a window of
    time.
    
    We worked around this for Cortex-X4 and Neoverse-V3, in commit:
    
      7187bb7d0b5c7dfa ("arm64: errata: Add workaround for Arm errata 3194386 and 3312417")
    
    ... as per their Software Developer Errata Notice (SDEN) documents:
    
    * Cortex-X4 SDEN v8.0, erratum 3194386:
      https://developer.arm.com/documentation/SDEN-2432808/0800/
    
    * Neoverse-V3 SDEN v6.0, erratum 3312417:
      https://developer.arm.com/documentation/SDEN-2891958/0600/
    
    Since then, similar errata have been published for a number of other Arm Ltd
    CPUs, for which the mitigation is the same. This is described in their
    respective SDEN documents:
    
    * Cortex-A710 SDEN v19.0, errataum 3324338
      https://developer.arm.com/documentation/SDEN-1775101/1900/?lang=en
    
    * Cortex-A720 SDEN v11.0, erratum 3456091
      https://developer.arm.com/documentation/SDEN-2439421/1100/?lang=en
    
    * Cortex-X2 SDEN v19.0, erratum 3324338
      https://developer.arm.com/documentation/SDEN-1775100/1900/?lang=en
    
    * Cortex-X3 SDEN v14.0, erratum 3324335
      https://developer.arm.com/documentation/SDEN-2055130/1400/?lang=en
    
    * Cortex-X925 SDEN v8.0, erratum 3324334
      https://developer.arm.com/documentation/109108/800/?lang=en
    
    * Neoverse-N2 SDEN v17.0, erratum 3324339
      https://developer.arm.com/documentation/SDEN-1982442/1700/?lang=en
    
    * Neoverse-V2 SDEN v9.0, erratum 3324336
      https://developer.arm.com/documentation/SDEN-2332927/900/?lang=en
    
    Note that due to shared design lineage, some CPUs share the same erratum
    number.
    
    Add these to the existing mitigation under CONFIG_ARM64_ERRATUM_3194386.
    As listing all of the erratum IDs in the runtime description would be
    unwieldy, this is reduced to:
    
            "SSBS not fully self-synchronizing"
    
    ... matching the description of the errata in all of the SDENs.
    
    Signed-off-by: Mark Rutland <[email protected]>
    Cc: James Morse <[email protected]>
    Cc: Will Deacon <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Catalin Marinas <[email protected]>
    [ Mark: trivial backport ]
    Signed-off-by: Mark Rutland <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

arm64: errata: Expand speculative SSBS workaround (again) [+ + +]
Author: Mark Rutland <[email protected]>
Date:   Fri Aug 9 10:51:20 2024 +0100

    arm64: errata: Expand speculative SSBS workaround (again)
    
    [ Upstream commit adeec61a4723fd3e39da68db4cc4d924e6d7f641 ]
    
    A number of Arm Ltd CPUs suffer from errata whereby an MSR to the SSBS
    special-purpose register does not affect subsequent speculative
    instructions, permitting speculative store bypassing for a window of
    time.
    
    We worked around this for a number of CPUs in commits:
    
    * 7187bb7d0b5c7dfa ("arm64: errata: Add workaround for Arm errata 3194386 and 3312417")
    * 75b3c43eab594bfb ("arm64: errata: Expand speculative SSBS workaround")
    
    Since then, similar errata have been published for a number of other Arm
    Ltd CPUs, for which the same mitigation is sufficient. This is described
    in their respective Software Developer Errata Notice (SDEN) documents:
    
    * Cortex-A76 (MP052) SDEN v31.0, erratum 3324349
      https://developer.arm.com/documentation/SDEN-885749/3100/
    
    * Cortex-A77 (MP074) SDEN v19.0, erratum 3324348
      https://developer.arm.com/documentation/SDEN-1152370/1900/
    
    * Cortex-A78 (MP102) SDEN v21.0, erratum 3324344
      https://developer.arm.com/documentation/SDEN-1401784/2100/
    
    * Cortex-A78C (MP138) SDEN v16.0, erratum 3324346
      https://developer.arm.com/documentation/SDEN-1707916/1600/
    
    * Cortex-A78C (MP154) SDEN v10.0, erratum 3324347
      https://developer.arm.com/documentation/SDEN-2004089/1000/
    
    * Cortex-A725 (MP190) SDEN v5.0, erratum 3456106
      https://developer.arm.com/documentation/SDEN-2832921/0500/
    
    * Cortex-X1 (MP077) SDEN v21.0, erratum 3324344
      https://developer.arm.com/documentation/SDEN-1401782/2100/
    
    * Cortex-X1C (MP136) SDEN v16.0, erratum 3324346
      https://developer.arm.com/documentation/SDEN-1707914/1600/
    
    * Neoverse-N1 (MP050) SDEN v32.0, erratum 3324349
      https://developer.arm.com/documentation/SDEN-885747/3200/
    
    * Neoverse-V1 (MP076) SDEN v19.0, erratum 3324341
      https://developer.arm.com/documentation/SDEN-1401781/1900/
    
    Note that due to the manner in which Arm develops IP and tracks errata,
    some CPUs share a common erratum number and some CPUs have multiple
    erratum numbers for the same HW issue.
    
    On parts without SB, it is necessary to use ISB for the workaround. The
    spec_bar() macro used in the mitigation will expand to a "DSB SY; ISB"
    sequence in this case, which is sufficient on all affected parts.
    
    Enable the existing mitigation by adding the relevant MIDRs to
    erratum_spec_ssbs_list. The list is sorted alphanumerically (involving
    moving Neoverse-V3 after Neoverse-V2) so that this is easy to audit and
    potentially extend again in future. The Kconfig text is also updated to
    clarify the set of affected parts and the mitigation.
    
    Signed-off-by: Mark Rutland <[email protected]>
    Cc: James Morse <[email protected]>
    Cc: Will Deacon <[email protected]>
    Reviewed-by: Anshuman Khandual <[email protected]>
    Acked-by: Will Deacon <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Catalin Marinas <[email protected]>
    [ Mark: trivial backport ]
    Signed-off-by: Mark Rutland <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

arm64: errata: Unify speculative SSBS errata logic [+ + +]
Author: Mark Rutland <[email protected]>
Date:   Fri Aug 9 10:51:16 2024 +0100

    arm64: errata: Unify speculative SSBS errata logic
    
    [ Upstream commit ec768766608092087dfb5c1fc45a16a6f524dee2 ]
    
    Cortex-X4 erratum 3194386 and Neoverse-V3 erratum 3312417 are identical,
    with duplicate Kconfig text and some unsightly ifdeffery. While we try
    to share code behind CONFIG_ARM64_WORKAROUND_SPECULATIVE_SSBS, having
    separate options results in a fair amount of boilerplate code, and this
    will only get worse as we expand the set of affected CPUs.
    
    To reduce this boilerplate, unify the two behind a common Kconfig
    option. This removes the duplicate text and Kconfig logic, and removes
    the need for the intermediate ARM64_WORKAROUND_SPECULATIVE_SSBS option.
    The set of affected CPUs is described as a list so that this can easily
    be extended.
    
    I've used ARM64_ERRATUM_3194386 (matching the Neoverse-V3 erratum ID) as
    the common option, matching the way we use ARM64_ERRATUM_1319367 to
    cover Cortex-A57 erratum 1319537 and Cortex-A72 erratum 1319367.
    
    Signed-off-by: Mark Rutland <[email protected]>
    Cc: James Morse <[email protected]>
    Cc: Will Deacon <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Catalin Marinas <[email protected]>
    [ Mark: trivial backport ]
    Signed-off-by: Mark Rutland <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
ASoC: amd: yc: Add quirk entry for OMEN by HP Gaming Laptop 16-n0xxx [+ + +]
Author: Takashi Iwai <[email protected]>
Date:   Wed Aug 7 19:02:27 2024 +0200

    ASoC: amd: yc: Add quirk entry for OMEN by HP Gaming Laptop 16-n0xxx
    
    commit 6675e76a5c441b52b1b983ebb714122087020ebe upstream.
    
    Fix the missing mic on OMEN by HP Gaming Laptop 16-n0xxx by adding the
    quirk entry with the board ID 8A44.
    
    Cc: [email protected]
    Link: https://bugzilla.suse.com/show_bug.cgi?id=1227182
    Signed-off-by: Takashi Iwai <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

ASoC: codecs: wcd938x-sdw: Correct Soundwire ports mask [+ + +]
Author: Krzysztof Kozlowski <[email protected]>
Date:   Fri Jul 26 16:10:42 2024 +0200

    ASoC: codecs: wcd938x-sdw: Correct Soundwire ports mask
    
    [ Upstream commit 3f6fb03dae9c7dfba7670858d29e03c8faaa89fe ]
    
    Device has up to WCD938X_MAX_SWR_PORTS number of ports and the array
    assigned to prop.src_dpn_prop and prop.sink_dpn_prop has
    0..WCD938X_MAX_SWR_PORTS-1 elements.  On the other hand, GENMASK(high,
    low) creates an inclusive mask between <high, low>, so we need the mask
    from 0 up to WCD938X_MAX_SWR_PORTS-1.
    
    Theoretically, too wide mask could cause an out of bounds read in
    sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy
    driver, e.g. adding incorrect number of ports via
    sdw_stream_add_slave().
    
    Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
    Signed-off-by: Krzysztof Kozlowski <[email protected]>
    Link: https://patch.msgid.link/20240726-asoc-wcd-wsa-swr-ports-genmask-v1-2-d4d7a8b56f05@linaro.org
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: codecs: wcd939x-sdw: Correct Soundwire ports mask [+ + +]
Author: Krzysztof Kozlowski <[email protected]>
Date:   Fri Jul 26 16:10:43 2024 +0200

    ASoC: codecs: wcd939x-sdw: Correct Soundwire ports mask
    
    [ Upstream commit 74a79977c4e1d09eced33e6e22f875a5bb3fad29 ]
    
    Device has up to WCD939X_MAX_TX_SWR_PORTS (or WCD939X_MAX_RX_SWR_PORTS
    for sink) number of ports and the array assigned to prop.src_dpn_prop
    and prop.sink_dpn_prop has 0..WCD939X_MAX_TX_SWR_PORTS-1 elements.  On
    the other hand, GENMASK(high, low) creates an inclusive mask between
    <high, low>, so we need the mask from 0 up to WCD939X_MAX_TX_SWR_PORTS-1.
    
    Theoretically, too wide mask could cause an out of bounds read in
    sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy
    driver, e.g. adding incorrect number of ports via
    sdw_stream_add_slave().
    
    Fixes: be2af391cea0 ("ASoC: codecs: Add WCD939x Soundwire devices driver")
    Signed-off-by: Krzysztof Kozlowski <[email protected]>
    Link: https://patch.msgid.link/20240726-asoc-wcd-wsa-swr-ports-genmask-v1-3-d4d7a8b56f05@linaro.org
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: codecs: wsa881x: Correct Soundwire ports mask [+ + +]
Author: Krzysztof Kozlowski <[email protected]>
Date:   Fri Jul 26 16:10:44 2024 +0200

    ASoC: codecs: wsa881x: Correct Soundwire ports mask
    
    [ Upstream commit eb11c3bb64ad0a05aeacdb01039863aa2aa3614b ]
    
    Device has up to WSA881X_MAX_SWR_PORTS number of ports and the array
    assigned to prop.sink_dpn_prop has 0..WSA881X_MAX_SWR_PORTS-1 elements.
    On the other hand, GENMASK(high, low) creates an inclusive mask between
    <high, low>, so we need the mask from 0 up to WSA881X_MAX_SWR_PORTS-1.
    
    Theoretically, too wide mask could cause an out of bounds read in
    sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy
    driver, e.g. adding incorrect number of ports via
    sdw_stream_add_slave().
    
    Fixes: a0aab9e1404a ("ASoC: codecs: add wsa881x amplifier support")
    Signed-off-by: Krzysztof Kozlowski <[email protected]>
    Link: https://patch.msgid.link/20240726-asoc-wcd-wsa-swr-ports-genmask-v1-4-d4d7a8b56f05@linaro.org
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: codecs: wsa883x: Correct Soundwire ports mask [+ + +]
Author: Krzysztof Kozlowski <[email protected]>
Date:   Fri Jul 26 16:10:45 2024 +0200

    ASoC: codecs: wsa883x: Correct Soundwire ports mask
    
    [ Upstream commit 6801ac36f25690e14955f7f9eace1eaa29edbdd0 ]
    
    Device has up to WSA883X_MAX_SWR_PORTS number of ports and the array
    assigned to prop.sink_dpn_prop has 0..WSA883X_MAX_SWR_PORTS-1 elements.
    On the other hand, GENMASK(high, low) creates an inclusive mask between
    <high, low>, so we need the mask from 0 up to WSA883X_MAX_SWR_PORTS-1.
    
    Theoretically, too wide mask could cause an out of bounds read in
    sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy
    driver, e.g. adding incorrect number of ports via
    sdw_stream_add_slave().
    
    Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support")
    Signed-off-by: Krzysztof Kozlowski <[email protected]>
    Link: https://patch.msgid.link/20240726-asoc-wcd-wsa-swr-ports-genmask-v1-5-d4d7a8b56f05@linaro.org
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: codecs: wsa883x: parse port-mapping information [+ + +]
Author: Srinivas Kandagatla <[email protected]>
Date:   Thu Jun 27 15:44:39 2024 +0100

    ASoC: codecs: wsa883x: parse port-mapping information
    
    [ Upstream commit 1cf3295bd108abbd7f128071ae9775fd18394ca9 ]
    
    Add support to parse static master port map information from device tree.
    
    Reviewed-by: Krzysztof Kozlowski <[email protected]>
    Tested-by: Krzysztof Kozlowski <[email protected]>
    Tested-by: Neil Armstrong <[email protected]> # on SM8650-HDK
    Signed-off-by: Srinivas Kandagatla <[email protected]>
    Reviewed-by: Dmitry Baryshkov <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Stable-dep-of: 6801ac36f256 ("ASoC: codecs: wsa883x: Correct Soundwire ports mask")
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: codecs: wsa884x: Correct Soundwire ports mask [+ + +]
Author: Krzysztof Kozlowski <[email protected]>
Date:   Fri Jul 26 16:10:46 2024 +0200

    ASoC: codecs: wsa884x: Correct Soundwire ports mask
    
    [ Upstream commit dcb6631d05152930e2ea70fd2abfd811b0e970b5 ]
    
    Device has up to WSA884X_MAX_SWR_PORTS number of ports and the array
    assigned to prop.sink_dpn_prop has 0..WSA884X_MAX_SWR_PORTS-1 elements.
    On the other hand, GENMASK(high, low) creates an inclusive mask between
    <high, low>, so we need the mask from 0 up to WSA884X_MAX_SWR_PORTS-1.
    
    Theoretically, too wide mask could cause an out of bounds read in
    sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy
    driver, e.g. adding incorrect number of ports via
    sdw_stream_add_slave().
    
    Fixes: aa21a7d4f68a ("ASoC: codecs: wsa884x: Add WSA884x family of speakers")
    Signed-off-by: Krzysztof Kozlowski <[email protected]>
    Link: https://patch.msgid.link/20240726-asoc-wcd-wsa-swr-ports-genmask-v1-6-d4d7a8b56f05@linaro.org
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: codecs: wsa884x: parse port-mapping information [+ + +]
Author: Srinivas Kandagatla <[email protected]>
Date:   Thu Jun 27 15:44:41 2024 +0100

    ASoC: codecs: wsa884x: parse port-mapping information
    
    [ Upstream commit e1bc5c324bcca3acdbe817ccbf9aa7992d89479d ]
    
    Add support to parse static master port map information from device tree.
    This is required for correct port mapping between soundwire device and
    master ports.
    
    Reviewed-by: Krzysztof Kozlowski <[email protected]>
    Tested-by: Krzysztof Kozlowski <[email protected]>
    Reviewed-by: Neil Armstrong <[email protected]>
    Tested-by: Neil Armstrong <[email protected]> # on SM8650-HDK
    Signed-off-by: Srinivas Kandagatla <[email protected]>
    Reviewed-by: Dmitry Baryshkov <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Stable-dep-of: dcb6631d0515 ("ASoC: codecs: wsa884x: Correct Soundwire ports mask")
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: cs-amp-lib: Fix NULL pointer crash if efi.get_variable is NULL [+ + +]
Author: Richard Fitzgerald <[email protected]>
Date:   Mon Aug 5 12:42:22 2024 +0100

    ASoC: cs-amp-lib: Fix NULL pointer crash if efi.get_variable is NULL
    
    [ Upstream commit dc268085e499666b9f4f0fcb4c5a94e1c0b193b3 ]
    
    Call efi_rt_services_supported() to check that efi.get_variable exists
    before calling it.
    
    Signed-off-by: Richard Fitzgerald <[email protected]>
    Fixes: 1cad8725f2b9 ("ASoC: cs-amp-lib: Add helpers for factory calibration data")
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: cs35l56: Handle OTP read latency over SoundWire [+ + +]
Author: Richard Fitzgerald <[email protected]>
Date:   Mon Aug 5 15:08:39 2024 +0100

    ASoC: cs35l56: Handle OTP read latency over SoundWire
    
    [ Upstream commit e42066df07c0fcedebb32ed56f8bc39b4bf86337 ]
    
    Use the late-read buffer in the CS35L56 SoundWire interface to
    read OTP memory.
    
    The OTP memory has a longer access latency than chip registers
    and cannot guarantee to return the data value in the SoundWire
    control response if the bus clock is >4.8 MHz. The Cirrus
    SoundWire peripheral IP exposes the bridge-to-bus read buffer
    and status bits. For a read from OTP the bridge status bits are
    polled to wait for the OTP data to be loaded into the read buffer
    and the data is then read from there.
    
    Signed-off-by: Richard Fitzgerald <[email protected]>
    Fixes: e1830f66f6c6 ("ASoC: cs35l56: Add helper functions for amp calibration")
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: cs35l56: Revert support for dual-ownership of ASP registers [+ + +]
Author: Richard Fitzgerald <[email protected]>
Date:   Mon Jul 1 11:44:42 2024 +0100

    ASoC: cs35l56: Revert support for dual-ownership of ASP registers
    
    [ Upstream commit 5d7e328e20b3d2bd3e1e8bea7a868ab8892aeed1 ]
    
    This patch reverts a series of commits that allowed for the ASP
    registers to be owned by either the driver or the firmware. Nothing
    currently depends on the functionality that is being reverted, so
    it is safe to remove.
    
    The commits being reverted are (last 3 are bugfixes to the first 2):
    commit 72a77d7631c6
    ("ASoC: cs35l56: Fix to ensure ASP1 registers match cache")
    commit 07f7d6e7a124
    ("ASoC: cs35l56: Fix for initializing ASP1 mixer registers")
    commit 4703b014f28b
    ("ASoC: cs35l56: fix reversed if statement in cs35l56_dspwait_asp1tx_put()")
    commit c14f09f010cc
    ("ASoC: cs35l56: Fix deadlock in ASP1 mixer register initialization")
    commit dfd2ffb37399
    ("ASoC: cs35l56: Prevent overwriting firmware ASP config")
    
    These reverts have been squashed into a single commit because there
    would be no reason to revert only some of them (which would just
    reintroduce bugs).
    
    The changes introduced by the commits were well-intentioned but
    somewhat misguided. ACPI does not provide any information about how
    audio hardware is linked together, so that information has to be
    hardcoded into drivers. On Windows the firmware is customized to
    statically setup appropriate configuration of the audio links,
    and the intent of the commits was to re-use this information if the
    Linux host drivers aren't taking control of the ASP. This would
    avoid having to hardcode the ASP config into the machine driver on
    some systems.
    
    However, this added complexity and race conditions into the driver.
    It also complicates implementation of new code.
    
    The only case where the ASP is used but the host is not taking
    ownership is when CS35L56 is used in SoundWire mode with the ASP
    as a reference audio interconnect. But even in that case it's not
    necessarily required even if the firmware initialized it. Typically
    it is used to avoid the host SDCA drivers having to be capable of
    aggregating capture paths from multiple SoundWire peripherals. But
    the SOF SoundWire support is capable of doing that aggregation.
    
    Reverting all these commits significantly simplifies the driver.
    Let's just use the normal Linux mechanisms of the machine driver and
    ALSA controls to set things up instead of trying to use the firmware
    to do use-case setup.
    
    Signed-off-by: Richard Fitzgerald <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Stable-dep-of: e42066df07c0 ("ASoC: cs35l56: Handle OTP read latency over SoundWire")
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: meson: axg-fifo: fix irq scheduling issue with PREEMPT_RT [+ + +]
Author: Jerome Brunet <[email protected]>
Date:   Wed Aug 7 18:27:03 2024 +0200

    ASoC: meson: axg-fifo: fix irq scheduling issue with PREEMPT_RT
    
    [ Upstream commit 5003d0ce5c7da3a02c0aff771f516f99731e7390 ]
    
    With PREEMPT_RT enabled a spinlock_t becomes a sleeping lock.
    
    This is usually not a problem with spinlocks used in IRQ context since
    IRQ handlers get threaded. However, if IRQF_ONESHOT is set, the primary
    handler won't be force-threaded and runs always in hardirq context. This is
    a problem because spinlock_t requires a preemptible context on PREEMPT_RT.
    
    In this particular instance, regmap mmio uses spinlock_t to protect the
    register access and IRQF_ONESHOT is set on the IRQ. In this case, it is
    actually better to do everything in threaded handler and it solves the
    problem with PREEMPT_RT.
    
    Reported-by: Arseniy Krasnov <[email protected]>
    Closes: https://lore.kernel.org/linux-amlogic/[email protected]
    Suggested-by: Sebastian Andrzej Siewior <[email protected]>
    Fixes: b11d26660dff ("ASoC: meson: axg-fifo: use threaded irq to check periods")
    Signed-off-by: Jerome Brunet <[email protected]>
    Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: SOF: Remove libraries from topology lookups [+ + +]
Author: Curtis Malainey <[email protected]>
Date:   Wed Jul 31 14:21:44 2024 -0700

    ASoC: SOF: Remove libraries from topology lookups
    
    [ Upstream commit 7354eb7f1558466e92e926802d36e69e42938ea9 ]
    
    Default firmware shipped in open source are not licensed for 3P
    libraries, therefore topologies should not reference them.
    
    If a OS wants to use 3P (that they have licensed) then they should use
    the appropriate topology override mechanisms.
    
    Fixes: 8a7d5d85ed2161 ("ASoC: SOF: mediatek: mt8195: Add devicetree support to select topologies")
    Signed-off-by: Curtis Malainey <[email protected]>
    Cc: Wojciech Macek <[email protected]>
    Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ASoC: sti: add missing probe entry for player and reader [+ + +]
Author: Jerome Audu <[email protected]>
Date:   Sat Jul 27 15:40:15 2024 +0200

    ASoC: sti: add missing probe entry for player and reader
    
    [ Upstream commit 6b99068d5ea0aa295f15f30afc98db74d056ec7b ]
    
    This patch addresses a regression in the ASoC STI drivers that was
    introduced in Linux version 6.6.y. The issue originated from a series of
    patches (see https://lore.kernel.org/all/[email protected]/)
    that unintentionally omitted necessary probe functions for the player
    and reader components.
    
    Probe function in `sound/soc/sti/sti_uniperif.c:415` is being replaced
    by another probe function located at `sound/soc/sti/sti_uniperif.c:453`,
    which should instead be derived from the player and reader components.
    This patch correctly reinserts the missing probe entries,
    restoring the intended functionality.
    
    Fixes: 9f625f5e6cf9 ("ASoC: sti: merge DAI call back functions into ops")
    Signed-off-by: Jerome Audu <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
block: change rq_integrity_vec to respect the iterator [+ + +]
Author: Mikulas Patocka <[email protected]>
Date:   Mon May 27 17:40:10 2024 +0200

    block: change rq_integrity_vec to respect the iterator
    
    [ Upstream commit cf546dd289e0f6d2594c25e2fb4e19ee67c6d988 ]
    
    If we allocate a bio that is larger than NVMe maximum request size,
    attach integrity metadata to it and send it to the NVMe subsystem, the
    integrity metadata will be corrupted.
    
    Splitting the bio works correctly. The function bio_split will clone the
    bio, trim the iterator of the first bio and advance the iterator of the
    second bio.
    
    However, the function rq_integrity_vec has a bug - it returns the first
    vector of the bio's metadata and completely disregards the metadata
    iterator that was advanced when the bio was split. Thus, the second bio
    uses the same metadata as the first bio and this leads to metadata
    corruption.
    
    This commit changes rq_integrity_vec, so that it calls mp_bvec_iter_bvec
    instead of returning the first vector. mp_bvec_iter_bvec reads the
    iterator and uses it to build a bvec for the current position in the
    iterator.
    
    The "queue_max_integrity_segments(rq->q) > 1" check was removed, because
    the updated rq_integrity_vec function works correctly with multiple
    segments.
    
    Signed-off-by: Mikulas Patocka <[email protected]>
    Reviewed-by: Anuj Gupta <[email protected]>
    Reviewed-by: Kanchan Joshi <[email protected]>
    Reviewed-by: Christoph Hellwig <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Jens Axboe <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

block: use the right type for stub rq_integrity_vec() [+ + +]
Author: Jens Axboe <[email protected]>
Date:   Wed Jun 26 19:01:58 2024 -0600

    block: use the right type for stub rq_integrity_vec()
    
    commit 69b6517687a4b1fb250bd8c9c193a0a304c8ba17 upstream.
    
    For !CONFIG_BLK_DEV_INTEGRITY, rq_integrity_vec() wasn't updated
    properly. Fix it up.
    
    Fixes: cf546dd289e0 ("block: change rq_integrity_vec to respect the iterator")
    Signed-off-by: Jens Axboe <[email protected]>
    Cc: Matthieu Baerts <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
Bluetooth: btnxpuart: Shutdown timer and prevent rearming when driver unloading [+ + +]
Author: Luke Wang <[email protected]>
Date:   Fri May 17 19:15:35 2024 +0800

    Bluetooth: btnxpuart: Shutdown timer and prevent rearming when driver unloading
    
    [ Upstream commit 0d0df1e750bac0fdaa77940e711c1625cff08d33 ]
    
    When unload the btnxpuart driver, its associated timer will be deleted.
    If the timer happens to be modified at this moment, it leads to the
    kernel call this timer even after the driver unloaded, resulting in
    kernel panic.
    Use timer_shutdown_sync() instead of del_timer_sync() to prevent rearming.
    
    panic log:
      Internal error: Oops: 0000000086000007 [#1] PREEMPT SMP
      Modules linked in: algif_hash algif_skcipher af_alg moal(O) mlan(O) crct10dif_ce polyval_ce polyval_generic   snd_soc_imx_card snd_soc_fsl_asoc_card snd_soc_imx_audmux mxc_jpeg_encdec v4l2_jpeg snd_soc_wm8962 snd_soc_fsl_micfil   snd_soc_fsl_sai flexcan snd_soc_fsl_utils ap130x rpmsg_ctrl imx_pcm_dma can_dev rpmsg_char pwm_fan fuse [last unloaded:   btnxpuart]
      CPU: 5 PID: 723 Comm: memtester Tainted: G           O       6.6.23-lts-next-06207-g4aef2658ac28 #1
      Hardware name: NXP i.MX95 19X19 board (DT)
      pstate: 20400009 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      pc : 0xffff80007a2cf464
      lr : call_timer_fn.isra.0+0x24/0x80
    ...
      Call trace:
       0xffff80007a2cf464
       __run_timers+0x234/0x280
       run_timer_softirq+0x20/0x40
       __do_softirq+0x100/0x26c
       ____do_softirq+0x10/0x1c
       call_on_irq_stack+0x24/0x4c
       do_softirq_own_stack+0x1c/0x2c
       irq_exit_rcu+0xc0/0xdc
       el0_interrupt+0x54/0xd8
       __el0_irq_handler_common+0x18/0x24
       el0t_64_irq_handler+0x10/0x1c
       el0t_64_irq+0x190/0x194
      Code: ???????? ???????? ???????? ???????? (????????)
      ---[ end trace 0000000000000000 ]---
      Kernel panic - not syncing: Oops: Fatal exception in interrupt
      SMP: stopping secondary CPUs
      Kernel Offset: disabled
      CPU features: 0x0,c0000000,40028143,1000721b
      Memory Limit: none
      ---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]---
    
    Signed-off-by: Luke Wang <[email protected]>
    Signed-off-by: Luiz Augusto von Dentz <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

Bluetooth: hci_sync: avoid dup filtering when passive scanning with adv monitor [+ + +]
Author: Anton Khirnov <[email protected]>
Date:   Mon Jul 29 21:58:10 2024 +0200

    Bluetooth: hci_sync: avoid dup filtering when passive scanning with adv monitor
    
    [ Upstream commit b5431dc2803ac159d6d4645ae237d15c3cb252db ]
    
    This restores behaviour (including the comment) from now-removed
    hci_request.c, and also matches existing code for active scanning.
    
    Without this, the duplicates filter is always active when passive
    scanning, which makes it impossible to work with devices that send
    nontrivial dynamic data in their advertisement reports.
    
    Fixes: abfeea476c68 ("Bluetooth: hci_sync: Convert MGMT_OP_START_DISCOVERY")
    Signed-off-by: Anton Khirnov <[email protected]>
    Signed-off-by: Luiz Augusto von Dentz <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

Bluetooth: l2cap: always unlock channel in l2cap_conless_channel() [+ + +]
Author: Dmitry Antipov <[email protected]>
Date:   Wed Jul 31 12:19:36 2024 +0300

    Bluetooth: l2cap: always unlock channel in l2cap_conless_channel()
    
    [ Upstream commit c531e63871c0b50c8c4e62c048535a08886fba3e ]
    
    Add missing call to 'l2cap_chan_unlock()' on receive error handling
    path in 'l2cap_conless_channel()'.
    
    Fixes: a24cce144b98 ("Bluetooth: Fix reference counting of global L2CAP channels")
    Reported-by: [email protected]
    Closes: https://syzkaller.appspot.com/bug?extid=45ac74737e866894acb0
    Signed-off-by: Dmitry Antipov <[email protected]>
    Signed-off-by: Luiz Augusto von Dentz <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
bnxt_en : Fix memory out-of-bounds in bnxt_fill_hw_rss_tbl() [+ + +]
Author: Michael Chan <[email protected]>
Date:   Mon Aug 5 22:37:42 2024 -0700

    bnxt_en : Fix memory out-of-bounds in bnxt_fill_hw_rss_tbl()
    
    [ Upstream commit da03f5d1b2c319a2b74fe76edeadcd8fa5f44376 ]
    
    A recent commit has modified the code in __bnxt_reserve_rings() to
    set the default RSS indirection table to default only when the number
    of RX rings is changing.  While this works for newer firmware that
    requires RX ring reservations, it causes the regression on older
    firmware not requiring RX ring resrvations (BNXT_NEW_RM() returns
    false).
    
    With older firmware, RX ring reservations are not required and so
    hw_resc->resv_rx_rings is not always set to the proper value.  The
    comparison:
    
    if (old_rx_rings != bp->hw_resc.resv_rx_rings)
    
    in __bnxt_reserve_rings() may be false even when the RX rings are
    changing.  This will cause __bnxt_reserve_rings() to skip setting
    the default RSS indirection table to default to match the current
    number of RX rings.  This may later cause bnxt_fill_hw_rss_tbl() to
    use an out-of-range index.
    
    We already have bnxt_check_rss_tbl_no_rmgr() to handle exactly this
    scenario.  We just need to move it up in bnxt_need_reserve_rings()
    to be called unconditionally when using older firmware.  Without the
    fix, if the TX rings are changing, we'll skip the
    bnxt_check_rss_tbl_no_rmgr() call and __bnxt_reserve_rings() may also
    skip the bnxt_set_dflt_rss_indir_tbl() call for the reason explained
    in the last paragraph.  Without setting the default RSS indirection
    table to default, it causes the regression:
    
    BUG: KASAN: slab-out-of-bounds in __bnxt_hwrm_vnic_set_rss+0xb79/0xe40
    Read of size 2 at addr ffff8881c5809618 by task ethtool/31525
    Call Trace:
    __bnxt_hwrm_vnic_set_rss+0xb79/0xe40
     bnxt_hwrm_vnic_rss_cfg_p5+0xf7/0x460
     __bnxt_setup_vnic_p5+0x12e/0x270
     __bnxt_open_nic+0x2262/0x2f30
     bnxt_open_nic+0x5d/0xf0
     ethnl_set_channels+0x5d4/0xb30
     ethnl_default_set_doit+0x2f1/0x620
    
    Reported-by: Breno Leitao <[email protected]>
    Closes: https://lore.kernel.org/netdev/[email protected]/
    Fixes: 98ba1d931f61 ("bnxt_en: Fix RSS logic in __bnxt_reserve_rings()")
    Reviewed-by: Pavan Chebbi <[email protected]>
    Reviewed-by: Kalesh AP <[email protected]>
    Reviewed-by: Somnath Kotur <[email protected]>
    Signed-off-by: Michael Chan <[email protected]>
    Tested-by: Breno Leitao <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
bpf: add missing check_func_arg_reg_off() to prevent out-of-bounds memory accesses [+ + +]
Author: Matt Bobrowski <[email protected]>
Date:   Tue Jun 25 06:28:56 2024 +0000

    bpf: add missing check_func_arg_reg_off() to prevent out-of-bounds memory accesses
    
    [ Upstream commit ec2b9a5e11e51fea1bb04c1e7e471952e887e874 ]
    
    Currently, it's possible to pass in a modified CONST_PTR_TO_DYNPTR to
    a global function as an argument. The adverse effects of this is that
    BPF helpers can continue to make use of this modified
    CONST_PTR_TO_DYNPTR from within the context of the global function,
    which can unintentionally result in out-of-bounds memory accesses and
    therefore compromise overall system stability i.e.
    
    [  244.157771] BUG: KASAN: slab-out-of-bounds in bpf_dynptr_data+0x137/0x140
    [  244.161345] Read of size 8 at addr ffff88810914be68 by task test_progs/302
    [  244.167151] CPU: 0 PID: 302 Comm: test_progs Tainted: G O E 6.10.0-rc3-00131-g66b586715063 #533
    [  244.174318] Call Trace:
    [  244.175787]  <TASK>
    [  244.177356]  dump_stack_lvl+0x66/0xa0
    [  244.179531]  print_report+0xce/0x670
    [  244.182314]  ? __virt_addr_valid+0x200/0x3e0
    [  244.184908]  kasan_report+0xd7/0x110
    [  244.187408]  ? bpf_dynptr_data+0x137/0x140
    [  244.189714]  ? bpf_dynptr_data+0x137/0x140
    [  244.192020]  bpf_dynptr_data+0x137/0x140
    [  244.194264]  bpf_prog_b02a02fdd2bdc5fa_global_call_bpf_dynptr_data+0x22/0x26
    [  244.198044]  bpf_prog_b0fe7b9d7dc3abde_callback_adjust_bpf_dynptr_reg_off+0x1f/0x23
    [  244.202136]  bpf_user_ringbuf_drain+0x2c7/0x570
    [  244.204744]  ? 0xffffffffc0009e58
    [  244.206593]  ? __pfx_bpf_user_ringbuf_drain+0x10/0x10
    [  244.209795]  bpf_prog_33ab33f6a804ba2d_user_ringbuf_callback_const_ptr_to_dynptr_reg_off+0x47/0x4b
    [  244.215922]  bpf_trampoline_6442502480+0x43/0xe3
    [  244.218691]  __x64_sys_prlimit64+0x9/0xf0
    [  244.220912]  do_syscall_64+0xc1/0x1d0
    [  244.223043]  entry_SYSCALL_64_after_hwframe+0x77/0x7f
    [  244.226458] RIP: 0033:0x7ffa3eb8f059
    [  244.228582] Code: 08 89 e8 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 8f 1d 0d 00 f7 d8 64 89 01 48
    [  244.241307] RSP: 002b:00007ffa3e9c6eb8 EFLAGS: 00000206 ORIG_RAX: 000000000000012e
    [  244.246474] RAX: ffffffffffffffda RBX: 00007ffa3e9c7cdc RCX: 00007ffa3eb8f059
    [  244.250478] RDX: 00007ffa3eb162b4 RSI: 0000000000000000 RDI: 00007ffa3e9c7fb0
    [  244.255396] RBP: 00007ffa3e9c6ed0 R08: 00007ffa3e9c76c0 R09: 0000000000000000
    [  244.260195] R10: 0000000000000000 R11: 0000000000000206 R12: ffffffffffffff80
    [  244.264201] R13: 000000000000001c R14: 00007ffc5d6b4260 R15: 00007ffa3e1c7000
    [  244.268303]  </TASK>
    
    Add a check_func_arg_reg_off() to the path in which the BPF verifier
    verifies the arguments of global function arguments, specifically
    those which take an argument of type ARG_PTR_TO_DYNPTR |
    MEM_RDONLY. Also, process_dynptr_func() doesn't appear to perform any
    explicit and strict type matching on the supplied register type, so
    let's also enforce that a register either type PTR_TO_STACK or
    CONST_PTR_TO_DYNPTR is by the caller.
    
    Reported-by: Kumar Kartikeya Dwivedi <[email protected]>
    Acked-by: Kumar Kartikeya Dwivedi <[email protected]>
    Acked-by: Eduard Zingerman <[email protected]>
    Signed-off-by: Matt Bobrowski <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Alexei Starovoitov <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

bpf: kprobe: remove unused declaring of bpf_kprobe_override [+ + +]
Author: Menglong Dong <[email protected]>
Date:   Mon Aug 5 14:01:21 2024 +0900

    bpf: kprobe: remove unused declaring of bpf_kprobe_override
    
    [ Upstream commit 0e8b53979ac86eddb3fd76264025a70071a25574 ]
    
    After the commit 66665ad2f102 ("tracing/kprobe: bpf: Compare instruction
    pointer with original one"), "bpf_kprobe_override" is not used anywhere
    anymore, and we can remove it now.
    
    Link: https://lore.kernel.org/all/[email protected]/
    
    Fixes: 66665ad2f102 ("tracing/kprobe: bpf: Compare instruction pointer with original one")
    Signed-off-by: Menglong Dong <[email protected]>
    Acked-by: Jiri Olsa <[email protected]>
    Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
btrfs: avoid using fixed char array size for tree names [+ + +]
Author: Qu Wenruo <[email protected]>
Date:   Fri Jul 19 18:56:46 2024 +0930

    btrfs: avoid using fixed char array size for tree names
    
    commit 12653ec36112ab55fa06c01db7c4432653d30a8d upstream.
    
    [BUG]
    There is a bug report that using the latest trunk GCC 15, btrfs would cause
    unterminated-string-initialization warning:
    
      linux-6.6/fs/btrfs/print-tree.c:29:49: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
       29 |         { BTRFS_BLOCK_GROUP_TREE_OBJECTID,      "BLOCK_GROUP_TREE"      },
          |
          ^~~~~~~~~~~~~~~~~~
    
    [CAUSE]
    To print tree names we have an array of root_name_map structure, which
    uses "char name[16];" to store the name string of a tree.
    
    But the following trees have names exactly at 16 chars length:
    - "BLOCK_GROUP_TREE"
    - "RAID_STRIPE_TREE"
    
    This means we will have no space for the terminating '\0', and can lead
    to unexpected access when printing the name.
    
    [FIX]
    Instead of "char name[16];" use "const char *" instead.
    
    Since the name strings are all read-only data, and are all NULL
    terminated by default, there is not much need to bother the length at
    all.
    
    Reported-by: Sam James <[email protected]>
    Reported-by: Alejandro Colomar <[email protected]>
    Fixes: edde81f1abf29 ("btrfs: add raid stripe tree pretty printer")
    Fixes: 9c54e80ddc6bd ("btrfs: add code to support the block group root")
    CC: [email protected] # 6.1+
    Suggested-by: Alejandro Colomar <[email protected]>
    Reviewed-by: Johannes Thumshirn <[email protected]>
    Reviewed-by: Alejandro Colomar <[email protected]>
    Signed-off-by: Qu Wenruo <[email protected]>
    Reviewed-by: David Sterba <[email protected]>
    Signed-off-by: David Sterba <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

btrfs: do not BUG_ON() when freeing tree block after error [+ + +]
Author: Filipe Manana <[email protected]>
Date:   Fri Jun 14 14:50:47 2024 +0100

    btrfs: do not BUG_ON() when freeing tree block after error
    
    [ Upstream commit bb3868033a4cccff7be57e9145f2117cbdc91c11 ]
    
    When freeing a tree block, at btrfs_free_tree_block(), if we fail to
    create a delayed reference we don't deal with the error and just do a
    BUG_ON(). The error most likely to happen is -ENOMEM, and we have a
    comment mentioning that only -ENOMEM can happen, but that is not true,
    because in case qgroups are enabled any error returned from
    btrfs_qgroup_trace_extent_post() (can be -EUCLEAN or anything returned
    from btrfs_search_slot() for example) can be propagated back to
    btrfs_free_tree_block().
    
    So stop doing a BUG_ON() and return the error to the callers and make
    them abort the transaction to prevent leaking space. Syzbot was
    triggering this, likely due to memory allocation failure injection.
    
    Reported-by: [email protected]
    Link: https://lore.kernel.org/linux-btrfs/[email protected]/
    Reviewed-by: Qu Wenruo <[email protected]>
    Signed-off-by: Filipe Manana <[email protected]>
    Reviewed-by: David Sterba <[email protected]>
    Signed-off-by: David Sterba <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

btrfs: do not clear page dirty inside extent_write_locked_range() [+ + +]
Author: Qu Wenruo <[email protected]>
Date:   Wed Mar 6 08:21:54 2024 +1030

    btrfs: do not clear page dirty inside extent_write_locked_range()
    
    [ Upstream commit 97713b1a2ced1e4a2a6c40045903797ebd44d7e0 ]
    
    [BUG]
    For subpage + zoned case, the following workload can lead to rsv data
    leak at unmount time:
    
      # mkfs.btrfs -f -s 4k $dev
      # mount $dev $mnt
      # fsstress -w -n 8 -d $mnt -s 1709539240
      0/0: fiemap - no filename
      0/1: copyrange read - no filename
      0/2: write - no filename
      0/3: rename - no source filename
      0/4: creat f0 x:0 0 0
      0/4: creat add id=0,parent=-1
      0/5: writev f0[259 1 0 0 0 0] [778052,113,965] 0
      0/6: ioctl(FIEMAP) f0[259 1 0 0 224 887097] [1294220,2291618343991484791,0x10000] -1
      0/7: dwrite - xfsctl(XFS_IOC_DIOINFO) f0[259 1 0 0 224 887097] return 25, fallback to stat()
      0/7: dwrite f0[259 1 0 0 224 887097] [696320,102400] 0
      # umount $mnt
    
    The dmesg includes the following rsv leak detection warning (all call
    trace skipped):
    
      ------------[ cut here ]------------
      WARNING: CPU: 2 PID: 4528 at fs/btrfs/inode.c:8653 btrfs_destroy_inode+0x1e0/0x200 [btrfs]
      ---[ end trace 0000000000000000 ]---
      ------------[ cut here ]------------
      WARNING: CPU: 2 PID: 4528 at fs/btrfs/inode.c:8654 btrfs_destroy_inode+0x1a8/0x200 [btrfs]
      ---[ end trace 0000000000000000 ]---
      ------------[ cut here ]------------
      WARNING: CPU: 2 PID: 4528 at fs/btrfs/inode.c:8660 btrfs_destroy_inode+0x1a0/0x200 [btrfs]
      ---[ end trace 0000000000000000 ]---
      BTRFS info (device sda): last unmount of filesystem 1b4abba9-de34-4f07-9e7f-157cf12a18d6
      ------------[ cut here ]------------
      WARNING: CPU: 3 PID: 4528 at fs/btrfs/block-group.c:4434 btrfs_free_block_groups+0x338/0x500 [btrfs]
      ---[ end trace 0000000000000000 ]---
      BTRFS info (device sda): space_info DATA has 268218368 free, is not full
      BTRFS info (device sda): space_info total=268435456, used=204800, pinned=0, reserved=0, may_use=12288, readonly=0 zone_unusable=0
      BTRFS info (device sda): global_block_rsv: size 0 reserved 0
      BTRFS info (device sda): trans_block_rsv: size 0 reserved 0
      BTRFS info (device sda): chunk_block_rsv: size 0 reserved 0
      BTRFS info (device sda): delayed_block_rsv: size 0 reserved 0
      BTRFS info (device sda): delayed_refs_rsv: size 0 reserved 0
      ------------[ cut here ]------------
      WARNING: CPU: 3 PID: 4528 at fs/btrfs/block-group.c:4434 btrfs_free_block_groups+0x338/0x500 [btrfs]
      ---[ end trace 0000000000000000 ]---
      BTRFS info (device sda): space_info METADATA has 267796480 free, is not full
      BTRFS info (device sda): space_info total=268435456, used=131072, pinned=0, reserved=0, may_use=262144, readonly=0 zone_unusable=245760
      BTRFS info (device sda): global_block_rsv: size 0 reserved 0
      BTRFS info (device sda): trans_block_rsv: size 0 reserved 0
      BTRFS info (device sda): chunk_block_rsv: size 0 reserved 0
      BTRFS info (device sda): delayed_block_rsv: size 0 reserved 0
      BTRFS info (device sda): delayed_refs_rsv: size 0 reserved 0
    
    Above $dev is a tcmu-runner emulated zoned HDD, which has a max zone
    append size of 64K, and the system has 64K page size.
    
    [CAUSE]
    I have added several trace_printk() to show the events (header skipped):
    
      > btrfs_dirty_pages: r/i=5/259 dirty start=774144 len=114688
      > btrfs_dirty_pages: r/i=5/259 dirty part of page=720896 off_in_page=53248 len_in_page=12288
      > btrfs_dirty_pages: r/i=5/259 dirty part of page=786432 off_in_page=0 len_in_page=65536
      > btrfs_dirty_pages: r/i=5/259 dirty part of page=851968 off_in_page=0 len_in_page=36864
    
    The above lines show our buffered write has dirtied 3 pages of inode
    259 of root 5:
    
      704K             768K              832K              896K
      I           |////I/////////////////I///////////|     I
                  756K                               868K
    
      |///| is the dirtied range using subpage bitmaps. and 'I' is the page
      boundary.
    
      Meanwhile all three pages (704K, 768K, 832K) have their PageDirty
      flag set.
    
      > btrfs_direct_write: r/i=5/259 start dio filepos=696320 len=102400
    
    Then direct IO write starts, since the range [680K, 780K) covers the
    beginning part of the above dirty range, we need to writeback the
    two pages at 704K and 768K.
    
      > cow_file_range: r/i=5/259 add ordered extent filepos=774144 len=65536
      > extent_write_locked_range: r/i=5/259 locked page=720896 start=774144 len=65536
    
    Now the above 2 lines show that we're writing back for dirty range
    [756K, 756K + 64K).
    We only writeback 64K because the zoned device has max zone append size
    as 64K.
    
      > extent_write_locked_range: r/i=5/259 clear dirty for page=786432
    
    !!! The above line shows the root cause. !!!
    
    We're calling clear_page_dirty_for_io() inside extent_write_locked_range(),
    for the page 768K.
    This is because extent_write_locked_range() can go beyond the current
    locked page, here we hit the page at 768K and clear its page dirt.
    
    In fact this would lead to the desync between subpage dirty and page
    dirty flags.  We have the page dirty flag cleared, but the subpage range
    [820K, 832K) is still dirty.
    
    After the writeback of range [756K, 820K), the dirty flags look like
    this, as page 768K no longer has dirty flag set.
    
      704K             768K              832K              896K
      I                I      |          I/////////////|   I
                              820K                     868K
    
    This means we will no longer writeback range [820K, 832K), thus the
    reserved data/metadata space would never be properly released.
    
      > extent_write_cache_pages: r/i=5/259 skip non-dirty folio=786432
    
    Now even though we try to start writeback for page 768K, since the
    page is not dirty, we completely skip it at extent_write_cache_pages()
    time.
    
      > btrfs_direct_write: r/i=5/259 dio done filepos=696320 len=0
    
    Now the direct IO finished.
    
      > cow_file_range: r/i=5/259 add ordered extent filepos=851968 len=36864
      > extent_write_locked_range: r/i=5/259 locked page=851968 start=851968 len=36864
    
    Now we writeback the remaining dirty range, which is [832K, 868K).
    Causing the range [820K, 832K) never to be submitted, thus leaking the
    reserved space.
    
    This bug only affects subpage and zoned case.  For non-subpage and zoned
    case, we have exactly one sector for each page, thus no such partial dirty
    cases.
    
    For subpage and non-zoned case, we never go into run_delalloc_cow(), and
    normally all the dirty subpage ranges would be properly submitted inside
    __extent_writepage_io().
    
    [FIX]
    Just do not clear the page dirty at all inside extent_write_locked_range().
    As __extent_writepage_io() would do a more accurate, subpage compatible
    clear for page and subpage dirty flags anyway.
    
    Now the correct trace would look like this:
    
      > btrfs_dirty_pages: r/i=5/259 dirty start=774144 len=114688
      > btrfs_dirty_pages: r/i=5/259 dirty part of page=720896 off_in_page=53248 len_in_page=12288
      > btrfs_dirty_pages: r/i=5/259 dirty part of page=786432 off_in_page=0 len_in_page=65536
      > btrfs_dirty_pages: r/i=5/259 dirty part of page=851968 off_in_page=0 len_in_page=36864
    
    The page dirty part is still the same 3 pages.
    
      > btrfs_direct_write: r/i=5/259 start dio filepos=696320 len=102400
      > cow_file_range: r/i=5/259 add ordered extent filepos=774144 len=65536
      > extent_write_locked_range: r/i=5/259 locked page=720896 start=774144 len=65536
    
    And the writeback for the first 64K is still correct.
    
      > cow_file_range: r/i=5/259 add ordered extent filepos=839680 len=49152
      > extent_write_locked_range: r/i=5/259 locked page=786432 start=839680 len=49152
    
    Now with the fix, we can properly writeback the range [820K, 832K), and
    properly release the reserved data/metadata space.
    
    Reviewed-by: Johannes Thumshirn <[email protected]>
    Signed-off-by: Qu Wenruo <[email protected]>
    Signed-off-by: David Sterba <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

btrfs: fix bitmap leak when loading free space cache on duplicate entry [+ + +]
Author: Filipe Manana <[email protected]>
Date:   Wed Jul 3 15:40:59 2024 +0100

    btrfs: fix bitmap leak when loading free space cache on duplicate entry
    
    [ Upstream commit 320d8dc612660da84c3b70a28658bb38069e5a9a ]
    
    If we failed to link a free space entry because there's already a
    conflicting entry for the same offset, we free the free space entry but
    we don't free the associated bitmap that we had just allocated before.
    Fix that by freeing the bitmap before freeing the entry.
    
    Reviewed-by: Johannes Thumshirn <[email protected]>
    Signed-off-by: Filipe Manana <[email protected]>
    Reviewed-by: David Sterba <[email protected]>
    Signed-off-by: David Sterba <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

btrfs: fix corruption after buffer fault in during direct IO append write [+ + +]
Author: Filipe Manana <[email protected]>
Date:   Fri Jul 26 11:12:52 2024 +0100

    btrfs: fix corruption after buffer fault in during direct IO append write
    
    commit 939b656bc8ab203fdbde26ccac22bcb7f0985be5 upstream.
    
    During an append (O_APPEND write flag) direct IO write if the input buffer
    was not previously faulted in, we can corrupt the file in a way that the
    final size is unexpected and it includes an unexpected hole.
    
    The problem happens like this:
    
    1) We have an empty file, with size 0, for example;
    
    2) We do an O_APPEND direct IO with a length of 4096 bytes and the input
       buffer is not currently faulted in;
    
    3) We enter btrfs_direct_write(), lock the inode and call
       generic_write_checks(), which calls generic_write_checks_count(), and
       that function sets the iocb position to 0 with the following code:
    
            if (iocb->ki_flags & IOCB_APPEND)
                    iocb->ki_pos = i_size_read(inode);
    
    4) We call btrfs_dio_write() and enter into iomap, which will end up
       calling btrfs_dio_iomap_begin() and that calls
       btrfs_get_blocks_direct_write(), where we update the i_size of the
       inode to 4096 bytes;
    
    5) After btrfs_dio_iomap_begin() returns, iomap will attempt to access
       the page of the write input buffer (at iomap_dio_bio_iter(), with a
       call to bio_iov_iter_get_pages()) and fail with -EFAULT, which gets
       returned to btrfs at btrfs_direct_write() via btrfs_dio_write();
    
    6) At btrfs_direct_write() we get the -EFAULT error, unlock the inode,
       fault in the write buffer and then goto to the label 'relock';
    
    7) We lock again the inode, do all the necessary checks again and call
       again generic_write_checks(), which calls generic_write_checks_count()
       again, and there we set the iocb's position to 4K, which is the current
       i_size of the inode, with the following code pointed above:
    
            if (iocb->ki_flags & IOCB_APPEND)
                    iocb->ki_pos = i_size_read(inode);
    
    8) Then we go again to btrfs_dio_write() and enter iomap and the write
       succeeds, but it wrote to the file range [4K, 8K), leaving a hole in
       the [0, 4K) range and an i_size of 8K, which goes against the
       expectations of having the data written to the range [0, 4K) and get an
       i_size of 4K.
    
    Fix this by not unlocking the inode before faulting in the input buffer,
    in case we get -EFAULT or an incomplete write, and not jumping to the
    'relock' label after faulting in the buffer - instead jump to a location
    immediately before calling iomap, skipping all the write checks and
    relocking. This solves this problem and it's fine even in case the input
    buffer is memory mapped to the same file range, since only holding the
    range locked in the inode's io tree can cause a deadlock, it's safe to
    keep the inode lock (VFS lock), as was fixed and described in commit
    51bd9563b678 ("btrfs: fix deadlock due to page faults during direct IO
    reads and writes").
    
    A sample reproducer provided by a reporter is the following:
    
       $ cat test.c
       #ifndef _GNU_SOURCE
       #define _GNU_SOURCE
       #endif
    
       #include <fcntl.h>
       #include <stdio.h>
       #include <sys/mman.h>
       #include <sys/stat.h>
       #include <unistd.h>
    
       int main(int argc, char *argv[])
       {
           if (argc < 2) {
               fprintf(stderr, "Usage: %s <test file>\n", argv[0]);
               return 1;
           }
    
           int fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC | O_DIRECT |
                         O_APPEND, 0644);
           if (fd < 0) {
               perror("creating test file");
               return 1;
           }
    
           char *buf = mmap(NULL, 4096, PROT_READ,
                            MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
           ssize_t ret = write(fd, buf, 4096);
           if (ret < 0) {
               perror("pwritev2");
               return 1;
           }
    
           struct stat stbuf;
           ret = fstat(fd, &stbuf);
           if (ret < 0) {
               perror("stat");
               return 1;
           }
    
           printf("size: %llu\n", (unsigned long long)stbuf.st_size);
           return stbuf.st_size == 4096 ? 0 : 1;
       }
    
    A test case for fstests will be sent soon.
    
    Reported-by: Hanna Czenczek <[email protected]>
    Link: https://lore.kernel.org/linux-btrfs/[email protected]/
    Fixes: 8184620ae212 ("btrfs: fix lost file sync on direct IO write with nowait and dsync iocb")
    CC: [email protected] # 6.1+
    Tested-by: Hanna Czenczek <[email protected]>
    Reviewed-by: Josef Bacik <[email protected]>
    Signed-off-by: Filipe Manana <[email protected]>
    Signed-off-by: David Sterba <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

btrfs: fix data race when accessing the last_trans field of a root [+ + +]
Author: Filipe Manana <[email protected]>
Date:   Mon Jul 1 10:51:28 2024 +0100

    btrfs: fix data race when accessing the last_trans field of a root
    
    [ Upstream commit ca84529a842f3a15a5f17beac6252aa11955923f ]
    
    KCSAN complains about a data race when accessing the last_trans field of a
    root:
    
      [  199.553628] BUG: KCSAN: data-race in btrfs_record_root_in_trans [btrfs] / record_root_in_trans [btrfs]
    
      [  199.555186] read to 0x000000008801e308 of 8 bytes by task 2812 on cpu 1:
      [  199.555210]  btrfs_record_root_in_trans+0x9a/0x128 [btrfs]
      [  199.555999]  start_transaction+0x154/0xcd8 [btrfs]
      [  199.556780]  btrfs_join_transaction+0x44/0x60 [btrfs]
      [  199.557559]  btrfs_dirty_inode+0x9c/0x140 [btrfs]
      [  199.558339]  btrfs_update_time+0x8c/0xb0 [btrfs]
      [  199.559123]  touch_atime+0x16c/0x1e0
      [  199.559151]  pipe_read+0x6a8/0x7d0
      [  199.559179]  vfs_read+0x466/0x498
      [  199.559204]  ksys_read+0x108/0x150
      [  199.559230]  __s390x_sys_read+0x68/0x88
      [  199.559257]  do_syscall+0x1c6/0x210
      [  199.559286]  __do_syscall+0xc8/0xf0
      [  199.559318]  system_call+0x70/0x98
    
      [  199.559431] write to 0x000000008801e308 of 8 bytes by task 2808 on cpu 0:
      [  199.559464]  record_root_in_trans+0x196/0x228 [btrfs]
      [  199.560236]  btrfs_record_root_in_trans+0xfe/0x128 [btrfs]
      [  199.561097]  start_transaction+0x154/0xcd8 [btrfs]
      [  199.561927]  btrfs_join_transaction+0x44/0x60 [btrfs]
      [  199.562700]  btrfs_dirty_inode+0x9c/0x140 [btrfs]
      [  199.563493]  btrfs_update_time+0x8c/0xb0 [btrfs]
      [  199.564277]  file_update_time+0xb8/0xf0
      [  199.564301]  pipe_write+0x8ac/0xab8
      [  199.564326]  vfs_write+0x33c/0x588
      [  199.564349]  ksys_write+0x108/0x150
      [  199.564372]  __s390x_sys_write+0x68/0x88
      [  199.564397]  do_syscall+0x1c6/0x210
      [  199.564424]  __do_syscall+0xc8/0xf0
      [  199.564452]  system_call+0x70/0x98
    
    This is because we update and read last_trans concurrently without any
    type of synchronization. This should be generally harmless and in the
    worst case it can make us do extra locking (btrfs_record_root_in_trans())
    trigger some warnings at ctree.c or do extra work during relocation - this
    would probably only happen in case of load or store tearing.
    
    So fix this by always reading and updating the field using READ_ONCE()
    and WRITE_ONCE(), this silences KCSAN and prevents load and store tearing.
    
    Reviewed-by: Josef Bacik <[email protected]>
    Signed-off-by: Filipe Manana <[email protected]>
    Signed-off-by: David Sterba <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

btrfs: fix double inode unlock for direct IO sync writes [+ + +]
Author: Filipe Manana <[email protected]>
Date:   Fri Aug 2 09:38:51 2024 +0100

    btrfs: fix double inode unlock for direct IO sync writes
    
    commit e0391e92f9ab4fb3dbdeb139c967dcfa7ac4b115 upstream.
    
    If we do a direct IO sync write, at btrfs_sync_file(), and we need to skip
    inode logging or we get an error starting a transaction or an error when
    flushing delalloc, we end up unlocking the inode when we shouldn't under
    the 'out_release_extents' label, and then unlock it again at
    btrfs_direct_write().
    
    Fix that by checking if we have to skip inode unlocking under that label.
    
    Reported-by: [email protected]
    Link: https://lore.kernel.org/linux-btrfs/[email protected]/
    Fixes: 939b656bc8ab ("btrfs: fix corruption after buffer fault in during direct IO append write")
    Reviewed-by: Josef Bacik <[email protected]>
    Signed-off-by: Filipe Manana <[email protected]>
    Signed-off-by: David Sterba <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

btrfs: reduce nesting for extent processing at btrfs_lookup_extent_info() [+ + +]
Author: Filipe Manana <[email protected]>
Date:   Tue Jun 18 11:52:19 2024 +0100

    btrfs: reduce nesting for extent processing at btrfs_lookup_extent_info()
    
    [ Upstream commit 5c83b3beaee06aa88d4015408ac2d8bb35380b06 ]
    
    Instead of using an if-else statement when processing the extent item at
    btrfs_lookup_extent_info(), use a single if statement for the error case
    since it does a goto at the end and leave the success (expected) case
    following the if statement, reducing indentation and making the logic a
    bit easier to follow. Also make the if statement's condition as unlikely
    since it's not expected to ever happen, as it signals some corruption,
    making it clear and hint the compiler to generate more efficient code.
    
    Reviewed-by: Qu Wenruo <[email protected]>
    Signed-off-by: Filipe Manana <[email protected]>
    Signed-off-by: David Sterba <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
can: mcp251xfd: tef: prepare to workaround broken TEF FIFO tail index erratum [+ + +]
Author: Marc Kleine-Budde <[email protected]>
Date:   Sun Jan 22 21:30:41 2023 +0100

    can: mcp251xfd: tef: prepare to workaround broken TEF FIFO tail index erratum
    
    [ Upstream commit b8e0ddd36ce9536ad7478dd27df06c9ae92370ba ]
    
    This is a preparatory patch to work around a problem similar to
    erratum DS80000789E 6 of the mcp2518fd, the other variants of the chip
    family (mcp2517fd and mcp251863) are probably also affected.
    
    Erratum DS80000789E 6 says "reading of the FIFOCI bits in the FIFOSTA
    register for an RX FIFO may be corrupted". However observation shows
    that this problem is not limited to RX FIFOs but also effects the TEF
    FIFO.
    
    When handling the TEF interrupt, the driver reads the FIFO header
    index from the TEF FIFO STA register of the chip.
    
    In the bad case, the driver reads a too large head index. In the
    original code, the driver always trusted the read value, which caused
    old CAN transmit complete events that were already processed to be
    re-processed.
    
    Instead of reading and trusting the head index, read the head index
    and calculate the number of CAN frames that were supposedly received -
    replace mcp251xfd_tef_ring_update() with mcp251xfd_get_tef_len().
    
    The mcp251xfd_handle_tefif() function reads the CAN transmit complete
    events from the chip, iterates over them and pushes them into the
    network stack. The original driver already contains code to detect old
    CAN transmit complete events, that will be updated in the next patch.
    
    Cc: Stefan Althöfer <[email protected]>
    Cc: Thomas Kopp <[email protected]>
    Signed-off-by: Marc Kleine-Budde <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

can: mcp251xfd: tef: update workaround for erratum DS80000789E 6 of mcp2518fd [+ + +]
Author: Marc Kleine-Budde <[email protected]>
Date:   Sun Jan 22 22:35:03 2023 +0100

    can: mcp251xfd: tef: update workaround for erratum DS80000789E 6 of mcp2518fd
    
    [ Upstream commit 3a0a88fcbaf9e027ecca3fe8775be9700b4d6460 ]
    
    This patch updates the workaround for a problem similar to erratum
    DS80000789E 6 of the mcp2518fd, the other variants of the chip
    family (mcp2517fd and mcp251863) are probably also affected.
    
    Erratum DS80000789E 6 says "reading of the FIFOCI bits in the FIFOSTA
    register for an RX FIFO may be corrupted". However observation shows
    that this problem is not limited to RX FIFOs but also effects the TEF
    FIFO.
    
    In the bad case, the driver reads a too large head index. As the FIFO
    is implemented as a ring buffer, this results in re-handling old CAN
    transmit complete events.
    
    Every transmit complete event contains with a sequence number that
    equals to the sequence number of the corresponding TX request. This
    way old TX complete events can be detected.
    
    If the original driver detects a non matching sequence number, it
    prints an info message and tries again later. As wrong sequence
    numbers can be explained by the erratum DS80000789E 6, demote the info
    message to debug level, streamline the code and update the comments.
    
    Keep the behavior: If an old CAN TX complete event is detected, abort
    the iteration and mark the number of valid CAN TX complete events as
    processed in the chip by incrementing the FIFO's tail index.
    
    Cc: Stefan Althöfer <[email protected]>
    Cc: Thomas Kopp <[email protected]>
    Signed-off-by: Marc Kleine-Budde <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
cifs: cifs_inval_name_dfs_link_error: correct the check for fullpath [+ + +]
Author: Gleb Korobeynikov <[email protected]>
Date:   Thu Aug 8 18:47:48 2024 +0300

    cifs: cifs_inval_name_dfs_link_error: correct the check for fullpath
    
    [ Upstream commit 36bb22a08a69d9984a8399c07310d18b115eae20 ]
    
    Replace the always-true check tcon->origin_fullpath with
    check of server->leaf_fullpath
    
    See https://bugzilla.kernel.org/show_bug.cgi?id=219083
    
    The check of the new @tcon will always be true during mounting,
    since @tcon->origin_fullpath will only be set after the tree is
    connected to the latest common resource, as well as checking if
    the prefix paths from it are fully accessible.
    
    Fixes: 3ae872de4107 ("smb: client: fix shared DFS root mounts with different prefixes")
    Reviewed-by: Paulo Alcantara (Red Hat) <[email protected]>
    Signed-off-by: Gleb Korobeynikov <[email protected]>
    Signed-off-by: Steve French <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
clocksource/drivers/sh_cmt: Address race condition for clock events [+ + +]
Author: Niklas Söderlund <[email protected]>
Date:   Tue Jul 2 21:02:30 2024 +0200

    clocksource/drivers/sh_cmt: Address race condition for clock events
    
    [ Upstream commit db19d3aa77612983a02bd223b3f273f896b243cf ]
    
    There is a race condition in the CMT interrupt handler. In the interrupt
    handler the driver sets a driver private flag, FLAG_IRQCONTEXT. This
    flag is used to indicate any call to set_next_event() should not be
    directly propagated to the device, but instead cached. This is done as
    the interrupt handler itself reprograms the device when needed before it
    completes and this avoids this operation to take place twice.
    
    It is unclear why this design was chosen, my suspicion is to allow the
    struct clock_event_device.event_handler callback, which is called while
    the FLAG_IRQCONTEXT is set, can update the next event without having to
    write to the device twice.
    
    Unfortunately there is a race between when the FLAG_IRQCONTEXT flag is
    set and later cleared where the interrupt handler have already started to
    write the next event to the device. If set_next_event() is called in
    this window the value is only cached in the driver but not written. This
    leads to the board to misbehave, or worse lockup and produce a splat.
    
       rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
       rcu:     0-...!: (0 ticks this GP) idle=f5e0/0/0x0 softirq=519/519 fqs=0 (false positive?)
       rcu:     (detected by 1, t=6502 jiffies, g=-595, q=77 ncpus=2)
       Sending NMI from CPU 1 to CPUs 0:
       NMI backtrace for cpu 0
       CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.10.0-rc5-arm64-renesas-00019-g74a6f86eaf1c-dirty #20
       Hardware name: Renesas Salvator-X 2nd version board based on r8a77965 (DT)
       pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
       pc : tick_check_broadcast_expired+0xc/0x40
       lr : cpu_idle_poll.isra.0+0x8c/0x168
       sp : ffff800081c63d70
       x29: ffff800081c63d70 x28: 00000000580000c8 x27: 00000000bfee5610
       x26: 0000000000000027 x25: 0000000000000000 x24: 0000000000000000
       x23: ffff00007fbb9100 x22: ffff8000818f1008 x21: ffff8000800ef07c
       x20: ffff800081c79ec0 x19: ffff800081c70c28 x18: 0000000000000000
       x17: 0000000000000000 x16: 0000000000000000 x15: 0000ffffc2c717d8
       x14: 0000000000000000 x13: ffff000009c18080 x12: ffff8000825f7fc0
       x11: 0000000000000000 x10: ffff8000818f3cd4 x9 : 0000000000000028
       x8 : ffff800081c79ec0 x7 : ffff800081c73000 x6 : 0000000000000000
       x5 : 0000000000000000 x4 : ffff7ffffe286000 x3 : 0000000000000000
       x2 : ffff7ffffe286000 x1 : ffff800082972900 x0 : ffff8000818f1008
       Call trace:
        tick_check_broadcast_expired+0xc/0x40
        do_idle+0x9c/0x280
        cpu_startup_entry+0x34/0x40
        kernel_init+0x0/0x11c
        do_one_initcall+0x0/0x260
        __primary_switched+0x80/0x88
       rcu: rcu_preempt kthread timer wakeup didn't happen for 6501 jiffies! g-595 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402
       rcu:     Possible timer handling issue on cpu=0 timer-softirq=262
       rcu: rcu_preempt kthread starved for 6502 jiffies! g-595 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402 ->cpu=0
       rcu:     Unless rcu_preempt kthread gets sufficient CPU time, OOM is now expected behavior.
       rcu: RCU grace-period kthread stack dump:
       task:rcu_preempt     state:I stack:0     pid:15    tgid:15    ppid:2      flags:0x00000008
       Call trace:
        __switch_to+0xbc/0x100
        __schedule+0x358/0xbe0
        schedule+0x48/0x148
        schedule_timeout+0xc4/0x138
        rcu_gp_fqs_loop+0x12c/0x764
        rcu_gp_kthread+0x208/0x298
        kthread+0x10c/0x110
        ret_from_fork+0x10/0x20
    
    The design have been part of the driver since it was first merged in
    early 2009. It becomes increasingly harder to trigger the issue the
    older kernel version one tries. It only takes a few boots on v6.10-rc5,
    while hundreds of boots are needed to trigger it on v5.10.
    
    Close the race condition by using the CMT channel lock for the two
    competing sections. The channel lock was added to the driver after its
    initial design.
    
    Signed-off-by: Niklas Söderlund <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Daniel Lezcano <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
clocksource: Fix brown-bag boolean thinko in cs_watchdog_read() [+ + +]
Author: Paul E. McKenney <[email protected]>
Date:   Fri Aug 2 08:46:15 2024 -0700

    clocksource: Fix brown-bag boolean thinko in cs_watchdog_read()
    
    commit f2655ac2c06a15558e51ed6529de280e1553c86e upstream.
    
    The current "nretries > 1 || nretries >= max_retries" check in
    cs_watchdog_read() will always evaluate to true, and thus pr_warn(), if
    nretries is greater than 1.  The intent is instead to never warn on the
    first try, but otherwise warn if the successful retry was the last retry.
    
    Therefore, change that "||" to "&&".
    
    Fixes: db3a34e17433 ("clocksource: Retry clock read if long delays detected")
    Reported-by: Borislav Petkov <[email protected]>
    Signed-off-by: Paul E. McKenney <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
cpufreq: amd-pstate: Allow users to write 'default' EPP string [+ + +]
Author: Mario Limonciello <[email protected]>
Date:   Wed Jun 12 09:20:49 2024 -0500

    cpufreq: amd-pstate: Allow users to write 'default' EPP string
    
    [ Upstream commit fc6e0837264a8b2504b6160e63ec92eb012540f3 ]
    
    The EPP string for 'default' represents what the firmware had configured
    as the default EPP value but once a user changes EPP to another string
    they can't reset it back to 'default'.
    
    Cache the firmware EPP value and allow the user to write 'default' using
    this value.
    
    Reported-by: Artem S. Tashkinov <[email protected]>
    Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931#c61
    Reviewed-by: Perry Yuan <[email protected]>
    Signed-off-by: Mario Limonciello <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

cpufreq: amd-pstate: auto-load pstate driver by default [+ + +]
Author: Perry Yuan <[email protected]>
Date:   Wed Jun 19 23:40:19 2024 +0800

    cpufreq: amd-pstate: auto-load pstate driver by default
    
    [ Upstream commit 4e4f600ee750facedf6a5dc97e8ae0b627ab4573 ]
    
    If the `amd-pstate` driver is not loaded automatically by default,
    it is because the kernel command line parameter has not been added.
    To resolve this issue, it is necessary to call the `amd_pstate_set_driver()`
    function to enable the desired mode (passive/active/guided) before registering
    the driver instance.
    
    This ensures that the driver is loaded correctly without relying on the kernel
    command line parameter.
    
    When there is no parameter added to command line, Kernel config will
    provide the default mode to load.
    
    Meanwhile, user can add driver mode in command line which will override
    the kernel config default option.
    
    Reported-by: Andrei Amuraritei <[email protected]>
    Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218705
    Signed-off-by: Perry Yuan <[email protected]>
    Reviewed-by: Mario Limonciello <[email protected]>
    Link: https://lore.kernel.org/r/83301c4cea4f92fb19e14b23f2bac7facfd8bdbb.1718811234.git.perry.yuan@amd.com
    Signed-off-by: Mario Limonciello <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
debugobjects: Annotate racy debug variables [+ + +]
Author: Breno Leitao <[email protected]>
Date:   Tue Jun 11 02:18:12 2024 -0700

    debugobjects: Annotate racy debug variables
    
    [ Upstream commit 5b5baba6222255d29626f63c41f101379ec5400b ]
    
    KCSAN has identified a potential data race in debugobjects, where the
    global variable debug_objects_maxchain is accessed for both reading and
    writing simultaneously in separate and parallel data paths. This results in
    the following splat printed by KCSAN:
    
      BUG: KCSAN: data-race in debug_check_no_obj_freed / debug_object_activate
    
      write to 0xffffffff847ccfc8 of 4 bytes by task 734 on cpu 41:
      debug_object_activate (lib/debugobjects.c:199 lib/debugobjects.c:564 lib/debugobjects.c:710)
      call_rcu (kernel/rcu/rcu.h:227 kernel/rcu/tree.c:2719 kernel/rcu/tree.c:2838)
      security_inode_free (security/security.c:1626)
      __destroy_inode (./include/linux/fsnotify.h:222 fs/inode.c:287)
      ...
      read to 0xffffffff847ccfc8 of 4 bytes by task 384 on cpu 31:
      debug_check_no_obj_freed (lib/debugobjects.c:1000 lib/debugobjects.c:1019)
      kfree (mm/slub.c:2081 mm/slub.c:4280 mm/slub.c:4390)
      percpu_ref_exit (lib/percpu-refcount.c:147)
      css_free_rwork_fn (kernel/cgroup/cgroup.c:5357)
      ...
      value changed: 0x00000070 -> 0x00000071
    
    The data race is actually harmless as this is just used for debugfs
    statistics, as all other debug variables.
    
    Annotate all debug variables as racy explicitly, since these variables
    are known to be racy and harmless.
    
    Signed-off-by: Breno Leitao <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
driver core: Fix uevent_show() vs driver detach race [+ + +]
Author: Dan Williams <[email protected]>
Date:   Fri Jul 12 12:42:09 2024 -0700

    driver core: Fix uevent_show() vs driver detach race
    
    commit 15fffc6a5624b13b428bb1c6e9088e32a55eb82c upstream.
    
    uevent_show() wants to de-reference dev->driver->name. There is no clean
    way for a device attribute to de-reference dev->driver unless that
    attribute is defined via (struct device_driver).dev_groups. Instead, the
    anti-pattern of taking the device_lock() in the attribute handler risks
    deadlocks with code paths that remove device attributes while holding
    the lock.
    
    This deadlock is typically invisible to lockdep given the device_lock()
    is marked lockdep_set_novalidate_class(), but some subsystems allocate a
    local lockdep key for @dev->mutex to reveal reports of the form:
    
     ======================================================
     WARNING: possible circular locking dependency detected
     6.10.0-rc7+ #275 Tainted: G           OE    N
     ------------------------------------------------------
     modprobe/2374 is trying to acquire lock:
     ffff8c2270070de0 (kn->active#6){++++}-{0:0}, at: __kernfs_remove+0xde/0x220
    
     but task is already holding lock:
     ffff8c22016e88f8 (&cxl_root_key){+.+.}-{3:3}, at: device_release_driver_internal+0x39/0x210
    
     which lock already depends on the new lock.
    
     the existing dependency chain (in reverse order) is:
    
     -> #1 (&cxl_root_key){+.+.}-{3:3}:
            __mutex_lock+0x99/0xc30
            uevent_show+0xac/0x130
            dev_attr_show+0x18/0x40
            sysfs_kf_seq_show+0xac/0xf0
            seq_read_iter+0x110/0x450
            vfs_read+0x25b/0x340
            ksys_read+0x67/0xf0
            do_syscall_64+0x75/0x190
            entry_SYSCALL_64_after_hwframe+0x76/0x7e
    
     -> #0 (kn->active#6){++++}-{0:0}:
            __lock_acquire+0x121a/0x1fa0
            lock_acquire+0xd6/0x2e0
            kernfs_drain+0x1e9/0x200
            __kernfs_remove+0xde/0x220
            kernfs_remove_by_name_ns+0x5e/0xa0
            device_del+0x168/0x410
            device_unregister+0x13/0x60
            devres_release_all+0xb8/0x110
            device_unbind_cleanup+0xe/0x70
            device_release_driver_internal+0x1c7/0x210
            driver_detach+0x47/0x90
            bus_remove_driver+0x6c/0xf0
            cxl_acpi_exit+0xc/0x11 [cxl_acpi]
            __do_sys_delete_module.isra.0+0x181/0x260
            do_syscall_64+0x75/0x190
            entry_SYSCALL_64_after_hwframe+0x76/0x7e
    
    The observation though is that driver objects are typically much longer
    lived than device objects. It is reasonable to perform lockless
    de-reference of a @driver pointer even if it is racing detach from a
    device. Given the infrequency of driver unregistration, use
    synchronize_rcu() in module_remove_driver() to close any potential
    races.  It is potentially overkill to suffer synchronize_rcu() just to
    handle the rare module removal racing uevent_show() event.
    
    Thanks to Tetsuo Handa for the debug analysis of the syzbot report [1].
    
    Fixes: c0a40097f0bc ("drivers: core: synchronize really_probe() and dev_uevent()")
    Reported-by: [email protected]
    Reported-by: Tetsuo Handa <[email protected]>
    Closes: http://lore.kernel.org/[email protected] [1]
    Link: http://lore.kernel.org/[email protected]
    Cc: [email protected]
    Cc: Ashish Sangwan <[email protected]>
    Cc: Namjae Jeon <[email protected]>
    Cc: Dirk Behme <[email protected]>
    Cc: Greg Kroah-Hartman <[email protected]>
    Cc: Rafael J. Wysocki <[email protected]>
    Signed-off-by: Dan Williams <[email protected]>
    Link: https://lore.kernel.org/r/172081332794.577428.9738802016494057132.stgit@dwillia2-xfh.jf.intel.com
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/admgpu: fix dereferencing null pointer context [+ + +]
Author: Jesse Zhang <[email protected]>
Date:   Thu May 9 10:57:04 2024 +0800

    drm/admgpu: fix dereferencing null pointer context
    
    [ Upstream commit 030ffd4d43b433bc6671d9ec34fc12c59220b95d ]
    
    When user space sets an invalid ta type, the pointer context will be empty.
    So it need to check the pointer context before using it
    
    Signed-off-by: Jesse Zhang <[email protected]>
    Suggested-by: Tim Huang <[email protected]>
    Reviewed-by: Tim Huang <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/amd/amdkfd: Fix a resource leak in svm_range_validate_and_map() [+ + +]
Author: Ramesh Errabolu <[email protected]>
Date:   Tue Apr 30 15:24:46 2024 -0500

    drm/amd/amdkfd: Fix a resource leak in svm_range_validate_and_map()
    
    [ Upstream commit d2d3a44008fea01ec7d5a9d9ca527286be2e0257 ]
    
    Analysis of code by Coverity, a static code analyser, has identified
    a resource leak in the symbol hmm_range. This leak occurs when one of
    the prior steps before it is released encounters an error.
    
    Signed-off-by: Ramesh Errabolu <[email protected]>
    Reviewed-by: Felix Kuehling <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/amd/display: Add delay to improve LTTPR UHBR interop [+ + +]
Author: Michael Strauss <[email protected]>
Date:   Tue Apr 9 12:00:34 2024 -0400

    drm/amd/display: Add delay to improve LTTPR UHBR interop
    
    [ Upstream commit 10839ee6a977ed1f7d0f4deb29f2d7e5d1f2a9dd ]
    
    [WHY]
    Avoid race condition which puts LTTPR into bad state during UHBR LT.
    
    [HOW]
    Delay 30ms between starting UHBR TPS1 PHY output and sending TPS1 via DPCD.
    
    Reviewed-by: Wenjing Liu <[email protected]>
    Acked-by: Aurabindo Pillai <[email protected]>
    Signed-off-by: Michael Strauss <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Add NULL check for 'afb' before dereferencing in amdgpu_dm_plane_handle_cursor_update [+ + +]
Author: Srinivasan Shanmugam <[email protected]>
Date:   Wed Jun 5 21:13:40 2024 +0530

    drm/amd/display: Add NULL check for 'afb' before dereferencing in amdgpu_dm_plane_handle_cursor_update
    
    [ Upstream commit 38e6f715b02b572f74677eb2f29d3b4bc6f1ddff ]
    
    This commit adds a null check for the 'afb' variable in the
    amdgpu_dm_plane_handle_cursor_update function. Previously, 'afb' was
    assumed to be null, but was used later in the code without a null check.
    This could potentially lead to a null pointer dereference.
    
    Fixes the below:
    drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_plane.c:1298 amdgpu_dm_plane_handle_cursor_update() error: we previously assumed 'afb' could be null (see line 1252)
    
    Cc: Tom Chung <[email protected]>
    Cc: Rodrigo Siqueira <[email protected]>
    Cc: Roman Li <[email protected]>
    Cc: Hersen Wu <[email protected]>
    Cc: Alex Hung <[email protected]>
    Cc: Aurabindo Pillai <[email protected]>
    Cc: Harry Wentland <[email protected]>
    Signed-off-by: Srinivasan Shanmugam <[email protected]>
    Reviewed-by: Harry Wentland <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Add null check in resource_log_pipe_topology_update [+ + +]
Author: Natanel Roizenman <[email protected]>
Date:   Wed Apr 3 16:52:48 2024 -0400

    drm/amd/display: Add null check in resource_log_pipe_topology_update
    
    commit 899d92fd26fe780aad711322aa671f68058207a6 upstream.
    
    [WHY]
    When switching from "Extend" to "Second Display Only" we sometimes
    call resource_get_otg_master_for_stream on a stream for the eDP,
    which is disconnected. This leads to a null pointer dereference.
    
    [HOW]
    Added a null check in dc_resource.c/resource_log_pipe_topology_update.
    
    CC: [email protected]
    Reviewed-by: Nicholas Kazlauskas <[email protected]>
    Acked-by: Aurabindo Pillai <[email protected]>
    Signed-off-by: Natanel Roizenman <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

drm/amd/display: Add null checker before passing variables [+ + +]
Author: Alex Hung <[email protected]>
Date:   Tue Jun 4 16:33:18 2024 -0600

    drm/amd/display: Add null checker before passing variables
    
    [ Upstream commit 8092aa3ab8f7b737a34b71f91492c676a843043a ]
    
    Checks null pointer before passing variables to functions.
    
    This fixes 3 NULL_RETURNS issues reported by Coverity.
    
    Reviewed-by: Harry Wentland <[email protected]>
    Acked-by: Hamza Mahfooz <[email protected]>
    Signed-off-by: Alex Hung <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Add null checks for 'stream' and 'plane' before dereferencing [+ + +]
Author: Srinivasan Shanmugam <[email protected]>
Date:   Mon May 27 20:15:21 2024 +0530

    drm/amd/display: Add null checks for 'stream' and 'plane' before dereferencing
    
    [ Upstream commit 15c2990e0f0108b9c3752d7072a97d45d4283aea ]
    
    This commit adds null checks for the 'stream' and 'plane' variables in
    the dcn30_apply_idle_power_optimizations function. These variables were
    previously assumed to be null at line 922, but they were used later in
    the code without checking if they were null. This could potentially lead
    to a null pointer dereference, which would cause a crash.
    
    The null checks ensure that 'stream' and 'plane' are not null before
    they are used, preventing potential crashes.
    
    Fixes the below static smatch checker:
    drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:938 dcn30_apply_idle_power_optimizations() error: we previously assumed 'stream' could be null (see line 922)
    drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:940 dcn30_apply_idle_power_optimizations() error: we previously assumed 'plane' could be null (see line 922)
    
    Cc: Tom Chung <[email protected]>
    Cc: Nicholas Kazlauskas <[email protected]>
    Cc: Bhawanpreet Lakha <[email protected]>
    Cc: Rodrigo Siqueira <[email protected]>
    Cc: Roman Li <[email protected]>
    Cc: Hersen Wu <[email protected]>
    Cc: Alex Hung <[email protected]>
    Cc: Aurabindo Pillai <[email protected]>
    Cc: Harry Wentland <[email protected]>
    Signed-off-by: Srinivasan Shanmugam <[email protected]>
    Reviewed-by: Aurabindo Pillai <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Change ASSR disable sequence [+ + +]
Author: Swapnil Patel <[email protected]>
Date:   Thu Apr 18 14:30:39 2024 -0400

    drm/amd/display: Change ASSR disable sequence
    
    commit 2d696cc837eaf5394d79bfd2b0b0483c4778aa83 upstream.
    
    [Why]
    Currently disabling ASSR before stream is disabled causes visible
    display corruption.
    
    [How]
    Move disable ASSR command to after stream has been disabled.
    
    Cc: Mario Limonciello <[email protected]>
    Cc: Alex Deucher <[email protected]>
    Cc: [email protected]
    Reviewed-by: Wenjing Liu <[email protected]>
    Acked-by: Wayne Lin <[email protected]>
    Signed-off-by: Swapnil Patel <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

drm/amd/display: Don't refer to dc_sink in is_dsc_need_re_compute [+ + +]
Author: Wayne Lin <[email protected]>
Date:   Tue May 21 11:54:26 2024 +0800

    drm/amd/display: Don't refer to dc_sink in is_dsc_need_re_compute
    
    [ Upstream commit fcf6a49d79923a234844b8efe830a61f3f0584e4 ]
    
    [Why]
    When unplug one of monitors connected after mst hub, encounter null pointer dereference.
    
    It's due to dc_sink get released immediately in early_unregister() or detect_ctx(). When
    commit new state which directly referring to info stored in dc_sink will cause null pointer
    dereference.
    
    [how]
    Remove redundant checking condition. Relevant condition should already be covered by checking
    if dsc_aux is null or not. Also reset dsc_aux to NULL when the connector is disconnected.
    
    Reviewed-by: Jerry Zuo <[email protected]>
    Acked-by: Zaeem Mohamed <[email protected]>
    Signed-off-by: Wayne Lin <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Fix null pointer deref in dcn20_resource.c [+ + +]
Author: Aurabindo Pillai <[email protected]>
Date:   Wed Jun 26 13:13:57 2024 -0400

    drm/amd/display: Fix null pointer deref in dcn20_resource.c
    
    [ Upstream commit ecbf60782662f0a388493685b85a645a0ba1613c ]
    
    Fixes a hang thats triggered when MPV is run on a DCN401 dGPU:
    
    mpv --hwdec=vaapi --vo=gpu --hwdec-codecs=all
    
    and then enabling fullscreen playback (double click on the video)
    
    The following calltrace will be seen:
    
    [  181.843989] BUG: kernel NULL pointer dereference, address: 0000000000000000
    [  181.843997] #PF: supervisor instruction fetch in kernel mode
    [  181.844003] #PF: error_code(0x0010) - not-present page
    [  181.844009] PGD 0 P4D 0
    [  181.844020] Oops: 0010 [#1] PREEMPT SMP NOPTI
    [  181.844028] CPU: 6 PID: 1892 Comm: gnome-shell Tainted: G        W  OE      6.5.0-41-generic #41~22.04.2-Ubuntu
    [  181.844038] Hardware name: System manufacturer System Product Name/CROSSHAIR VI HERO, BIOS 6302 10/23/2018
    [  181.844044] RIP: 0010:0x0
    [  181.844079] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
    [  181.844084] RSP: 0018:ffffb593c2b8f7b0 EFLAGS: 00010246
    [  181.844093] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000004
    [  181.844099] RDX: ffffb593c2b8f804 RSI: ffffb593c2b8f7e0 RDI: ffff9e3c8e758400
    [  181.844105] RBP: ffffb593c2b8f7b8 R08: ffffb593c2b8f9c8 R09: ffffb593c2b8f96c
    [  181.844110] R10: 0000000000000000 R11: 0000000000000000 R12: ffffb593c2b8f9c8
    [  181.844115] R13: 0000000000000001 R14: ffff9e3c88000000 R15: 0000000000000005
    [  181.844121] FS:  00007c6e323bb5c0(0000) GS:ffff9e3f85f80000(0000) knlGS:0000000000000000
    [  181.844128] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [  181.844134] CR2: ffffffffffffffd6 CR3: 0000000140fbe000 CR4: 00000000003506e0
    [  181.844141] Call Trace:
    [  181.844146]  <TASK>
    [  181.844153]  ? show_regs+0x6d/0x80
    [  181.844167]  ? __die+0x24/0x80
    [  181.844179]  ? page_fault_oops+0x99/0x1b0
    [  181.844192]  ? do_user_addr_fault+0x31d/0x6b0
    [  181.844204]  ? exc_page_fault+0x83/0x1b0
    [  181.844216]  ? asm_exc_page_fault+0x27/0x30
    [  181.844237]  dcn20_get_dcc_compression_cap+0x23/0x30 [amdgpu]
    [  181.845115]  amdgpu_dm_plane_validate_dcc.constprop.0+0xe5/0x180 [amdgpu]
    [  181.845985]  amdgpu_dm_plane_fill_plane_buffer_attributes+0x300/0x580 [amdgpu]
    [  181.846848]  fill_dc_plane_info_and_addr+0x258/0x350 [amdgpu]
    [  181.847734]  fill_dc_plane_attributes+0x162/0x350 [amdgpu]
    [  181.848748]  dm_update_plane_state.constprop.0+0x4e3/0x6b0 [amdgpu]
    [  181.849791]  ? dm_update_plane_state.constprop.0+0x4e3/0x6b0 [amdgpu]
    [  181.850840]  amdgpu_dm_atomic_check+0xdfe/0x1760 [amdgpu]
    
    Signed-off-by: Aurabindo Pillai <[email protected]>
    Reviewed-by: Rodrigo Siqueira <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Fix NULL pointer dereference for DTN log in DCN401 [+ + +]
Author: Rodrigo Siqueira <[email protected]>
Date:   Mon Jun 3 15:31:15 2024 -0600

    drm/amd/display: Fix NULL pointer dereference for DTN log in DCN401
    
    [ Upstream commit 5af757124792817f8eb1bd0c80ad60fab519586b ]
    
    When users run the command:
    
    cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
    
    The following NULL pointer dereference happens:
    
    [  +0.000003] BUG: kernel NULL pointer dereference, address: NULL
    [  +0.000005] #PF: supervisor instruction fetch in kernel mode
    [  +0.000002] #PF: error_code(0x0010) - not-present page
    [  +0.000002] PGD 0 P4D 0
    [  +0.000004] Oops: 0010 [#1] PREEMPT SMP NOPTI
    [  +0.000003] RIP: 0010:0x0
    [  +0.000008] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
    [...]
    [  +0.000002] PKRU: 55555554
    [  +0.000002] Call Trace:
    [  +0.000002]  <TASK>
    [  +0.000003]  ? show_regs+0x65/0x70
    [  +0.000006]  ? __die+0x24/0x70
    [  +0.000004]  ? page_fault_oops+0x160/0x470
    [  +0.000006]  ? do_user_addr_fault+0x2b5/0x690
    [  +0.000003]  ? prb_read_valid+0x1c/0x30
    [  +0.000005]  ? exc_page_fault+0x8c/0x1a0
    [  +0.000005]  ? asm_exc_page_fault+0x27/0x30
    [  +0.000012]  dcn10_log_color_state+0xf9/0x510 [amdgpu]
    [  +0.000306]  ? srso_alias_return_thunk+0x5/0xfbef5
    [  +0.000003]  ? vsnprintf+0x2fb/0x600
    [  +0.000009]  dcn10_log_hw_state+0xfd0/0xfe0 [amdgpu]
    [  +0.000218]  ? __mod_memcg_lruvec_state+0xe8/0x170
    [  +0.000008]  ? srso_alias_return_thunk+0x5/0xfbef5
    [  +0.000002]  ? debug_smp_processor_id+0x17/0x20
    [  +0.000003]  ? srso_alias_return_thunk+0x5/0xfbef5
    [  +0.000002]  ? srso_alias_return_thunk+0x5/0xfbef5
    [  +0.000002]  ? set_ptes.isra.0+0x2b/0x90
    [  +0.000004]  ? srso_alias_return_thunk+0x5/0xfbef5
    [  +0.000002]  ? _raw_spin_unlock+0x19/0x40
    [  +0.000004]  ? srso_alias_return_thunk+0x5/0xfbef5
    [  +0.000002]  ? do_anonymous_page+0x337/0x700
    [  +0.000004]  dtn_log_read+0x82/0x120 [amdgpu]
    [  +0.000207]  full_proxy_read+0x66/0x90
    [  +0.000007]  vfs_read+0xb0/0x340
    [  +0.000005]  ? __count_memcg_events+0x79/0xe0
    [  +0.000002]  ? srso_alias_return_thunk+0x5/0xfbef5
    [  +0.000003]  ? count_memcg_events.constprop.0+0x1e/0x40
    [  +0.000003]  ? handle_mm_fault+0xb2/0x370
    [  +0.000003]  ksys_read+0x6b/0xf0
    [  +0.000004]  __x64_sys_read+0x19/0x20
    [  +0.000003]  do_syscall_64+0x60/0x130
    [  +0.000004]  entry_SYSCALL_64_after_hwframe+0x6e/0x76
    [  +0.000003] RIP: 0033:0x7fdf32f147e2
    [...]
    
    This error happens when the color log tries to read the gamut remap
    information from DCN401 which is not initialized in the dcn401_dpp_funcs
    which leads to a null pointer dereference. This commit addresses this
    issue by adding a proper guard to access the gamut_remap callback in
    case the specific ASIC did not implement this function.
    
    Reviewed-by: Aurabindo Pillai <[email protected]>
    Acked-by: Hamza Mahfooz <[email protected]>
    Signed-off-by: Rodrigo Siqueira <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Handle HPD_IRQ for internal link [+ + +]
Author: Sung-huai Wang <[email protected]>
Date:   Wed Apr 10 14:40:32 2024 +0800

    drm/amd/display: Handle HPD_IRQ for internal link
    
    [ Upstream commit 239b31bd5c3fef3698440bf6436b2068c6bb08a3 ]
    
    [Why]
    TCON data is corrupted after electro static discharge test.
    Once the TCON data get corrupted, they will get themselves
    reset and send HPD_IRQ to source side.
    
    [How]
    Support HPD_IRQ for internal link, and restore the PSR/Replay setup.
    
    Reviewed-by: Robin Chen <[email protected]>
    Acked-by: Aurabindo Pillai <[email protected]>
    Signed-off-by: Sung-huai Wang <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: reduce ODM slice count to initial new dc state only when needed [+ + +]
Author: Wenjing Liu <[email protected]>
Date:   Tue May 21 17:05:41 2024 -0400

    drm/amd/display: reduce ODM slice count to initial new dc state only when needed
    
    [ Upstream commit 9a29c4adb0997be6ba3dd92dfba14ea75a8c6ce4 ]
    
    [why]
    We need to decrease ODM slice when adding or removing planes because MPO
    support takes precedence over dynamic ODM combine. However there is a case where
    we remove ODM combine even for ODM combine required timing in the initial new
    dc state. This is normally okay because ODM will be added back after we pass DML
    bandwidth validation. However since we remove ODM combine in the initial new
    state, the previous ODM pipe allocation is lost. This may cause the new plane to
    take away the original secondary OPP head pipe that is still required in the new
    state.
    
    For a timing that requires ODM 2:1 but optimized with ODM 4:1, if we add an MPO
    plane, we will not have enough pipe to preserve ODM 4:1. In this case we should
    reduce ODM slice count then try to add the MPO plane again. By reducing, we are
    gradually remove 1 ODM slice from right most side one at a time until we have
    enough free pipes for the new plane. If we remove ODM combine entirely, we could
    use the pipe at ODM slice index 1 as a DPP pipe for the new plane. But ODM slice
    1 is still needed as the timing requires ODM 2:1. This transition is not
    seamless and user will see corruption on the screen.
    
    [how]
    Remove single ODM slice one at time until we have enough pipes for a new plane.
    Remove previous logic to always remove ODM combine entirely.
    
    Reviewed-by: Dillon Varone <[email protected]>
    Acked-by: Zaeem Mohamed <[email protected]>
    Signed-off-by: Wenjing Liu <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Refactor function dm_dp_mst_is_port_support_mode() [+ + +]
Author: Wayne Lin <[email protected]>
Date:   Mon May 20 16:37:01 2024 +0800

    drm/amd/display: Refactor function dm_dp_mst_is_port_support_mode()
    
    commit fa57924c76d995e87ca3533ec60d1d5e55769a27 upstream.
    
    [Why]
    dm_dp_mst_is_port_support_mode() is a bit not following the original design rule and cause
    light up issue with multiple 4k monitors after mst dsc hub.
    
    [How]
    Refactor function dm_dp_mst_is_port_support_mode() a bit to solve the light up issue.
    
    Reviewed-by: Jerry Zuo <[email protected]>
    Acked-by: Zaeem Mohamed <[email protected]>
    Signed-off-by: Wayne Lin <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    [[email protected]: Resolved merge conflict in .../amdgpu_dm_mst_types.c]
    Fixes: 4df96ba6676034 ("drm/amd/display: Add timing pixel encoding for mst mode validation")
    Link: https://lore.kernel.org/stable/[email protected]/T/#u
    Signed-off-by: Kevin Holm <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>
drm/amd/display: remove dpp pipes on failure to update pipe params [+ + +]
Author: Wenjing Liu <[email protected]>
Date:   Wed May 29 14:17:34 2024 -0400

    drm/amd/display: remove dpp pipes on failure to update pipe params
    
    [ Upstream commit 3ddd9c83ff7ac0ead38188425b14d03dc2f2c133 ]
    
    [why]
    There are cases where update pipe params could fail but dpp pipes are already
    added to the state. In this case, we should remove dpp pipes so dc state is
    restored back. If it is not restored, dc state is corrupted after calling this
    function, so if we call the same interface with the corrupted state again, we
    may end up programming pipe topology based on a corrupted dc state.
    
    Reviewed-by: Dillon Varone <[email protected]>
    Acked-by: Zaeem Mohamed <[email protected]>
    Signed-off-by: Wenjing Liu <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Replace dm_execute_dmub_cmd with dc_wake_and_execute_dmub_cmd [+ + +]
Author: Rodrigo Siqueira <[email protected]>
Date:   Mon Dec 4 16:35:04 2023 -0500

    drm/amd/display: Replace dm_execute_dmub_cmd with dc_wake_and_execute_dmub_cmd
    
    [ Upstream commit f2aaed194a54d78c307c44d1829c7e1ba67e9ba5 ]
    
    In the commit c2cec7a872b6 ("drm/amd/display: Wake DMCUB before sending
    a command for replay feature"), replaced dm_execute_dmub_cmd with
    dc_wake_and_execute_dmub_cmd in multiple areas, but due to merge issues
    the replacement of this function in the dmub_replay_copy_settings was
    missed. This commit replaces the old dm_execute_dmub_cmd with
    dc_wake_and_execute_dmub_cmd.
    
    Fixes: 3601a35a2e9d ("drm/amd/display: Wake DMCUB before sending a command for replay feature")
    Reviewed-by: Aurabindo Pillai <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Rodrigo Siqueira <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    (cherry picked from commit 6cc213b9aa34bc3213e20f9256345c5cc1495b0b)
    Signed-off-by: Sasha Levin <[email protected]>

drm/amd/display: Skip Recompute DSC Params if no Stream on Link [+ + +]
Author: Fangzhi Zuo <[email protected]>
Date:   Fri Jul 12 16:30:03 2024 -0400

    drm/amd/display: Skip Recompute DSC Params if no Stream on Link
    
    commit 50e376f1fe3bf571d0645ddf48ad37eb58323919 upstream.
    
    [why]
    Encounter NULL pointer dereference uner mst + dsc setup.
    
    BUG: kernel NULL pointer dereference, address: 0000000000000008
        PGD 0 P4D 0
        Oops: 0000 [#1] PREEMPT SMP NOPTI
        CPU: 4 PID: 917 Comm: sway Not tainted 6.3.9-arch1-1 #1 124dc55df4f5272ccb409f39ef4872fc2b3376a2
        Hardware name: LENOVO 20NKS01Y00/20NKS01Y00, BIOS R12ET61W(1.31 ) 07/28/2022
        RIP: 0010:drm_dp_atomic_find_time_slots+0x5e/0x260 [drm_display_helper]
        Code: 01 00 00 48 8b 85 60 05 00 00 48 63 80 88 00 00 00 3b 43 28 0f 8d 2e 01 00 00 48 8b 53 30 48 8d 04 80 48 8d 04 c2 48 8b 40 18 <48> 8>
        RSP: 0018:ffff960cc2df77d8 EFLAGS: 00010293
        RAX: 0000000000000000 RBX: ffff8afb87e81280 RCX: 0000000000000224
        RDX: ffff8afb9ee37c00 RSI: ffff8afb8da1a578 RDI: ffff8afb87e81280
        RBP: ffff8afb83d67000 R08: 0000000000000001 R09: ffff8afb9652f850
        R10: ffff960cc2df7908 R11: 0000000000000002 R12: 0000000000000000
        R13: ffff8afb8d7688a0 R14: ffff8afb8da1a578 R15: 0000000000000224
        FS:  00007f4dac35ce00(0000) GS:ffff8afe30b00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000008 CR3: 000000010ddc6000 CR4: 00000000003506e0
        Call Trace:
    <TASK>
         ? __die+0x23/0x70
         ? page_fault_oops+0x171/0x4e0
         ? plist_add+0xbe/0x100
         ? exc_page_fault+0x7c/0x180
         ? asm_exc_page_fault+0x26/0x30
         ? drm_dp_atomic_find_time_slots+0x5e/0x260 [drm_display_helper 0e67723696438d8e02b741593dd50d80b44c2026]
         ? drm_dp_atomic_find_time_slots+0x28/0x260 [drm_display_helper 0e67723696438d8e02b741593dd50d80b44c2026]
         compute_mst_dsc_configs_for_link+0x2ff/0xa40 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
         ? fill_plane_buffer_attributes+0x419/0x510 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
         compute_mst_dsc_configs_for_state+0x1e1/0x250 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
         amdgpu_dm_atomic_check+0xecd/0x1190 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
         drm_atomic_check_only+0x5c5/0xa40
         drm_mode_atomic_ioctl+0x76e/0xbc0
    
    [how]
    dsc recompute should be skipped if no mode change detected on the new
    request. If detected, keep checking whether the stream is already on
    current state or not.
    
    Cc: Mario Limonciello <[email protected]>
    Cc: Alex Deucher <[email protected]>
    Cc: [email protected]
    Reviewed-by: Rodrigo Siqueira <[email protected]>
    Signed-off-by: Fangzhi Zuo <[email protected]>
    Signed-off-by: Wayne Lin <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    (cherry picked from commit 8151a6c13111b465dbabe07c19f572f7cbd16fef)
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

drm/amd/display: Wake DMCUB before sending a command for replay feature [+ + +]
Author: Nicholas Kazlauskas <[email protected]>
Date:   Mon Dec 4 16:35:04 2023 -0500

    drm/amd/display: Wake DMCUB before sending a command for replay feature
    
    [ Upstream commit 3601a35a2e9d640233f4bc3496f7603b93f9c143 ]
    
    [Why]
    We can hang in place trying to send commands when the DMCUB isn't
    powered on.
    
    [How]
    For functions that execute within a DC context or DC lock we can wrap
    the direct calls to dm_execute_dmub_cmd/list with code that exits idle
    power optimizations and reallows once we're done with the command
    submission on success.
    
    For DM direct submissions the DM will need to manage the enter/exit
    sequencing manually.
    
    We cannot invoke a DMCUB command directly within the DM execution helper
    or we can deadlock.
    
    Reviewed-by: Rodrigo Siqueira <[email protected]>
    Signed-off-by: Nicholas Kazlauskas <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/amd/pm: Fix the null pointer dereference for vega10_hwmgr [+ + +]
Author: Bob Zhou <[email protected]>
Date:   Fri May 31 15:01:22 2024 +0800

    drm/amd/pm: Fix the null pointer dereference for vega10_hwmgr
    
    [ Upstream commit 50151b7f1c79a09117837eb95b76c2de76841dab ]
    
    Check return value and conduct null pointer handling to avoid null pointer dereference.
    
    Signed-off-by: Bob Zhou <[email protected]>
    Reviewed-by: Tim Huang <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/amdgpu/pm: Fix the null pointer dereference for smu7 [+ + +]
Author: Ma Jun <[email protected]>
Date:   Fri May 10 15:01:59 2024 +0800

    drm/amdgpu/pm: Fix the null pointer dereference for smu7
    
    [ Upstream commit c02c1960c93eede587576625a1221205a68a904f ]
    
    optimize the code to avoid pass a null pointer (hwmgr->backend)
    to function smu7_update_edc_leakage_table.
    
    Signed-off-by: Ma Jun <[email protected]>
    Reviewed-by: Yang Wang <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amdgpu/pm: Fix the null pointer dereference in apply_state_adjust_rules [+ + +]
Author: Ma Jun <[email protected]>
Date:   Thu May 9 15:51:35 2024 +0800

    drm/amdgpu/pm: Fix the null pointer dereference in apply_state_adjust_rules
    
    [ Upstream commit d19fb10085a49b77578314f69fff21562f7cd054 ]
    
    Check the pointer value to fix potential null pointer
    dereference
    
    Acked-by: Yang Wang<[email protected]>
    Signed-off-by: Ma Jun <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amdgpu/pm: Fix the param type of set_power_profile_mode [+ + +]
Author: Ma Jun <[email protected]>
Date:   Sun Apr 28 15:58:10 2024 +0800

    drm/amdgpu/pm: Fix the param type of set_power_profile_mode
    
    [ Upstream commit f683f24093dd94a831085fe0ea8e9dc4c6c1a2d1 ]
    
    Function .set_power_profile_mode need an array as input
    parameter. So define variable workload as an array to fix
    the below coverity warning.
    
    "Passing &workload to function hwmgr->hwmgr_func->set_power_profile_mode
    which uses it as an array. This might corrupt or misinterpret adjacent
    memory locations"
    
    Signed-off-by: Ma Jun <[email protected]>
    Acked-by: Alex Deucher <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/amdgpu: Add lock around VF RLCG interface [+ + +]
Author: Victor Skvortsov <[email protected]>
Date:   Mon May 27 16:10:43 2024 -0400

    drm/amdgpu: Add lock around VF RLCG interface
    
    [ Upstream commit e864180ee49b4d30e640fd1e1d852b86411420c9 ]
    
    flush_gpu_tlb may be called from another thread while
    device_gpu_recover is running.
    
    Both of these threads access registers through the VF
    RLCG interface during VF Full Access. Add a lock around this interface
    to prevent race conditions between these threads.
    
    Signed-off-by: Victor Skvortsov <[email protected]>
    Reviewed-by: Zhigang Luo <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amdgpu: fix potential resource leak warning [+ + +]
Author: Tim Huang <[email protected]>
Date:   Thu Apr 25 11:09:00 2024 +0800

    drm/amdgpu: fix potential resource leak warning
    
    [ Upstream commit 22a5daaec0660dd19740c4c6608b78f38760d1e6 ]
    
    Clear resource leak warning that when the prepare fails,
    the allocated amdgpu job object will never be released.
    
    Signed-off-by: Tim Huang <[email protected]>
    Reviewed-by: Christian König <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amdgpu: Fix the null pointer dereference to ras_manager [+ + +]
Author: Ma Jun <[email protected]>
Date:   Sat May 11 15:48:02 2024 +0800

    drm/amdgpu: Fix the null pointer dereference to ras_manager
    
    [ Upstream commit 4c11d30c95576937c6c35e6f29884761f2dddb43 ]
    
    Check ras_manager before using it
    
    Signed-off-by: Ma Jun <[email protected]>
    Reviewed-by: Lijo Lazar <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/amdgpu: Forward soft recovery errors to userspace [+ + +]
Author: Joshua Ashton <[email protected]>
Date:   Thu Mar 7 19:04:31 2024 +0000

    drm/amdgpu: Forward soft recovery errors to userspace
    
    commit 829798c789f567ef6ba4b084c15b7b5f3bd98d51 upstream.
    
    As we discussed before[1], soft recovery should be
    forwarded to userspace, or we can get into a really
    bad state where apps will keep submitting hanging
    command buffers cascading us to a hard reset.
    
    1: https://lore.kernel.org/all/[email protected]/
    Signed-off-by: Joshua Ashton <[email protected]>
    Reviewed-by: Marek Olšák <[email protected]>
    Signed-off-by: Christian König <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    (cherry picked from commit 434967aadbbbe3ad9103cc29e9a327de20fdba01)
    Cc: [email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/atomic: allow no-op FB_ID updates for async flips [+ + +]
Author: Simon Ser <[email protected]>
Date:   Wed Jul 31 19:10:20 2024 +0000

    drm/atomic: allow no-op FB_ID updates for async flips
    
    [ Upstream commit 929725bd7eb4eea1f75197d9847f3f1ea5afdad1 ]
    
    User-space is allowed to submit any property in an async flip as
    long as the value doesn't change. However we missed one case:
    as things stand, the kernel rejects no-op FB_ID changes on
    non-primary planes. Fix this by changing the conditional and
    skipping drm_atomic_check_prop_changes() only for FB_ID on the
    primary plane (instead of skipping for FB_ID on any plane).
    
    Fixes: 0e26cc72c71c ("drm: Refuse to async flip with atomic prop changes")
    Signed-off-by: Simon Ser <[email protected]>
    Reviewed-by: André Almeida <[email protected]>
    Tested-by: Xaver Hugl <[email protected]>
    Cc: Alex Deucher <[email protected]>
    Cc: Christian König <[email protected]>
    Cc: Michel Dänzer <[email protected]>
    Cc: Ville Syrjälä <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/bridge: analogix_dp: properly handle zero sized AUX transactions [+ + +]
Author: Lucas Stach <[email protected]>
Date:   Mon Mar 18 21:39:23 2024 +0100

    drm/bridge: analogix_dp: properly handle zero sized AUX transactions
    
    commit e82290a2e0e8ec5e836ecad1ca025021b3855c2d upstream.
    
    Address only transactions without any data are valid and should not
    be flagged as short transactions. Simply return the message size when
    no transaction errors occured.
    
    CC: [email protected]
    Signed-off-by: Lucas Stach <[email protected]>
    Reviewed-by: Robert Foss <[email protected]>
    Signed-off-by: Robert Foss <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/client: fix null pointer dereference in drm_client_modeset_probe [+ + +]
Author: Ma Ke <[email protected]>
Date:   Fri Aug 2 12:47:36 2024 +0800

    drm/client: fix null pointer dereference in drm_client_modeset_probe
    
    commit 113fd6372a5bb3689aba8ef5b8a265ed1529a78f upstream.
    
    In drm_client_modeset_probe(), the return value of drm_mode_duplicate() is
    assigned to modeset->mode, which will lead to a possible NULL pointer
    dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.
    
    Cc: [email protected]
    Fixes: cf13909aee05 ("drm/fb-helper: Move out modeset config code")
    Signed-off-by: Ma Ke <[email protected]>
    Reviewed-by: Thomas Zimmermann <[email protected]>
    Signed-off-by: Thomas Zimmermann <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/dp_mst: Skip CSN if topology probing is not done yet [+ + +]
Author: Wayne Lin <[email protected]>
Date:   Wed Jun 26 16:48:24 2024 +0800

    drm/dp_mst: Skip CSN if topology probing is not done yet
    
    commit ddf983488c3e8d30d5c2e2b315ae7d9cd87096ed upstream.
    
    [Why]
    During resume, observe that we receive CSN event before we start topology
    probing. Handling CSN at this moment based on uncertain topology is
    unnecessary.
    
    [How]
    Add checking condition in drm_dp_mst_handle_up_req() to skip handling CSN
    if the topology is yet to be probed.
    
    Cc: Lyude Paul <[email protected]>
    Cc: Harry Wentland <[email protected]>
    Cc: Jani Nikula <[email protected]>
    Cc: Imre Deak <[email protected]>
    Cc: Daniel Vetter <[email protected]>
    Cc: [email protected]
    Signed-off-by: Wayne Lin <[email protected]>
    Reviewed-by: Lyude Paul <[email protected]>
    Signed-off-by: Lyude Paul <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/i915/display: correct dual pps handling for MTL_PCH+ [+ + +]
Author: Dnyaneshwar Bhadane <[email protected]>
Date:   Thu Aug 1 16:41:41 2024 +0530

    drm/i915/display: correct dual pps handling for MTL_PCH+
    
    commit 1b85bdb0fadb42f5ef75ddcd259fc1ef13ec04de upstream.
    
    On the PCH side the second PPS was introduced in ICP+.Add condition
    On MTL_PCH and greater platform also having the second PPS.
    
    Note that DG1/2 south block only has the single PPS, so need
    to exclude the fake DG1/2 PCHs
    
    Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11488
    Fixes: 93cbc1accbce ("drm/i915/mtl: Add fake PCH for Meteor Lake")
    Cc: <[email protected]> # v6.9+
    Signed-off-by: Dnyaneshwar Bhadane <[email protected]>
    Reviewed-by: Jani Nikula <[email protected]>
    Signed-off-by: Jani Nikula <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit da1878b61c8d480c361ba6a39ce8a31c80b65826)
    Signed-off-by: Joonas Lahtinen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/i915/gem: Adjust vma offset for framebuffer mmap offset [+ + +]
Author: Andi Shyti <[email protected]>
Date:   Fri Aug 2 10:38:49 2024 +0200

    drm/i915/gem: Adjust vma offset for framebuffer mmap offset
    
    commit 1ac5167b3a90c9820daa64cc65e319b2d958d686 upstream.
    
    When mapping a framebuffer object, the virtual memory area (VMA)
    offset ('vm_pgoff') should be adjusted by the start of the
    'vma_node' associated with the object. This ensures that the VMA
    offset is correctly aligned with the corresponding offset within
    the GGTT aperture.
    
    Increment vm_pgoff by the start of the vma_node with the offset=
    provided by the user.
    
    Suggested-by: Chris Wilson <[email protected]>
    Signed-off-by: Andi Shyti <[email protected]>
    Reviewed-by: Jonathan Cavitt <[email protected]>
    Reviewed-by: Rodrigo Vivi <[email protected]>
    Cc: <[email protected]> # v4.9+
    [Joonas: Add Cc: stable]
    Signed-off-by: Joonas Lahtinen <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit 60a2066c50058086510c91f404eb582029650970)
    Signed-off-by: Joonas Lahtinen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

drm/i915/gem: Fix Virtual Memory mapping boundaries calculation [+ + +]
Author: Andi Shyti <[email protected]>
Date:   Fri Aug 2 10:38:50 2024 +0200

    drm/i915/gem: Fix Virtual Memory mapping boundaries calculation
    
    commit 8bdd9ef7e9b1b2a73e394712b72b22055e0e26c3 upstream.
    
    Calculating the size of the mapped area as the lesser value
    between the requested size and the actual size does not consider
    the partial mapping offset. This can cause page fault access.
    
    Fix the calculation of the starting and ending addresses, the
    total size is now deduced from the difference between the end and
    start addresses.
    
    Additionally, the calculations have been rewritten in a clearer
    and more understandable form.
    
    Fixes: c58305af1835 ("drm/i915: Use remap_io_mapping() to prefault all PTE in a single pass")
    Reported-by: Jann Horn <[email protected]>
    Co-developed-by: Chris Wilson <[email protected]>
    Signed-off-by: Chris Wilson <[email protected]>
    Signed-off-by: Andi Shyti <[email protected]>
    Cc: Joonas Lahtinen <[email protected]>
    Cc: Matthew Auld <[email protected]>
    Cc: Rodrigo Vivi <[email protected]>
    Cc: <[email protected]> # v4.9+
    Reviewed-by: Jann Horn <[email protected]>
    Reviewed-by: Jonathan Cavitt <[email protected]>
    [Joonas: Add Requires: tag]
    Requires: 60a2066c5005 ("drm/i915/gem: Adjust vma offset for framebuffer mmap offset")
    Signed-off-by: Joonas Lahtinen <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit 97b6784753da06d9d40232328efc5c5367e53417)
    Signed-off-by: Joonas Lahtinen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/i915: Allow evicting to use the requested placement [+ + +]
Author: David Gow <[email protected]>
Date:   Sun Aug 4 17:18:47 2024 +0800

    drm/i915: Allow evicting to use the requested placement
    
    [ Upstream commit 264b5b5980061d8c6a6a30c031cdec1179fe2bae ]
    
    In commit a78a8da51b36 ("drm/ttm: replace busy placement with flags v6"),
    the old system of having a separate placement list (for placements
    which should be used without eviction) and a 'busy' placement list (for
    placements which should be attempted if eviction is required) was
    replaced with a new one where placements could be marked 'FALLBACK' (to
    be attempted if eviction is required) or 'DESIRED' (to be attempted
    first, but not if eviction is required).
    
    i915 had always included the requested placement in the list of
    'busy' placements: i.e., the placement could be used either if eviction
    is required or not. But when the new system was put in place, the
    requested (first) placement was marked 'DESIRED', so would never be used
    if eviction became necessary. While a bug in the original commit
    prevented this flag from working, when this was fixed in
    4a0e7b3c ("drm/i915: fix applying placement flag"), it caused long hangs
    on DG2 systems with small BAR.
    
    Don't mark the requested placement DESIRED (or FALLBACK), allowing it to
    be used in both situations. This matches the old behaviour, and resolves
    the hangs.
    
    Thanks to Justin Brewer for bisecting the issue.
    
    Fixes: a78a8da51b36 ("drm/ttm: replace busy placement with flags v6")
    Fixes: 4a0e7b3c3753 ("drm/i915: fix applying placement flag")
    Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11255
    Signed-off-by: David Gow <[email protected]>
    Reviewed-by: Jonathan Cavitt <[email protected]>
    Reviewed-by: Andi Shyti <[email protected]>
    Signed-off-by: Andi Shyti <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit 54bf0af90844fbf18f5be3272eda69198dfdb622)
    Signed-off-by: Joonas Lahtinen <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/i915: Attempt to get pages without eviction first [+ + +]
Author: David Gow <[email protected]>
Date:   Sun Aug 4 17:18:48 2024 +0800

    drm/i915: Attempt to get pages without eviction first
    
    [ Upstream commit 787db3bb6ed5cee56fc97fecdd61517d89763f0a ]
    
    In commit a78a8da51b36 ("drm/ttm: replace busy placement with flags v6"),
    __i915_ttm_get_pages was updated to use flags instead of the separate
    'busy' placement list. However, the behaviour was subtly changed.
    Originally, the function would attempt to use the preferred placement
    without eviction, and give an opportunity to restart the operation
    before falling back to allowing eviction.
    
    This was unintentionally changed, as the preferred placement was not
    given the TTM_PL_FLAG_DESIRED flag, and so eviction could be triggered
    in that first pass. This caused thrashing, and a significant performance
    regression on DG2 systems with small BAR. For example, Minecraft and
    Team Fortress 2 would drop to single-digit framerates.
    
    Restore the original behaviour by marking the initial placement as
    desired on that first attempt. Also, rework this to use a separate
    struct ttm_palcement, as the individual placements are marked 'const',
    so hot-patching the flags is even more dodgy than before.
    
    Thanks to Justin Brewer for bisecting this.
    
    Fixes: a78a8da51b36 ("drm/ttm: replace busy placement with flags v6")
    Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11255
    Signed-off-by: David Gow <[email protected]>
    Reviewed-by: Jonathan Cavitt <[email protected]>
    Reviewed-by: Andi Shyti <[email protected]>
    Signed-off-by: Andi Shyti <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit 92653f2a572505adaf7f13f695c1907e71a1dc84)
    Signed-off-by: Joonas Lahtinen <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/lima: Mark simple_ondemand governor as softdep [+ + +]
Author: Dragan Simic <[email protected]>
Date:   Mon Jun 17 22:22:02 2024 +0200

    drm/lima: Mark simple_ondemand governor as softdep
    
    commit 0c94f58cef319ad054fd909b3bf4b7d09c03e11c upstream.
    
    Lima DRM driver uses devfreq to perform DVFS, while using simple_ondemand
    devfreq governor by default.  This causes driver initialization to fail on
    boot when simple_ondemand governor isn't built into the kernel statically,
    as a result of the missing module dependency and, consequently, the
    required governor module not being included in the initial ramdisk.  Thus,
    let's mark simple_ondemand governor as a softdep for Lima, to have its
    kernel module included in the initial ramdisk.
    
    This is a rather longstanding issue that has forced distributions to build
    devfreq governors statically into their kernels, [1][2] or may have forced
    some users to introduce unnecessary workarounds.
    
    Having simple_ondemand marked as a softdep for Lima may not resolve this
    issue for all Linux distributions.  In particular, it will remain
    unresolved for the distributions whose utilities for the initial ramdisk
    generation do not handle the available softdep information [3] properly
    yet.  However, some Linux distributions already handle softdeps properly
    while generating their initial ramdisks, [4] and this is a prerequisite
    step in the right direction for the distributions that don't handle them
    properly yet.
    
    [1] https://gitlab.manjaro.org/manjaro-arm/packages/core/linux-pinephone/-/blob/6.7-megi/config?ref_type=heads#L5749
    [2] https://gitlab.com/postmarketOS/pmaports/-/blob/7f64e287e7732c9eaa029653e73ca3d4ba1c8598/main/linux-postmarketos-allwinner/config-postmarketos-allwinner.aarch64#L4654
    [3] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit/?id=49d8e0b59052999de577ab732b719cfbeb89504d
    [4] https://github.com/archlinux/mkinitcpio/commit/97ac4d37aae084a050be512f6d8f4489054668ad
    
    Cc: Philip Muller <[email protected]>
    Cc: Oliver Smith <[email protected]>
    Cc: Daniel Smith <[email protected]>
    Cc: [email protected]
    Fixes: 1996970773a3 ("drm/lima: Add optional devfreq and cooling device support")
    Signed-off-by: Dragan Simic <[email protected]>
    Signed-off-by: Qiang Yu <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/fdaf2e41bb6a0c5118ff9cc21f4f62583208d885.1718655070.git.dsimic@manjaro.org
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/mgag200: Bind I2C lifetime to DRM device [+ + +]
Author: Thomas Zimmermann <[email protected]>
Date:   Mon May 13 14:51:07 2024 +0200

    drm/mgag200: Bind I2C lifetime to DRM device
    
    commit eb1ae34e48a09b7a1179c579aed042b032e408f4 upstream.
    
    Managed cleanup with devm_add_action_or_reset() will release the I2C
    adapter when the underlying Linux device goes away. But the connector
    still refers to it, so this cleanup leaves behind a stale pointer
    in struct drm_connector.ddc.
    
    Bind the lifetime of the I2C adapter to the connector's lifetime by
    using DRM's managed release. When the DRM device goes away (after
    the Linux device) DRM will first clean up the connector and then
    clean up the I2C adapter.
    
    Signed-off-by: Thomas Zimmermann <[email protected]>
    Reviewed-by: Jocelyn Falempe <[email protected]>
    Fixes: b279df242972 ("drm/mgag200: Switch I2C code to managed cleanup")
    Cc: Thomas Zimmermann <[email protected]>
    Cc: Jocelyn Falempe <[email protected]>
    Cc: Dave Airlie <[email protected]>
    Cc: [email protected]
    Cc: <[email protected]> # v6.0+
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

drm/mgag200: Set DDC timeout in milliseconds [+ + +]
Author: Thomas Zimmermann <[email protected]>
Date:   Mon May 13 14:51:06 2024 +0200

    drm/mgag200: Set DDC timeout in milliseconds
    
    commit ecde5db1598aecab54cc392282c15114f526f05f upstream.
    
    Compute the i2c timeout in jiffies from a value in milliseconds. The
    original values of 2 jiffies equals 2 milliseconds if HZ has been
    configured to a value of 1000. This corresponds to 2.2 milliseconds
    used by most other DRM drivers. Update mgag200 accordingly.
    
    Signed-off-by: Thomas Zimmermann <[email protected]>
    Reviewed-by: Jocelyn Falempe <[email protected]>
    Fixes: 414c45310625 ("mgag200: initial g200se driver (v2)")
    Cc: Dave Airlie <[email protected]>
    Cc: Maarten Lankhorst <[email protected]>
    Cc: Maxime Ripard <[email protected]>
    Cc: Thomas Zimmermann <[email protected]>
    Cc: Jocelyn Falempe <[email protected]>
    Cc: [email protected]
    Cc: <[email protected]> # v3.5+
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/radeon: Remove __counted_by from StateArray.states[] [+ + +]
Author: Bill Wendling <[email protected]>
Date:   Wed May 29 14:54:44 2024 -0700

    drm/radeon: Remove __counted_by from StateArray.states[]
    
    commit 2bac084468847cfe5bbc7166082b2a208514bb1c upstream.
    
    Work for __counted_by on generic pointers in structures (not just
    flexible array members) has started landing in Clang 19 (current tip of
    tree). During the development of this feature, a restriction was added
    to __counted_by to prevent the flexible array member's element type from
    including a flexible array member itself such as:
    
      struct foo {
        int count;
        char buf[];
      };
    
      struct bar {
        int count;
        struct foo data[] __counted_by(count);
      };
    
    because the size of data cannot be calculated with the standard array
    size formula:
    
      sizeof(struct foo) * count
    
    This restriction was downgraded to a warning but due to CONFIG_WERROR,
    it can still break the build. The application of __counted_by on the
    states member of 'struct _StateArray' triggers this restriction,
    resulting in:
    
      drivers/gpu/drm/radeon/pptable.h:442:5: error: 'counted_by' should not be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member. This will be an error in a future compiler version [-Werror,-Wbounds-safety-counted-by-elt-type-unknown-size]
        442 |     ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
            |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      1 error generated.
    
    Remove this use of __counted_by to fix the warning/error. However,
    rather than remove it altogether, leave it commented, as it may be
    possible to support this in future compiler releases.
    
    Cc: [email protected]
    Closes: https://github.com/ClangBuiltLinux/linux/issues/2028
    Fixes: efade6fe50e7 ("drm/radeon: silence UBSAN warning (v3)")
    Signed-off-by: Bill Wendling <[email protected]>
    Co-developed-by: Nathan Chancellor <[email protected]>
    Signed-off-by: Nathan Chancellor <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/test: fix the gem shmem test to map the sg table. [+ + +]
Author: Dave Airlie <[email protected]>
Date:   Mon Jul 15 18:35:51 2024 +1000

    drm/test: fix the gem shmem test to map the sg table.
    
    commit 62b45bab010d1b0cea6166f818f1cd0666a6d8d8 upstream.
    
    The test here creates an sg table, but never maps it, when
    we get to drm_gem_shmem_free, the helper tries to unmap and this
    causes warnings on some platforms and debug kernels.
    
    This also sets a 64-bit dma mask, as I see an swiotlb warning if I
    stick with the default 32-bit one.
    
    Fixes: 93032ae634d4 ("drm/test: add a test suite for GEM objects backed by shmem")
    Cc: [email protected]
    Signed-off-by: Dave Airlie <[email protected]>
    Reviewed-by: Michael J. Ruhl <[email protected]>
    Acked-by: Daniel Vetter <[email protected]>
    Reviewed-by: Marco Pagani <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Maxime Ripard <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
drm/xe/hwmon: Fix PL1 disable flow in xe_hwmon_power_max_write [+ + +]
Author: Karthik Poosa <[email protected]>
Date:   Thu Aug 1 16:54:24 2024 +0530

    drm/xe/hwmon: Fix PL1 disable flow in xe_hwmon_power_max_write
    
    [ Upstream commit ac3191c5cf47e2d5220a1ed7353a2e498a1f415e ]
    
    In xe_hwmon_power_max_write, for PL1 disable supported case, instead of
    returning after PL1 disable, PL1 enable path was also being run.
    Fixed it by returning after disable.
    
    v2: Correct typo and grammar in commit message. (Jonathan)
    
    Signed-off-by: Karthik Poosa <[email protected]>
    Fixes: fef6dd12b45a ("drm/xe/hwmon: Protect hwmon rw attributes with hwmon_lock")
    Reviewed-by: Jonathan Cavitt <[email protected]>
    Signed-off-by: Matt Roper <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit 146458645e505f5eac498759bcd865cf7c0dfd9a)
    Signed-off-by: Rodrigo Vivi <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/xe/preempt_fence: enlarge the fence critical section [+ + +]
Author: Matthew Auld <[email protected]>
Date:   Thu Apr 18 15:46:31 2024 +0100

    drm/xe/preempt_fence: enlarge the fence critical section
    
    [ Upstream commit 3cd1585e57908b6efcd967465ef7685f40b2a294 ]
    
    It is really easy to introduce subtle deadlocks in
    preempt_fence_work_func() since we operate on single global ordered-wq
    for signalling our preempt fences behind the scenes, so even though we
    signal a particular fence, everything in the callback should be in the
    fence critical section, since blocking in the callback will prevent
    other published fences from signalling. If we enlarge the fence critical
    section to cover the entire callback, then lockdep should be able to
    understand this better, and complain if we grab a sensitive lock like
    vm->lock, which is also held when waiting on preempt fences.
    
    Signed-off-by: Matthew Auld <[email protected]>
    Cc: Matthew Brost <[email protected]>
    Reviewed-by: Matthew Brost <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/xe/rtp: Fix off-by-one when processing rules [+ + +]
Author: Lucas De Marchi <[email protected]>
Date:   Thu Jul 25 23:43:35 2024 -0700

    drm/xe/rtp: Fix off-by-one when processing rules
    
    [ Upstream commit ae02c7b7fea3e034fbd724c21d88406f71ccc2f8 ]
    
    Gustavo noticed an odd "+ 2" in rtp_mark_active() while processing
    rtp rules and pointed that it should be "+ 1". In fact, while processing
    entries without actions (OOB workarounds), if the WA is activated and
    has OR rules, it will also inadvertently activate the very next
    workaround.
    
    Test in a LNL B0 platform by moving 18024947630 on top of 16020292621,
    makes the latter become active:
    
            $ cat /sys/kernel/debug/dri/0/gt0/workarounds
            ...
            OOB Workarounds
                    18024947630
                    16020292621
                    14018094691
                    16022287689
                    13011645652
                    22019338487_display
    
    In future a kunit test will be added to cover the rtp checks for entries
    without actions.
    
    Fixes: fe19328b900c ("drm/xe/rtp: Add support for entries with no action")
    Cc: Gustavo Sousa <[email protected]>
    Reviewed-by: Gustavo Sousa <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Lucas De Marchi <[email protected]>
    (cherry picked from commit fd6797ec50c561f085bc94e3ee26f484a52af79e)
    Signed-off-by: Rodrigo Vivi <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/xe/xe_guc_submit: Fix exec queue stop race condition [+ + +]
Author: Jonathan Cavitt <[email protected]>
Date:   Fri May 10 12:45:38 2024 -0700

    drm/xe/xe_guc_submit: Fix exec queue stop race condition
    
    [ Upstream commit 1564d411e17f51e2f64655b4e4da015be1ba7eaa ]
    
    Reorder the xe_sched_tdr_queue_imm and set_exec_queue_banned calls in
    guc_exec_queue_stop.  This prevents a possible race condition between
    the two events in which it's possible for xe_sched_tdr_queue_imm to
    wake the ufence waiter before the exec queue is banned, causing the
    ufence waiter to miss the banned state.
    
    Suggested-by: Matthew Brost <[email protected]>
    Signed-off-by: Jonathan Cavitt <[email protected]>
    Reviewed-by: Matthew Brost <[email protected]>
    Reviewed-by: Stuart Summers <[email protected]>
    Signed-off-by: Matthew Brost <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
drm/xe: Minor cleanup in LRC handling [+ + +]
Author: Niranjana Vishwanathapura <[email protected]>
Date:   Tue May 7 15:42:50 2024 -0700

    drm/xe: Minor cleanup in LRC handling
    
    [ Upstream commit 85cfc412579c041f1aaebba71427acec75ceca39 ]
    
    Properly define register fields and remove redundant
    lower_32_bits().
    
    Signed-off-by: Niranjana Vishwanathapura <[email protected]>
    Reviewed-by: Himal Prasad Ghimiray <[email protected]>
    Reviewed-by: Stuart Summers <[email protected]>
    Reviewed-by: Matt Roper <[email protected]>
    Signed-off-by: Matt Roper <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Stable-dep-of: 642dfc9d5964 ("drm/xe: Take ref to VM in delayed snapshot")
    Signed-off-by: Sasha Levin <[email protected]>

drm/xe: Take ref to VM in delayed snapshot [+ + +]
Author: Matthew Brost <[email protected]>
Date:   Thu Aug 1 08:41:16 2024 -0700

    drm/xe: Take ref to VM in delayed snapshot
    
    [ Upstream commit 642dfc9d5964b26f66fa6c28ce2861e11f9232aa ]
    
    Kernel BO's don't take a ref to the VM, we need the VM for the
    delayed snapshot, so take a ref to the VM in delayed snapshot.
    
    v2:
     - Check for lrc_bo before taking a VM ref (CI)
     - Check lrc_bo->vm before taking / dropping a VM ref (CI)
     - Drop VM in xe_lrc_snapshot_free
    v5:
     - Fix commit message wording (Johnathan)
    
    Fixes: 47058633d9c5 ("drm/xe: Move lrc snapshot capturing to xe_lrc.c")
    Cc: Maarten Lankhorst <[email protected]>
    Signed-off-by: Matthew Brost <[email protected]>
    Reviewed-by: Jonathan Cavitt <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit c3bc97d2f102ddd5a8341eeb2dbae2a3e98bb46a)
    Signed-off-by: Rodrigo Vivi <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

drm/xe: Use dma_fence_chain_free in chain fence unused as a sync [+ + +]
Author: Matthew Brost <[email protected]>
Date:   Fri Jul 26 18:22:16 2024 -0700

    drm/xe: Use dma_fence_chain_free in chain fence unused as a sync
    
    [ Upstream commit 4f854a8b1b85d46abd5ce206936d23f87ac5e0c9 ]
    
    A chain fence is uninitialized if not installed in a drm sync obj. Thus
    if xe_sync_entry_cleanup is called and sync->chain_fence is non-NULL the
    proper cleanup is dma_fence_chain_free rather than a dma-fence put.
    
    Reported-by: Paulo Zanoni <[email protected]>
    Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2411
    Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2261
    Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
    Signed-off-by: Matthew Brost <[email protected]>
    Reviewed-by: Matthew Auld <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    (cherry picked from commit 7f7a2da3bf8bc0e0f6c239af495b7050056e889c)
    Signed-off-by: Rodrigo Vivi <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
eventfs: Don't return NULL in eventfs_create_dir() [+ + +]
Author: Mathias Krause <[email protected]>
Date:   Tue Jul 23 14:25:21 2024 +0200

    eventfs: Don't return NULL in eventfs_create_dir()
    
    commit 12c20c65d0460cf34f9a665d8f0c0d77d45a3829 upstream.
    
    Commit 77a06c33a22d ("eventfs: Test for ei->is_freed when accessing
    ei->dentry") added another check, testing if the parent was freed after
    we released the mutex. If so, the function returns NULL. However, all
    callers expect it to either return a valid pointer or an error pointer,
    at least since commit 5264a2f4bb3b ("tracing: Fix a NULL vs IS_ERR() bug
    in event_subsystem_dir()"). Returning NULL will therefore fail the error
    condition check in the caller.
    
    Fix this by substituting the NULL return value with a fitting error
    pointer.
    
    Cc: Masami Hiramatsu <[email protected]>
    Cc: Mathieu Desnoyers <[email protected]>
    Cc: [email protected]
    Fixes: 77a06c33a22d ("eventfs: Test for ei->is_freed when accessing ei->dentry")
    Link: https://lore.kernel.org/[email protected]
    Reviewed-by: Dan Carpenter <[email protected]>
    Reviewed-by: Ajay Kaher <[email protected]>
    Signed-off-by: Mathias Krause <[email protected]>
    Signed-off-by: Steven Rostedt (Google) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

eventfs: Use SRCU for freeing eventfs_inodes [+ + +]
Author: Mathias Krause <[email protected]>
Date:   Tue Jul 23 23:07:53 2024 +0200

    eventfs: Use SRCU for freeing eventfs_inodes
    
    commit 8e556432477e97ad6179c61b61a32bf5f1af2355 upstream.
    
    To mirror the SRCU lock held in eventfs_iterate() when iterating over
    eventfs inodes, use call_srcu() to free them too.
    
    This was accidentally(?) degraded to RCU in commit 43aa6f97c2d0
    ("eventfs: Get rid of dentry pointers without refcounts").
    
    Cc: Ajay Kaher <[email protected]>
    Cc: Masami Hiramatsu <[email protected]>
    Cc: Mathieu Desnoyers <[email protected]>
    Cc: Linus Torvalds <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/[email protected]
    Fixes: 43aa6f97c2d0 ("eventfs: Get rid of dentry pointers without refcounts")
    Signed-off-by: Mathias Krause <[email protected]>
    Signed-off-by: Steven Rostedt (Google) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
ext4: fix uninitialized variable in ext4_inlinedir_to_tree [+ + +]
Author: Xiaxi Shen <[email protected]>
Date:   Tue Apr 30 20:30:17 2024 -0700

    ext4: fix uninitialized variable in ext4_inlinedir_to_tree
    
    [ Upstream commit 8dc9c3da79c84b13fdb135e2fb0a149a8175bffe ]
    
    Syzbot has found an uninit-value bug in ext4_inlinedir_to_tree
    
    This error happens because ext4_inlinedir_to_tree does not
    handle the case when ext4fs_dirhash returns an error
    
    This can be avoided by checking the return value of ext4fs_dirhash
    and propagating the error,
    similar to how it's done with ext4_htree_store_dirent
    
    Signed-off-by: Xiaxi Shen <[email protected]>
    Reported-and-tested-by: [email protected]
    Closes: https://syzkaller.appspot.com/bug?extid=eaba5abe296837a640c0
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Theodore Ts'o <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

ext4: sanity check for NULL pointer after ext4_force_shutdown [+ + +]
Author: Wojciech Gładysz <[email protected]>
Date:   Wed Jul 3 09:01:12 2024 +0200

    ext4: sanity check for NULL pointer after ext4_force_shutdown
    
    [ Upstream commit 83f4414b8f84249d538905825b088ff3ae555652 ]
    
    Test case: 2 threads write short inline data to a file.
    In ext4_page_mkwrite the resulting inline data is converted.
    Handling ext4_grp_locked_error with description "block bitmap
    and bg descriptor inconsistent: X vs Y free clusters" calls
    ext4_force_shutdown. The conversion clears
    EXT4_STATE_MAY_INLINE_DATA but fails for
    ext4_destroy_inline_data_nolock and ext4_mark_iloc_dirty due
    to ext4_forced_shutdown. The restoration of inline data fails
    for the same reason not setting EXT4_STATE_MAY_INLINE_DATA.
    Without the flag set a regular process path in ext4_da_write_end
    follows trying to dereference page folio private pointer that has
    not been set. The fix calls early return with -EIO error shall the
    pointer to private be NULL.
    
    Sample crash report:
    
    Unable to handle kernel paging request at virtual address dfff800000000004
    KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
    Mem abort info:
      ESR = 0x0000000096000005
      EC = 0x25: DABT (current EL), IL = 32 bits
      SET = 0, FnV = 0
      EA = 0, S1PTW = 0
      FSC = 0x05: level 1 translation fault
    Data abort info:
      ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
      CM = 0, WnR = 0, TnD = 0, TagAccess = 0
      GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
    [dfff800000000004] address between user and kernel address ranges
    Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP
    Modules linked in:
    CPU: 1 PID: 20274 Comm: syz-executor185 Not tainted 6.9.0-rc7-syzkaller-gfda5695d692c #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
    pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    pc : __block_commit_write+0x64/0x2b0 fs/buffer.c:2167
    lr : __block_commit_write+0x3c/0x2b0 fs/buffer.c:2160
    sp : ffff8000a1957600
    x29: ffff8000a1957610 x28: dfff800000000000 x27: ffff0000e30e34b0
    x26: 0000000000000000 x25: dfff800000000000 x24: dfff800000000000
    x23: fffffdffc397c9e0 x22: 0000000000000020 x21: 0000000000000020
    x20: 0000000000000040 x19: fffffdffc397c9c0 x18: 1fffe000367bd196
    x17: ffff80008eead000 x16: ffff80008ae89e3c x15: 00000000200000c0
    x14: 1fffe0001cbe4e04 x13: 0000000000000000 x12: 0000000000000000
    x11: 0000000000000001 x10: 0000000000ff0100 x9 : 0000000000000000
    x8 : 0000000000000004 x7 : 0000000000000000 x6 : 0000000000000000
    x5 : fffffdffc397c9c0 x4 : 0000000000000020 x3 : 0000000000000020
    x2 : 0000000000000040 x1 : 0000000000000020 x0 : fffffdffc397c9c0
    Call trace:
     __block_commit_write+0x64/0x2b0 fs/buffer.c:2167
     block_write_end+0xb4/0x104 fs/buffer.c:2253
     ext4_da_do_write_end fs/ext4/inode.c:2955 [inline]
     ext4_da_write_end+0x2c4/0xa40 fs/ext4/inode.c:3028
     generic_perform_write+0x394/0x588 mm/filemap.c:3985
     ext4_buffered_write_iter+0x2c0/0x4ec fs/ext4/file.c:299
     ext4_file_write_iter+0x188/0x1780
     call_write_iter include/linux/fs.h:2110 [inline]
     new_sync_write fs/read_write.c:497 [inline]
     vfs_write+0x968/0xc3c fs/read_write.c:590
     ksys_write+0x15c/0x26c fs/read_write.c:643
     __do_sys_write fs/read_write.c:655 [inline]
     __se_sys_write fs/read_write.c:652 [inline]
     __arm64_sys_write+0x7c/0x90 fs/read_write.c:652
     __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline]
     invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48
     el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:133
     do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:152
     el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712
     el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730
     el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598
    Code: 97f85911 f94002da 91008356 d343fec8 (38796908)
    ---[ end trace 0000000000000000 ]---
    ----------------
    Code disassembly (best guess):
       0:   97f85911        bl      0xffffffffffe16444
       4:   f94002da        ldr     x26, [x22]
       8:   91008356        add     x22, x26, #0x20
       c:   d343fec8        lsr     x8, x22, #3
    * 10:   38796908        ldrb    w8, [x8, x25] <-- trapping instruction
    
    Reported-by: [email protected]
    Closes: https://syzkaller.appspot.com/bug?extid=18df508cf00a0598d9a6
    Link: https://lore.kernel.org/all/[email protected]/T/
    Signed-off-by: Wojciech Gładysz <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Theodore Ts'o <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
genirq/irqdesc: Honor caller provided affinity in alloc_desc() [+ + +]
Author: Shay Drory <[email protected]>
Date:   Tue Aug 6 10:20:44 2024 +0300

    genirq/irqdesc: Honor caller provided affinity in alloc_desc()
    
    commit edbbaae42a56f9a2b39c52ef2504dfb3fb0a7858 upstream.
    
    Currently, whenever a caller is providing an affinity hint for an
    interrupt, the allocation code uses it to calculate the node and copies the
    cpumask into irq_desc::affinity.
    
    If the affinity for the interrupt is not marked 'managed' then the startup
    of the interrupt ignores irq_desc::affinity and uses the system default
    affinity mask.
    
    Prevent this by setting the IRQD_AFFINITY_SET flag for the interrupt in the
    allocator, which causes irq_setup_affinity() to use irq_desc::affinity on
    interrupt startup if the mask contains an online CPU.
    
    [ tglx: Massaged changelog ]
    
    Fixes: 45ddcecbfa94 ("genirq: Use affinity hint in irqdesc allocation")
    Signed-off-by: Shay Drory <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Cc: <[email protected]>
    Link: https://lore.kernel.org/all/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
gpio: prevent potential speculation leaks in gpio_device_get_desc() [+ + +]
Author: Hagar Hemdan <[email protected]>
Date:   Thu May 23 08:53:32 2024 +0000

    gpio: prevent potential speculation leaks in gpio_device_get_desc()
    
    [ Upstream commit d795848ecce24a75dfd46481aee066ae6fe39775 ]
    
    Userspace may trigger a speculative read of an address outside the gpio
    descriptor array.
    Users can do that by calling gpio_ioctl() with an offset out of range.
    Offset is copied from user and then used as an array index to get
    the gpio descriptor without sanitization in gpio_device_get_desc().
    
    This change ensures that the offset is sanitized by using
    array_index_nospec() to mitigate any possibility of speculative
    information leaks.
    
    This bug was discovered and resolved using Coverity Static Analysis
    Security Testing (SAST) by Synopsys, Inc.
    
    Signed-off-by: Hagar Hemdan <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Bartosz Golaszewski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
gve: Fix use of netif_carrier_ok() [+ + +]
Author: Praveen Kaligineedi <[email protected]>
Date:   Thu Aug 1 13:56:19 2024 -0700

    gve: Fix use of netif_carrier_ok()
    
    [ Upstream commit fba917b169bea5f8f2ee300e19d5f7a6341a5251 ]
    
    GVE driver wrongly relies on netif_carrier_ok() to check the
    interface administrative state when resources are being
    allocated/deallocated for queue(s). netif_carrier_ok() needs
    to be replaced with netif_running() for all such cases.
    
    Administrative state is the result of "ip link set dev <dev>
    up/down". It reflects whether the administrator wants to use
    the device for traffic and the corresponding resources have
    been allocated.
    
    Fixes: 5f08cd3d6423 ("gve: Alloc before freeing when adjusting queues")
    Signed-off-by: Praveen Kaligineedi <[email protected]>
    Reviewed-by: Shailend Chand <[email protected]>
    Reviewed-by: Willem de Bruijn <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
hwmon: corsair-psu: add USB id of HX1200i Series 2023 psu [+ + +]
Author: Wilken Gottwalt <[email protected]>
Date:   Fri May 24 04:38:11 2024 +0000

    hwmon: corsair-psu: add USB id of HX1200i Series 2023 psu
    
    [ Upstream commit b9c15c96ccb47ad860af2e075c5f3c90c4cd1730 ]
    
    Add the usb id of the HX1200i Series 2023. Update the documentation
    accordingly. Also fix the version comments, there are no Series 2022
    products. That are legacy or first version products going back many
    many years.
    
    Signed-off-by: Wilken Gottwalt <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Guenter Roeck <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
i2c: qcom-geni: Add missing clk_disable_unprepare in geni_i2c_runtime_resume [+ + +]
Author: Gaosheng Cui <[email protected]>
Date:   Sat Aug 3 14:10:41 2024 +0800

    i2c: qcom-geni: Add missing clk_disable_unprepare in geni_i2c_runtime_resume
    
    [ Upstream commit b93d16bee557302d4e588375ececd833cc048acc ]
    
    Add the missing clk_disable_unprepare() before return in
    geni_i2c_runtime_resume().
    
    Fixes: 14d02fbadb5d ("i2c: qcom-geni: add desc struct to prepare support for I2C Master Hub variant")
    Signed-off-by: Gaosheng Cui <[email protected]>
    Reviewed-by: Vladimir Zapolskiy <[email protected]>
    Signed-off-by: Andi Shyti <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

i2c: qcom-geni: Add missing geni_icc_disable in geni_i2c_runtime_resume [+ + +]
Author: Gaosheng Cui <[email protected]>
Date:   Tue Aug 6 20:53:31 2024 +0800

    i2c: qcom-geni: Add missing geni_icc_disable in geni_i2c_runtime_resume
    
    [ Upstream commit 9ba48db9f77ce0001dbb882476fa46e092feb695 ]
    
    Add the missing geni_icc_disable() before return in
    geni_i2c_runtime_resume().
    
    Fixes: bf225ed357c6 ("i2c: i2c-qcom-geni: Add interconnect support")
    Signed-off-by: Gaosheng Cui <[email protected]>
    Reviewed-by: Vladimir Zapolskiy <[email protected]>
    Signed-off-by: Andi Shyti <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

i2c: smbus: Improve handling of stuck alerts [+ + +]
Author: Guenter Roeck <[email protected]>
Date:   Mon Jan 10 09:28:56 2022 -0800

    i2c: smbus: Improve handling of stuck alerts
    
    [ Upstream commit 37c526f00bc1c4f847fc800085f8f009d2e11be6 ]
    
    The following messages were observed while testing alert functionality
    on systems with multiple I2C devices on a single bus if alert was active
    on more than one chip.
    
    smbus_alert 3-000c: SMBALERT# from dev 0x0c, flag 0
    smbus_alert 3-000c: no driver alert()!
    
    and:
    
    smbus_alert 3-000c: SMBALERT# from dev 0x28, flag 0
    
    Once it starts, this message repeats forever at high rate. There is no
    device at any of the reported addresses.
    
    Analysis shows that this is seen if multiple devices have the alert pin
    active. Apparently some devices do not support SMBus arbitration correctly.
    They keep sending address bits after detecting an address collision and
    handle the collision not at all or too late.
    Specifically, address 0x0c is seen with ADT7461A at address 0x4c and
    ADM1021 at address 0x18 if alert is active on both chips. Address 0x28 is
    seen with ADT7483 at address 0x2a and ADT7461 at address 0x4c if alert is
    active on both chips.
    
    Once the system is in bad state (alert is set by more than one chip),
    it often only recovers by power cycling.
    
    To reduce the impact of this problem, abort the endless loop in
    smbus_alert() if the same address is read more than once and not
    handled by a driver.
    
    Fixes: b5527a7766f0 ("i2c: Add SMBus alert support")
    Signed-off-by: Guenter Roeck <[email protected]>
    [wsa: it also fixed an interrupt storm in one of my experiments]
    Tested-by: Wolfram Sang <[email protected]>
    [wsa: rebased, moved a comment as well, improved the 'invalid' value]
    Signed-off-by: Wolfram Sang <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

i2c: smbus: Send alert notifications to all devices if source not found [+ + +]
Author: Guenter Roeck <[email protected]>
Date:   Tue Jul 30 07:19:41 2024 -0700

    i2c: smbus: Send alert notifications to all devices if source not found
    
    [ Upstream commit f6c29f710c1ff2590109f83be3e212b86c01e0f3 ]
    
    If a SMBus alert is received and the originating device is not found,
    the reason may be that the address reported on the SMBus alert address
    is corrupted, for example because multiple devices asserted alert and
    do not correctly implement SMBus arbitration.
    
    If this happens, call alert handlers on all devices connected to the
    given I2C bus, in the hope that this cleans up the situation.
    
    This change reliably fixed the problem on a system with multiple devices
    on a single bus. Example log where the device on address 0x18 (ADM1021)
    and on address 0x4c (ADT7461A) both had the alert line asserted:
    
    smbus_alert 3-000c: SMBALERT# from dev 0x0c, flag 0
    smbus_alert 3-000c: no driver alert()!
    smbus_alert 3-000c: SMBALERT# from dev 0x0c, flag 0
    smbus_alert 3-000c: no driver alert()!
    lm90 3-0018: temp1 out of range, please check!
    lm90 3-0018: Disabling ALERT#
    lm90 3-0029: Everything OK
    lm90 3-002a: Everything OK
    lm90 3-004c: temp1 out of range, please check!
    lm90 3-004c: temp2 out of range, please check!
    lm90 3-004c: Disabling ALERT#
    
    Fixes: b5527a7766f0 ("i2c: Add SMBus alert support")
    Signed-off-by: Guenter Roeck <[email protected]>
    [wsa: fixed a typo in the commit message]
    Signed-off-by: Wolfram Sang <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
ice: Fix reset handler [+ + +]
Author: Grzegorz Nitka <[email protected]>
Date:   Mon Jul 15 17:39:10 2024 +0200

    ice: Fix reset handler
    
    [ Upstream commit 25a7123579ecac9a89a7e5b8d8a580bee4b68acd ]
    
    Synchronize OICR IRQ when preparing for reset to avoid potential
    race conditions between the reset procedure and OICR
    
    Fixes: 4aad5335969f ("ice: add individual interrupt allocation")
    Signed-off-by: Grzegorz Nitka <[email protected]>
    Signed-off-by: Sergey Temerkhanov <[email protected]>
    Reviewed-by: Przemek Kitszel <[email protected]>
    Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel)
    Signed-off-by: Tony Nguyen <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
idpf: fix memleak in vport interrupt configuration [+ + +]
Author: Michal Kubiak <[email protected]>
Date:   Tue Aug 6 15:09:21 2024 -0700

    idpf: fix memleak in vport interrupt configuration
    
    commit 3cc88e8405b8d55e0ff035e31971aadd6baee2b6 upstream.
    
    The initialization of vport interrupt consists of two functions:
     1) idpf_vport_intr_init() where a generic configuration is done
     2) idpf_vport_intr_req_irq() where the irq for each q_vector is
       requested.
    
    The first function used to create a base name for each interrupt using
    "kasprintf()" call. Unfortunately, although that call allocated memory
    for a text buffer, that memory was never released.
    
    Fix this by removing creating the interrupt base name in 1).
    Instead, always create a full interrupt name in the function 2), because
    there is no need to create a base name separately, considering that the
    function 2) is never called out of idpf_vport_intr_init() context.
    
    Fixes: d4d558718266 ("idpf: initialize interrupts and enable vport")
    Cc: [email protected] # 6.7
    Signed-off-by: Michal Kubiak <[email protected]>
    Reviewed-by: Pavan Kumar Linga <[email protected]>
    Signed-off-by: Alexander Lobakin <[email protected]>
    Reviewed-by: Simon Horman <[email protected]>
    Tested-by: Krishneil Singh <[email protected]>
    Signed-off-by: Tony Nguyen <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

idpf: fix memory leaks and crashes while performing a soft reset [+ + +]
Author: Alexander Lobakin <[email protected]>
Date:   Tue Aug 6 15:09:20 2024 -0700

    idpf: fix memory leaks and crashes while performing a soft reset
    
    [ Upstream commit f01032a2ca099ec8d619aaa916c3762aa62495df ]
    
    The second tagged commit introduced a UAF, as it removed restoring
    q_vector->vport pointers after reinitializating the structures.
    This is due to that all queue allocation functions are performed here
    with the new temporary vport structure and those functions rewrite
    the backpointers to the vport. Then, this new struct is freed and
    the pointers start leading to nowhere.
    
    But generally speaking, the current logic is very fragile. It claims
    to be more reliable when the system is low on memory, but in fact, it
    consumes two times more memory as at the moment of running this
    function, there are two vports allocated with their queues and vectors.
    Moreover, it claims to prevent the driver from running into "bad state",
    but in fact, any error during the rebuild leaves the old vport in the
    partially allocated state.
    Finally, if the interface is down when the function is called, it always
    allocates a new queue set, but when the user decides to enable the
    interface later on, vport_open() allocates them once again, IOW there's
    a clear memory leak here.
    
    Just don't allocate a new queue set when performing a reset, that solves
    crashes and memory leaks. Readd the old queue number and reopen the
    interface on rollback - that solves limbo states when the device is left
    disabled and/or without HW queues enabled.
    
    Fixes: 02cbfba1add5 ("idpf: add ethtool callbacks")
    Fixes: e4891e4687c8 ("idpf: split &idpf_queue into 4 strictly-typed queue structures")
    Signed-off-by: Alexander Lobakin <[email protected]>
    Reviewed-by: Simon Horman <[email protected]>
    Tested-by: Krishneil Singh <[email protected]>
    Signed-off-by: Tony Nguyen <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

idpf: fix UAFs when destroying the queues [+ + +]
Author: Alexander Lobakin <[email protected]>
Date:   Tue Aug 6 15:09:22 2024 -0700

    idpf: fix UAFs when destroying the queues
    
    [ Upstream commit 290f1c033281c1a502a3cd1c53c3a549259c491f ]
    
    The second tagged commit started sometimes (very rarely, but possible)
    throwing WARNs from
    net/core/page_pool.c:page_pool_disable_direct_recycling().
    Turned out idpf frees interrupt vectors with embedded NAPIs *before*
    freeing the queues making page_pools' NAPI pointers lead to freed
    memory before these pools are destroyed by libeth.
    It's not clear whether there are other accesses to the freed vectors
    when destroying the queues, but anyway, we usually free queue/interrupt
    vectors only when the queues are destroyed and the NAPIs are guaranteed
    to not be referenced anywhere.
    
    Invert the allocation and freeing logic making queue/interrupt vectors
    be allocated first and freed last. Vectors don't require queues to be
    present, so this is safe. Additionally, this change allows to remove
    that useless queue->q_vector pointer cleanup, as vectors are still
    valid when freeing the queues (+ both are freed within one function,
    so it's not clear why nullify the pointers at all).
    
    Fixes: 1c325aac10a8 ("idpf: configure resources for TX queues")
    Fixes: 90912f9f4f2d ("idpf: convert header split mode to libeth + napi_build_skb()")
    Reported-by: Michal Kubiak <[email protected]>
    Signed-off-by: Alexander Lobakin <[email protected]>
    Reviewed-by: Simon Horman <[email protected]>
    Tested-by: Krishneil Singh <[email protected]>
    Signed-off-by: Tony Nguyen <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
io_uring/net: don't pick multiple buffers for non-bundle send [+ + +]
Author: Jens Axboe <[email protected]>
Date:   Wed Aug 7 15:09:33 2024 -0600

    io_uring/net: don't pick multiple buffers for non-bundle send
    
    commit 8fe8ac24adcd76b12edbfdefa078567bfff117d4 upstream.
    
    If a send is issued marked with IOSQE_BUFFER_SELECT for selecting a
    buffer, unless it's a bundle, it should not select multiple buffers.
    
    Cc: [email protected]
    Fixes: a05d1f625c7a ("io_uring/net: support bundles for send")
    Signed-off-by: Jens Axboe <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

io_uring/net: ensure expanded bundle recv gets marked for cleanup [+ + +]
Author: Jens Axboe <[email protected]>
Date:   Wed Aug 7 15:06:45 2024 -0600

    io_uring/net: ensure expanded bundle recv gets marked for cleanup
    
    commit 11893e144ed75be55d99349760513ca104781fc0 upstream.
    
    If the iovec inside the kmsg isn't already allocated AND one gets
    expanded beyond the fixed size, then the request may not already have
    been marked for cleanup. Ensure that it is.
    
    Cc: [email protected]
    Fixes: 2f9c9515bdfd ("io_uring/net: support bundles for recv")
    Signed-off-by: Jens Axboe <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

io_uring/net: ensure expanded bundle send gets marked for cleanup [+ + +]
Author: Jens Axboe <[email protected]>
Date:   Wed Aug 7 15:08:17 2024 -0600

    io_uring/net: ensure expanded bundle send gets marked for cleanup
    
    commit 70ed519ed59da3a92c3acedeb84a30e5a66051ce upstream.
    
    If the iovec inside the kmsg isn't already allocated AND one gets
    expanded beyond the fixed size, then the request may not already have
    been marked for cleanup. Ensure that it is.
    
    Cc: [email protected]
    Fixes: a05d1f625c7a ("io_uring/net: support bundles for send")
    Signed-off-by: Jens Axboe <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq() [+ + +]
Author: Huacai Chen <[email protected]>
Date:   Tue Jul 23 14:45:08 2024 +0800

    irqchip/loongarch-cpu: Fix return value of lpic_gsi_to_irq()
    
    commit 81a91abab1307d7725fa4620952c0767beae7753 upstream.
    
    lpic_gsi_to_irq() should return a valid Linux interrupt number if
    acpi_register_gsi() succeeds, and return 0 otherwise. But lpic_gsi_to_irq()
    converts a negative return value of acpi_register_gsi() to a positive value
    silently.
    
    Convert the return value explicitly.
    
    Fixes: e8bba72b396c ("irqchip / ACPI: Introduce ACPI_IRQ_MODEL_LPIC for LoongArch")
    Reported-by: Miao Wang <[email protected]>
    Signed-off-by: Huacai Chen <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Reviewed-by: Jiaxun Yang <[email protected]>
    Cc: <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
irqchip/mbigen: Fix mbigen node address layout [+ + +]
Author: Yipeng Zou <[email protected]>
Date:   Tue Jul 30 09:44:00 2024 +0800

    irqchip/mbigen: Fix mbigen node address layout
    
    [ Upstream commit 6be6cba9c4371d27f78d900ccfe34bb880d9ee20 ]
    
    The mbigen interrupt chip has its per node registers located in a
    contiguous region of page sized chunks. The code maps them into virtual
    address space as a contiguous region and determines the address of a node
    by using the node ID as index.
    
                        mbigen chip
           |-----------------|------------|--------------|
       mgn_node_0         mgn_node_1     ...         mgn_node_i
    |--------------|   |--------------|       |----------------------|
    [0x0000, 0x0x0FFF] [0x1000, 0x1FFF]    [i*0x1000, (i+1)*0x1000 - 1]
    
    This works correctly up to 10 nodes, but then fails because the 11th's
    array slot is used for the MGN_CLEAR registers.
    
                             mbigen chip
        |-----------|--------|--------|---------------|--------|
    mgn_node_0  mgn_node_1  ...  mgn_clear_register  ...   mgn_node_i
                                |-----------------|
                                 [0xA000, 0xAFFF]
    
    Skip the MGN_CLEAR register space when calculating the offset for node IDs
    greater than or equal to ten.
    
    Fixes: a6c2f87b8820 ("irqchip/mbigen: Implement the mbigen irq chip operation functions")
    Signed-off-by: Yipeng Zou <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Link: https://lore.kernel.org/all/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
irqchip/meson-gpio: Convert meson_gpio_irq_controller::lock to 'raw_spinlock_t' [+ + +]
Author: Arseniy Krasnov <[email protected]>
Date:   Mon Jul 29 16:18:50 2024 +0300

    irqchip/meson-gpio: Convert meson_gpio_irq_controller::lock to 'raw_spinlock_t'
    
    commit f872d4af79fe8c71ae291ce8875b477e1669a6c7 upstream.
    
    This lock is acquired under irq_desc::lock with interrupts disabled.
    
    When PREEMPT_RT is enabled, 'spinlock_t' becomes preemptible, which results
    in invalid lock acquire context;
    
      [ BUG: Invalid wait context ]
      swapper/0/1 is trying to lock:
      ffff0000008fed30 (&ctl->lock){....}-{3:3}, at: meson_gpio_irq_update_bits0
      other info that might help us debug this:
      context-{5:5}
      3 locks held by swapper/0/1:
       #0: ffff0000003cd0f8 (&dev->mutex){....}-{4:4}, at: __driver_attach+0x90c
       #1: ffff000004714650 (&desc->request_mutex){+.+.}-{4:4}, at: __setup_irq0
       #2: ffff0000047144c8 (&irq_desc_lock_class){-.-.}-{2:2}, at: __setup_irq0
      stack backtrace:
      CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.9.9-sdkernel #1
      Call trace:
       _raw_spin_lock_irqsave+0x60/0x88
       meson_gpio_irq_update_bits+0x34/0x70
       meson8_gpio_irq_set_type+0x78/0xc4
       meson_gpio_irq_set_type+0x30/0x60
       __irq_set_trigger+0x60/0x180
       __setup_irq+0x30c/0x6e0
       request_threaded_irq+0xec/0x1a4
    
    Fixes: 215f4cc0fb20 ("irqchip/meson: Add support for gpio interrupt controller")
    Signed-off-by: Arseniy Krasnov <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
irqchip/riscv-aplic: Retrigger MSI interrupt on source configuration [+ + +]
Author: Yong-Xuan Wang <[email protected]>
Date:   Fri Aug 9 15:10:47 2024 +0800

    irqchip/riscv-aplic: Retrigger MSI interrupt on source configuration
    
    commit 03f9885c60adf73488fe32aab628ee3d4a39598e upstream.
    
    The section 4.5.2 of the RISC-V AIA specification says that "any write
    to a sourcecfg register of an APLIC might (or might not) cause the
    corresponding interrupt-pending bit to be set to one if the rectified
    input value is high (= 1) under the new source mode."
    
    When the interrupt type is changed in the sourcecfg register, the APLIC
    device might not set the corresponding pending bit, so the interrupt might
    never become pending.
    
    To handle sourcecfg register changes for level-triggered interrupts in MSI
    mode, manually set the pending bit for retriggering interrupt so it gets
    retriggered if it was already asserted.
    
    Fixes: ca8df97fe679 ("irqchip/riscv-aplic: Add support for MSI-mode")
    Signed-off-by: Yong-Xuan Wang <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Reviewed-by: Vincent Chen <[email protected]>
    Reviewed-by: Anup Patel <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
irqchip/xilinx: Fix shift out of bounds [+ + +]
Author: Radhey Shyam Pandey <[email protected]>
Date:   Fri Aug 9 12:32:24 2024 +0530

    irqchip/xilinx: Fix shift out of bounds
    
    commit d73f0f49daa84176c3beee1606e73c7ffb6af8b2 upstream.
    
    The device tree property 'xlnx,kind-of-intr' is sanity checked that the
    bitmask contains only set bits which are in the range of the number of
    interrupts supported by the controller.
    
    The check is done by shifting the mask right by the number of supported
    interrupts and checking the result for zero.
    
    The data type of the mask is u32 and the number of supported interrupts is
    up to 32. In case of 32 interrupts the shift is out of bounds, resulting in
    a mismatch warning. The out of bounds condition is also reported by UBSAN:
    
      UBSAN: shift-out-of-bounds in irq-xilinx-intc.c:332:22
      shift exponent 32 is too large for 32-bit type 'unsigned int'
    
    Fix it by promoting the mask to u64 for the test.
    
    Fixes: d50466c90724 ("microblaze: intc: Refactor DT sanity check")
    Signed-off-by: Radhey Shyam Pandey <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
jbd2: avoid memleak in jbd2_journal_write_metadata_buffer [+ + +]
Author: Kemeng Shi <[email protected]>
Date:   Tue May 14 19:24:30 2024 +0800

    jbd2: avoid memleak in jbd2_journal_write_metadata_buffer
    
    [ Upstream commit cc102aa24638b90e04364d64e4f58a1fa91a1976 ]
    
    The new_bh is from alloc_buffer_head, we should call free_buffer_head to
    free it in error case.
    
    Signed-off-by: Kemeng Shi <[email protected]>
    Reviewed-by: Zhang Yi <[email protected]>
    Reviewed-by: Jan Kara <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Theodore Ts'o <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
jump_label: Fix the fix, brown paper bags galore [+ + +]
Author: Peter Zijlstra <[email protected]>
Date:   Wed Jul 31 12:43:21 2024 +0200

    jump_label: Fix the fix, brown paper bags galore
    
    [ Upstream commit 224fa3552029a3d14bec7acf72ded8171d551b88 ]
    
    Per the example of:
    
      !atomic_cmpxchg(&key->enabled, 0, 1)
    
    the inverse was written as:
    
      atomic_cmpxchg(&key->enabled, 1, 0)
    
    except of course, that while !old is only true for old == 0, old is
    true for everything except old == 0.
    
    Fix it to read:
    
      atomic_cmpxchg(&key->enabled, 1, 0) == 1
    
    such that only the 1->0 transition returns true and goes on to disable
    the keys.
    
    Fixes: 83ab38ef0a0b ("jump_label: Fix concurrency issues in static_key_slow_dec()")
    Reported-by: Darrick J. Wong <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Tested-by: Darrick J. Wong <[email protected]>
    Link: https://lkml.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
kcov: properly check for softirq context [+ + +]
Author: Andrey Konovalov <[email protected]>
Date:   Mon Jul 29 04:21:58 2024 +0200

    kcov: properly check for softirq context
    
    commit 7d4df2dad312f270d62fecb0e5c8b086c6d7dcfc upstream.
    
    When collecting coverage from softirqs, KCOV uses in_serving_softirq() to
    check whether the code is running in the softirq context.  Unfortunately,
    in_serving_softirq() is > 0 even when the code is running in the hardirq
    or NMI context for hardirqs and NMIs that happened during a softirq.
    
    As a result, if a softirq handler contains a remote coverage collection
    section and a hardirq with another remote coverage collection section
    happens during handling the softirq, KCOV incorrectly detects a nested
    softirq coverate collection section and prints a WARNING, as reported by
    syzbot.
    
    This issue was exposed by commit a7f3813e589f ("usb: gadget: dummy_hcd:
    Switch to hrtimer transfer scheduler"), which switched dummy_hcd to using
    hrtimer and made the timer's callback be executed in the hardirq context.
    
    Change the related checks in KCOV to account for this behavior of
    in_serving_softirq() and make KCOV ignore remote coverage collection
    sections in the hardirq and NMI contexts.
    
    This prevents the WARNING printed by syzbot but does not fix the inability
    of KCOV to collect coverage from the __usb_hcd_giveback_urb when dummy_hcd
    is in use (caused by a7f3813e589f); a separate patch is required for that.
    
    Link: https://lkml.kernel.org/r/[email protected]
    Fixes: 5ff3b30ab57d ("kcov: collect coverage from interrupts")
    Signed-off-by: Andrey Konovalov <[email protected]>
    Reported-by: [email protected]
    Closes: https://syzkaller.appspot.com/bug?extid=2388cdaeb6b10f0c13ac
    Acked-by: Marco Elver <[email protected]>
    Cc: Alan Stern <[email protected]>
    Cc: Aleksandr Nogikh <[email protected]>
    Cc: Alexander Potapenko <[email protected]>
    Cc: Dmitry Vyukov <[email protected]>
    Cc: Greg Kroah-Hartman <[email protected]>
    Cc: Marcello Sylvester Bauer <[email protected]>
    Cc: <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
kprobes: Fix to check symbol prefixes correctly [+ + +]
Author: Masami Hiramatsu (Google) <[email protected]>
Date:   Fri Aug 2 22:53:15 2024 +0900

    kprobes: Fix to check symbol prefixes correctly
    
    [ Upstream commit 8c8acb8f26cbde665b233dd1b9bbcbb9b86822dc ]
    
    Since str_has_prefix() takes the prefix as the 2nd argument and the string
    as the first, is_cfi_preamble_symbol() always fails to check the prefix.
    Fix the function parameter order so that it correctly check the prefix.
    
    Link: https://lore.kernel.org/all/172260679559.362040.7360872132937227206.stgit@devnote2/
    
    Fixes: de02f2ac5d8c ("kprobes: Prohibit probing on CFI preamble symbol")
    Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
l2tp: fix lockdep splat [+ + +]
Author: James Chapman <[email protected]>
Date:   Tue Aug 6 17:06:26 2024 +0100

    l2tp: fix lockdep splat
    
    [ Upstream commit 86a41ea9fd79ddb6145cb8ebf5aeafceabca6f7d ]
    
    When l2tp tunnels use a socket provided by userspace, we can hit
    lockdep splats like the below when data is transmitted through another
    (unrelated) userspace socket which then gets routed over l2tp.
    
    This issue was previously discussed here:
    https://lore.kernel.org/netdev/[email protected]/
    
    The solution is to have lockdep treat socket locks of l2tp tunnel
    sockets separately than those of standard INET sockets. To do so, use
    a different lockdep subclass where lock nesting is possible.
    
      ============================================
      WARNING: possible recursive locking detected
      6.10.0+ #34 Not tainted
      --------------------------------------------
      iperf3/771 is trying to acquire lock:
      ffff8881027601d8 (slock-AF_INET/1){+.-.}-{2:2}, at: l2tp_xmit_skb+0x243/0x9d0
    
      but task is already holding lock:
      ffff888102650d98 (slock-AF_INET/1){+.-.}-{2:2}, at: tcp_v4_rcv+0x1848/0x1e10
    
      other info that might help us debug this:
       Possible unsafe locking scenario:
    
             CPU0
             ----
        lock(slock-AF_INET/1);
        lock(slock-AF_INET/1);
    
       *** DEADLOCK ***
    
       May be due to missing lock nesting notation
    
      10 locks held by iperf3/771:
       #0: ffff888102650258 (sk_lock-AF_INET){+.+.}-{0:0}, at: tcp_sendmsg+0x1a/0x40
       #1: ffffffff822ac220 (rcu_read_lock){....}-{1:2}, at: __ip_queue_xmit+0x4b/0xbc0
       #2: ffffffff822ac220 (rcu_read_lock){....}-{1:2}, at: ip_finish_output2+0x17a/0x1130
       #3: ffffffff822ac220 (rcu_read_lock){....}-{1:2}, at: process_backlog+0x28b/0x9f0
       #4: ffffffff822ac220 (rcu_read_lock){....}-{1:2}, at: ip_local_deliver_finish+0xf9/0x260
       #5: ffff888102650d98 (slock-AF_INET/1){+.-.}-{2:2}, at: tcp_v4_rcv+0x1848/0x1e10
       #6: ffffffff822ac220 (rcu_read_lock){....}-{1:2}, at: __ip_queue_xmit+0x4b/0xbc0
       #7: ffffffff822ac220 (rcu_read_lock){....}-{1:2}, at: ip_finish_output2+0x17a/0x1130
       #8: ffffffff822ac1e0 (rcu_read_lock_bh){....}-{1:2}, at: __dev_queue_xmit+0xcc/0x1450
       #9: ffff888101f33258 (dev->qdisc_tx_busylock ?: &qdisc_tx_busylock#2){+...}-{2:2}, at: __dev_queue_xmit+0x513/0x1450
    
      stack backtrace:
      CPU: 2 UID: 0 PID: 771 Comm: iperf3 Not tainted 6.10.0+ #34
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
      Call Trace:
       <IRQ>
       dump_stack_lvl+0x69/0xa0
       dump_stack+0xc/0x20
       __lock_acquire+0x135d/0x2600
       ? srso_alias_return_thunk+0x5/0xfbef5
       lock_acquire+0xc4/0x2a0
       ? l2tp_xmit_skb+0x243/0x9d0
       ? __skb_checksum+0xa3/0x540
       _raw_spin_lock_nested+0x35/0x50
       ? l2tp_xmit_skb+0x243/0x9d0
       l2tp_xmit_skb+0x243/0x9d0
       l2tp_eth_dev_xmit+0x3c/0xc0
       dev_hard_start_xmit+0x11e/0x420
       sch_direct_xmit+0xc3/0x640
       __dev_queue_xmit+0x61c/0x1450
       ? ip_finish_output2+0xf4c/0x1130
       ip_finish_output2+0x6b6/0x1130
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? __ip_finish_output+0x217/0x380
       ? srso_alias_return_thunk+0x5/0xfbef5
       __ip_finish_output+0x217/0x380
       ip_output+0x99/0x120
       __ip_queue_xmit+0xae4/0xbc0
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? tcp_options_write.constprop.0+0xcb/0x3e0
       ip_queue_xmit+0x34/0x40
       __tcp_transmit_skb+0x1625/0x1890
       __tcp_send_ack+0x1b8/0x340
       tcp_send_ack+0x23/0x30
       __tcp_ack_snd_check+0xa8/0x530
       ? srso_alias_return_thunk+0x5/0xfbef5
       tcp_rcv_established+0x412/0xd70
       tcp_v4_do_rcv+0x299/0x420
       tcp_v4_rcv+0x1991/0x1e10
       ip_protocol_deliver_rcu+0x50/0x220
       ip_local_deliver_finish+0x158/0x260
       ip_local_deliver+0xc8/0xe0
       ip_rcv+0xe5/0x1d0
       ? __pfx_ip_rcv+0x10/0x10
       __netif_receive_skb_one_core+0xce/0xe0
       ? process_backlog+0x28b/0x9f0
       __netif_receive_skb+0x34/0xd0
       ? process_backlog+0x28b/0x9f0
       process_backlog+0x2cb/0x9f0
       __napi_poll.constprop.0+0x61/0x280
       net_rx_action+0x332/0x670
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? find_held_lock+0x2b/0x80
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? srso_alias_return_thunk+0x5/0xfbef5
       handle_softirqs+0xda/0x480
       ? __dev_queue_xmit+0xa2c/0x1450
       do_softirq+0xa1/0xd0
       </IRQ>
       <TASK>
       __local_bh_enable_ip+0xc8/0xe0
       ? __dev_queue_xmit+0xa2c/0x1450
       __dev_queue_xmit+0xa48/0x1450
       ? ip_finish_output2+0xf4c/0x1130
       ip_finish_output2+0x6b6/0x1130
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? __ip_finish_output+0x217/0x380
       ? srso_alias_return_thunk+0x5/0xfbef5
       __ip_finish_output+0x217/0x380
       ip_output+0x99/0x120
       __ip_queue_xmit+0xae4/0xbc0
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? tcp_options_write.constprop.0+0xcb/0x3e0
       ip_queue_xmit+0x34/0x40
       __tcp_transmit_skb+0x1625/0x1890
       tcp_write_xmit+0x766/0x2fb0
       ? __entry_text_end+0x102ba9/0x102bad
       ? srso_alias_return_thunk+0x5/0xfbef5
       ? __might_fault+0x74/0xc0
       ? srso_alias_return_thunk+0x5/0xfbef5
       __tcp_push_pending_frames+0x56/0x190
       tcp_push+0x117/0x310
       tcp_sendmsg_locked+0x14c1/0x1740
       tcp_sendmsg+0x28/0x40
       inet_sendmsg+0x5d/0x90
       sock_write_iter+0x242/0x2b0
       vfs_write+0x68d/0x800
       ? __pfx_sock_write_iter+0x10/0x10
       ksys_write+0xc8/0xf0
       __x64_sys_write+0x3d/0x50
       x64_sys_call+0xfaf/0x1f50
       do_syscall_64+0x6d/0x140
       entry_SYSCALL_64_after_hwframe+0x76/0x7e
      RIP: 0033:0x7f4d143af992
      Code: c3 8b 07 85 c0 75 24 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> e9 01 cc ff ff 41 54 b8 02 00 00 0
      RSP: 002b:00007ffd65032058 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f4d143af992
      RDX: 0000000000000025 RSI: 00007f4d143f3bcc RDI: 0000000000000005
      RBP: 00007f4d143f2b28 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00007f4d143f3bcc
      R13: 0000000000000005 R14: 0000000000000000 R15: 00007ffd650323f0
       </TASK>
    
    Fixes: 0b2c59720e65 ("l2tp: close all race conditions in l2tp_tunnel_register()")
    Suggested-by: Eric Dumazet <[email protected]>
    Reported-by: [email protected]
    Closes: https://syzkaller.appspot.com/bug?extid=6acef9e0a4d1f46c83d4
    CC: [email protected]
    CC: [email protected]
    Signed-off-by: James Chapman <[email protected]>
    Signed-off-by: Tom Parkin <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
Linux: Linux 6.10.5 [+ + +]
Author: Greg Kroah-Hartman <[email protected]>
Date:   Wed Aug 14 15:34:38 2024 +0200

    Linux 6.10.5
    
    Link: https://lore.kernel.org/r/[email protected]
    Tested-by: Ronald Warsow <[email protected]>
    Tested-by: Salvatore Bonaccorso <[email protected]>
    Tested-by: Pavel Machek (CIP) <[email protected]>
    Tested-by: Linux Kernel Functional Testing <[email protected]>
    Tested-by: Peter Schneider <[email protected]>
    Tested-by: Mark Brown <[email protected]>
    Tested-by: Markus Reichelt <[email protected]>
    Tested-by: Florian Fainelli <[email protected]>
    Tested-by: Jon Hunter <[email protected]>
    Tested-by: Ron Economos <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
locking/pvqspinlock: Correct the type of "old" variable in pv_kick_node() [+ + +]
Author: Uros Bizjak <[email protected]>
Date:   Sun Jul 21 18:45:41 2024 +0200

    locking/pvqspinlock: Correct the type of "old" variable in pv_kick_node()
    
    [ Upstream commit 6623b0217d0c9bed80bfa43b778ce1c0eb03b497 ]
    
    "enum vcpu_state" is not compatible with "u8" type for all targets,
    resulting in:
    
    error: initialization of 'u8 *' {aka 'unsigned char *'} from incompatible pointer type 'enum vcpu_state *'
    
    for LoongArch. Correct the type of "old" variable to "u8".
    
    Fixes: fea0e1820b51 ("locking/pvqspinlock: Use try_cmpxchg() in qspinlock_paravirt.h")
    Closes: https://lore.kernel.org/lkml/[email protected]/
    Reported-by: Bibo Mao <[email protected]>
    Signed-off-by: Uros Bizjak <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Acked-by: Waiman Long <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
LoongArch: Enable general EFI poweroff method [+ + +]
Author: Miao Wang <[email protected]>
Date:   Wed Aug 7 17:37:11 2024 +0800

    LoongArch: Enable general EFI poweroff method
    
    commit e688c220732e518c2eb1639e9ef77d4a9311713c upstream.
    
    efi_shutdown_init() can register a general sys_off handler named
    efi_power_off(). Enable this by providing efi_poweroff_required(),
    like arm and x86. Since EFI poweroff is also supported on LoongArch,
    and the enablement makes the poweroff function usable for hardwares
    which lack ACPI S5.
    
    We prefer ACPI poweroff rather than EFI poweroff (like x86), so we only
    require EFI poweroff if acpi_gbl_reduced_hardware or acpi_no_s5 is true.
    
    Cc: [email protected]
    Acked-by: Ard Biesheuvel <[email protected]>
    Signed-off-by: Miao Wang <[email protected]>
    Signed-off-by: Huacai Chen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
md/raid5: avoid BUG_ON() while continue reshape after reassembling [+ + +]
Author: Yu Kuai <[email protected]>
Date:   Tue Jun 11 21:22:51 2024 +0800

    md/raid5: avoid BUG_ON() while continue reshape after reassembling
    
    [ Upstream commit 305a5170dc5cf3d395bb4c4e9239bca6d0b54b49 ]
    
    Currently, mdadm support --revert-reshape to abort the reshape while
    reassembling, as the test 07revert-grow. However, following BUG_ON()
    can be triggerred by the test:
    
    kernel BUG at drivers/md/raid5.c:6278!
    invalid opcode: 0000 [#1] PREEMPT SMP PTI
    irq event stamp: 158985
    CPU: 6 PID: 891 Comm: md0_reshape Not tainted 6.9.0-03335-g7592a0b0049a #94
    RIP: 0010:reshape_request+0x3f1/0xe60
    Call Trace:
     <TASK>
     raid5_sync_request+0x43d/0x550
     md_do_sync+0xb7a/0x2110
     md_thread+0x294/0x2b0
     kthread+0x147/0x1c0
     ret_from_fork+0x59/0x70
     ret_from_fork_asm+0x1a/0x30
     </TASK>
    
    Root cause is that --revert-reshape update the raid_disks from 5 to 4,
    while reshape position is still set, and after reassembling the array,
    reshape position will be read from super block, then during reshape the
    checking of 'writepos' that is caculated by old reshape position will
    fail.
    
    Fix this panic the easy way first, by converting the BUG_ON() to
    WARN_ON(), and stop the reshape if checkings fail.
    
    Noted that mdadm must fix --revert-shape as well, and probably md/raid
    should enhance metadata validation as well, however this means
    reassemble will fail and there must be user tools to fix the wrong
    metadata.
    
    Signed-off-by: Yu Kuai <[email protected]>
    Signed-off-by: Song Liu <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
md: change the return value type of md_write_start to void [+ + +]
Author: Li Nan <[email protected]>
Date:   Sun May 26 02:52:56 2024 +0800

    md: change the return value type of md_write_start to void
    
    [ Upstream commit 03e792eaf18ec2e93e2c623f9f1a4bdb97fe4126 ]
    
    Commit cc27b0c78c79 ("md: fix deadlock between mddev_suspend() and
    md_write_start()") aborted md_write_start() with false when mddev is
    suspended, which fixed a deadlock if calling mddev_suspend() with
    holding reconfig_mutex(). Since mddev_suspend() now includes
    lockdep_assert_not_held(), it no longer holds the reconfig_mutex. This
    makes previous abort unnecessary. Now, remove unnecessary abort and
    change function return value to void.
    
    Signed-off-by: Li Nan <[email protected]>
    Reviewed-by: Yu Kuai <[email protected]>
    Signed-off-by: Song Liu <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

md: do not delete safemode_timer in mddev_suspend [+ + +]
Author: Li Nan <[email protected]>
Date:   Wed May 8 17:20:53 2024 +0800

    md: do not delete safemode_timer in mddev_suspend
    
    [ Upstream commit a8768a134518e406d41799a3594aeb74e0889cf7 ]
    
    The deletion of safemode_timer in mddev_suspend() is redundant and
    potentially harmful now. If timer is about to be woken up but gets
    deleted, 'in_sync' will remain 0 until the next write, causing array
    to stay in the 'active' state instead of transitioning to 'clean'.
    
    Commit 0d9f4f135eb6 ("MD: Add del_timer_sync to mddev_suspend (fix
    nasty panic))" introduced this deletion for dm, because if timer fired
    after dm is destroyed, the resource which the timer depends on might
    have been freed.
    
    However, commit 0dd84b319352 ("md: call __md_stop_writes in md_stop")
    added __md_stop_writes() to md_stop(), which is called before freeing
    resource. Timer is deleted in __md_stop_writes(), and the origin issue
    is resolved. Therefore, delete safemode_timer can be removed safely now.
    
    Signed-off-by: Li Nan <[email protected]>
    Reviewed-by: Yu Kuai <[email protected]>
    Signed-off-by: Song Liu <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
media: amphion: Remove lock in s_ctrl callback [+ + +]
Author: Ming Qian <[email protected]>
Date:   Mon May 6 17:49:17 2024 +0900

    media: amphion: Remove lock in s_ctrl callback
    
    [ Upstream commit 065927b51eb1f042c3e026cebfd55e72ccc26093 ]
    
    There is no need to add a lock in s_ctrl callback, it has been
    synchronized by the ctrl_handler's lock, otherwise it may led to
    a deadlock if the driver calls v4l2_ctrl_s_ctrl().
    
    Signed-off-by: Ming Qian <[email protected]>
    Signed-off-by: Sebastian Fricke <[email protected]>
    Signed-off-by: Hans Verkuil <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

media: i2c: ov5647: replacing of_node_put with __free(device_node) [+ + +]
Author: Abdulrasaq Lawani <[email protected]>
Date:   Wed Jun 12 06:51:58 2024 -0400

    media: i2c: ov5647: replacing of_node_put with __free(device_node)
    
    [ Upstream commit 971b4eef86ccb8b107ad2875993e510eec4fdeae ]
    
    Replace instance of of_node_put with __free(device_node)
    to protect against any memory leaks due to future changes
    in control flow.
    
    Signed-off-by: Abdulrasaq Lawani <[email protected]>
    Acked-by: Dave Stevenson <[email protected]>
    Signed-off-by: Sakari Ailus <[email protected]>
    Signed-off-by: Hans Verkuil <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

media: intel/ipu6: select AUXILIARY_BUS in Kconfig [+ + +]
Author: Bingbu Cao <[email protected]>
Date:   Wed Jul 17 15:40:50 2024 +0800

    media: intel/ipu6: select AUXILIARY_BUS in Kconfig
    
    commit 423a77ae3a3f916809ff3ab1c8db6d3d580c3120 upstream.
    
    Intel IPU6 PCI driver need register its devices on auxiliary
    bus, so it needs to select the AUXILIARY_BUS in Kconfig.
    
    Reported-by: kernel test robot <[email protected]>
    Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
    Fixes: c70281cc83d6 ("media: intel/ipu6: add Kconfig and Makefile")
    Signed-off-by: Bingbu Cao <[email protected]>
    Cc: [email protected] # for v6.10
    Signed-off-by: Sakari Ailus <[email protected]>
    Signed-off-by: Hans Verkuil <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

media: ipu-bridge: fix ipu6 Kconfig dependencies [+ + +]
Author: Arnd Bergmann <[email protected]>
Date:   Fri Jul 19 11:53:50 2024 +0200

    media: ipu-bridge: fix ipu6 Kconfig dependencies
    
    commit d7b5f7537c8282e1e1919408d0b6c69877fd35f8 upstream.
    
    Commit 4670c8c3fb04 ("media: ipu-bridge: Fix Kconfig dependencies") changed
    how IPU_BRIDGE dependencies are handled for all drivers, but the IPU6
    variant was added the old way, which causes build time warnings when I2C is
    turned off:
    
    WARNING: unmet direct dependencies detected for IPU_BRIDGE
      Depends on [n]: MEDIA_SUPPORT [=m] && PCI [=y] && MEDIA_PCI_SUPPORT [=y] && (ACPI [=y] || COMPILE_TEST [=y]) && I2C [=n]
      Selected by [m]:
      - VIDEO_INTEL_IPU6 [=m] && MEDIA_SUPPORT [=m] && PCI [=y] && MEDIA_PCI_SUPPORT [=y] && (ACPI [=y] || COMPILE_TEST [=y]) && VIDEO_DEV [=m] && X86 [=y] && X86_64 [=y] && HAS_DMA [=y]
    
    To make it consistent with the other IPU drivers as well as avoid this
    warning, change the 'select' into 'depends on'.
    
    Fixes: c70281cc83d6 ("media: intel/ipu6: add Kconfig and Makefile")
    Signed-off-by: Arnd Bergmann <[email protected]>
    [Sakari Ailus: Alternatively depend on !IPU_BRIDGE.]
    Cc: [email protected] # for v6.10
    Signed-off-by: Sakari Ailus <[email protected]>
    Signed-off-by: Hans Verkuil <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

media: uvcvideo: Fix the bandwdith quirk on USB 3.x [+ + +]
Author: Michal Pecio <[email protected]>
Date:   Sun Apr 14 19:00:40 2024 +0200

    media: uvcvideo: Fix the bandwdith quirk on USB 3.x
    
    [ Upstream commit 9e3d55fbd160b3ca376599a68b4cddfdc67d4153 ]
    
    The bandwidth fixup quirk doesn't know that SuperSpeed exists and has
    the same 8 service intervals per millisecond as High Speed, hence its
    calculations are wrong.
    
    Assume that all speeds from HS up use 8 intervals per millisecond.
    
    No further changes are needed, updated code has been confirmed to work
    with all speeds from FS to SS.
    
    Signed-off-by: Michal Pecio <[email protected]>
    Reviewed-by: Ricardo Ribalda <[email protected]>
    Reviewed-by: Laurent Pinchart <[email protected]>
    Link: https://lore.kernel.org/r/20240414190040.2255a0bc@foxbook
    Signed-off-by: Laurent Pinchart <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

media: uvcvideo: Ignore empty TS packets [+ + +]
Author: Ricardo Ribalda <[email protected]>
Date:   Sat Mar 23 10:48:03 2024 +0000

    media: uvcvideo: Ignore empty TS packets
    
    [ Upstream commit 5cd7c25f6f0576073b3d03bc4cfb1e8ca63a1195 ]
    
    Some SunplusIT cameras took a borderline interpretation of the UVC 1.5
    standard, and fill the PTS and SCR fields with invalid data if the
    package does not contain data.
    
    "STC must be captured when the first video data of a video frame is put
    on the USB bus."
    
    Some SunplusIT devices send, e.g.,
    
    buffer: 0xa7755c00 len 000012 header:0x8c stc 00000000 sof 0000 pts 00000000
    buffer: 0xa7755c00 len 000012 header:0x8c stc 00000000 sof 0000 pts 00000000
    buffer: 0xa7755c00 len 000668 header:0x8c stc 73779dba sof 070c pts 7376d37a
    
    While the UVC specification meant that the first two packets shouldn't
    have had the SCR bit set in the header.
    
    This borderline/buggy interpretation has been implemented in a variety
    of devices, from directly SunplusIT and from other OEMs that rebrand
    SunplusIT products. So quirking based on VID:PID will be problematic.
    
    All the affected modules have the following extension unit:
    VideoControl Interface Descriptor:
      guidExtensionCode         {82066163-7050-ab49-b8cc-b3855e8d221d}
    
    But the vendor plans to use that GUID in the future and fix the bug,
    this means that we should use heuristic to figure out the broken
    packets.
    
    This patch takes care of this.
    
    lsusb of one of the affected cameras:
    
    Bus 001 Device 003: ID 1bcf:2a01 Sunplus Innovation Technology Inc.
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               2.01
      bDeviceClass          239 Miscellaneous Device
      bDeviceSubClass         2 ?
      bDeviceProtocol         1 Interface Association
      bMaxPacketSize0        64
      idVendor           0x1bcf Sunplus Innovation Technology Inc.
      idProduct          0x2a01
      bcdDevice            0.02
      iManufacturer           1 SunplusIT Inc
      iProduct                2 HanChen Wise Camera
      iSerial                 3 01.00.00
      bNumConfigurations      1
    
    Tested-by: HungNien Chen <[email protected]>
    Reviewed-by: Sergey Senozhatsky <[email protected]>
    Reviewed-by: Laurent Pinchart <[email protected]>
    Signed-off-by: Ricardo Ribalda <[email protected]>
    Reviewed-by: Tomasz Figa <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Laurent Pinchart <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

media: v4l: Fix missing tabular column hint for Y14P format [+ + +]
Author: Jean-Michel Hautbois <[email protected]>
Date:   Sat Jun 8 18:41:27 2024 +0200

    media: v4l: Fix missing tabular column hint for Y14P format
    
    commit 914f8961879de6fadd166ebd75151a778481e09a upstream.
    
    The original patch added two columns in the flat-table of Luma-Only
    Image Formats, without updating hints to latex: above it.  This results
    in wrong column count in the output of Sphinx's latex builder.
    
    Fix it.
    
    Reported-by: Akira Yokosawa <[email protected]>
    Closes: https://lore.kernel.org/linux-media/[email protected]/
    Fixes: adb1d4655e53 ("media: v4l: Add V4L2-PIX-FMT-Y14P format")
    Cc: [email protected] # for v6.10
    Signed-off-by: Jean-Michel Hautbois <[email protected]>
    Signed-off-by: Hans Verkuil <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

media: xc2028: avoid use-after-free in load_firmware_cb() [+ + +]
Author: Chi Zhiling <[email protected]>
Date:   Fri Jun 14 08:22:25 2024 -0700

    media: xc2028: avoid use-after-free in load_firmware_cb()
    
    [ Upstream commit 68594cec291ff9523b9feb3f43fd853dcddd1f60 ]
    
    syzkaller reported use-after-free in load_firmware_cb() [1].
    The reason is because the module allocated a struct tuner in tuner_probe(),
    and then the module initialization failed, the struct tuner was released.
    A worker which created during module initialization accesses this struct
    tuner later, it caused use-after-free.
    
    The process is as follows:
    
    task-6504           worker_thread
    tuner_probe                             <= alloc dvb_frontend [2]
    ...
    request_firmware_nowait                 <= create a worker
    ...
    tuner_remove                            <= free dvb_frontend
    ...
                        request_firmware_work_func  <= the firmware is ready
                        load_firmware_cb    <= but now the dvb_frontend has been freed
    
    To fix the issue, check the dvd_frontend in load_firmware_cb(), if it is
    null, report a warning and just return.
    
    [1]:
        ==================================================================
         BUG: KASAN: use-after-free in load_firmware_cb+0x1310/0x17a0
         Read of size 8 at addr ffff8000d7ca2308 by task kworker/2:3/6504
    
         Call trace:
          load_firmware_cb+0x1310/0x17a0
          request_firmware_work_func+0x128/0x220
          process_one_work+0x770/0x1824
          worker_thread+0x488/0xea0
          kthread+0x300/0x430
          ret_from_fork+0x10/0x20
    
         Allocated by task 6504:
          kzalloc
          tuner_probe+0xb0/0x1430
          i2c_device_probe+0x92c/0xaf0
          really_probe+0x678/0xcd0
          driver_probe_device+0x280/0x370
          __device_attach_driver+0x220/0x330
          bus_for_each_drv+0x134/0x1c0
          __device_attach+0x1f4/0x410
          device_initial_probe+0x20/0x30
          bus_probe_device+0x184/0x200
          device_add+0x924/0x12c0
          device_register+0x24/0x30
          i2c_new_device+0x4e0/0xc44
          v4l2_i2c_new_subdev_board+0xbc/0x290
          v4l2_i2c_new_subdev+0xc8/0x104
          em28xx_v4l2_init+0x1dd0/0x3770
    
         Freed by task 6504:
          kfree+0x238/0x4e4
          tuner_remove+0x144/0x1c0
          i2c_device_remove+0xc8/0x290
          __device_release_driver+0x314/0x5fc
          device_release_driver+0x30/0x44
          bus_remove_device+0x244/0x490
          device_del+0x350/0x900
          device_unregister+0x28/0xd0
          i2c_unregister_device+0x174/0x1d0
          v4l2_device_unregister+0x224/0x380
          em28xx_v4l2_init+0x1d90/0x3770
    
         The buggy address belongs to the object at ffff8000d7ca2000
          which belongs to the cache kmalloc-2k of size 2048
         The buggy address is located 776 bytes inside of
          2048-byte region [ffff8000d7ca2000, ffff8000d7ca2800)
         The buggy address belongs to the page:
         page:ffff7fe00035f280 count:1 mapcount:0 mapping:ffff8000c001f000 index:0x0
         flags: 0x7ff800000000100(slab)
         raw: 07ff800000000100 ffff7fe00049d880 0000000300000003 ffff8000c001f000
         raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
         page dumped because: kasan: bad access detected
    
         Memory state around the buggy address:
          ffff8000d7ca2200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
          ffff8000d7ca2280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
         >ffff8000d7ca2300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
          ffff8000d7ca2380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
          ffff8000d7ca2400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
         ==================================================================
    
    [2]
        Actually, it is allocated for struct tuner, and dvb_frontend is inside.
    
    Signed-off-by: Chi Zhiling <[email protected]>
    Signed-off-by: Hans Verkuil <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
memcg: protect concurrent access to mem_cgroup_idr [+ + +]
Author: Shakeel Butt <[email protected]>
Date:   Fri Aug 2 16:58:22 2024 -0700

    memcg: protect concurrent access to mem_cgroup_idr
    
    commit 9972605a238339b85bd16b084eed5f18414d22db upstream.
    
    Commit 73f576c04b94 ("mm: memcontrol: fix cgroup creation failure after
    many small jobs") decoupled the memcg IDs from the CSS ID space to fix the
    cgroup creation failures.  It introduced IDR to maintain the memcg ID
    space.  The IDR depends on external synchronization mechanisms for
    modifications.  For the mem_cgroup_idr, the idr_alloc() and idr_replace()
    happen within css callback and thus are protected through cgroup_mutex
    from concurrent modifications.  However idr_remove() for mem_cgroup_idr
    was not protected against concurrency and can be run concurrently for
    different memcgs when they hit their refcnt to zero.  Fix that.
    
    We have been seeing list_lru based kernel crashes at a low frequency in
    our fleet for a long time.  These crashes were in different part of
    list_lru code including list_lru_add(), list_lru_del() and reparenting
    code.  Upon further inspection, it looked like for a given object (dentry
    and inode), the super_block's list_lru didn't have list_lru_one for the
    memcg of that object.  The initial suspicions were either the object is
    not allocated through kmem_cache_alloc_lru() or somehow
    memcg_list_lru_alloc() failed to allocate list_lru_one() for a memcg but
    returned success.  No evidence were found for these cases.
    
    Looking more deeply, we started seeing situations where valid memcg's id
    is not present in mem_cgroup_idr and in some cases multiple valid memcgs
    have same id and mem_cgroup_idr is pointing to one of them.  So, the most
    reasonable explanation is that these situations can happen due to race
    between multiple idr_remove() calls or race between
    idr_alloc()/idr_replace() and idr_remove().  These races are causing
    multiple memcgs to acquire the same ID and then offlining of one of them
    would cleanup list_lrus on the system for all of them.  Later access from
    other memcgs to the list_lru cause crashes due to missing list_lru_one.
    
    Link: https://lkml.kernel.org/r/[email protected]
    Fixes: 73f576c04b94 ("mm: memcontrol: fix cgroup creation failure after many small jobs")
    Signed-off-by: Shakeel Butt <[email protected]>
    Acked-by: Muchun Song <[email protected]>
    Reviewed-by: Roman Gushchin <[email protected]>
    Acked-by: Johannes Weiner <[email protected]>
    Cc: Michal Hocko <[email protected]>
    Cc: <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
mlxsw: pci: Lock configuration space of upstream bridge during reset [+ + +]
Author: Ido Schimmel <[email protected]>
Date:   Mon Jul 8 16:23:42 2024 +0200

    mlxsw: pci: Lock configuration space of upstream bridge during reset
    
    [ Upstream commit 0970836c348b6bc2ea77ce4348a136d6febfd440 ]
    
    The driver triggers a "Secondary Bus Reset" (SBR) by calling
    __pci_reset_function_locked() which asserts the SBR bit in the "Bridge
    Control Register" in the configuration space of the upstream bridge for
    2ms. This is done without locking the configuration space of the
    upstream bridge port, allowing user space to access it concurrently.
    
    Linux 6.11 will start warning about such unlocked resets [1][2]:
    
    pcieport 0000:00:01.0: unlocked secondary bus reset via: pci_reset_bus_function+0x51c/0x6a0
    
    Avoid the warning and the concurrent access by locking the configuration
    space of the upstream bridge prior to the reset and unlocking it
    afterwards.
    
    [1] https://lore.kernel.org/all/171711746953.1628941.4692125082286867825.stgit@dwillia2-xfh.jf.intel.com/
    [2] https://lore.kernel.org/all/20240531213150.GA610983@bhelgaas/
    
    Signed-off-by: Ido Schimmel <[email protected]>
    Signed-off-by: Petr Machata <[email protected]>
    Reviewed-by: Przemek Kitszel <[email protected]>
    Link: https://patch.msgid.link/9937b0afdb50f2f2825945393c94c093c04a5897.1720447210.git.petrm@nvidia.com
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
mm, slub: do not call do_slab_free for kfence object [+ + +]
Author: Rik van Riel <[email protected]>
Date:   Mon Jul 29 14:19:28 2024 -0400

    mm, slub: do not call do_slab_free for kfence object
    
    commit a371d558e6f3aed977a8a7346350557de5d25190 upstream.
    
    In 782f8906f805 the freeing of kfence objects was moved from deep
    inside do_slab_free to the wrapper functions outside. This is a nice
    change, but unfortunately it missed one spot in __kmem_cache_free_bulk.
    
    This results in a crash like this:
    
    BUG skbuff_head_cache (Tainted: G S  B       E     ): Padding overwritten. 0xffff88907fea0f00-0xffff88907fea0fff @offset=3840
    
    slab_err (mm/slub.c:1129)
    free_to_partial_list (mm/slub.c:? mm/slub.c:4036)
    slab_pad_check (mm/slub.c:864 mm/slub.c:1290)
    check_slab (mm/slub.c:?)
    free_to_partial_list (mm/slub.c:3171 mm/slub.c:4036)
    kmem_cache_alloc_bulk (mm/slub.c:? mm/slub.c:4495 mm/slub.c:4586 mm/slub.c:4635)
    napi_build_skb (net/core/skbuff.c:348 net/core/skbuff.c:527 net/core/skbuff.c:549)
    
    All the other callers to do_slab_free appear to be ok.
    
    Add a kfence_free check in __kmem_cache_free_bulk to avoid the crash.
    
    Reported-by: Chris Mason <[email protected]>
    Fixes: 782f8906f805 ("mm/slub: free KFENCE objects in slab_free_hook()")
    Cc: [email protected]
    Signed-off-by: Rik van Riel <[email protected]>
    Signed-off-by: Vlastimil Babka <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
mm: list_lru: fix UAF for memory cgroup [+ + +]
Author: Muchun Song <[email protected]>
Date:   Thu Jul 18 16:36:07 2024 +0800

    mm: list_lru: fix UAF for memory cgroup
    
    commit 5161b48712dcd08ec427c450399d4d1483e21dea upstream.
    
    The mem_cgroup_from_slab_obj() is supposed to be called under rcu lock or
    cgroup_mutex or others which could prevent returned memcg from being
    freed.  Fix it by adding missing rcu read lock.
    
    Found by code inspection.
    
    [[email protected]: only grab rcu lock when necessary, per Vlastimil]
      Link: https://lkml.kernel.org/r/[email protected]
    Link: https://lkml.kernel.org/r/[email protected]
    Fixes: 0a97c01cd20b ("list_lru: allow explicit memcg and NUMA node selection")
    Signed-off-by: Muchun Song <[email protected]>
    Acked-by: Shakeel Butt <[email protected]>
    Acked-by: Vlastimil Babka <[email protected]>
    Cc: Johannes Weiner <[email protected]>
    Cc: Nhat Pham <[email protected]>
    Cc: <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
module: make waiting for a concurrent module loader interruptible [+ + +]
Author: Linus Torvalds <[email protected]>
Date:   Fri Aug 9 08:33:28 2024 -0700

    module: make waiting for a concurrent module loader interruptible
    
    [ Upstream commit 2124d84db293ba164059077944e6b429ba530495 ]
    
    The recursive aes-arm-bs module load situation reported by Russell King
    is getting fixed in the crypto layer, but this in the meantime fixes the
    "recursive load hangs forever" by just making the waiting for the first
    module load be interruptible.
    
    This should now match the old behavior before commit 9b9879fc0327
    ("modules: catch concurrent module loads, treat them as idempotent"),
    which used the different "wait for module to be ready" code in
    module_patient_check_exists().
    
    End result: a recursive module load will still block, but now a signal
    will interrupt it and fail the second module load, at which point the
    first module will successfully complete loading.
    
    Fixes: 9b9879fc0327 ("modules: catch concurrent module loads, treat them as idempotent")
    Cc: Russell King <[email protected]>
    Cc: Herbert Xu <[email protected]>
    Signed-off-by: Linus Torvalds <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

module: warn about excessively long module waits [+ + +]
Author: Linus Torvalds <[email protected]>
Date:   Thu Aug 8 12:29:40 2024 -0700

    module: warn about excessively long module waits
    
    [ Upstream commit cb5b81bc9a448f8db817566f60f92e2ea788ea0f ]
    
    Russell King reported that the arm cbc(aes) crypto module hangs when
    loaded, and Herbert Xu bisected it to commit 9b9879fc0327 ("modules:
    catch concurrent module loads, treat them as idempotent"), and noted:
    
     "So what's happening here is that the first modprobe tries to load a
      fallback CBC implementation, in doing so it triggers a load of the
      exact same module due to module aliases.
    
      IOW we're loading aes-arm-bs which provides cbc(aes). However, this
      needs a fallback of cbc(aes) to operate, which is made out of the
      generic cbc module + any implementation of aes, or ecb(aes). The
      latter happens to also be provided by aes-arm-cb so that's why it
      tries to load the same module again"
    
    So loading the aes-arm-bs module ends up wanting to recursively load
    itself, and the recursive load then ends up waiting for the original
    module load to complete.
    
    This is a regression, in that it used to be that we just tried to load
    the module multiple times, and then as we went on to install it the
    second time we would instead just error out because the module name
    already existed.
    
    That is actually also exactly what the original "catch concurrent loads"
    patch did in commit 9828ed3f695a ("module: error out early on concurrent
    load of the same module file"), but it turns out that it ends up being
    racy, in that erroring out before the module has been fully initialized
    will cause failures in dependent module loading.
    
    See commit ac2263b588df (which was the revert of that "error out early")
    commit for details about why erroring out before the module has been
    initialized is actually fundamentally racy.
    
    Now, for the actual recursive module load (as opposed to just
    concurrently loading the same module twice), the race is not an issue.
    
    At the same time it's hard for the kernel to see that this is recursion,
    because the module load is always done from a usermode helper, so the
    recursion is not some simple callchain within the kernel.
    
    End result: this is not the real fix, but this at least adds a warning
    for the situation (admittedly much too late for all the debugging pain
    that Russell and Herbert went through) and if we can come to a
    resolution on how to detect the recursion properly, this re-organizes
    the code to make that easier.
    
    Link: https://lore.kernel.org/all/[email protected]/
    Reported-by: Russell King <[email protected]>
    Debugged-by: Herbert Xu <[email protected]>
    Signed-off-by: Linus Torvalds <[email protected]>
    Stable-dep-of: 2124d84db293 ("module: make waiting for a concurrent module loader interruptible")
    Signed-off-by: Sasha Levin <[email protected]>

 
mptcp: fully established after ADD_ADDR echo on MPJ [+ + +]
Author: Matthieu Baerts (NGI0) <[email protected]>
Date:   Wed Jul 31 13:05:53 2024 +0200

    mptcp: fully established after ADD_ADDR echo on MPJ
    
    commit d67c5649c1541dc93f202eeffc6f49220a4ed71d upstream.
    
    Before this patch, receiving an ADD_ADDR echo on the just connected
    MP_JOIN subflow -- initiator side, after the MP_JOIN 3WHS -- was
    resulting in an MP_RESET. That's because only ACKs with a DSS or
    ADD_ADDRs without the echo bit were allowed.
    
    Not allowing the ADD_ADDR echo after an MP_CAPABLE 3WHS makes sense, as
    we are not supposed to send an ADD_ADDR before because it requires to be
    in full established mode first. For the MP_JOIN 3WHS, that's different:
    the ADD_ADDR can be sent on a previous subflow, and the ADD_ADDR echo
    can be received on the recently created one. The other peer will already
    be in fully established, so it is allowed to send that.
    
    We can then relax the conditions here to accept the ADD_ADDR echo for
    MPJ subflows.
    
    Fixes: 67b12f792d5e ("mptcp: full fully established support after ADD_ADDR")
    Cc: [email protected]
    Reviewed-by: Mat Martineau <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Link: https://patch.msgid.link/20240731-upstream-net-20240731-mptcp-endp-subflow-signal-v1-1-c8a9b036493b@kernel.org
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

mptcp: pm: deny endp with signal + subflow + port [+ + +]
Author: Matthieu Baerts (NGI0) <[email protected]>
Date:   Wed Jul 31 13:05:54 2024 +0200

    mptcp: pm: deny endp with signal + subflow + port
    
    commit 8af1f11865f259c882cce71d32f85ee9004e2660 upstream.
    
    As mentioned in the 'Fixes' commit, the port flag is only supported by
    the 'signal' flag, and not by the 'subflow' one. Then if both the
    'signal' and 'subflow' flags are set, the problem is the same: the
    feature cannot work with the 'subflow' flag.
    
    Technically, if both the 'signal' and 'subflow' flags are set, it will
    be possible to create the listening socket, but not to establish a
    subflow using this source port. So better to explicitly deny it, not to
    create some confusions because the expected behaviour is not possible.
    
    Fixes: 09f12c3ab7a5 ("mptcp: allow to use port and non-signal in set_flags")
    Cc: [email protected]
    Reviewed-by: Mat Martineau <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Link: https://patch.msgid.link/20240731-upstream-net-20240731-mptcp-endp-subflow-signal-v1-2-c8a9b036493b@kernel.org
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

mptcp: pm: do not ignore 'subflow' if 'signal' flag is also set [+ + +]
Author: Matthieu Baerts (NGI0) <[email protected]>
Date:   Mon Aug 12 17:02:17 2024 +0200

    mptcp: pm: do not ignore 'subflow' if 'signal' flag is also set
    
    commit 85df533a787bf07bf4367ce2a02b822ff1fba1a3 upstream.
    
    Up to the 'Fixes' commit, having an endpoint with both the 'signal' and
    'subflow' flags, resulted in the creation of a subflow and an address
    announcement using the address linked to this endpoint. After this
    commit, only the address announcement was done, ignoring the 'subflow'
    flag.
    
    That's because the same bitmap is used for the two flags. It is OK to
    keep this single bitmap, the already selected local endpoint simply have
    to be re-used, but not via select_local_address() not to look at the
    just modified bitmap.
    
    Note that it is unusual to set the two flags together: creating a new
    subflow using a new local address will implicitly advertise it to the
    other peer. So in theory, no need to advertise it explicitly as well.
    Maybe there are use-cases -- the subflow might not reach the other peer
    that way, we can ask the other peer to try initiating the new subflow
    without delay -- or very likely the user is confused, and put both flags
    "just to be sure at least the right one is set". Still, if it is
    allowed, the kernel should do what has been asked: using this endpoint
    to announce the address and to create a new subflow from it.
    
    An alternative is to forbid the use of the two flags together, but
    that's probably too late, there are maybe use-cases, and it was working
    before. This patch will avoid people complaining subflows are not
    created using the endpoint they added with the 'subflow' and 'signal'
    flag.
    
    Note that with the current patch, the subflow might not be created in
    some corner cases, e.g. if the 'subflows' limit was reached when sending
    the ADD_ADDR, but changed later on. It is probably not worth splitting
    id_avail_bitmap per target ('signal', 'subflow'), which will add another
    large field to the msk "just" to track (again) endpoints. Anyway,
    currently when the limits are changed, the kernel doesn't check if new
    subflows can be created or removed, because we would need to keep track
    of the received ADD_ADDR, and more. It sounds OK to assume that the
    limits should be properly configured before establishing new
    connections.
    
    Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk")
    Cc: [email protected]
    Suggested-by: Paolo Abeni <[email protected]>
    Reviewed-by: Mat Martineau <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Link: https://patch.msgid.link/20240731-upstream-net-20240731-mptcp-endp-subflow-signal-v1-5-c8a9b036493b@kernel.org
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

mptcp: pm: don't try to create sf if alloc failed [+ + +]
Author: Matthieu Baerts (NGI0) <[email protected]>
Date:   Mon Aug 12 17:02:16 2024 +0200

    mptcp: pm: don't try to create sf if alloc failed
    
    commit cd7c957f936f8cb80d03e5152f4013aae65bd986 upstream.
    
    It sounds better to avoid wasting cycles and / or put extreme memory
    pressure on the system by trying to create new subflows if it was not
    possible to add a new item in the announce list.
    
    While at it, a warning is now printed if the entry was already in the
    list as it should not happen with the in-kernel path-manager. With this
    PM, mptcp_pm_alloc_anno_list() should only fail in case of memory
    pressure.
    
    Fixes: b6c08380860b ("mptcp: remove addr and subflow in PM netlink")
    Cc: [email protected]
    Suggested-by: Paolo Abeni <[email protected]>
    Reviewed-by: Mat Martineau <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Link: https://patch.msgid.link/20240731-upstream-net-20240731-mptcp-endp-subflow-signal-v1-4-c8a9b036493b@kernel.org
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

mptcp: pm: reduce indentation blocks [+ + +]
Author: Matthieu Baerts (NGI0) <[email protected]>
Date:   Mon Aug 12 17:02:15 2024 +0200

    mptcp: pm: reduce indentation blocks
    
    commit c95eb32ced823a00be62202b43966b07b2f20b7f upstream.
    
    That will simplify the following commits.
    
    No functional changes intended.
    
    Suggested-by: Paolo Abeni <[email protected]>
    Reviewed-by: Mat Martineau <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Link: https://patch.msgid.link/20240731-upstream-net-20240731-mptcp-endp-subflow-signal-v1-3-c8a9b036493b@kernel.org
    Signed-off-by: Jakub Kicinski <[email protected]>
    Stable-dep-of: cd7c957f936f ("mptcp: pm: don't try to create sf if alloc failed")
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
net/mlx5e: SHAMPO, Fix invalid WQ linked list unlink [+ + +]
Author: Dragos Tatulea <[email protected]>
Date:   Tue Jun 4 00:22:08 2024 +0300

    net/mlx5e: SHAMPO, Fix invalid WQ linked list unlink
    
    [ Upstream commit fba8334721e266f92079632598e46e5f89082f30 ]
    
    When all the strides in a WQE have been consumed, the WQE is unlinked
    from the WQ linked list (mlx5_wq_ll_pop()). For SHAMPO, it is possible
    to receive CQEs with 0 consumed strides for the same WQE even after the
    WQE is fully consumed and unlinked. This triggers an additional unlink
    for the same wqe which corrupts the linked list.
    
    Fix this scenario by accepting 0 sized consumed strides without
    unlinking the WQE again.
    
    Signed-off-by: Dragos Tatulea <[email protected]>
    Signed-off-by: Tariq Toukan <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
net/smc: add the max value of fallback reason count [+ + +]
Author: Zhengchao Shao <[email protected]>
Date:   Mon Aug 5 12:38:56 2024 +0800

    net/smc: add the max value of fallback reason count
    
    [ Upstream commit d27a835f41d947f62e6a95e89ba523299c9e6437 ]
    
    The number of fallback reasons defined in the smc_clc.h file has reached
    36. For historical reasons, some are no longer quoted, and there's 33
    actually in use. So, add the max value of fallback reason count to 36.
    
    Fixes: 6ac1e6563f59 ("net/smc: support smc v2.x features validate")
    Fixes: 7f0620b9940b ("net/smc: support max connections per lgr negotiation")
    Fixes: 69b888e3bb4b ("net/smc: support max links per lgr negotiation in clc handshake")
    Signed-off-by: Zhengchao Shao <[email protected]>
    Reviewed-by: Wenjia Zhang <[email protected]>
    Reviewed-by: D. Wythe <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
net/tcp: Disable TCP-AO static key after RCU grace period [+ + +]
Author: Dmitry Safonov <[email protected]>
Date:   Thu Aug 1 01:13:28 2024 +0100

    net/tcp: Disable TCP-AO static key after RCU grace period
    
    commit 14ab4792ee120c022f276a7e4768f4dcb08f0cdd upstream.
    
    The lifetime of TCP-AO static_key is the same as the last
    tcp_ao_info. On the socket destruction tcp_ao_info ceases to be
    with RCU grace period, while tcp-ao static branch is currently deferred
    destructed. The static key definition is
    : DEFINE_STATIC_KEY_DEFERRED_FALSE(tcp_ao_needed, HZ);
    
    which means that if RCU grace period is delayed by more than a second
    and tcp_ao_needed is in the process of disablement, other CPUs may
    yet see tcp_ao_info which atent dead, but soon-to-be.
    And that breaks the assumption of static_key_fast_inc_not_disabled().
    
    See the comment near the definition:
    > * The caller must make sure that the static key can't get disabled while
    > * in this function. It doesn't patch jump labels, only adds a user to
    > * an already enabled static key.
    
    Originally it was introduced in commit eb8c507296f6 ("jump_label:
    Prevent key->enabled int overflow"), which is needed for the atomic
    contexts, one of which would be the creation of a full socket from a
    request socket. In that atomic context, it's known by the presence
    of the key (md5/ao) that the static branch is already enabled.
    So, the ref counter for that static branch is just incremented
    instead of holding the proper mutex.
    static_key_fast_inc_not_disabled() is just a helper for such usage
    case. But it must not be used if the static branch could get disabled
    in parallel as it's not protected by jump_label_mutex and as a result,
    races with jump_label_update() implementation details.
    
    Happened on netdev test-bot[1], so not a theoretical issue:
    
    [] jump_label: Fatal kernel bug, unexpected op at tcp_inbound_hash+0x1a7/0x870 [ffffffffa8c4e9b7] (eb 50 0f 1f 44 != 66 90 0f 1f 00)) size:2 type:1
    [] ------------[ cut here ]------------
    [] kernel BUG at arch/x86/kernel/jump_label.c:73!
    [] Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
    [] CPU: 3 PID: 243 Comm: kworker/3:3 Not tainted 6.10.0-virtme #1
    [] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
    [] Workqueue: events jump_label_update_timeout
    [] RIP: 0010:__jump_label_patch+0x2f6/0x350
    ...
    [] Call Trace:
    []  <TASK>
    []  arch_jump_label_transform_queue+0x6c/0x110
    []  __jump_label_update+0xef/0x350
    []  __static_key_slow_dec_cpuslocked.part.0+0x3c/0x60
    []  jump_label_update_timeout+0x2c/0x40
    []  process_one_work+0xe3b/0x1670
    []  worker_thread+0x587/0xce0
    []  kthread+0x28a/0x350
    []  ret_from_fork+0x31/0x70
    []  ret_from_fork_asm+0x1a/0x30
    []  </TASK>
    [] Modules linked in: veth
    [] ---[ end trace 0000000000000000 ]---
    [] RIP: 0010:__jump_label_patch+0x2f6/0x350
    
    [1]: https://netdev-3.bots.linux.dev/vmksft-tcp-ao-dbg/results/696681/5-connect-deny-ipv6/stderr
    
    Cc: [email protected]
    Fixes: 67fa83f7c86a ("net/tcp: Add static_key for TCP-AO")
    Signed-off-by: Dmitry Safonov <[email protected]>
    Reviewed-by: Eric Dumazet <[email protected]>
    Signed-off-by: David S. Miller <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
net: bcmgenet: Properly overlay PHY and MAC Wake-on-LAN capabilities [+ + +]
Author: Florian Fainelli <[email protected]>
Date:   Tue Aug 6 10:56:59 2024 -0700

    net: bcmgenet: Properly overlay PHY and MAC Wake-on-LAN capabilities
    
    [ Upstream commit 9ee09edc05f20422e7ced84b1f8a5d3359926ac8 ]
    
    Some Wake-on-LAN modes such as WAKE_FILTER may only be supported by the MAC,
    while others might be only supported by the PHY. Make sure that the .get_wol()
    returns the union of both rather than only that of the PHY if the PHY supports
    Wake-on-LAN.
    
    Fixes: 7e400ff35cbe ("net: bcmgenet: Add support for PHY-based Wake-on-LAN")
    Signed-off-by: Florian Fainelli <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: bridge: mcast: wait for previous gc cycles when removing port [+ + +]
Author: Nikolay Aleksandrov <[email protected]>
Date:   Fri Aug 2 11:07:30 2024 +0300

    net: bridge: mcast: wait for previous gc cycles when removing port
    
    [ Upstream commit 92c4ee25208d0f35dafc3213cdf355fbe449e078 ]
    
    syzbot hit a use-after-free[1] which is caused because the bridge doesn't
    make sure that all previous garbage has been collected when removing a
    port. What happens is:
          CPU 1                   CPU 2
     start gc cycle           remove port
                             acquire gc lock first
     wait for lock
                             call br_multicasg_gc() directly
     acquire lock now but    free port
     the port can be freed
     while grp timers still
     running
    
    Make sure all previous gc cycles have finished by using flush_work before
    freeing the port.
    
    [1]
      BUG: KASAN: slab-use-after-free in br_multicast_port_group_expired+0x4c0/0x550 net/bridge/br_multicast.c:861
      Read of size 8 at addr ffff888071d6d000 by task syz.5.1232/9699
    
      CPU: 1 PID: 9699 Comm: syz.5.1232 Not tainted 6.10.0-rc5-syzkaller-00021-g24ca36a562d6 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
      Call Trace:
       <IRQ>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:114
       print_address_description mm/kasan/report.c:377 [inline]
       print_report+0xc3/0x620 mm/kasan/report.c:488
       kasan_report+0xd9/0x110 mm/kasan/report.c:601
       br_multicast_port_group_expired+0x4c0/0x550 net/bridge/br_multicast.c:861
       call_timer_fn+0x1a3/0x610 kernel/time/timer.c:1792
       expire_timers kernel/time/timer.c:1843 [inline]
       __run_timers+0x74b/0xaf0 kernel/time/timer.c:2417
       __run_timer_base kernel/time/timer.c:2428 [inline]
       __run_timer_base kernel/time/timer.c:2421 [inline]
       run_timer_base+0x111/0x190 kernel/time/timer.c:2437
    
    Reported-by: [email protected]
    Closes: https://syzkaller.appspot.com/bug?extid=263426984509be19c9a0
    Fixes: e12cec65b554 ("net: bridge: mcast: destroy all entries via gc")
    Signed-off-by: Nikolay Aleksandrov <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: drop bad gso csum_start and offset in virtio_net_hdr [+ + +]
Author: Willem de Bruijn <[email protected]>
Date:   Mon Jul 29 16:10:12 2024 -0400

    net: drop bad gso csum_start and offset in virtio_net_hdr
    
    commit 89add40066f9ed9abe5f7f886fe5789ff7e0c50e upstream.
    
    Tighten csum_start and csum_offset checks in virtio_net_hdr_to_skb
    for GSO packets.
    
    The function already checks that a checksum requested with
    VIRTIO_NET_HDR_F_NEEDS_CSUM is in skb linear. But for GSO packets
    this might not hold for segs after segmentation.
    
    Syzkaller demonstrated to reach this warning in skb_checksum_help
    
            offset = skb_checksum_start_offset(skb);
            ret = -EINVAL;
            if (WARN_ON_ONCE(offset >= skb_headlen(skb)))
    
    By injecting a TSO packet:
    
    WARNING: CPU: 1 PID: 3539 at net/core/dev.c:3284 skb_checksum_help+0x3d0/0x5b0
     ip_do_fragment+0x209/0x1b20 net/ipv4/ip_output.c:774
     ip_finish_output_gso net/ipv4/ip_output.c:279 [inline]
     __ip_finish_output+0x2bd/0x4b0 net/ipv4/ip_output.c:301
     iptunnel_xmit+0x50c/0x930 net/ipv4/ip_tunnel_core.c:82
     ip_tunnel_xmit+0x2296/0x2c70 net/ipv4/ip_tunnel.c:813
     __gre_xmit net/ipv4/ip_gre.c:469 [inline]
     ipgre_xmit+0x759/0xa60 net/ipv4/ip_gre.c:661
     __netdev_start_xmit include/linux/netdevice.h:4850 [inline]
     netdev_start_xmit include/linux/netdevice.h:4864 [inline]
     xmit_one net/core/dev.c:3595 [inline]
     dev_hard_start_xmit+0x261/0x8c0 net/core/dev.c:3611
     __dev_queue_xmit+0x1b97/0x3c90 net/core/dev.c:4261
     packet_snd net/packet/af_packet.c:3073 [inline]
    
    The geometry of the bad input packet at tcp_gso_segment:
    
    [   52.003050][ T8403] skb len=12202 headroom=244 headlen=12093 tailroom=0
    [   52.003050][ T8403] mac=(168,24) mac_len=24 net=(192,52) trans=244
    [   52.003050][ T8403] shinfo(txflags=0 nr_frags=1 gso(size=1552 type=3 segs=0))
    [   52.003050][ T8403] csum(0x60000c7 start=199 offset=1536
    ip_summed=3 complete_sw=0 valid=0 level=0)
    
    Mitigate with stricter input validation.
    
    csum_offset: for GSO packets, deduce the correct value from gso_type.
    This is already done for USO. Extend it to TSO. Let UFO be:
    udp[46]_ufo_fragment ignores these fields and always computes the
    checksum in software.
    
    csum_start: finding the real offset requires parsing to the transport
    header. Do not add a parser, use existing segmentation parsing. Thanks
    to SKB_GSO_DODGY, that also catches bad packets that are hw offloaded.
    Again test both TSO and USO. Do not test UFO for the above reason, and
    do not test UDP tunnel offload.
    
    GSO packet are almost always CHECKSUM_PARTIAL. USO packets may be
    CHECKSUM_NONE since commit 10154dbded6d6 ("udp: Allow GSO transmit
    from devices with no checksum offload"), but then still these fields
    are initialized correctly in udp4_hwcsum/udp6_hwcsum_outgoing. So no
    need to test for ip_summed == CHECKSUM_PARTIAL first.
    
    This revises an existing fix mentioned in the Fixes tag, which broke
    small packets with GSO offload, as detected by kselftests.
    
    Link: https://syzkaller.appspot.com/bug?extid=e1db31216c789f552871
    Link: https://lore.kernel.org/netdev/[email protected]
    Fixes: e269d79c7d35 ("net: missing check virtio")
    Cc: [email protected]
    Signed-off-by: Willem de Bruijn <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

net: dsa: bcm_sf2: Fix a possible memory leak in bcm_sf2_mdio_register() [+ + +]
Author: Joe Hattori <[email protected]>
Date:   Tue Aug 6 10:13:27 2024 +0900

    net: dsa: bcm_sf2: Fix a possible memory leak in bcm_sf2_mdio_register()
    
    [ Upstream commit e3862093ee93fcfbdadcb7957f5f8974fffa806a ]
    
    bcm_sf2_mdio_register() calls of_phy_find_device() and then
    phy_device_remove() in a loop to remove existing PHY devices.
    of_phy_find_device() eventually calls bus_find_device(), which calls
    get_device() on the returned struct device * to increment the refcount.
    The current implementation does not decrement the refcount, which causes
    memory leak.
    
    This commit adds the missing phy_device_free() call to decrement the
    refcount via put_device() to balance the refcount.
    
    Fixes: 771089c2a485 ("net: dsa: bcm_sf2: Ensure that MDIO diversion is used")
    Signed-off-by: Joe Hattori <[email protected]>
    Tested-by: Florian Fainelli <[email protected]>
    Reviewed-by: Florian Fainelli <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: dsa: microchip: disable EEE for KSZ8567/KSZ9567/KSZ9896/KSZ9897. [+ + +]
Author: Martin Whitaker <[email protected]>
Date:   Wed Aug 7 21:52:09 2024 +0100

    net: dsa: microchip: disable EEE for KSZ8567/KSZ9567/KSZ9896/KSZ9897.
    
    [ Upstream commit 0411f73c13afcf619d7aa7546edbc5710a871cae ]
    
    As noted in the device errata [1-8], EEE support is not fully operational
    in the KSZ8567, KSZ9477, KSZ9567, KSZ9896, and KSZ9897 devices, causing
    link drops when connected to another device that supports EEE. The patch
    series "net: add EEE support for KSZ9477 switch family" merged in commit
    9b0bf4f77162 caused EEE support to be enabled in these devices. A fix for
    this regression for the KSZ9477 alone was merged in commit 08c6d8bae48c2.
    This patch extends this fix to the other affected devices.
    
    [1] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ8567R-Errata-DS80000752.pdf
    [2] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ8567S-Errata-DS80000753.pdf
    [3] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ9477S-Errata-DS80000754.pdf
    [4] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ9567R-Errata-DS80000755.pdf
    [5] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ9567S-Errata-DS80000756.pdf
    [6] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ9896C-Errata-DS80000757.pdf
    [7] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ9897R-Errata-DS80000758.pdf
    [8] https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/Errata/KSZ9897S-Errata-DS80000759.pdf
    
    Fixes: 69d3b36ca045 ("net: dsa: microchip: enable EEE support") # for KSZ8567/KSZ9567/KSZ9896/KSZ9897
    Link: https://lore.kernel.org/netdev/[email protected]/
    Signed-off-by: Martin Whitaker <[email protected]>
    Acked-by: Arun Ramadoss <[email protected]>
    Reviewed-by: Oleksij Rempel <[email protected]>
    Reviewed-by: Lukasz Majewski <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: dsa: microchip: Fix Wake-on-LAN check to not return an error [+ + +]
Author: Tristram Ha <[email protected]>
Date:   Mon Aug 5 16:52:00 2024 -0700

    net: dsa: microchip: Fix Wake-on-LAN check to not return an error
    
    [ Upstream commit c7a19018bd557c24072b59088ad2684fd83ea3f4 ]
    
    The wol variable in ksz_port_set_mac_address() is declared with random
    data, but the code in ksz_get_wol call may not be executed so the
    WAKE_MAGIC check may be invalid resulting in an error message when
    setting a MAC address after starting the DSA driver.
    
    Fixes: 3b454b6390c3 ("net: dsa: microchip: ksz9477: Add Wake on Magic Packet support")
    Signed-off-by: Tristram Ha <[email protected]>
    Reviewed-by: Oleksij Rempel <[email protected]>
    Reviewed-by: Florian Fainelli <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: fec: Stop PPS on driver remove [+ + +]
Author: Csókás, Bence <[email protected]>
Date:   Wed Aug 7 10:09:56 2024 +0200

    net: fec: Stop PPS on driver remove
    
    [ Upstream commit 8fee6d5ad5fa18c270eedb2a2cdf58dbadefb94b ]
    
    PPS was not stopped in `fec_ptp_stop()`, called when
    the adapter was removed. Consequentially, you couldn't
    safely reload the driver with the PPS signal on.
    
    Fixes: 32cba57ba74b ("net: fec: introduce fec_ptp_stop and use in probe fail path")
    Reviewed-by: Fabio Estevam <[email protected]>
    Link: https://lore.kernel.org/netdev/CAOMZO5BzcZR8PwKKwBssQq_wAGzVgf1ffwe_nhpQJjviTdxy-w@mail.gmail.com/T/#m01dcb810bfc451a492140f6797ca77443d0cb79f
    Signed-off-by: Csókás, Bence <[email protected]>
    Reviewed-by: Andrew Lunn <[email protected]>
    Reviewed-by: Frank Li <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: linkwatch: use system_unbound_wq [+ + +]
Author: Eric Dumazet <[email protected]>
Date:   Mon Aug 5 08:58:21 2024 +0000

    net: linkwatch: use system_unbound_wq
    
    [ Upstream commit 3e7917c0cdad835a5121520fc5686d954b7a61ab ]
    
    linkwatch_event() grabs possibly very contended RTNL mutex.
    
    system_wq is not suitable for such work.
    
    Inspired by many noisy syzbot reports.
    
    3 locks held by kworker/0:7/5266:
     #0: ffff888015480948 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3206 [inline]
     #0: ffff888015480948 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0x90a/0x1830 kernel/workqueue.c:3312
     #1: ffffc90003f6fd00 ((linkwatch_work).work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3207 [inline]
     , at: process_scheduled_works+0x945/0x1830 kernel/workqueue.c:3312
     #2: ffffffff8fa6f208 (rtnl_mutex){+.+.}-{3:3}, at: linkwatch_event+0xe/0x60 net/core/link_watch.c:276
    
    Reported-by: syzbot <[email protected]>
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Dumazet <[email protected]>
    Reviewed-by: Kuniyuki Iwashima <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: pse-pd: tps23881: Fix the device ID check [+ + +]
Author: Kyle Swenson <[email protected]>
Date:   Wed Jul 31 15:42:14 2024 +0000

    net: pse-pd: tps23881: Fix the device ID check
    
    [ Upstream commit 89108cb5c28527c1882df2987394e5c261a1f4aa ]
    
    The DEVID register contains two pieces of information: the device ID in
    the upper nibble, and the silicon revision number in the lower nibble.
    The driver should work fine with any silicon revision, so let's mask
    that out in the device ID check.
    
    Fixes: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
    Signed-off-by: Kyle Swenson <[email protected]>
    Reviewed-by: Thomas Petazzoni <[email protected]>
    Acked-by: Oleksij Rempel <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: pse-pd: tps23881: include missing bitfield.h header [+ + +]
Author: Arnd Bergmann <[email protected]>
Date:   Wed Aug 7 09:54:22 2024 +0200

    net: pse-pd: tps23881: include missing bitfield.h header
    
    [ Upstream commit a70b637db15b4de25af3c5946c4399144b3bc241 ]
    
    Using FIELD_GET() fails in configurations that don't already include
    the header file indirectly:
    
    drivers/net/pse-pd/tps23881.c: In function 'tps23881_i2c_probe':
    drivers/net/pse-pd/tps23881.c:755:13: error: implicit declaration of function 'FIELD_GET' [-Wimplicit-function-declaration]
      755 |         if (FIELD_GET(TPS23881_REG_DEVID_MASK, ret) != TPS23881_DEVICE_ID) {
          |             ^~~~~~~~~
    
    Fixes: 89108cb5c285 ("net: pse-pd: tps23881: Fix the device ID check")
    Signed-off-by: Arnd Bergmann <[email protected]>
    Acked-by: Oleksij Rempel <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: stmmac: qcom-ethqos: enable SGMII loopback during DMA reset on sa8775p-ride-r3 [+ + +]
Author: Bartosz Golaszewski <[email protected]>
Date:   Wed Jul 3 20:14:59 2024 +0200

    net: stmmac: qcom-ethqos: enable SGMII loopback during DMA reset on sa8775p-ride-r3
    
    [ Upstream commit 3c466d6537b99f801b3f68af3d8124d4312437a0 ]
    
    On sa8775p-ride-r3 the RX clocks from the AQR115C PHY are not available at
    the time of the DMA reset. We can however extract the RX clock from the
    internal SERDES block. Once the link is up, we can revert to the
    previous state.
    
    The AQR115C PHY doesn't support in-band signalling so we can count on
    getting the link up notification and safely reuse existing callbacks
    which are already used by another HW quirk workaround which enables the
    functional clock to avoid a DMA reset due to timeout.
    
    Only enable loopback on revision 3 of the board - check the phy_mode to
    make sure.
    
    Signed-off-by: Bartosz Golaszewski <[email protected]>
    Reviewed-by: Andrew Lunn <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

net: usb: qmi_wwan: fix memory leak for not ip packets [+ + +]
Author: Daniele Palmas <[email protected]>
Date:   Thu Aug 1 15:55:12 2024 +0200

    net: usb: qmi_wwan: fix memory leak for not ip packets
    
    [ Upstream commit 7ab107544b777c3bd7feb9fe447367d8edd5b202 ]
    
    Free the unused skb when not ip packets arrive.
    
    Fixes: c6adf77953bc ("net: usb: qmi_wwan: add qmap mux protocol support")
    Signed-off-by: Daniele Palmas <[email protected]>
    Acked-by: Bjørn Mork <[email protected]>
    Signed-off-by: David S. Miller <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
nfsd: don't set SVC_SOCK_ANONYMOUS when creating nfsd sockets [+ + +]
Author: Jeff Layton <[email protected]>
Date:   Fri Jul 19 14:55:53 2024 -0400

    nfsd: don't set SVC_SOCK_ANONYMOUS when creating nfsd sockets
    
    [ Upstream commit 91da337e5d506f2c065d20529d105ca40090e320 ]
    
    When creating nfsd sockets via the netlink interface, we do want to
    register with the portmapper. Don't set SVC_SOCK_ANONYMOUS.
    
    Reported-by: Steve Dickson <[email protected]>
    Fixes: 16a471177496 ("NFSD: add listener-{set,get} netlink command")
    Cc: Lorenzo Bianconi <[email protected]>
    Signed-off-by: Jeff Layton <[email protected]>
    Signed-off-by: Chuck Lever <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
ntp: Clamp maxerror and esterror to operating range [+ + +]
Author: Justin Stitt <[email protected]>
Date:   Fri May 17 20:22:44 2024 +0000

    ntp: Clamp maxerror and esterror to operating range
    
    [ Upstream commit 87d571d6fb77ec342a985afa8744bb9bb75b3622 ]
    
    Using syzkaller alongside the newly reintroduced signed integer overflow
    sanitizer spits out this report:
    
    UBSAN: signed-integer-overflow in ../kernel/time/ntp.c:461:16
    9223372036854775807 + 500 cannot be represented in type 'long'
    Call Trace:
     handle_overflow+0x171/0x1b0
     second_overflow+0x2d6/0x500
     accumulate_nsecs_to_secs+0x60/0x160
     timekeeping_advance+0x1fe/0x890
     update_wall_time+0x10/0x30
    
    time_maxerror is unconditionally incremented and the result is checked
    against NTP_PHASE_LIMIT, but the increment itself can overflow, resulting
    in wrap-around to negative space.
    
    Before commit eea83d896e31 ("ntp: NTP4 user space bits update") the user
    supplied value was sanity checked to be in the operating range. That change
    removed the sanity check and relied on clamping in handle_overflow() which
    does not work correctly when the user supplied value is in the overflow
    zone of the '+ 500' operation.
    
    The operation requires CAP_SYS_TIME and the side effect of the overflow is
    NTP getting out of sync.
    
    Miroslav confirmed that the input value should be clamped to the operating
    range and the same applies to time_esterror. The latter is not used by the
    kernel, but the value still should be in the operating range as it was
    before the sanity check got removed.
    
    Clamp them to the operating range.
    
    [ tglx: Changed it to clamping and included time_esterror ]
    
    Fixes: eea83d896e31 ("ntp: NTP4 user space bits update")
    Signed-off-by: Justin Stitt <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Cc: Miroslav Lichvar <[email protected]>
    Link: https://lore.kernel.org/all/[email protected]
    Closes: https://github.com/KSPP/linux/issues/354
    Signed-off-by: Sasha Levin <[email protected]>

ntp: Safeguard against time_constant overflow [+ + +]
Author: Justin Stitt <[email protected]>
Date:   Fri May 17 00:47:10 2024 +0000

    ntp: Safeguard against time_constant overflow
    
    commit 06c03c8edce333b9ad9c6b207d93d3a5ae7c10c0 upstream.
    
    Using syzkaller with the recently reintroduced signed integer overflow
    sanitizer produces this UBSAN report:
    
    UBSAN: signed-integer-overflow in ../kernel/time/ntp.c:738:18
    9223372036854775806 + 4 cannot be represented in type 'long'
    Call Trace:
     handle_overflow+0x171/0x1b0
     __do_adjtimex+0x1236/0x1440
     do_adjtimex+0x2be/0x740
    
    The user supplied time_constant value is incremented by four and then
    clamped to the operating range.
    
    Before commit eea83d896e31 ("ntp: NTP4 user space bits update") the user
    supplied value was sanity checked to be in the operating range. That change
    removed the sanity check and relied on clamping after incrementing which
    does not work correctly when the user supplied value is in the overflow
    zone of the '+ 4' operation.
    
    The operation requires CAP_SYS_TIME and the side effect of the overflow is
    NTP getting out of sync.
    
    Similar to the fixups for time_maxerror and time_esterror, clamp the user
    space supplied value to the operating range.
    
    [ tglx: Switch to clamping ]
    
    Fixes: eea83d896e31 ("ntp: NTP4 user space bits update")
    Signed-off-by: Justin Stitt <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Cc: Miroslav Lichvar <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/[email protected]
    Closes: https://github.com/KSPP/linux/issues/352
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
nvme: apple: fix device reference counting [+ + +]
Author: Keith Busch <[email protected]>
Date:   Tue Jun 4 11:59:04 2024 -0700

    nvme: apple: fix device reference counting
    
    [ Upstream commit b9ecbfa45516182cd062fecd286db7907ba84210 ]
    
    Drivers must call nvme_uninit_ctrl after a successful nvme_init_ctrl.
    Split the allocation side out to make the error handling boundary easier
    to navigate. The apple driver had been doing this wrong, leaking the
    controller device memory on a tagset failure.
    
    Reviewed-by: Christoph Hellwig <[email protected]>
    Reviewed-by: Chaitanya Kulkarni <[email protected]>
    Signed-off-by: Keith Busch <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
padata: Fix possible divide-by-0 panic in padata_mt_helper() [+ + +]
Author: Waiman Long <[email protected]>
Date:   Tue Aug 6 13:46:47 2024 -0400

    padata: Fix possible divide-by-0 panic in padata_mt_helper()
    
    commit 6d45e1c948a8b7ed6ceddb14319af69424db730c upstream.
    
    We are hit with a not easily reproducible divide-by-0 panic in padata.c at
    bootup time.
    
      [   10.017908] Oops: divide error: 0000 1 PREEMPT SMP NOPTI
      [   10.017908] CPU: 26 PID: 2627 Comm: kworker/u1666:1 Not tainted 6.10.0-15.el10.x86_64 #1
      [   10.017908] Hardware name: Lenovo ThinkSystem SR950 [7X12CTO1WW]/[7X12CTO1WW], BIOS [PSE140J-2.30] 07/20/2021
      [   10.017908] Workqueue: events_unbound padata_mt_helper
      [   10.017908] RIP: 0010:padata_mt_helper+0x39/0xb0
        :
      [   10.017963] Call Trace:
      [   10.017968]  <TASK>
      [   10.018004]  ? padata_mt_helper+0x39/0xb0
      [   10.018084]  process_one_work+0x174/0x330
      [   10.018093]  worker_thread+0x266/0x3a0
      [   10.018111]  kthread+0xcf/0x100
      [   10.018124]  ret_from_fork+0x31/0x50
      [   10.018138]  ret_from_fork_asm+0x1a/0x30
      [   10.018147]  </TASK>
    
    Looking at the padata_mt_helper() function, the only way a divide-by-0
    panic can happen is when ps->chunk_size is 0.  The way that chunk_size is
    initialized in padata_do_multithreaded(), chunk_size can be 0 when the
    min_chunk in the passed-in padata_mt_job structure is 0.
    
    Fix this divide-by-0 panic by making sure that chunk_size will be at least
    1 no matter what the input parameters are.
    
    Link: https://lkml.kernel.org/r/[email protected]
    Fixes: 004ed42638f4 ("padata: add basic support for multithreaded jobs")
    Signed-off-by: Waiman Long <[email protected]>
    Cc: Daniel Jordan <[email protected]>
    Cc: Steffen Klassert <[email protected]>
    Cc: Waiman Long <[email protected]>
    Cc: <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
parisc: fix a possible DMA corruption [+ + +]
Author: Mikulas Patocka <[email protected]>
Date:   Sat Jul 27 20:22:52 2024 +0200

    parisc: fix a possible DMA corruption
    
    commit 7ae04ba36b381bffe2471eff3a93edced843240f upstream.
    
    ARCH_DMA_MINALIGN was defined as 16 - this is too small - it may be
    possible that two unrelated 16-byte allocations share a cache line. If
    one of these allocations is written using DMA and the other is written
    using cached write, the value that was written with DMA may be
    corrupted.
    
    This commit changes ARCH_DMA_MINALIGN to be 128 on PA20 and 32 on PA1.1 -
    that's the largest possible cache line size.
    
    As different parisc microarchitectures have different cache line size, we
    define arch_slab_minalign(), cache_line_size() and
    dma_get_cache_alignment() so that the kernel may tune slab cache
    parameters dynamically, based on the detected cache line size.
    
    Signed-off-by: Mikulas Patocka <[email protected]>
    Cc: [email protected]
    Signed-off-by: Helge Deller <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

parisc: fix unaligned accesses in BPF [+ + +]
Author: Mikulas Patocka <[email protected]>
Date:   Sat Jul 27 12:11:02 2024 +0200

    parisc: fix unaligned accesses in BPF
    
    commit 1fd2c10acb7b35d72101a4619ee5b2cddb9efd3a upstream.
    
    There were spurious unaligned access warnings when calling BPF code.
    Sometimes, the warnings were triggered with any incoming packet, making
    the machine hard to use.
    
    The reason for the warnings is this: on parisc64, pointers to functions
    are not really pointers to functions, they are pointers to 16-byte
    descriptor. The first 8 bytes of the descriptor is a pointer to the
    function and the next 8 bytes of the descriptor is the content of the
    "dp" register. This descriptor is generated in the function
    bpf_jit_build_prologue.
    
    The problem is that the function bpf_int_jit_compile advertises 4-byte
    alignment when calling bpf_jit_binary_alloc, bpf_jit_binary_alloc
    randomizes the returned array and if the array happens to be not aligned
    on 8-byte boundary, the descriptor generated in bpf_jit_build_prologue is
    also not aligned and this triggers the unaligned access warning.
    
    Fix this by advertising 8-byte alignment on parisc64 when calling
    bpf_jit_binary_alloc.
    
    Signed-off-by: Mikulas Patocka <[email protected]>
    Cc: [email protected]
    Signed-off-by: Helge Deller <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
PCI: Add Edimax Vendor ID to pci_ids.h [+ + +]
Author: FUJITA Tomonori <[email protected]>
Date:   Mon Jun 24 08:55:01 2024 +0900

    PCI: Add Edimax Vendor ID to pci_ids.h
    
    [ Upstream commit eee5528890d54b22b46f833002355a5ee94c3bb4 ]
    
    Add the Edimax Vendor ID (0x1432) for an ethernet driver for Tehuti
    Networks TN40xx chips. This ID can be used for Realtek 8180 and Ralink
    rt28xx wireless drivers.
    
    Signed-off-by: FUJITA Tomonori <[email protected]>
    Acked-by: Bjorn Helgaas <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
perf/x86/amd: Use try_cmpxchg() in events/amd/{un,}core.c [+ + +]
Author: Uros Bizjak <[email protected]>
Date:   Thu Apr 25 12:16:14 2024 +0200

    perf/x86/amd: Use try_cmpxchg() in events/amd/{un,}core.c
    
    [ Upstream commit cd84351c8c1baec86342d784feb884ace007d51c ]
    
    Replace this pattern in events/amd/{un,}core.c:
    
        cmpxchg(*ptr, old, new) == old
    
    ... with the simpler and faster:
    
        try_cmpxchg(*ptr, &old, new)
    
    The x86 CMPXCHG instruction returns success in the ZF flag, so this change
    saves a compare after the CMPXCHG.
    
    No functional change intended.
    
    Signed-off-by: Uros Bizjak <[email protected]>
    Signed-off-by: Ingo Molnar <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Stable-dep-of: f73cefa3b72e ("perf/x86: Fix smp_processor_id()-in-preemptible warnings")
    Signed-off-by: Sasha Levin <[email protected]>

 
perf/x86/intel/cstate: Add Arrowlake support [+ + +]
Author: Zhang Rui <[email protected]>
Date:   Fri Jun 28 11:17:57 2024 +0800

    perf/x86/intel/cstate: Add Arrowlake support
    
    [ Upstream commit a31000753d41305d2fb7faa8cc80a8edaeb7b56b ]
    
    Like Alderlake, Arrowlake supports CC1/CC6/CC7 and PC2/PC3/PC6/PC8/PC10.
    
    Signed-off-by: Zhang Rui <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Reviewed-by: Kan Liang <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Stable-dep-of: b1d0e15c8725 ("perf/x86/intel/cstate: Add pkg C2 residency counter for Sierra Forest")
    Signed-off-by: Sasha Levin <[email protected]>

perf/x86/intel/cstate: Add Lunarlake support [+ + +]
Author: Zhang Rui <[email protected]>
Date:   Fri Jun 28 11:17:58 2024 +0800

    perf/x86/intel/cstate: Add Lunarlake support
    
    [ Upstream commit 26579860fbd5129e18de9d6fa0751a48420b26b7 ]
    
    Compared with previous client platforms, PC8 is removed from Lunarlake.
    It supports CC1/CC6/CC7 and PC2/PC3/PC6/PC10 residency counters.
    
    Signed-off-by: Zhang Rui <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Reviewed-by: Kan Liang <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Stable-dep-of: b1d0e15c8725 ("perf/x86/intel/cstate: Add pkg C2 residency counter for Sierra Forest")
    Signed-off-by: Sasha Levin <[email protected]>

perf/x86/intel/cstate: Add pkg C2 residency counter for Sierra Forest [+ + +]
Author: Zhenyu Wang <[email protected]>
Date:   Wed Jul 17 11:16:09 2024 +0800

    perf/x86/intel/cstate: Add pkg C2 residency counter for Sierra Forest
    
    [ Upstream commit b1d0e15c8725d21a73c22c099418a63940261041 ]
    
    Package C2 residency counter is also available on Sierra Forest.
    So add it support in srf_cstates.
    
    Fixes: 3877d55a0db2 ("perf/x86/intel/cstate: Add Sierra Forest support")
    Signed-off-by: Zhenyu Wang <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Reviewed-by: Kan Liang <[email protected]>
    Tested-by: Wendy Wang <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
perf/x86/intel: Support the PEBS event mask [+ + +]
Author: Kan Liang <[email protected]>
Date:   Wed Jun 26 07:35:33 2024 -0700

    perf/x86/intel: Support the PEBS event mask
    
    [ Upstream commit a23eb2fc1d818cdac9b31f032842d55483a6a040 ]
    
    The current perf assumes that the counters that support PEBS are
    contiguous. But it's not guaranteed with the new leaf 0x23 introduced.
    The counters are enumerated with a counter mask. There may be holes in
    the counter mask for future platforms or in a virtualization
    environment.
    
    Store the PEBS event mask rather than the maximum number of PEBS
    counters in the x86 PMU structures.
    
    Signed-off-by: Kan Liang <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Reviewed-by: Andi Kleen <[email protected]>
    Reviewed-by: Ian Rogers <[email protected]>
    Link: https://lkml.kernel.org/r/[email protected]
    Stable-dep-of: f73cefa3b72e ("perf/x86: Fix smp_processor_id()-in-preemptible warnings")
    Signed-off-by: Sasha Levin <[email protected]>

 
perf/x86: Fix smp_processor_id()-in-preemptible warnings [+ + +]
Author: Li Huafei <[email protected]>
Date:   Tue Jul 30 06:09:28 2024 +0800

    perf/x86: Fix smp_processor_id()-in-preemptible warnings
    
    [ Upstream commit f73cefa3b72eaa90abfc43bf6d68137ba059d4b1 ]
    
    The following bug was triggered on a system built with
    CONFIG_DEBUG_PREEMPT=y:
    
     # echo p > /proc/sysrq-trigger
    
     BUG: using smp_processor_id() in preemptible [00000000] code: sh/117
     caller is perf_event_print_debug+0x1a/0x4c0
     CPU: 3 UID: 0 PID: 117 Comm: sh Not tainted 6.11.0-rc1 #109
     Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
     Call Trace:
      <TASK>
      dump_stack_lvl+0x4f/0x60
      check_preemption_disabled+0xc8/0xd0
      perf_event_print_debug+0x1a/0x4c0
      __handle_sysrq+0x140/0x180
      write_sysrq_trigger+0x61/0x70
      proc_reg_write+0x4e/0x70
      vfs_write+0xd0/0x430
      ? handle_mm_fault+0xc8/0x240
      ksys_write+0x9c/0xd0
      do_syscall_64+0x96/0x190
      entry_SYSCALL_64_after_hwframe+0x4b/0x53
    
    This is because the commit d4b294bf84db ("perf/x86: Hybrid PMU support
    for counters") took smp_processor_id() outside the irq critical section.
    If a preemption occurs in perf_event_print_debug() and the task is
    migrated to another cpu, we may get incorrect pmu debug information.
    Move smp_processor_id() back inside the irq critical section to fix this
    issue.
    
    Fixes: d4b294bf84db ("perf/x86: Hybrid PMU support for counters")
    Signed-off-by: Li Huafei <[email protected]>
    Reviewed-and-tested-by: K Prateek Nayak <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Reviewed-by: Kan Liang <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

perf/x86: Support counter mask [+ + +]
Author: Kan Liang <[email protected]>
Date:   Wed Jun 26 07:35:34 2024 -0700

    perf/x86: Support counter mask
    
    [ Upstream commit 722e42e45c2f1c6d1adec7813651dba5139f52f4 ]
    
    The current perf assumes that both GP and fixed counters are contiguous.
    But it's not guaranteed on newer Intel platforms or in a virtualization
    environment.
    
    Use the counter mask to replace the number of counters for both GP and
    the fixed counters. For the other ARCHs or old platforms which don't
    support a counter mask, using GENMASK_ULL(num_counter - 1, 0) to
    replace. There is no functional change for them.
    
    The interface to KVM is not changed. The number of counters still be
    passed to KVM. It can be updated later separately.
    
    Signed-off-by: Kan Liang <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Reviewed-by: Andi Kleen <[email protected]>
    Reviewed-by: Ian Rogers <[email protected]>
    Link: https://lkml.kernel.org/r/[email protected]
    Stable-dep-of: f73cefa3b72e ("perf/x86: Fix smp_processor_id()-in-preemptible warnings")
    Signed-off-by: Sasha Levin <[email protected]>

 
platform/chrome: cros_ec_lpc: Add a new quirk for ACPI id [+ + +]
Author: Ben Walsh <[email protected]>
Date:   Wed Jun 5 07:33:49 2024 +0100

    platform/chrome: cros_ec_lpc: Add a new quirk for ACPI id
    
    [ Upstream commit 040159e0912c31fe959d8671f9700bda105ab63a ]
    
    Framework Laptops' ACPI exposes the EC with id "PNP0C09". But
    "PNP0C09" is part of the ACPI standard; there are lots of computers
    with EC chips with this id, and most of them don't support the cros_ec
    protocol.
    
    The driver could find the ACPI device by having "PNP0C09" in the
    acpi_match_table, but this would match devices which don't support the
    cros_ec protocol. Instead, add a new quirk "CROS_EC_LPC_QUIRK_ACPI_ID"
    which allows the id to be specified. This quirk is applied after the
    DMI check shows that the device is supported.
    
    Tested-by: Dustin L. Howett <[email protected]>
    Signed-off-by: Ben Walsh <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Tzung-Bi Shih <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
platform/x86/intel/ifs: Initialize union ifs_status to zero [+ + +]
Author: Kuppuswamy Sathyanarayanan <[email protected]>
Date:   Tue Jul 30 15:59:30 2024 +0000

    platform/x86/intel/ifs: Initialize union ifs_status to zero
    
    [ Upstream commit 3114f77e9453daa292ec0906f313a715c69b5943 ]
    
    If the IFS scan test exits prematurely due to a timeout before
    completing a single run, the union ifs_status remains uninitialized,
    leading to incorrect test status reporting. To prevent this, always
    initialize the union ifs_status to zero.
    
    Fixes: 2b40e654b73a ("platform/x86/intel/ifs: Add scan test support")
    Suggested-by: Ilpo Järvinen <[email protected]>
    Reviewed-by: Jithu Joseph <[email protected]>
    Reviewed-by: Ashok Raj <[email protected]>
    Signed-off-by: Kuppuswamy Sathyanarayanan <[email protected]>
    Link: https://lore.kernel.org/r/20240730155930.1754744-1-sathyanarayanan.kuppuswamy@linux.intel.com
    Reviewed-by: Ilpo Järvinen <[email protected]>
    Signed-off-by: Ilpo Järvinen <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
platform/x86: intel-vbtn: Protect ACPI notify handler against recursion [+ + +]
Author: Hans de Goede <[email protected]>
Date:   Mon Jul 29 14:04:43 2024 +0200

    platform/x86: intel-vbtn: Protect ACPI notify handler against recursion
    
    [ Upstream commit e075c3b13a0a142dcd3151b25d29a24f31b7b640 ]
    
    Since commit e2ffcda16290 ("ACPI: OSL: Allow Notify () handlers to run on
    all CPUs") ACPI notify handlers like the intel-vbtn notify_handler() may
    run on multiple CPU cores racing with themselves.
    
    This race gets hit on Dell Venue 7140 tablets when undocking from
    the keyboard, causing the handler to try and register priv->switches_dev
    twice, as can be seen from the dev_info() message getting logged twice:
    
    [ 83.861800] intel-vbtn INT33D6:00: Registering Intel Virtual Switches input-dev after receiving a switch event
    [ 83.861858] input: Intel Virtual Switches as /devices/pci0000:00/0000:00:1f.0/PNP0C09:00/INT33D6:00/input/input17
    [ 83.861865] intel-vbtn INT33D6:00: Registering Intel Virtual Switches input-dev after receiving a switch event
    
    After which things go seriously wrong:
    [ 83.861872] sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:1f.0/PNP0C09:00/INT33D6:00/input/input17'
    ...
    [ 83.861967] kobject: kobject_add_internal failed for input17 with -EEXIST, don't try to register things with the same name in the same directory.
    [ 83.877338] BUG: kernel NULL pointer dereference, address: 0000000000000018
    ...
    
    Protect intel-vbtn notify_handler() from racing with itself with a mutex
    to fix this.
    
    Fixes: e2ffcda16290 ("ACPI: OSL: Allow Notify () handlers to run on all CPUs")
    Reported-by: En-Wei Wu <[email protected]>
    Closes: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2073001
    Tested-by: Kostadin Stoilov <[email protected]>
    Signed-off-by: Hans de Goede <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Reviewed-by: Ilpo Järvinen <[email protected]>
    Signed-off-by: Ilpo Järvinen <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
power: supply: axp288_charger: Fix constant_charge_voltage writes [+ + +]
Author: Hans de Goede <[email protected]>
Date:   Wed Jul 17 22:03:32 2024 +0200

    power: supply: axp288_charger: Fix constant_charge_voltage writes
    
    commit b34ce4a59cfe9cd0d6f870e6408e8ec88a964585 upstream.
    
    info->max_cv is in millivolts, divide the microvolt value being written
    to constant_charge_voltage by 1000 *before* clamping it to info->max_cv.
    
    Before this fix the code always tried to set constant_charge_voltage
    to max_cv / 1000 = 4 millivolt, which ends up in setting it to 4.1V
    which is the lowest supported value.
    
    Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver")
    Cc: [email protected]
    Signed-off-by: Hans de Goede <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sebastian Reichel <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

power: supply: axp288_charger: Round constant_charge_voltage writes down [+ + +]
Author: Hans de Goede <[email protected]>
Date:   Wed Jul 17 22:03:33 2024 +0200

    power: supply: axp288_charger: Round constant_charge_voltage writes down
    
    commit 81af7f2342d162e24ac820c10e68684d9f927663 upstream.
    
    Round constant_charge_voltage writes down to the first supported lower
    value, rather then rounding them up to the first supported higher value.
    
    This fixes e.g. writing 4250000 resulting in a value of 4350000 which
    might be dangerous, instead writing 4250000 will now result in a safe
    4200000 value.
    
    Fixes: 843735b788a4 ("power: axp288_charger: axp288 charger driver")
    Cc: [email protected]
    Signed-off-by: Hans de Goede <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sebastian Reichel <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

power: supply: qcom_battmgr: return EAGAIN when firmware service is not up [+ + +]
Author: Neil Armstrong <[email protected]>
Date:   Mon Jul 15 14:57:06 2024 +0200

    power: supply: qcom_battmgr: return EAGAIN when firmware service is not up
    
    commit bf9d5cb588755ee41ac12a8976dccf44ae18281b upstream.
    
    The driver returns -ENODEV when the firmware battmrg service hasn't
    started yet, while per-se -ENODEV is fine, we usually use -EAGAIN to
    tell the user to retry again later. And the power supply core uses
    -EGAIN when the device isn't initialized, let's use the same return.
    
    This notably causes an infinite spam of:
    thermal thermal_zoneXX: failed to read out thermal zone (-19)
    because the thermal core doesn't understand -ENODEV, but only
    considers -EAGAIN as a non-fatal error.
    
    While it didn't appear until now, commit [1] fixes thermal core
    and no more ignores thermal zones returning an error at first
    temperature update.
    
    [1] 5725f40698b9 ("thermal: core: Call monitor_thermal_zone() if zone temperature is invalid")
    
    Link: https://lore.kernel.org/all/[email protected]/
    Cc: [email protected]
    Fixes: 29e8142b5623 ("power: supply: Introduce Qualcomm PMIC GLINK power supply")
    Signed-off-by: Neil Armstrong <[email protected]>
    Tested-by: Stephan Gerhold <[email protected]>
    Reviewed-by: Stephan Gerhold <[email protected]>
    Link: https://lore.kernel.org/r/20240715-topic-sm8x50-upstream-fix-battmgr-temp-tz-warn-v1-1-16e842ccead7@linaro.org
    Signed-off-by: Sebastian Reichel <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

power: supply: rt5033: Bring back i2c_set_clientdata [+ + +]
Author: Nikita Travkin <[email protected]>
Date:   Wed Jun 5 18:53:27 2024 +0500

    power: supply: rt5033: Bring back i2c_set_clientdata
    
    [ Upstream commit d3911f1639e67fc7b12aae0efa5a540976d7443b ]
    
    Commit 3a93da231c12 ("power: supply: rt5033: Use devm_power_supply_register() helper")
    reworked the driver to use devm. While at it, the i2c_set_clientdata
    was dropped along with the remove callback. Unfortunately other parts
    of the driver also rely on i2c clientdata so this causes kernel oops.
    
    Bring the call back to fix the driver.
    
    Fixes: 3a93da231c12 ("power: supply: rt5033: Use devm_power_supply_register() helper")
    Tested-by: Raymond Hackley <[email protected]>
    Signed-off-by: Nikita Travkin <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sebastian Reichel <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
profiling: remove profile=sleep support [+ + +]
Author: Tetsuo Handa <[email protected]>
Date:   Sun Aug 4 18:48:10 2024 +0900

    profiling: remove profile=sleep support
    
    commit b88f55389ad27f05ed84af9e1026aa64dbfabc9a upstream.
    
    The kernel sleep profile is no longer working due to a recursive locking
    bug introduced by commit 42a20f86dc19 ("sched: Add wrapper for get_wchan()
    to keep task blocked")
    
    Booting with the 'profile=sleep' kernel command line option added or
    executing
    
      # echo -n sleep > /sys/kernel/profiling
    
    after boot causes the system to lock up.
    
    Lockdep reports
    
      kthreadd/3 is trying to acquire lock:
      ffff93ac82e08d58 (&p->pi_lock){....}-{2:2}, at: get_wchan+0x32/0x70
    
      but task is already holding lock:
      ffff93ac82e08d58 (&p->pi_lock){....}-{2:2}, at: try_to_wake_up+0x53/0x370
    
    with the call trace being
    
       lock_acquire+0xc8/0x2f0
       get_wchan+0x32/0x70
       __update_stats_enqueue_sleeper+0x151/0x430
       enqueue_entity+0x4b0/0x520
       enqueue_task_fair+0x92/0x6b0
       ttwu_do_activate+0x73/0x140
       try_to_wake_up+0x213/0x370
       swake_up_locked+0x20/0x50
       complete+0x2f/0x40
       kthread+0xfb/0x180
    
    However, since nobody noticed this regression for more than two years,
    let's remove 'profile=sleep' support based on the assumption that nobody
    needs this functionality.
    
    Fixes: 42a20f86dc19 ("sched: Add wrapper for get_wchan() to keep task blocked")
    Cc: [email protected] # v5.16+
    Signed-off-by: Tetsuo Handa <[email protected]>
    Signed-off-by: Linus Torvalds <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
rcu: Fix rcu_barrier() VS post CPUHP_TEARDOWN_CPU invocation [+ + +]
Author: Frederic Weisbecker <[email protected]>
Date:   Fri May 24 16:05:24 2024 +0200

    rcu: Fix rcu_barrier() VS post CPUHP_TEARDOWN_CPU invocation
    
    [ Upstream commit 55d4669ef1b76823083caecfab12a8bd2ccdcf64 ]
    
    When rcu_barrier() calls rcu_rdp_cpu_online() and observes a CPU off
    rnp->qsmaskinitnext, it means that all accesses from the offline CPU
    preceding the CPUHP_TEARDOWN_CPU are visible to RCU barrier, including
    callbacks expiration and counter updates.
    
    However interrupts can still fire after stop_machine() re-enables
    interrupts and before rcutree_report_cpu_dead(). The related accesses
    happening between CPUHP_TEARDOWN_CPU and rnp->qsmaskinitnext clearing
    are _NOT_ guaranteed to be seen by rcu_barrier() without proper
    ordering, especially when callbacks are invoked there to the end, making
    rcutree_migrate_callback() bypass barrier_lock.
    
    The following theoretical race example can make rcu_barrier() hang:
    
    CPU 0                                               CPU 1
    -----                                               -----
    //cpu_down()
    smpboot_park_threads()
    //ksoftirqd is parked now
    <IRQ>
    rcu_sched_clock_irq()
       invoke_rcu_core()
    do_softirq()
       rcu_core()
          rcu_do_batch()
             // callback storm
             // rcu_do_batch() returns
             // before completing all
             // of them
       // do_softirq also returns early because of
       // timeout. It defers to ksoftirqd but
       // it's parked
    </IRQ>
    stop_machine()
       take_cpu_down()
                                                        rcu_barrier()
                                                            spin_lock(barrier_lock)
                                                            // observes rcu_segcblist_n_cbs(&rdp->cblist) != 0
    <IRQ>
    do_softirq()
       rcu_core()
          rcu_do_batch()
             //completes all pending callbacks
             //smp_mb() implied _after_ callback number dec
    </IRQ>
    
    rcutree_report_cpu_dead()
       rnp->qsmaskinitnext &= ~rdp->grpmask;
    
    rcutree_migrate_callback()
       // no callback, early return without locking
       // barrier_lock
                                                            //observes !rcu_rdp_cpu_online(rdp)
                                                            rcu_barrier_entrain()
                                                               rcu_segcblist_entrain()
                                                                  // Observe rcu_segcblist_n_cbs(rsclp) == 0
                                                                  // because no barrier between reading
                                                                  // rnp->qsmaskinitnext and rsclp->len
                                                                  rcu_segcblist_add_len()
                                                                     smp_mb__before_atomic()
                                                                     // will now observe the 0 count and empty
                                                                     // list, but too late, we enqueue regardless
                                                                     WRITE_ONCE(rsclp->len, rsclp->len + v);
                                                            // ignored barrier callback
                                                            // rcu barrier stall...
    
    This could be solved with a read memory barrier, enforcing the message
    passing between rnp->qsmaskinitnext and rsclp->len, matching the full
    memory barrier after rsclp->len addition in rcu_segcblist_add_len()
    performed at the end of rcu_do_batch().
    
    However the rcu_barrier() is complicated enough and probably doesn't
    need too many more subtleties. CPU down is a slowpath and the
    barrier_lock seldom contended. Solve the issue with unconditionally
    locking the barrier_lock on rcutree_migrate_callbacks(). This makes sure
    that either rcu_barrier() sees the empty queue or its entrained
    callback will be migrated.
    
    Signed-off-by: Frederic Weisbecker <[email protected]>
    Signed-off-by: Paul E. McKenney <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
rcutorture: Fix rcu_torture_fwd_cb_cr() data race [+ + +]
Author: Paul E. McKenney <[email protected]>
Date:   Fri Apr 5 12:02:11 2024 -0700

    rcutorture: Fix rcu_torture_fwd_cb_cr() data race
    
    [ Upstream commit 6040072f4774a575fa67b912efe7722874be337b ]
    
    On powerpc systems, spinlock acquisition does not order prior stores
    against later loads.  This means that this statement:
    
            rfcp->rfc_next = NULL;
    
    Can be reordered to follow this statement:
    
            WRITE_ONCE(*rfcpp, rfcp);
    
    Which is then a data race with rcu_torture_fwd_prog_cr(), specifically,
    this statement:
    
            rfcpn = READ_ONCE(rfcp->rfc_next)
    
    KCSAN located this data race, which represents a real failure on powerpc.
    
    Signed-off-by: Paul E. McKenney <[email protected]>
    Acked-by: Marco Elver <[email protected]>
    Cc: Andrey Konovalov <[email protected]>
    Cc: <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap() [+ + +]
Author: Richard Fitzgerald <[email protected]>
Date:   Thu Apr 11 11:37:24 2024 +0100

    regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap()
    
    [ Upstream commit c3820641da87442251e0c00b6874ef1022da8f58 ]
    
    - Use kunit_kcalloc() to allocate the defaults table so that it will be
      freed when the test case ends.
    - kfree() the buf and *data buffers on the error paths.
    - Use kunit_add_action_or_reset() instead of kunit_add_action() so that
      if it fails it will call regmap_exit().
    
    Signed-off-by: Richard Fitzgerald <[email protected]>
    Link: https://msgid.link/r/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
Revert "drm/amd/display: Add NULL check for 'afb' before dereferencing in amdgpu_dm_plane_handle_cursor_update" [+ + +]
Author: Ivan Lipski <[email protected]>
Date:   Fri Jun 7 12:33:59 2024 -0400

    Revert "drm/amd/display: Add NULL check for 'afb' before dereferencing in amdgpu_dm_plane_handle_cursor_update"
    
    commit 778e3979c5dc9cbdb5d1b92afed427de6bc483b4 upstream.
    
    [WHY]
    This patch is a dupplicate implementation of 14bcf29b, which we
    are reverting due to a regression with kms_plane_cursor IGT tests.
    
    This reverts commit 38e6f715b02b572f74677eb2f29d3b4bc6f1ddff.
    
    Reviewed-by: Srinivasan Shanmugam <[email protected]>
    Tested-by: George Zhang <[email protected]>
    Signed-off-by: Ivan Lipski <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

Revert "drm/amd/display: Handle HPD_IRQ for internal link" [+ + +]
Author: Sung-huai Wang <[email protected]>
Date:   Fri May 31 15:43:44 2024 +0800

    Revert "drm/amd/display: Handle HPD_IRQ for internal link"
    
    commit a2919b25778b7479e477cf49af8c680017eafc24 upstream.
    
    [How&Why]
    This reverts commit 239b31bd5c3fef3698440bf6436b2068c6bb08a3.
    
    Due to the it effects Replay resync.
    
    Reviewed-by: Wenjing Liu <[email protected]>
    Acked-by: Zaeem Mohamed <[email protected]>
    Signed-off-by: Sung-huai Wang <[email protected]>
    Tested-by: Daniel Wheeler <[email protected]>
    Signed-off-by: Alex Deucher <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
Revert "rcu-tasks: Fix synchronize_rcu_tasks() VS zap_pid_ns_processes()" [+ + +]
Author: Frederic Weisbecker <[email protected]>
Date:   Thu Apr 25 16:24:04 2024 +0200

    Revert "rcu-tasks: Fix synchronize_rcu_tasks() VS zap_pid_ns_processes()"
    
    [ Upstream commit 9855c37edf0009cc276cecfee09f7e76e2380212 ]
    
    This reverts commit 28319d6dc5e2ffefa452c2377dd0f71621b5bff0. The race
    it fixed was subject to conditions that don't exist anymore since:
    
            1612160b9127 ("rcu-tasks: Eliminate deadlocks involving do_exit() and RCU tasks")
    
    This latter commit removes the use of SRCU that used to cover the
    RCU-tasks blind spot on exit between the tasklist's removal and the
    final preemption disabling. The task is now placed instead into a
    temporary list inside which voluntary sleeps are accounted as RCU-tasks
    quiescent states. This would disarm the deadlock initially reported
    against PID namespace exit.
    
    Signed-off-by: Frederic Weisbecker <[email protected]>
    Reviewed-by: Oleg Nesterov <[email protected]>
    Signed-off-by: Paul E. McKenney <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
s390/sclp: Prevent release of buffer in I/O [+ + +]
Author: Peter Oberparleiter <[email protected]>
Date:   Thu Jun 20 14:20:27 2024 +0200

    s390/sclp: Prevent release of buffer in I/O
    
    [ Upstream commit bf365071ea92b9579d5a272679b74052a5643e35 ]
    
    When a task waiting for completion of a Store Data operation is
    interrupted, an attempt is made to halt this operation. If this attempt
    fails due to a hardware or firmware problem, there is a chance that the
    SCLP facility might store data into buffers referenced by the original
    operation at a later time.
    
    Handle this situation by not releasing the referenced data buffers if
    the halt attempt fails. For current use cases, this might result in a
    leak of few pages of memory in case of a rare hardware/firmware
    malfunction.
    
    Reviewed-by: Heiko Carstens <[email protected]>
    Signed-off-by: Peter Oberparleiter <[email protected]>
    Signed-off-by: Alexander Gordeev <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
sched/core: Fix unbalance set_rq_online/offline() in sched_cpu_deactivate() [+ + +]
Author: Yang Yingliang <[email protected]>
Date:   Wed Jul 3 11:16:10 2024 +0800

    sched/core: Fix unbalance set_rq_online/offline() in sched_cpu_deactivate()
    
    commit fe7a11c78d2a9bdb8b50afc278a31ac177000948 upstream.
    
    If cpuset_cpu_inactive() fails, set_rq_online() need be called to rollback.
    
    Fixes: 120455c514f7 ("sched: Fix hotplug vs CPU bandwidth control")
    Cc: [email protected]
    Signed-off-by: Yang Yingliang <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

sched/core: Introduce sched_set_rq_on/offline() helper [+ + +]
Author: Yang Yingliang <[email protected]>
Date:   Wed Jul 3 11:16:09 2024 +0800

    sched/core: Introduce sched_set_rq_on/offline() helper
    
    commit 2f027354122f58ee846468a6f6b48672fff92e9b upstream.
    
    Introduce sched_set_rq_on/offline() helper, so it can be called
    in normal or error path simply. No functional changed.
    
    Cc: [email protected]
    Signed-off-by: Yang Yingliang <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
sched/cputime: Fix mul_u64_u64_div_u64() precision for cputime [+ + +]
Author: Zheng Zucheng <[email protected]>
Date:   Fri Jul 26 02:32:35 2024 +0000

    sched/cputime: Fix mul_u64_u64_div_u64() precision for cputime
    
    commit 77baa5bafcbe1b2a15ef9c37232c21279c95481c upstream.
    
    In extreme test scenarios:
    the 14th field utime in /proc/xx/stat is greater than sum_exec_runtime,
    utime = 18446744073709518790 ns, rtime = 135989749728000 ns
    
    In cputime_adjust() process, stime is greater than rtime due to
    mul_u64_u64_div_u64() precision problem.
    before call mul_u64_u64_div_u64(),
    stime = 175136586720000, rtime = 135989749728000, utime = 1416780000.
    after call mul_u64_u64_div_u64(),
    stime = 135989949653530
    
    unsigned reversion occurs because rtime is less than stime.
    utime = rtime - stime = 135989749728000 - 135989949653530
                          = -199925530
                          = (u64)18446744073709518790
    
    Trigger condition:
      1). User task run in kernel mode most of time
      2). ARM64 architecture
      3). TICK_CPU_ACCOUNTING=y
          CONFIG_VIRT_CPU_ACCOUNTING_NATIVE is not set
    
    Fix mul_u64_u64_div_u64() conversion precision by reset stime to rtime
    
    Fixes: 3dc167ba5729 ("sched/cputime: Improve cputime_adjust()")
    Signed-off-by: Zheng Zucheng <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Cc: <[email protected]>
    Link: https://lkml.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
sched/smt: Fix unbalance sched_smt_present dec/inc [+ + +]
Author: Yang Yingliang <[email protected]>
Date:   Wed Jul 3 11:16:08 2024 +0800

    sched/smt: Fix unbalance sched_smt_present dec/inc
    
    commit e22f910a26cc2a3ac9c66b8e935ef2a7dd881117 upstream.
    
    I got the following warn report while doing stress test:
    
    jump label: negative count!
    WARNING: CPU: 3 PID: 38 at kernel/jump_label.c:263 static_key_slow_try_dec+0x9d/0xb0
    Call Trace:
     <TASK>
     __static_key_slow_dec_cpuslocked+0x16/0x70
     sched_cpu_deactivate+0x26e/0x2a0
     cpuhp_invoke_callback+0x3ad/0x10d0
     cpuhp_thread_fun+0x3f5/0x680
     smpboot_thread_fn+0x56d/0x8d0
     kthread+0x309/0x400
     ret_from_fork+0x41/0x70
     ret_from_fork_asm+0x1b/0x30
     </TASK>
    
    Because when cpuset_cpu_inactive() fails in sched_cpu_deactivate(),
    the cpu offline failed, but sched_smt_present is decremented before
    calling sched_cpu_deactivate(), it leads to unbalanced dec/inc, so
    fix it by incrementing sched_smt_present in the error path.
    
    Fixes: c5511d03ec09 ("sched/smt: Make sched_smt_present track topology")
    Cc: [email protected]
    Signed-off-by: Yang Yingliang <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Reviewed-by: Chen Yu <[email protected]>
    Reviewed-by: Tim Chen <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

sched/smt: Introduce sched_smt_present_inc/dec() helper [+ + +]
Author: Yang Yingliang <[email protected]>
Date:   Wed Jul 3 11:16:07 2024 +0800

    sched/smt: Introduce sched_smt_present_inc/dec() helper
    
    commit 31b164e2e4af84d08d2498083676e7eeaa102493 upstream.
    
    Introduce sched_smt_present_inc/dec() helper, so it can be called
    in normal or error path simply. No functional changed.
    
    Cc: [email protected]
    Signed-off-by: Yang Yingliang <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
scsi: mpi3mr: Avoid IOMMU page faults on REPORT ZONES [+ + +]
Author: Damien Le Moal <[email protected]>
Date:   Fri Jul 19 16:39:11 2024 +0900

    scsi: mpi3mr: Avoid IOMMU page faults on REPORT ZONES
    
    commit 1abc900ddda8ad2ef739fedf498d415655b6c3b8 upstream.
    
    Some firmware versions of the 9600 series SAS HBA byte-swap the REPORT
    ZONES command reply buffer from ATA-ZAC devices by directly accessing the
    buffer in the host memory. This does not respect the default command DMA
    direction and causes IOMMU page faults on architectures with an IOMMU
    enforcing write-only mappings for DMA_FROM_DEVICE DMA direction (e.g. AMD
    hosts), leading to the device capacity to be dropped to 0:
    
    scsi 18:0:58:0: Direct-Access-ZBC ATA      WDC  WSH722626AL W930 PQ: 0 ANSI: 7
    scsi 18:0:58:0: Power-on or device reset occurred
    sd 18:0:58:0: Attached scsi generic sg9 type 20
    sd 18:0:58:0: [sdj] Host-managed zoned block device
    mpi3mr 0000:c1:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xfec0c400 flags=0x0050]
    mpi3mr 0000:c1:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0001 address=0xfec0c500 flags=0x0050]
    sd 18:0:58:0: [sdj] REPORT ZONES start lba 0 failed
    sd 18:0:58:0: [sdj] REPORT ZONES: Result: hostbyte=DID_SOFT_ERROR driverbyte=DRIVER_OK
    sd 18:0:58:0: [sdj] 0 4096-byte logical blocks: (0 B/0 B)
    sd 18:0:58:0: [sdj] Write Protect is off
    sd 18:0:58:0: [sdj] Mode Sense: 6b 00 10 08
    sd 18:0:58:0: [sdj] Write cache: enabled, read cache: enabled, supports DPO and FUA
    sd 18:0:58:0: [sdj] Attached SCSI disk
    
    Avoid this issue by always mapping the buffer of REPORT ZONES commands
    using DMA_BIDIRECTIONAL, that is, using a read-write IOMMU mapping.
    
    Suggested-by: Christoph Hellwig <[email protected]>
    Fixes: 023ab2a9b4ed ("scsi: mpi3mr: Add support for queue command processing")
    Cc: [email protected]
    Signed-off-by: Damien Le Moal <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Reviewed-by: Christoph Hellwig <[email protected]>
    Reviewed-by: Johannes Thumshirn <[email protected]>
    Signed-off-by: Martin K. Petersen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

scsi: mpt3sas: Avoid IOMMU page faults on REPORT ZONES [+ + +]
Author: Damien Le Moal <[email protected]>
Date:   Fri Jul 19 16:39:12 2024 +0900

    scsi: mpt3sas: Avoid IOMMU page faults on REPORT ZONES
    
    commit 82dbb57ac8d06dfe8227ba9ab11a49de2b475ae5 upstream.
    
    Some firmware versions of the 9600 series SAS HBA byte-swap the REPORT
    ZONES command reply buffer from ATA-ZAC devices by directly accessing the
    buffer in the host memory. This does not respect the default command DMA
    direction and causes IOMMU page faults on architectures with an IOMMU
    enforcing write-only mappings for DMA_FROM_DEVICE DMA driection (e.g. AMD
    hosts).
    
    scsi 18:0:0:0: Direct-Access-ZBC ATA      WDC  WSH722020AL W870 PQ: 0 ANSI: 6
    scsi 18:0:0:0: SATA: handle(0x0027), sas_addr(0x300062b2083e7c40), phy(0), device_name(0x5000cca29dc35e11)
    scsi 18:0:0:0: enclosure logical id (0x300062b208097c40), slot(0)
    scsi 18:0:0:0: enclosure level(0x0000), connector name( C0.0)
    scsi 18:0:0:0: atapi(n), ncq(y), asyn_notify(n), smart(y), fua(y), sw_preserve(y)
    scsi 18:0:0:0: qdepth(32), tagged(1), scsi_level(7), cmd_que(1)
    sd 18:0:0:0: Attached scsi generic sg2 type 20
    sd 18:0:0:0: [sdc] Host-managed zoned block device
    mpt3sas 0000:41:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0021 address=0xfff9b200 flags=0x0050]
    mpt3sas 0000:41:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0021 address=0xfff9b300 flags=0x0050]
    mpt3sas_cm0: mpt3sas_ctl_pre_reset_handler: Releasing the trace buffer due to adapter reset.
    mpt3sas_cm0 fault info from func: mpt3sas_base_make_ioc_ready
    mpt3sas_cm0: fault_state(0x2666)!
    mpt3sas_cm0: sending diag reset !!
    mpt3sas_cm0: diag reset: SUCCESS
    sd 18:0:0:0: [sdc] REPORT ZONES start lba 0 failed
    sd 18:0:0:0: [sdc] REPORT ZONES: Result: hostbyte=DID_RESET driverbyte=DRIVER_OK
    sd 18:0:0:0: [sdc] 0 4096-byte logical blocks: (0 B/0 B)
    
    Avoid such issue by always mapping the buffer of REPORT ZONES commands
    using DMA_BIDIRECTIONAL (read+write IOMMU mapping). This is done by
    introducing the helper function _base_scsi_dma_map() and using this helper
    in _base_build_sg_scmd() and _base_build_sg_scmd_ieee() instead of calling
    directly scsi_dma_map().
    
    Fixes: 471ef9d4e498 ("mpt3sas: Build MPI SGL LIST on GEN2 HBAs and IEEE SGL LIST on GEN3 HBAs")
    Cc: [email protected]
    Signed-off-by: Damien Le Moal <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Reviewed-by: Christoph Hellwig <[email protected]>
    Reviewed-by: Johannes Thumshirn <[email protected]>
    Signed-off-by: Martin K. Petersen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

scsi: Revert "scsi: sd: Do not repeat the starting disk message" [+ + +]
Author: Johan Hovold <[email protected]>
Date:   Tue Jul 16 18:11:01 2024 +0200

    scsi: Revert "scsi: sd: Do not repeat the starting disk message"
    
    commit da3e19ef0b3de0aa4b25595bdc214c02a04f19b8 upstream.
    
    This reverts commit 7a6bbc2829d4ab592c7e440a6f6f5deb3cd95db4.
    
    The offending commit tried to suppress a double "Starting disk" message for
    some drivers, but instead started spamming the log with bogus messages
    every five seconds:
    
            [  311.798956] sd 0:0:0:0: [sda] Starting disk
            [  316.919103] sd 0:0:0:0: [sda] Starting disk
            [  322.040775] sd 0:0:0:0: [sda] Starting disk
            [  327.161140] sd 0:0:0:0: [sda] Starting disk
            [  332.281352] sd 0:0:0:0: [sda] Starting disk
            [  337.401878] sd 0:0:0:0: [sda] Starting disk
            [  342.521527] sd 0:0:0:0: [sda] Starting disk
            [  345.850401] sd 0:0:0:0: [sda] Starting disk
            [  350.967132] sd 0:0:0:0: [sda] Starting disk
            [  356.090454] sd 0:0:0:0: [sda] Starting disk
            ...
    
    on machines that do not actually stop the disk on runtime suspend (e.g.
    the Qualcomm sc8280xp CRD with UFS).
    
    Let's just revert for now to address the regression.
    
    Fixes: 7a6bbc2829d4 ("scsi: sd: Do not repeat the starting disk message")
    Cc: [email protected]
    Signed-off-by: Johan Hovold <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Reviewed-by: Bart Van Assche <[email protected]>
    Reviewed-by: Damien Le Moal <[email protected]>
    Signed-off-by: Martin K. Petersen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

scsi: ufs: core: Do not set link to OFF state while waking up from hibernation [+ + +]
Author: Manivannan Sadhasivam <[email protected]>
Date:   Thu Jul 18 22:36:59 2024 +0530

    scsi: ufs: core: Do not set link to OFF state while waking up from hibernation
    
    commit ac6efb12ca64156f4a94e964acdb96ee7d59630d upstream.
    
    UFS link is just put into hibern8 state during the 'freeze' process of the
    hibernation. Afterwards, the system may get powered down. But that doesn't
    matter during wakeup. Because during wakeup from hibernation, UFS link is
    again put into hibern8 state by the restore kernel and then the control is
    handed over to the to image kernel.
    
    So in both the places, UFS link is never turned OFF. But
    ufshcd_system_restore() just assumes that the link will be in OFF state and
    sets the link state accordingly. And this breaks hibernation wakeup:
    
    [ 2445.371335] phy phy-1d87000.phy.3: phy_power_on was called before phy_init
    [ 2445.427883] ufshcd-qcom 1d84000.ufshc: Controller enable failed
    [ 2445.427890] ufshcd-qcom 1d84000.ufshc: ufshcd_host_reset_and_restore: Host init failed -5
    [ 2445.427906] ufs_device_wlun 0:0:0:49488: ufshcd_wl_resume failed: -5
    [ 2445.427918] ufs_device_wlun 0:0:0:49488: PM: dpm_run_callback(): scsi_bus_restore returns -5
    [ 2445.427973] ufs_device_wlun 0:0:0:49488: PM: failed to restore async: error -5
    
    So fix the issue by removing the code that sets the link to OFF state.
    
    Cc: Anjana Hari <[email protected]>
    Cc: [email protected] # 6.3
    Fixes: 88441a8d355d ("scsi: ufs: core: Add hibernation callbacks")
    Signed-off-by: Manivannan Sadhasivam <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Reviewed-by: Bart Van Assche <[email protected]>
    Signed-off-by: Martin K. Petersen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

scsi: ufs: core: Fix deadlock during RTC update [+ + +]
Author: Peter Wang <[email protected]>
Date:   Mon Jul 15 14:38:31 2024 +0800

    scsi: ufs: core: Fix deadlock during RTC update
    
    commit 3911af778f208e5f49d43ce739332b91e26bc48e upstream.
    
    There is a deadlock when runtime suspend waits for the flush of RTC work,
    and the RTC work calls ufshcd_rpm_get_sync() to wait for runtime resume.
    
    Here is deadlock backtrace:
    
    kworker/0:1     D 4892.876354 10 10971 4859 0x4208060 0x8 10 0 120 670730152367
    ptr            f0ffff80c2e40000 0 1 0x00000001 0x000000ff 0x000000ff 0x000000ff
    <ffffffee5e71ddb0> __switch_to+0x1a8/0x2d4
    <ffffffee5e71e604> __schedule+0x684/0xa98
    <ffffffee5e71ea60> schedule+0x48/0xc8
    <ffffffee5e725f78> schedule_timeout+0x48/0x170
    <ffffffee5e71fb74> do_wait_for_common+0x108/0x1b0
    <ffffffee5e71efe0> wait_for_completion+0x44/0x60
    <ffffffee5d6de968> __flush_work+0x39c/0x424
    <ffffffee5d6decc0> __cancel_work_sync+0xd8/0x208
    <ffffffee5d6dee2c> cancel_delayed_work_sync+0x14/0x28
    <ffffffee5e2551b8> __ufshcd_wl_suspend+0x19c/0x480
    <ffffffee5e255fb8> ufshcd_wl_runtime_suspend+0x3c/0x1d4
    <ffffffee5dffd80c> scsi_runtime_suspend+0x78/0xc8
    <ffffffee5df93580> __rpm_callback+0x94/0x3e0
    <ffffffee5df90b0c> rpm_suspend+0x2d4/0x65c
    <ffffffee5df91448> __pm_runtime_suspend+0x80/0x114
    <ffffffee5dffd95c> scsi_runtime_idle+0x38/0x6c
    <ffffffee5df912f4> rpm_idle+0x264/0x338
    <ffffffee5df90f14> __pm_runtime_idle+0x80/0x110
    <ffffffee5e24ce44> ufshcd_rtc_work+0x128/0x1e4
    <ffffffee5d6e3a40> process_one_work+0x26c/0x650
    <ffffffee5d6e65c8> worker_thread+0x260/0x3d8
    <ffffffee5d6edec8> kthread+0x110/0x134
    <ffffffee5d616b18> ret_from_fork+0x10/0x20
    
    Skip updating RTC if RPM state is not RPM_ACTIVE.
    
    Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
    Cc: [email protected] # 6.9.x
    Signed-off-by: Peter Wang <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Reviewed-by: Bean Huo <[email protected]>
    Reviewed-by: Bart Van Assche <[email protected]>
    Signed-off-by: Martin K. Petersen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic [+ + +]
Author: Vamshi Gajjela <[email protected]>
Date:   Wed Jul 24 19:21:26 2024 +0530

    scsi: ufs: core: Fix hba->last_dme_cmd_tstamp timestamp updating logic
    
    commit ab9fd06cb8f0db0854291833fc40c789e43a361f upstream.
    
    The ufshcd_add_delay_before_dme_cmd() always introduces a delay of
    MIN_DELAY_BEFORE_DME_CMDS_US between DME commands even when it's not
    required. The delay is added when the UFS host controller supplies the
    quirk UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS.
    
    Fix the logic to update hba->last_dme_cmd_tstamp to ensure subsequent DME
    commands have the correct delay in the range of 0 to
    MIN_DELAY_BEFORE_DME_CMDS_US.
    
    Update the timestamp at the end of the function to ensure it captures the
    latest time after any necessary delay has been applied.
    
    Signed-off-by: Vamshi Gajjela <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Fixes: cad2e03d8607 ("ufs: add support to allow non standard behaviours (quirks)")
    Cc: [email protected]
    Reviewed-by: Bart Van Assche <[email protected]>
    Signed-off-by: Martin K. Petersen <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
sctp: Fix null-ptr-deref in reuseport_add_sock(). [+ + +]
Author: Kuniyuki Iwashima <[email protected]>
Date:   Wed Jul 31 16:46:24 2024 -0700

    sctp: Fix null-ptr-deref in reuseport_add_sock().
    
    [ Upstream commit 9ab0faa7f9ffe31296dbb9bbe6f76c72c14eea18 ]
    
    syzbot reported a null-ptr-deref while accessing sk2->sk_reuseport_cb in
    reuseport_add_sock(). [0]
    
    The repro first creates a listener with SO_REUSEPORT.  Then, it creates
    another listener on the same port and concurrently closes the first
    listener.
    
    The second listen() calls reuseport_add_sock() with the first listener as
    sk2, where sk2->sk_reuseport_cb is not expected to be cleared concurrently,
    but the close() does clear it by reuseport_detach_sock().
    
    The problem is SCTP does not properly synchronise reuseport_alloc(),
    reuseport_add_sock(), and reuseport_detach_sock().
    
    The caller of reuseport_alloc() and reuseport_{add,detach}_sock() must
    provide synchronisation for sockets that are classified into the same
    reuseport group.
    
    Otherwise, such sockets form multiple identical reuseport groups, and
    all groups except one would be silently dead.
    
      1. Two sockets call listen() concurrently
      2. No socket in the same group found in sctp_ep_hashtable[]
      3. Two sockets call reuseport_alloc() and form two reuseport groups
      4. Only one group hit first in __sctp_rcv_lookup_endpoint() receives
          incoming packets
    
    Also, the reported null-ptr-deref could occur.
    
    TCP/UDP guarantees that would not happen by holding the hash bucket lock.
    
    Let's apply the locking strategy to __sctp_hash_endpoint() and
    __sctp_unhash_endpoint().
    
    [0]:
    Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN PTI
    KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
    CPU: 1 UID: 0 PID: 10230 Comm: syz-executor119 Not tainted 6.10.0-syzkaller-12585-g301927d2d2eb #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
    RIP: 0010:reuseport_add_sock+0x27e/0x5e0 net/core/sock_reuseport.c:350
    Code: 00 0f b7 5d 00 bf 01 00 00 00 89 de e8 1b a4 ff f7 83 fb 01 0f 85 a3 01 00 00 e8 6d a0 ff f7 49 8d 7e 12 48 89 f8 48 c1 e8 03 <42> 0f b6 04 28 84 c0 0f 85 4b 02 00 00 41 0f b7 5e 12 49 8d 7e 14
    RSP: 0018:ffffc9000b947c98 EFLAGS: 00010202
    RAX: 0000000000000002 RBX: ffff8880252ddf98 RCX: ffff888079478000
    RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000012
    RBP: 0000000000000001 R08: ffffffff8993e18d R09: 1ffffffff1fef385
    R10: dffffc0000000000 R11: fffffbfff1fef386 R12: ffff8880252ddac0
    R13: dffffc0000000000 R14: 0000000000000000 R15: 0000000000000000
    FS:  00007f24e45b96c0(0000) GS:ffff8880b9300000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007ffcced5f7b8 CR3: 00000000241be000 CR4: 00000000003506f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
     DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     <TASK>
     __sctp_hash_endpoint net/sctp/input.c:762 [inline]
     sctp_hash_endpoint+0x52a/0x600 net/sctp/input.c:790
     sctp_listen_start net/sctp/socket.c:8570 [inline]
     sctp_inet_listen+0x767/0xa20 net/sctp/socket.c:8625
     __sys_listen_socket net/socket.c:1883 [inline]
     __sys_listen+0x1b7/0x230 net/socket.c:1894
     __do_sys_listen net/socket.c:1902 [inline]
     __se_sys_listen net/socket.c:1900 [inline]
     __x64_sys_listen+0x5a/0x70 net/socket.c:1900
     do_syscall_x64 arch/x86/entry/common.c:52 [inline]
     do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
     entry_SYSCALL_64_after_hwframe+0x77/0x7f
    RIP: 0033:0x7f24e46039b9
    Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 91 1a 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
    RSP: 002b:00007f24e45b9228 EFLAGS: 00000246 ORIG_RAX: 0000000000000032
    RAX: ffffffffffffffda RBX: 00007f24e468e428 RCX: 00007f24e46039b9
    RDX: 00007f24e46039b9 RSI: 0000000000000003 RDI: 0000000000000004
    RBP: 00007f24e468e420 R08: 00007f24e45b96c0 R09: 00007f24e45b96c0
    R10: 00007f24e45b96c0 R11: 0000000000000246 R12: 00007f24e468e42c
    R13: 00007f24e465a5dc R14: 0020000000000001 R15: 00007ffcced5f7d8
     </TASK>
    Modules linked in:
    
    Fixes: 6ba845740267 ("sctp: process sk_reuseport in sctp_get_port_local")
    Reported-by: [email protected]
    Closes: https://syzkaller.appspot.com/bug?extid=e6979a5d2f10ecb700e4
    Tested-by: [email protected]
    Signed-off-by: Kuniyuki Iwashima <[email protected]>
    Acked-by: Xin Long <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
selftests/bpf: Fix send_signal test with nested CONFIG_PARAVIRT [+ + +]
Author: Yonghong Song <[email protected]>
Date:   Wed Jun 5 13:12:03 2024 -0700

    selftests/bpf: Fix send_signal test with nested CONFIG_PARAVIRT
    
    [ Upstream commit 7015843afcaf68c132784c89528dfddc0005e483 ]
    
    Alexei reported that send_signal test may fail with nested CONFIG_PARAVIRT
    configs. In this particular case, the base VM is AMD with 166 cpus, and I
    run selftests with regular qemu on top of that and indeed send_signal test
    failed. I also tried with an Intel box with 80 cpus and there is no issue.
    
    The main qemu command line includes:
    
      -enable-kvm -smp 16 -cpu host
    
    The failure log looks like:
    
      $ ./test_progs -t send_signal
      [   48.501588] watchdog: BUG: soft lockup - CPU#9 stuck for 26s! [test_progs:2225]
      [   48.503622] Modules linked in: bpf_testmod(O)
      [   48.503622] CPU: 9 PID: 2225 Comm: test_progs Tainted: G           O       6.9.0-08561-g2c1713a8f1c9-dirty #69
      [   48.507629] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014
      [   48.511635] RIP: 0010:handle_softirqs+0x71/0x290
      [   48.511635] Code: [...] 10 0a 00 00 00 31 c0 65 66 89 05 d5 f4 fa 7e fb bb ff ff ff ff <49> c7 c2 cb
      [   48.518527] RSP: 0018:ffffc90000310fa0 EFLAGS: 00000246
      [   48.519579] RAX: 0000000000000000 RBX: 00000000ffffffff RCX: 00000000000006e0
      [   48.522526] RDX: 0000000000000006 RSI: ffff88810791ae80 RDI: 0000000000000000
      [   48.523587] RBP: ffffc90000fabc88 R08: 00000005a0af4f7f R09: 0000000000000000
      [   48.525525] R10: 0000000561d2f29c R11: 0000000000006534 R12: 0000000000000280
      [   48.528525] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
      [   48.528525] FS:  00007f2f2885cd00(0000) GS:ffff888237c40000(0000) knlGS:0000000000000000
      [   48.531600] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   48.535520] CR2: 00007f2f287059f0 CR3: 0000000106a28002 CR4: 00000000003706f0
      [   48.537538] Call Trace:
      [   48.537538]  <IRQ>
      [   48.537538]  ? watchdog_timer_fn+0x1cd/0x250
      [   48.539590]  ? lockup_detector_update_enable+0x50/0x50
      [   48.539590]  ? __hrtimer_run_queues+0xff/0x280
      [   48.542520]  ? hrtimer_interrupt+0x103/0x230
      [   48.544524]  ? __sysvec_apic_timer_interrupt+0x4f/0x140
      [   48.545522]  ? sysvec_apic_timer_interrupt+0x3a/0x90
      [   48.547612]  ? asm_sysvec_apic_timer_interrupt+0x1a/0x20
      [   48.547612]  ? handle_softirqs+0x71/0x290
      [   48.547612]  irq_exit_rcu+0x63/0x80
      [   48.551585]  sysvec_apic_timer_interrupt+0x75/0x90
      [   48.552521]  </IRQ>
      [   48.553529]  <TASK>
      [   48.553529]  asm_sysvec_apic_timer_interrupt+0x1a/0x20
      [   48.555609] RIP: 0010:finish_task_switch.isra.0+0x90/0x260
      [   48.556526] Code: [...] 9f 58 0a 00 00 48 85 db 0f 85 89 01 00 00 4c 89 ff e8 53 d9 bd 00 fb 66 90 <4d> 85 ed 74
      [   48.562524] RSP: 0018:ffffc90000fabd38 EFLAGS: 00000282
      [   48.563589] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff83385620
      [   48.563589] RDX: ffff888237c73ae4 RSI: 0000000000000000 RDI: ffff888237c6fd00
      [   48.568521] RBP: ffffc90000fabd68 R08: 0000000000000000 R09: 0000000000000000
      [   48.569528] R10: 0000000000000001 R11: 0000000000000000 R12: ffff8881009d0000
      [   48.573525] R13: ffff8881024e5400 R14: ffff88810791ae80 R15: ffff888237c6fd00
      [   48.575614]  ? finish_task_switch.isra.0+0x8d/0x260
      [   48.576523]  __schedule+0x364/0xac0
      [   48.577535]  schedule+0x2e/0x110
      [   48.578555]  pipe_read+0x301/0x400
      [   48.579589]  ? destroy_sched_domains_rcu+0x30/0x30
      [   48.579589]  vfs_read+0x2b3/0x2f0
      [   48.579589]  ksys_read+0x8b/0xc0
      [   48.583590]  do_syscall_64+0x3d/0xc0
      [   48.583590]  entry_SYSCALL_64_after_hwframe+0x4b/0x53
      [   48.586525] RIP: 0033:0x7f2f28703fa1
      [   48.587592] Code: [...] 00 00 00 0f 1f 44 00 00 f3 0f 1e fa 80 3d c5 23 14 00 00 74 13 31 c0 0f 05 <48> 3d 00 f0
      [   48.593534] RSP: 002b:00007ffd90f8cf88 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
      [   48.595589] RAX: ffffffffffffffda RBX: 00007ffd90f8d5e8 RCX: 00007f2f28703fa1
      [   48.595589] RDX: 0000000000000001 RSI: 00007ffd90f8cfb0 RDI: 0000000000000006
      [   48.599592] RBP: 00007ffd90f8d2f0 R08: 0000000000000064 R09: 0000000000000000
      [   48.602527] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      [   48.603589] R13: 00007ffd90f8d608 R14: 00007f2f288d8000 R15: 0000000000f6bdb0
      [   48.605527]  </TASK>
    
    In the test, two processes are communicating through pipe. Further debugging
    with strace found that the above splat is triggered as read() syscall could
    not receive the data even if the corresponding write() syscall in another
    process successfully wrote data into the pipe.
    
    The failed subtest is "send_signal_perf". The corresponding perf event has
    sample_period 1 and config PERF_COUNT_SW_CPU_CLOCK. sample_period 1 means every
    overflow event will trigger a call to the BPF program. So I suspect this may
    overwhelm the system. So I increased the sample_period to 100,000 and the test
    passed. The sample_period 10,000 still has the test failed.
    
    In other parts of selftest, e.g., [1], sample_freq is used instead. So I
    decided to use sample_freq = 1,000 since the test can pass as well.
    
      [1] https://lore.kernel.org/bpf/[email protected]/
    
    Reported-by: Alexei Starovoitov <[email protected]>
    Signed-off-by: Yonghong Song <[email protected]>
    Signed-off-by: Daniel Borkmann <[email protected]>
    Link: https://lore.kernel.org/bpf/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
selftests: ksft: Fix finished() helper exit code on skipped tests [+ + +]
Author: Laura Nao <[email protected]>
Date:   Tue Jul 30 12:29:28 2024 +0200

    selftests: ksft: Fix finished() helper exit code on skipped tests
    
    [ Upstream commit 170c966cbe274e664288cfc12ee919d5e706dc50 ]
    
    The Python finished() helper currently exits with KSFT_FAIL when there
    are only passed and skipped tests. Fix the logic to exit with KSFT_PASS
    instead, making it consistent with its C and bash counterparts
    (ksft_finished() and ktap_finished() respectively).
    
    Reviewed-by: Nícolas F. R. A. Prado <[email protected]>
    Fixes: dacf1d7a78bf ("kselftest: Add test to verify probe of devices from discoverable buses")
    Signed-off-by: Laura Nao <[email protected]>
    Reviewed-by: Muhammad Usama Anjum <[email protected]>
    Signed-off-by: Shuah Khan <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

selftests: mm: add s390 to ARCH check [+ + +]
Author: Nico Pache <[email protected]>
Date:   Wed Jul 24 15:35:17 2024 -0600

    selftests: mm: add s390 to ARCH check
    
    commit 30b651c8bc788c068a978dc760e9d5f824f7019e upstream.
    
    commit 0518dbe97fe6 ("selftests/mm: fix cross compilation with LLVM")
    changed the env variable for the architecture from MACHINE to ARCH.
    
    This is preventing 3 required TEST_GEN_FILES from being included when
    cross compiling s390x and errors when trying to run the test suite.  This
    is due to the ARCH variable already being set and the arch folder name
    being s390.
    
    Add "s390" to the filtered list to cover this case and have the 3 files
    included in the build.
    
    Link: https://lkml.kernel.org/r/[email protected]
    Fixes: 0518dbe97fe6 ("selftests/mm: fix cross compilation with LLVM")
    Signed-off-by: Nico Pache <[email protected]>
    Cc: Mark Brown <[email protected]>
    Cc: Albert Ou <[email protected]>
    Cc: Palmer Dabbelt <[email protected]>
    Cc: Paul Walmsley <[email protected]>
    Cc: Shuah Khan <[email protected]>
    Cc: <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

selftests: mptcp: join: ability to invert ADD_ADDR check [+ + +]
Author: Matthieu Baerts (NGI0) <[email protected]>
Date:   Mon Aug 12 17:02:18 2024 +0200

    selftests: mptcp: join: ability to invert ADD_ADDR check
    
    commit bec1f3b119ebc613d08dfbcdbaef01a79aa7de92 upstream.
    
    In the following commit, the client will initiate the ADD_ADDR, instead
    of the server. We need to way to verify the ADD_ADDR have been correctly
    sent.
    
    Note: the default expected counters for when the port number is given
    are never changed by the caller, no need to accept them as parameter
    then.
    
    The 'Fixes' tag here below is the same as the one from the previous
    commit: this patch here is not fixing anything wrong in the selftests,
    but it validates the previous fix for an issue introduced by this commit
    ID.
    
    Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk")
    Reviewed-by: Mat Martineau <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Link: https://patch.msgid.link/20240731-upstream-net-20240731-mptcp-endp-subflow-signal-v1-6-c8a9b036493b@kernel.org
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

selftests: mptcp: join: test both signal & subflow [+ + +]
Author: Matthieu Baerts (NGI0) <[email protected]>
Date:   Mon Aug 12 17:02:19 2024 +0200

    selftests: mptcp: join: test both signal & subflow
    
    commit 4d2868b5d191c74262f7407972d68d1bf3245d6a upstream.
    
    It should be quite uncommon to set both the subflow and the signal
    flags: the initiator of the connection is typically the one creating new
    subflows, not the other peer, then no need to announce additional local
    addresses, and use it to create subflows.
    
    But some people might be confused about the flags, and set both "just to
    be sure at least the right one is set". To verify the previous fix, and
    avoid future regressions, this specific case is now validated: the
    client announces a new address, and initiates a new subflow from the
    same address.
    
    While working on this, another bug has been noticed, where the client
    reset the new subflow because an ADD_ADDR echo got received as the 3rd
    ACK: this new test also explicitly checks that no RST have been sent by
    the client and server.
    
    The 'Fixes' tag here below is the same as the one from the previous
    commit: this patch here is not fixing anything wrong in the selftests,
    but it validates the previous fix for an issue introduced by this commit
    ID.
    
    Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk")
    Reviewed-by: Mat Martineau <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Link: https://patch.msgid.link/20240731-upstream-net-20240731-mptcp-endp-subflow-signal-v1-7-c8a9b036493b@kernel.org
    Signed-off-by: Jakub Kicinski <[email protected]>
    Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
serial: core: check uartclk for zero to avoid divide by zero [+ + +]
Author: George Kennedy <[email protected]>
Date:   Wed Jul 17 07:24:38 2024 -0500

    serial: core: check uartclk for zero to avoid divide by zero
    
    commit 6eabce6608d6f3440f4c03aa3d3ef50a47a3d193 upstream.
    
    Calling ioctl TIOCSSERIAL with an invalid baud_base can
    result in uartclk being zero, which will result in a
    divide by zero error in uart_get_divisor(). The check for
    uartclk being zero in uart_set_info() needs to be done
    before other settings are made as subsequent calls to
    ioctl TIOCSSERIAL for the same port would be impacted if
    the uartclk check was done where uartclk gets set.
    
    Oops: divide error: 0000  PREEMPT SMP KASAN PTI
    RIP: 0010:uart_get_divisor (drivers/tty/serial/serial_core.c:580)
    Call Trace:
     <TASK>
    serial8250_get_divisor (drivers/tty/serial/8250/8250_port.c:2576
        drivers/tty/serial/8250/8250_port.c:2589)
    serial8250_do_set_termios (drivers/tty/serial/8250/8250_port.c:502
        drivers/tty/serial/8250/8250_port.c:2741)
    serial8250_set_termios (drivers/tty/serial/8250/8250_port.c:2862)
    uart_change_line_settings (./include/linux/spinlock.h:376
        ./include/linux/serial_core.h:608 drivers/tty/serial/serial_core.c:222)
    uart_port_startup (drivers/tty/serial/serial_core.c:342)
    uart_startup (drivers/tty/serial/serial_core.c:368)
    uart_set_info (drivers/tty/serial/serial_core.c:1034)
    uart_set_info_user (drivers/tty/serial/serial_core.c:1059)
    tty_set_serial (drivers/tty/tty_io.c:2637)
    tty_ioctl (drivers/tty/tty_io.c:2647 drivers/tty/tty_io.c:2791)
    __x64_sys_ioctl (fs/ioctl.c:52 fs/ioctl.c:907
        fs/ioctl.c:893 fs/ioctl.c:893)
    do_syscall_64 (arch/x86/entry/common.c:52
        (discriminator 1) arch/x86/entry/common.c:83 (discriminator 1))
    entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
    
    Reported-by: syzkaller <[email protected]>
    Cc: [email protected]
    Signed-off-by: George Kennedy <[email protected]>
    Rule: add
    Link: https://lore.kernel.org/stable/1721148848-9784-1-git-send-email-george.kennedy%40oracle.com
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

serial: sc16is7xx: fix invalid FIFO access with special register set [+ + +]
Author: Hugo Villeneuve <[email protected]>
Date:   Tue Jul 23 08:53:01 2024 -0400

    serial: sc16is7xx: fix invalid FIFO access with special register set
    
    commit 7d3b793faaab1305994ce568b59d61927235f57b upstream.
    
    When enabling access to the special register set, Receiver time-out and
    RHR interrupts can happen. In this case, the IRQ handler will try to read
    from the FIFO thru the RHR register at address 0x00, but address 0x00 is
    mapped to DLL register, resulting in erroneous FIFO reading.
    
    Call graph example:
        sc16is7xx_startup(): entry
        sc16is7xx_ms_proc(): entry
        sc16is7xx_set_termios(): entry
        sc16is7xx_set_baud(): DLH/DLL = $009C --> access special register set
        sc16is7xx_port_irq() entry            --> IIR is 0x0C
        sc16is7xx_handle_rx() entry
        sc16is7xx_fifo_read(): --> unable to access FIFO (RHR) because it is
                                   mapped to DLL (LCR=LCR_CONF_MODE_A)
        sc16is7xx_set_baud(): exit --> Restore access to general register set
    
    Fix the problem by claiming the efr_lock mutex when accessing the Special
    register set.
    
    Fixes: dfeae619d781 ("serial: sc16is7xx")
    Cc: [email protected]
    Signed-off-by: Hugo Villeneuve <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

serial: sc16is7xx: fix TX fifo corruption [+ + +]
Author: Hugo Villeneuve <[email protected]>
Date:   Tue Jul 23 08:53:00 2024 -0400

    serial: sc16is7xx: fix TX fifo corruption
    
    commit 133f4c00b8b2bfcacead9b81e7e8edfceb4b06c4 upstream.
    
    Sometimes, when a packet is received on channel A at almost the same time
    as a packet is about to be transmitted on channel B, we observe with a
    logic analyzer that the received packet on channel A is transmitted on
    channel B. In other words, the Tx buffer data on channel B is corrupted
    with data from channel A.
    
    The problem appeared since commit 4409df5866b7 ("serial: sc16is7xx: change
    EFR lock to operate on each channels"), which changed the EFR locking to
    operate on each channel instead of chip-wise.
    
    This commit has introduced a regression, because the EFR lock is used not
    only to protect the EFR registers access, but also, in a very obscure and
    undocumented way, to protect access to the data buffer, which is shared by
    the Tx and Rx handlers, but also by each channel of the IC.
    
    Fix this regression first by switching to kfifo_out_linear_ptr() in
    sc16is7xx_handle_tx() to eliminate the need for a shared Rx/Tx buffer.
    
    Secondly, replace the chip-wise Rx buffer with a separate Rx buffer for
    each channel.
    
    Fixes: 4409df5866b7 ("serial: sc16is7xx: change EFR lock to operate on each channels")
    Cc: [email protected]
    Signed-off-by: Hugo Villeneuve <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
smb3: fix setting SecurityFlags when encryption is required [+ + +]
Author: Steve French <[email protected]>
Date:   Wed Jul 31 21:38:50 2024 -0500

    smb3: fix setting SecurityFlags when encryption is required
    
    commit 1b5487aefb1ce7a6b1f15a33297d1231306b4122 upstream.
    
    Setting encryption as required in security flags was broken.
    For example (to require all mounts to be encrypted by setting):
    
      "echo 0x400c5 > /proc/fs/cifs/SecurityFlags"
    
    Would return "Invalid argument" and log "Unsupported security flags"
    This patch fixes that (e.g. allowing overriding the default for
    SecurityFlags  0x00c5, including 0x40000 to require seal, ie
    SMB3.1.1 encryption) so now that works and forces encryption
    on subsequent mounts.
    
    Acked-by: Bharath SM <[email protected]>
    Cc: [email protected]
    Signed-off-by: Steve French <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
smb: client: handle lack of FSCTL_GET_REPARSE_POINT support [+ + +]
Author: Paulo Alcantara <[email protected]>
Date:   Wed Jul 31 10:23:39 2024 -0300

    smb: client: handle lack of FSCTL_GET_REPARSE_POINT support
    
    [ Upstream commit 4b96024ef2296b1d323af327cae5e52809b61420 ]
    
    As per MS-FSA 2.1.5.10.14, support for FSCTL_GET_REPARSE_POINT is
    optional and if the server doesn't support it,
    STATUS_INVALID_DEVICE_REQUEST must be returned for the operation.
    
    If we find files with reparse points and we can't read them due to
    lack of client or server support, just ignore it and then treat them
    as regular files or junctions.
    
    Fixes: 5f71ebc41294 ("smb: client: parse reparse point flag in create response")
    Reported-by: Sebastian Steinbeisser <[email protected]>
    Tested-by: Sebastian Steinbeisser <[email protected]>
    Acked-by: Tom Talpey <[email protected]>
    Signed-off-by: Paulo Alcantara (Red Hat) <[email protected]>
    Signed-off-by: Steve French <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
soc: qcom: icc-bwmon: Allow for interrupts to be shared across instances [+ + +]
Author: Sibi Sankar <[email protected]>
Date:   Mon Jun 24 14:52:13 2024 +0530

    soc: qcom: icc-bwmon: Allow for interrupts to be shared across instances
    
    [ Upstream commit dc18836435e7f8dda019db2c618c69194933157f ]
    
    The multiple BWMONv4 instances available on the X1E80100 SoC use the
    same interrupt number. Mark them are shared to allow for re-use across
    instances.
    
    Using IRQF_SHARED coupled with devm_request_threaded_irq implies that
    the irq can still trigger during/after bwmon_remove due to other active
    bwmon instances. Handle this race by relying on bwmon_disable to disable
    the interrupt and coupled with explicit request/free irqs.
    
    Signed-off-by: Sibi Sankar <[email protected]>
    Reviewed-by: Dmitry Baryshkov <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Bjorn Andersson <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
spi: spi-fsl-lpspi: Fix scldiv calculation [+ + +]
Author: Stefan Wahren <[email protected]>
Date:   Sun Aug 4 13:36:11 2024 +0200

    spi: spi-fsl-lpspi: Fix scldiv calculation
    
    [ Upstream commit 730bbfaf7d4890bd99e637db7767dc68cfeb24e7 ]
    
    The effective SPI clock frequency should never exceed speed_hz
    otherwise this might result in undefined behavior of the SPI device.
    
    Currently the scldiv calculation could violate this constraint.
    For the example parameters perclk_rate = 24 MHz and speed_hz = 7 MHz,
    the function fsl_lpspi_set_bitrate will determine perscale = 0 and
    scldiv = 1, which is a effective SPI clock of 8 MHz.
    
    So fix this by rounding up the quotient of perclk_rate and speed_hz.
    While this never change within the loop, we can pull this out.
    
    Fixes: 5314987de5e5 ("spi: imx: add lpspi bus driver")
    Signed-off-by: Stefan Wahren <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

spi: spidev: Add missing spi_device_id for bh2228fv [+ + +]
Author: Geert Uytterhoeven <[email protected]>
Date:   Tue Jul 30 15:35:47 2024 +0200

    spi: spidev: Add missing spi_device_id for bh2228fv
    
    [ Upstream commit e4c4638b6a10427d30e29d22351c375886025f47 ]
    
    When the of_device_id entry for "rohm,bh2228fv" was added, the
    corresponding spi_device_id was forgotten, causing a warning message
    during boot-up:
    
        SPI driver spidev has no spi_device_id for rohm,bh2228fv
    
    Fix module autoloading and shut up the warning by adding the missing
    entry.
    
    Fixes: fc28d1c1fe3b3e2f ("spi: spidev: add correct compatible for Rohm BH2228FV")
    Signed-off-by: Geert Uytterhoeven <[email protected]>
    Link: https://patch.msgid.link/cb571d4128f41175f31319cd9febc829417ea167.1722346539.git.geert+renesas@glider.be
    Signed-off-by: Mark Brown <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
spmi: pmic-arb: add missing newline in dev_err format strings [+ + +]
Author: David Collins <[email protected]>
Date:   Thu Jul 25 09:46:33 2024 -0700

    spmi: pmic-arb: add missing newline in dev_err format strings
    
    [ Upstream commit ffcf2eb4bfa24f7256de53a95182c3e3e23fdc6c ]
    
    dev_err() format strings should end with '\n'.  Several such
    format strings in the spmi-pmic-arb driver are missing it.
    Add newlines where needed.
    
    Fixes: 02922ccbb330 ("spmi: pmic-arb: Register controller for bus instead of arbiter")
    Signed-off-by: David Collins <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Reviewed-by: Bjorn Andersson <[email protected]>
    Signed-off-by: Stephen Boyd <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

spmi: pmic-arb: Pass the correct of_node to irq_domain_add_tree [+ + +]
Author: Konrad Dybcio <[email protected]>
Date:   Thu Jul 25 09:46:32 2024 -0700

    spmi: pmic-arb: Pass the correct of_node to irq_domain_add_tree
    
    commit f38ba5459ced3441852f37f20fcfb7bd39d20f62 upstream.
    
    Currently, irqchips for all of the subnodes (which represent a given
    bus master) point to the parent wrapper node. This is no bueno, as
    no interrupts arrive, ever (because nothing references that node).
    
    Fix that by passing a reference to the respective master's of_node.
    
    Worth noting, this is a NOP for devices with only a single master
    described.
    
    Signed-off-by: Konrad Dybcio <[email protected]>
    Link: https://lore.kernel.org/r/20240522-topic-spmi_multi_master_irqfix-v2-1-7ec92a862b9f@linaro.org
    Reviewed-by: Abel Vesa <[email protected]>
    Tested-by: Dmitry Baryshkov <[email protected]>
    Reviewed-by: Dmitry Baryshkov <[email protected]>
    Fixes: 02922ccbb330 ("spmi: pmic-arb: Register controller for bus instead of arbiter")
    Cc: [email protected]
    Signed-off-by: Stephen Boyd <[email protected]>
    Reviewed-by: Bjorn Andersson <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
SUNRPC: Fix a race to wake a sync task [+ + +]
Author: Benjamin Coddington <[email protected]>
Date:   Wed Jul 17 10:49:33 2024 -0400

    SUNRPC: Fix a race to wake a sync task
    
    [ Upstream commit ed0172af5d6fc07d1b40ca82f5ca3979300369f7 ]
    
    We've observed NFS clients with sync tasks sleeping in __rpc_execute
    waiting on RPC_TASK_QUEUED that have not responded to a wake-up from
    rpc_make_runnable().  I suspect this problem usually goes unnoticed,
    because on a busy client the task will eventually be re-awoken by another
    task completion or xprt event.  However, if the state manager is draining
    the slot table, a sync task missing a wake-up can result in a hung client.
    
    We've been able to prove that the waker in rpc_make_runnable() successfully
    calls wake_up_bit() (ie- there's no race to tk_runstate), but the
    wake_up_bit() call fails to wake the waiter.  I suspect the waker is
    missing the load of the bit's wait_queue_head, so waitqueue_active() is
    false.  There are some very helpful comments about this problem above
    wake_up_bit(), prepare_to_wait(), and waitqueue_active().
    
    Fix this by inserting smp_mb__after_atomic() before the wake_up_bit(),
    which pairs with prepare_to_wait() calling set_current_state().
    
    Signed-off-by: Benjamin Coddington <[email protected]>
    Reviewed-by: Jeff Layton <[email protected]>
    Signed-off-by: Anna Schumaker <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
thermal: intel: hfi: Give HFI instances package scope [+ + +]
Author: Zhang Rui <[email protected]>
Date:   Wed Jul 3 13:54:45 2024 +0800

    thermal: intel: hfi: Give HFI instances package scope
    
    [ Upstream commit b755367602d70deade956cbe0b8a3f5a12f569dc ]
    
    The Intel Software Developer's Manual defines the scope of HFI (registers
    and memory buffer) as a package. Use package scope(*) in the software
    representation of an HFI instance.
    
    Using die scope in HFI instances has the effect of creating multiple
    conflicting instances for the same package: each instance allocates its
    own memory buffer and configures the same package-level registers.
    Specifically, only one of the allocated memory buffers can be set in the
    MSR_IA32_HW_FEEDBACK_PTR register. CPUs get incorrect HFI data from the
    table.
    
    The problem does not affect current HFI-capable platforms because they
    all have single-die processors.
    
    (*) We used die scope for HFI instances because there had been
        processors with packages enumerated as dies. None of those systems
        supported HFI, though. If such a system emerged, it would need to
        be quirked.
    
    Co-developed-by: Chen Yu <[email protected]>
    Signed-off-by: Chen Yu <[email protected]>
    Signed-off-by: Zhang Rui <[email protected]>
    Reviewed-by: Ricardo Neri <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    [ rjw: Changelog edits ]
    Signed-off-by: Rafael J. Wysocki <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
tick/broadcast: Move per CPU pointer access into the atomic section [+ + +]
Author: Thomas Gleixner <[email protected]>
Date:   Wed Jul 31 12:23:51 2024 +0200

    tick/broadcast: Move per CPU pointer access into the atomic section
    
    commit 6881e75237a84093d0986f56223db3724619f26e upstream.
    
    The recent fix for making the take over of the broadcast timer more
    reliable retrieves a per CPU pointer in preemptible context.
    
    This went unnoticed as compilers hoist the access into the non-preemptible
    region where the pointer is actually used. But of course it's valid that
    the compiler keeps it at the place where the code puts it which rightfully
    triggers:
    
      BUG: using smp_processor_id() in preemptible [00000000] code:
           caller is hotplug_cpu__broadcast_tick_pull+0x1c/0xc0
    
    Move it to the actual usage site which is in a non-preemptible region.
    
    Fixes: f7d43dd206e7 ("tick/broadcast: Make takeover of broadcast hrtimer reliable")
    Reported-by: David Wang <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Tested-by: Yu Liao <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/87ttg56ers.ffs@tglx
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
timekeeping: Fix bogus clock_was_set() invocation in do_adjtimex() [+ + +]
Author: Thomas Gleixner <[email protected]>
Date:   Sat Aug 3 17:07:51 2024 +0200

    timekeeping: Fix bogus clock_was_set() invocation in do_adjtimex()
    
    commit 5916be8a53de6401871bdd953f6c60237b47d6d3 upstream.
    
    The addition of the bases argument to clock_was_set() fixed up all call
    sites correctly except for do_adjtimex(). This uses CLOCK_REALTIME
    instead of CLOCK_SET_WALL as argument. CLOCK_REALTIME is 0.
    
    As a result the effect of that clock_was_set() notification is incomplete
    and might result in timers expiring late because the hrtimer code does
    not re-evaluate the affected clock bases.
    
    Use CLOCK_SET_WALL instead of CLOCK_REALTIME to tell the hrtimers code
    which clock bases need to be re-evaluated.
    
    Fixes: 17a1b8826b45 ("hrtimer: Add bases argument to clock_was_set()")
    Signed-off-by: Thomas Gleixner <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/877ccx7igo.ffs@tglx
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
tracefs: Fix inode allocation [+ + +]
Author: Mathias Krause <[email protected]>
Date:   Wed Aug 7 13:51:38 2024 +0200

    tracefs: Fix inode allocation
    
    commit 0df2ac59bebfac221463ef57ed3554899b41d75f upstream.
    
    The leading comment above alloc_inode_sb() is pretty explicit about it:
    
      /*
       * This must be used for allocating filesystems specific inodes to set
       * up the inode reclaim context correctly.
       */
    
    Switch tracefs over to alloc_inode_sb() to make sure inodes are properly
    linked.
    
    Cc: Ajay Kaher <[email protected]>
    Cc: Masami Hiramatsu <[email protected]>
    Cc: Mathieu Desnoyers <[email protected]>
    Cc: Al Viro <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/[email protected]
    Fixes: ba37ff75e04b ("eventfs: Implement tracefs_inode_cache")
    Signed-off-by: Mathias Krause <[email protected]>
    Signed-off-by: Steven Rostedt (Google) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

tracefs: Use generic inode RCU for synchronizing freeing [+ + +]
Author: Steven Rostedt <[email protected]>
Date:   Wed Aug 7 18:54:02 2024 -0400

    tracefs: Use generic inode RCU for synchronizing freeing
    
    commit 0b6743bd60a56a701070b89fb80c327a44b7b3e2 upstream.
    
    With structure layout randomization enabled for 'struct inode' we need to
    avoid overlapping any of the RCU-used / initialized-only-once members,
    e.g. i_lru or i_sb_list to not corrupt related list traversals when making
    use of the rcu_head.
    
    For an unlucky structure layout of 'struct inode' we may end up with the
    following splat when running the ftrace selftests:
    
    [<...>] list_del corruption, ffff888103ee2cb0->next (tracefs_inode_cache+0x0/0x4e0 [slab object]) is NULL (prev is tracefs_inode_cache+0x78/0x4e0 [slab object])
    [<...>] ------------[ cut here ]------------
    [<...>] kernel BUG at lib/list_debug.c:54!
    [<...>] invalid opcode: 0000 [#1] PREEMPT SMP KASAN
    [<...>] CPU: 3 PID: 2550 Comm: mount Tainted: G                 N  6.8.12-grsec+ #122 ed2f536ca62f28b087b90e3cc906a8d25b3ddc65
    [<...>] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
    [<...>] RIP: 0010:[<ffffffff84656018>] __list_del_entry_valid_or_report+0x138/0x3e0
    [<...>] Code: 48 b8 99 fb 65 f2 ff ff ff ff e9 03 5c d9 fc cc 48 b8 99 fb 65 f2 ff ff ff ff e9 33 5a d9 fc cc 48 b8 99 fb 65 f2 ff ff ff ff <0f> 0b 4c 89 e9 48 89 ea 48 89 ee 48 c7 c7 60 8f dd 89 31 c0 e8 2f
    [<...>] RSP: 0018:fffffe80416afaf0 EFLAGS: 00010283
    [<...>] RAX: 0000000000000098 RBX: ffff888103ee2cb0 RCX: 0000000000000000
    [<...>] RDX: ffffffff84655fe8 RSI: ffffffff89dd8b60 RDI: 0000000000000001
    [<...>] RBP: ffff888103ee2cb0 R08: 0000000000000001 R09: fffffbd0082d5f25
    [<...>] R10: fffffe80416af92f R11: 0000000000000001 R12: fdf99c16731d9b6d
    [<...>] R13: 0000000000000000 R14: ffff88819ad4b8b8 R15: 0000000000000000
    [<...>] RBX: tracefs_inode_cache+0x0/0x4e0 [slab object]
    [<...>] RDX: __list_del_entry_valid_or_report+0x108/0x3e0
    [<...>] RSI: __func__.47+0x4340/0x4400
    [<...>] RBP: tracefs_inode_cache+0x0/0x4e0 [slab object]
    [<...>] RSP: process kstack fffffe80416afaf0+0x7af0/0x8000 [mount 2550 2550]
    [<...>] R09: kasan shadow of process kstack fffffe80416af928+0x7928/0x8000 [mount 2550 2550]
    [<...>] R10: process kstack fffffe80416af92f+0x792f/0x8000 [mount 2550 2550]
    [<...>] R14: tracefs_inode_cache+0x78/0x4e0 [slab object]
    [<...>] FS:  00006dcb380c1840(0000) GS:ffff8881e0600000(0000) knlGS:0000000000000000
    [<...>] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [<...>] CR2: 000076ab72b30e84 CR3: 000000000b088004 CR4: 0000000000360ef0 shadow CR4: 0000000000360ef0
    [<...>] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [<...>] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [<...>] ASID: 0003
    [<...>] Stack:
    [<...>]  ffffffff818a2315 00000000f5c856ee ffffffff896f1840 ffff888103ee2cb0
    [<...>]  ffff88812b6b9750 0000000079d714b6 fffffbfff1e9280b ffffffff8f49405f
    [<...>]  0000000000000001 0000000000000000 ffff888104457280 ffffffff8248b392
    [<...>] Call Trace:
    [<...>]  <TASK>
    [<...>]  [<ffffffff818a2315>] ? lock_release+0x175/0x380 fffffe80416afaf0
    [<...>]  [<ffffffff8248b392>] list_lru_del+0x152/0x740 fffffe80416afb48
    [<...>]  [<ffffffff8248ba93>] list_lru_del_obj+0x113/0x280 fffffe80416afb88
    [<...>]  [<ffffffff8940fd19>] ? _atomic_dec_and_lock+0x119/0x200 fffffe80416afb90
    [<...>]  [<ffffffff8295b244>] iput_final+0x1c4/0x9a0 fffffe80416afbb8
    [<...>]  [<ffffffff8293a52b>] dentry_unlink_inode+0x44b/0xaa0 fffffe80416afbf8
    [<...>]  [<ffffffff8293fefc>] __dentry_kill+0x23c/0xf00 fffffe80416afc40
    [<...>]  [<ffffffff8953a85f>] ? __this_cpu_preempt_check+0x1f/0xa0 fffffe80416afc48
    [<...>]  [<ffffffff82949ce5>] ? shrink_dentry_list+0x1c5/0x760 fffffe80416afc70
    [<...>]  [<ffffffff82949b71>] ? shrink_dentry_list+0x51/0x760 fffffe80416afc78
    [<...>]  [<ffffffff82949da8>] shrink_dentry_list+0x288/0x760 fffffe80416afc80
    [<...>]  [<ffffffff8294ae75>] shrink_dcache_sb+0x155/0x420 fffffe80416afcc8
    [<...>]  [<ffffffff8953a7c3>] ? debug_smp_processor_id+0x23/0xa0 fffffe80416afce0
    [<...>]  [<ffffffff8294ad20>] ? do_one_tree+0x140/0x140 fffffe80416afcf8
    [<...>]  [<ffffffff82997349>] ? do_remount+0x329/0xa00 fffffe80416afd18
    [<...>]  [<ffffffff83ebf7a1>] ? security_sb_remount+0x81/0x1c0 fffffe80416afd38
    [<...>]  [<ffffffff82892096>] reconfigure_super+0x856/0x14e0 fffffe80416afd70
    [<...>]  [<ffffffff815d1327>] ? ns_capable_common+0xe7/0x2a0 fffffe80416afd90
    [<...>]  [<ffffffff82997436>] do_remount+0x416/0xa00 fffffe80416afdd0
    [<...>]  [<ffffffff829b2ba4>] path_mount+0x5c4/0x900 fffffe80416afe28
    [<...>]  [<ffffffff829b25e0>] ? finish_automount+0x13a0/0x13a0 fffffe80416afe60
    [<...>]  [<ffffffff82903812>] ? user_path_at_empty+0xb2/0x140 fffffe80416afe88
    [<...>]  [<ffffffff829b2ff5>] do_mount+0x115/0x1c0 fffffe80416afeb8
    [<...>]  [<ffffffff829b2ee0>] ? path_mount+0x900/0x900 fffffe80416afed8
    [<...>]  [<ffffffff8272461c>] ? __kasan_check_write+0x1c/0xa0 fffffe80416afee0
    [<...>]  [<ffffffff829b31cf>] __do_sys_mount+0x12f/0x280 fffffe80416aff30
    [<...>]  [<ffffffff829b36cd>] __x64_sys_mount+0xcd/0x2e0 fffffe80416aff70
    [<...>]  [<ffffffff819f8818>] ? syscall_trace_enter+0x218/0x380 fffffe80416aff88
    [<...>]  [<ffffffff8111655e>] x64_sys_call+0x5d5e/0x6720 fffffe80416affa8
    [<...>]  [<ffffffff8952756d>] do_syscall_64+0xcd/0x3c0 fffffe80416affb8
    [<...>]  [<ffffffff8100119b>] entry_SYSCALL_64_safe_stack+0x4c/0x87 fffffe80416affe8
    [<...>]  </TASK>
    [<...>]  <PTREGS>
    [<...>] RIP: 0033:[<00006dcb382ff66a>] vm_area_struct[mount 2550 2550 file 6dcb38225000-6dcb3837e000 22 55(read|exec|mayread|mayexec)]+0x0/0xb8 [userland map]
    [<...>] Code: 48 8b 0d 29 18 0d 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d f6 17 0d 00 f7 d8 64 89 01 48
    [<...>] RSP: 002b:0000763d68192558 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
    [<...>] RAX: ffffffffffffffda RBX: 00006dcb38433264 RCX: 00006dcb382ff66a
    [<...>] RDX: 000017c3e0d11210 RSI: 000017c3e0d1a5a0 RDI: 000017c3e0d1ae70
    [<...>] RBP: 000017c3e0d10fb0 R08: 000017c3e0d11260 R09: 00006dcb383d1be0
    [<...>] R10: 000000000020002e R11: 0000000000000246 R12: 0000000000000000
    [<...>] R13: 000017c3e0d1ae70 R14: 000017c3e0d11210 R15: 000017c3e0d10fb0
    [<...>] RBX: vm_area_struct[mount 2550 2550 file 6dcb38433000-6dcb38434000 5b 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] RCX: vm_area_struct[mount 2550 2550 file 6dcb38225000-6dcb3837e000 22 55(read|exec|mayread|mayexec)]+0x0/0xb8 [userland map]
    [<...>] RDX: vm_area_struct[mount 2550 2550 anon 17c3e0d0f000-17c3e0d31000 17c3e0d0f 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] RSI: vm_area_struct[mount 2550 2550 anon 17c3e0d0f000-17c3e0d31000 17c3e0d0f 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] RDI: vm_area_struct[mount 2550 2550 anon 17c3e0d0f000-17c3e0d31000 17c3e0d0f 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] RBP: vm_area_struct[mount 2550 2550 anon 17c3e0d0f000-17c3e0d31000 17c3e0d0f 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] RSP: vm_area_struct[mount 2550 2550 anon 763d68173000-763d68195000 7ffffffdd 100133(read|write|mayread|maywrite|growsdown|account)]+0x0/0xb8 [userland map]
    [<...>] R08: vm_area_struct[mount 2550 2550 anon 17c3e0d0f000-17c3e0d31000 17c3e0d0f 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] R09: vm_area_struct[mount 2550 2550 file 6dcb383d1000-6dcb383d3000 1cd 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] R13: vm_area_struct[mount 2550 2550 anon 17c3e0d0f000-17c3e0d31000 17c3e0d0f 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] R14: vm_area_struct[mount 2550 2550 anon 17c3e0d0f000-17c3e0d31000 17c3e0d0f 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>] R15: vm_area_struct[mount 2550 2550 anon 17c3e0d0f000-17c3e0d31000 17c3e0d0f 100033(read|write|mayread|maywrite|account)]+0x0/0xb8 [userland map]
    [<...>]  </PTREGS>
    [<...>] Modules linked in:
    [<...>] ---[ end trace 0000000000000000 ]---
    
    The list debug message as well as RBX's symbolic value point out that the
    object in question was allocated from 'tracefs_inode_cache' and that the
    list's '->next' member is at offset 0. Dumping the layout of the relevant
    parts of 'struct tracefs_inode' gives the following:
    
      struct tracefs_inode {
        union {
          struct inode {
            struct list_head {
              struct list_head * next;                    /*     0     8 */
              struct list_head * prev;                    /*     8     8 */
            } i_lru;
            [...]
          } vfs_inode;
          struct callback_head {
            void (*func)(struct callback_head *);         /*     0     8 */
            struct callback_head * next;                  /*     8     8 */
          } rcu;
        };
        [...]
      };
    
    Above shows that 'vfs_inode.i_lru' overlaps with 'rcu' which will
    destroy the 'i_lru' list as soon as the 'rcu' member gets used, e.g. in
    call_rcu() or later when calling the RCU callback. This will disturb
    concurrent list traversals as well as object reuse which assumes these
    list heads will keep their integrity.
    
    For reproduction, the following diff manually overlays 'i_lru' with
    'rcu' as, otherwise, one would require some good portion of luck for
    gambling an unlucky RANDSTRUCT seed:
    
      --- a/include/linux/fs.h
      +++ b/include/linux/fs.h
      @@ -629,6 +629,7 @@ struct inode {
            umode_t                 i_mode;
            unsigned short          i_opflags;
            kuid_t                  i_uid;
      +     struct list_head        i_lru;          /* inode LRU list */
            kgid_t                  i_gid;
            unsigned int            i_flags;
    
      @@ -690,7 +691,6 @@ struct inode {
            u16                     i_wb_frn_avg_time;
            u16                     i_wb_frn_history;
       #endif
      -     struct list_head        i_lru;          /* inode LRU list */
            struct list_head        i_sb_list;
            struct list_head        i_wb_list;      /* backing dev writeback list */
            union {
    
    The tracefs inode does not need to supply its own RCU delayed destruction
    of its inode. The inode code itself offers both a "destroy_inode()"
    callback that gets called when the last reference of the inode is
    released, and the "free_inode()" which is called after a RCU
    synchronization period from the "destroy_inode()".
    
    The tracefs code can unlink the inode from its list in the destroy_inode()
    callback, and the simply free it from the free_inode() callback. This
    should provide the same protection.
    
    Link: https://lore.kernel.org/all/[email protected]/
    
    Cc: [email protected]
    Cc: Masami Hiramatsu <[email protected]>
    Cc: Mathieu Desnoyers <[email protected]>
    Cc: Ajay Kaher <[email protected]>
    Cc: Ilkka =?utf-8?b?TmF1bGFww6TDpA==?= <[email protected]>
    Link: https://lore.kernel.org/[email protected]
    Fixes: baa23a8d4360 ("tracefs: Reset permissions on remount if permissions are options")
    Reported-by: Mathias Krause <[email protected]>
    Reported-by: Brad Spengler <[email protected]>
    Suggested-by: Al Viro <[email protected]>
    Signed-off-by: Steven Rostedt (Google) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
tracing: Fix overflow in get_free_elt() [+ + +]
Author: Tze-nan Wu <[email protected]>
Date:   Mon Aug 5 13:59:22 2024 +0800

    tracing: Fix overflow in get_free_elt()
    
    commit bcf86c01ca4676316557dd482c8416ece8c2e143 upstream.
    
    "tracing_map->next_elt" in get_free_elt() is at risk of overflowing.
    
    Once it overflows, new elements can still be inserted into the tracing_map
    even though the maximum number of elements (`max_elts`) has been reached.
    Continuing to insert elements after the overflow could result in the
    tracing_map containing "tracing_map->max_size" elements, leaving no empty
    entries.
    If any attempt is made to insert an element into a full tracing_map using
    `__tracing_map_insert()`, it will cause an infinite loop with preemption
    disabled, leading to a CPU hang problem.
    
    Fix this by preventing any further increments to "tracing_map->next_elt"
    once it reaches "tracing_map->max_elt".
    
    Cc: [email protected]
    Cc: Masami Hiramatsu <[email protected]>
    Fixes: 08d43a5fa063e ("tracing: Add lock-free tracing_map")
    Co-developed-by: Cheng-Jui Wang <[email protected]>
    Link: https://lore.kernel.org/[email protected]
    Signed-off-by: Cheng-Jui Wang <[email protected]>
    Signed-off-by: Tze-nan Wu <[email protected]>
    Signed-off-by: Steven Rostedt (Google) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

tracing: Have format file honor EVENT_FILE_FL_FREED [+ + +]
Author: Steven Rostedt <[email protected]>
Date:   Tue Jul 30 11:06:57 2024 -0400

    tracing: Have format file honor EVENT_FILE_FL_FREED
    
    commit b1560408692cd0ab0370cfbe9deb03ce97ab3f6d upstream.
    
    When eventfs was introduced, special care had to be done to coordinate the
    freeing of the file meta data with the files that are exposed to user
    space. The file meta data would have a ref count that is set when the file
    is created and would be decremented and freed after the last user that
    opened the file closed it. When the file meta data was to be freed, it
    would set a flag (EVENT_FILE_FL_FREED) to denote that the file is freed,
    and any new references made (like new opens or reads) would fail as it is
    marked freed. This allowed other meta data to be freed after this flag was
    set (under the event_mutex).
    
    All the files that were dynamically created in the events directory had a
    pointer to the file meta data and would call event_release() when the last
    reference to the user space file was closed. This would be the time that it
    is safe to free the file meta data.
    
    A shortcut was made for the "format" file. It's i_private would point to
    the "call" entry directly and not point to the file's meta data. This is
    because all format files are the same for the same "call", so it was
    thought there was no reason to differentiate them.  The other files
    maintain state (like the "enable", "trigger", etc). But this meant if the
    file were to disappear, the "format" file would be unaware of it.
    
    This caused a race that could be trigger via the user_events test (that
    would create dynamic events and free them), and running a loop that would
    read the user_events format files:
    
    In one console run:
    
     # cd tools/testing/selftests/user_events
     # while true; do ./ftrace_test; done
    
    And in another console run:
    
     # cd /sys/kernel/tracing/
     # while true; do cat events/user_events/__test_event/format; done 2>/dev/null
    
    With KASAN memory checking, it would trigger a use-after-free bug report
    (which was a real bug). This was because the format file was not checking
    the file's meta data flag "EVENT_FILE_FL_FREED", so it would access the
    event that the file meta data pointed to after the event was freed.
    
    After inspection, there are other locations that were found to not check
    the EVENT_FILE_FL_FREED flag when accessing the trace_event_file. Add a
    new helper function: event_file_file() that will make sure that the
    event_mutex is held, and will return NULL if the trace_event_file has the
    EVENT_FILE_FL_FREED flag set. Have the first reference of the struct file
    pointer use event_file_file() and check for NULL. Later uses can still use
    the event_file_data() helper function if the event_mutex is still held and
    was not released since the event_file_file() call.
    
    Link: https://lore.kernel.org/all/[email protected]/
    
    Cc: [email protected]
    Cc: Masami Hiramatsu <[email protected]>
    Cc: Mathieu Desnoyers   <[email protected]>
    Cc: Ajay Kaher <[email protected]>
    Cc: Ilkka Naulapää    <[email protected]>
    Cc: Linus Torvalds <[email protected]>
    Cc: Al   Viro <[email protected]>
    Cc: Dan Carpenter   <[email protected]>
    Cc: Beau Belgrave <[email protected]>
    Cc: Florian Fainelli  <[email protected]>
    Cc: Alexey Makhalov    <[email protected]>
    Cc: Vasavi Sirnapalli    <[email protected]>
    Link: https://lore.kernel.org/[email protected]
    Fixes: b63db58e2fa5d ("eventfs/tracing: Add callback for release of an eventfs_inode")
    Reported-by: Mathias Krause <[email protected]>
    Tested-by: Mathias Krause <[email protected]>
    Signed-off-by: Steven Rostedt (Google) <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
tty: vt: conmakehash: cope with abs_srctree no longer in env [+ + +]
Author: Max Krummenacher <[email protected]>
Date:   Thu Jul 25 15:20:45 2024 +0200

    tty: vt: conmakehash: cope with abs_srctree no longer in env
    
    commit 6e20753da6bc651e02378a0cdb78f16c42098c88 upstream.
    
    conmakehash uses getenv("abs_srctree") from the environment to strip
    the absolute path from the generated sources.
    However since commit e2bad142bb3d ("kbuild: unexport abs_srctree and
    abs_objtree") this environment variable no longer gets set.
    Instead use basename() to indicate the used file in a comment of the
    generated source file.
    
    Fixes: 3bd85c6c97b2 ("tty: vt: conmakehash: Don't mention the full path of the input in output")
    Cc: stable <[email protected]>
    Signed-off-by: Max Krummenacher <[email protected]>
    Link: https://lore.kernel.org/stable/20240725132056.9151-1-max.oss.09%40gmail.com
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
udf: prevent integer overflow in udf_bitmap_free_blocks() [+ + +]
Author: Roman Smirnov <[email protected]>
Date:   Thu Jun 20 10:24:13 2024 +0300

    udf: prevent integer overflow in udf_bitmap_free_blocks()
    
    [ Upstream commit 56e69e59751d20993f243fb7dd6991c4e522424c ]
    
    An overflow may occur if the function is called with the last
    block and an offset greater than zero. It is necessary to add
    a check to avoid this.
    
    Found by Linux Verification Center (linuxtesting.org) with Svace.
    
    [JK: Make test cover also unalloc table freeing]
    
    Link: https://patch.msgid.link/[email protected]
    Suggested-by: Jan Kara <[email protected]>
    Signed-off-by: Roman Smirnov <[email protected]>
    Signed-off-by: Jan Kara <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
usb: gadget: core: Check for unset descriptor [+ + +]
Author: Chris Wulff <[email protected]>
Date:   Wed Jul 24 21:04:20 2024 -0400

    usb: gadget: core: Check for unset descriptor
    
    commit 973a57891608a98e894db2887f278777f564de18 upstream.
    
    Make sure the descriptor has been set before looking at maxpacket.
    This fixes a null pointer panic in this case.
    
    This may happen if the gadget doesn't properly set up the endpoint
    for the current speed, or the gadget descriptors are malformed and
    the descriptor for the speed/endpoint are not found.
    
    No current gadget driver is known to have this problem, but this
    may cause a hard-to-find bug during development of new gadgets.
    
    Fixes: 54f83b8c8ea9 ("USB: gadget: Reject endpoints with 0 maxpacket value")
    Cc: [email protected]
    Signed-off-by: Chris Wulff <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

usb: gadget: f_fs: restore ffs_func_disable() functionality [+ + +]
Author: Tudor Ambarus <[email protected]>
Date:   Fri Aug 2 14:04:27 2024 +0000

    usb: gadget: f_fs: restore ffs_func_disable() functionality
    
    commit 382b6eabb0316b7334d97afbdcf33a4e20b0ecd8 upstream.
    
    The blamed commit made ffs_func_disable() always return -EINVAL as the
    method calls ffs_func_set_alt() with the ``alt`` argument being
    ``(unsigned)-1``, which is always greater than MAX_ALT_SETTINGS.
    Use the MAX_ALT_SETTINGS check just in the f->set_alt() code path,
    f->disable() doesn't care about the ``alt`` parameter.
    
    Make a surgical fix, but really the f->disable() code shall be pulled
    out from ffs_func_set_alt(), the code will become clearer. A patch will
    follow.
    
    Note that ffs_func_disable() always returning -EINVAL made pixel6 crash
    on USB disconnect.
    
    Fixes: 2f550553e23c ("usb: gadget: f_fs: Add the missing get_alt callback")
    Cc: stable <[email protected]>
    Reported-by: William McVicker <[email protected]>
    Signed-off-by: Tudor Ambarus <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

usb: gadget: midi2: Fix the response for FB info with block 0xff [+ + +]
Author: Takashi Iwai <[email protected]>
Date:   Wed Jul 17 11:50:53 2024 +0200

    usb: gadget: midi2: Fix the response for FB info with block 0xff
    
    commit 228a953e61d6d608a3facc1c3a27b9fb03c99de7 upstream.
    
    When the block number 0xff is given to Function Block Discovery
    message, the device should return the information of all Function
    Blocks, but currently the gadget driver treats it as an error.
    
    Implement the proper behavior for the block 0xff instead.
    
    Fixes: 8b645922b223 ("usb: gadget: Add support for USB MIDI 2.0 function driver")
    Cc: [email protected]
    Signed-off-by: Takashi Iwai <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

usb: gadget: u_audio: Check return codes from usb_ep_enable and config_ep_by_speed. [+ + +]
Author: Chris Wulff <[email protected]>
Date:   Sun Jul 21 15:23:15 2024 -0400

    usb: gadget: u_audio: Check return codes from usb_ep_enable and config_ep_by_speed.
    
    commit 76a7bfc445b8e9893c091e24ccfd4f51dfdc0a70 upstream.
    
    These functions can fail if descriptors are malformed, or missing,
    for the selected USB speed.
    
    Fixes: eb9fecb9e69b ("usb: gadget: f_uac2: split out audio core")
    Fixes: 24f779dac8f3 ("usb: gadget: f_uac2/u_audio: add feedback endpoint support")
    Cc: [email protected]
    Signed-off-by: Chris Wulff <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

usb: gadget: u_serial: Set start_delayed during suspend [+ + +]
Author: Prashanth K <[email protected]>
Date:   Tue Jul 30 18:27:54 2024 +0530

    usb: gadget: u_serial: Set start_delayed during suspend
    
    commit 5a444bea37e2759549ef72bfe83d1c8712e76b3d upstream.
    
    Upstream commit aba3a8d01d62 ("usb: gadget: u_serial: add suspend
    resume callbacks") added started_delayed flag, so that new ports
    which are opened after USB suspend can start IO while resuming.
    But if the port was already opened, and gadget suspend kicks in
    afterwards, start_delayed will never be set. This causes resume
    to bail out before calling gs_start_io(). Fix this by setting
    start_delayed during suspend.
    
    Fixes: aba3a8d01d62 ("usb: gadget: u_serial: add suspend resume callbacks")
    Cc: [email protected]
    Signed-off-by: Prashanth K <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
USB: serial: debug: do not echo input by default [+ + +]
Author: Marek Marczykowski-Górecki <[email protected]>
Date:   Mon Jul 15 12:44:53 2024 +0200

    USB: serial: debug: do not echo input by default
    
    commit 00af4f3dda1461ec90d892edc10bec6d3c50c554 upstream.
    
    This driver is intended as a "client" end of the console connection.
    When connected to a host it's supposed to receive debug logs, and
    possibly allow to interact with whatever debug console is available
    there. Feeding messages back, depending on a configuration may cause log
    messages be executed as shell commands (which can be really bad if one
    is unlucky, imagine a log message like "prevented running `rm -rf
    /home`"). In case of Xen, it exposes sysrq-like debug interface, and
    feeding it its own logs will pretty quickly hit 'R' for "instant
    reboot".
    
    Contrary to a classic serial console, the USB one cannot be configured
    ahead of time, as the device shows up only when target OS is up. And at
    the time device is opened to execute relevant ioctl, it's already too
    late, especially when logs start flowing shortly after device is
    initialized.
    Avoid the issue by changing default to no echo for this type of devices.
    
    Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
    [ johan: amend summary; disable also ECHONL ]
    Cc: [email protected]
    Signed-off-by: Johan Hovold <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
usb: typec: fsa4480: Check if the chip is really there [+ + +]
Author: Konrad Dybcio <[email protected]>
Date:   Mon Jul 29 10:42:58 2024 +0200

    usb: typec: fsa4480: Check if the chip is really there
    
    commit e885f5f1f2b43575aa8e4e31404132d77d6663d1 upstream.
    
    Currently, the driver will happily register the switch/mux devices, and
    so long as the i2c master doesn't complain, the user would never know
    there's something wrong.
    
    Add a device id check (based on [1]) and return -ENODEV if the read
    fails or returns nonsense.
    
    Checking the value on a Qualcomm SM6115P-based Lenovo Tab P11 tablet,
    the ID mentioned in the datasheet does indeed show up:
     fsa4480 1-0042: Found FSA4480 v1.1 (Vendor ID = 0)
    
    [1] https://www.onsemi.com/pdf/datasheet/fsa4480-d.pdf
    
    Fixes: 1dc246320c6b ("usb: typec: mux: Add On Semi fsa4480 driver")
    Cc: stable <[email protected]>
    Reviewed-by: Dmitry Baryshkov <[email protected]>
    Signed-off-by: Konrad Dybcio <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

usb: vhci-hcd: Do not drop references before new references are gained [+ + +]
Author: Oliver Neukum <[email protected]>
Date:   Tue Jul 9 13:38:41 2024 +0200

    usb: vhci-hcd: Do not drop references before new references are gained
    
    commit afdcfd3d6fcdeca2735ca8d994c5f2d24a368f0a upstream.
    
    At a few places the driver carries stale pointers
    to references that can still be used. Make sure that does not happen.
    This strictly speaking closes ZDI-CAN-22273, though there may be
    similar races in the driver.
    
    Signed-off-by: Oliver Neukum <[email protected]>
    Cc: stable <[email protected]>
    Acked-by: Shuah Khan <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
vhost-vdpa: switch to use vmf_insert_pfn() in the fault handler [+ + +]
Author: Jason Wang <[email protected]>
Date:   Mon Jul 1 11:31:59 2024 +0800

    vhost-vdpa: switch to use vmf_insert_pfn() in the fault handler
    
    commit 0823dc64586ba5ea13a7d200a5d33e4c5fa45950 upstream.
    
    remap_pfn_page() should not be called in the fault handler as it may
    change the vma->flags which may trigger lockdep warning since the vma
    write lock is not held. Actually there's no need to modify the
    vma->flags as it has been set in the mmap(). So this patch switches to
    use vmf_insert_pfn() instead.
    
    Reported-by: Dragos Tatulea <[email protected]>
    Tested-by: Dragos Tatulea <[email protected]>
    Fixes: ddd89d0a059d ("vhost_vdpa: support doorbell mapping via mmap")
    Cc: [email protected]
    Signed-off-by: Jason Wang <[email protected]>
    Message-Id: <[email protected]>
    Signed-off-by: Michael S. Tsirkin <[email protected]>
    Reviewed-by: Michal Kubiak <[email protected]>
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
virtio-net: unbreak vq resizing when coalescing is not negotiated [+ + +]
Author: Heng Qi <[email protected]>
Date:   Thu Aug 1 21:23:38 2024 +0800

    virtio-net: unbreak vq resizing when coalescing is not negotiated
    
    [ Upstream commit 4ba8d97083707409822264fd1776aad7233f353e ]
    
    Don't break the resize action if the vq coalescing feature
    named VIRTIO_NET_F_VQ_NOTF_COAL is not negotiated.
    
    Fixes: f61fe5f081cf ("virtio-net: fix the vq coalescing setting for vq resize")
    Signed-off-by: Heng Qi <[email protected]>
    Reviewed-by: Xuan Zhuo <[email protected]>
    Acked-by: Eugenio Pé rez <[email protected]>
    Acked-by: Jason Wang <[email protected]>
    Signed-off-by: David S. Miller <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

 
wifi: ath12k: fix memory leak in ath12k_dp_rx_peer_frag_setup() [+ + +]
Author: Baochen Qiang <[email protected]>
Date:   Sun May 26 20:42:26 2024 +0800

    wifi: ath12k: fix memory leak in ath12k_dp_rx_peer_frag_setup()
    
    [ Upstream commit 3d60041543189438cd1b03a1fa40ff6681c77970 ]
    
    Currently the resource allocated by crypto_alloc_shash() is not
    freed in case ath12k_peer_find() fails, resulting in memory leak.
    
    Add crypto_free_shash() to fix it.
    
    This is found during code review, compile tested only.
    
    Signed-off-by: Baochen Qiang <[email protected]>
    Acked-by: Jeff Johnson <[email protected]>
    Signed-off-by: Kalle Valo <[email protected]>
    Link: https://msgid.link/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

wifi: ath12k: fix race due to setting ATH12K_FLAG_EXT_IRQ_ENABLED too early [+ + +]
Author: Baochen Qiang <[email protected]>
Date:   Fri May 24 10:36:42 2024 +0800

    wifi: ath12k: fix race due to setting ATH12K_FLAG_EXT_IRQ_ENABLED too early
    
    [ Upstream commit 0a993772e0f0934d730c0d451622c80e03a40ab1 ]
    
    Commit 5082b3e3027e ("wifi: ath11k: fix race due to setting
    ATH11K_FLAG_EXT_IRQ_ENABLED too early") fixes a race in ath11k
    driver. Since ath12k shares the same logic as ath11k, currently
    the race also exists in ath12k: in ath12k_pci_ext_irq_enable(),
    ATH12K_FLAG_EXT_IRQ_ENABLED is set before NAPI is enabled.
    In cases where only one MSI vector is allocated, this results
    in a race condition: after ATH12K_FLAG_EXT_IRQ_ENABLED is set
    but before NAPI enabled, CE interrupt breaks in. Since IRQ is
    shared by CE and data path, ath12k_pci_ext_interrupt_handler()
    is also called where we call disable_irq_nosync() to disable
    IRQ. Then napi_schedule() is called but it does nothing because
    NAPI is not enabled at that time, meaning that
    ath12k_pci_ext_grp_napi_poll() will never run, so we have
    no chance to call enable_irq() to enable IRQ back. Since IRQ
    is shared, all interrupts are disabled and we would finally
    get no response from target.
    
    So port ath11k fix here, this is done by setting
    ATH12K_FLAG_EXT_IRQ_ENABLED after all NAPI and IRQ work are
    done. With the fix, we are sure that by the time
    ATH12K_FLAG_EXT_IRQ_ENABLED is set, NAPI is enabled.
    
    Note that the fix above also introduce some side effects:
    if ath12k_pci_ext_interrupt_handler() breaks in after NAPI
    enabled but before ATH12K_FLAG_EXT_IRQ_ENABLED set, nothing
    will be done by the handler this time, the work will be
    postponed till the next time the IRQ fires.
    
    This is found during code review.
    
    Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
    
    Signed-off-by: Baochen Qiang <[email protected]>
    Acked-by: Jeff Johnson <[email protected]>
    Signed-off-by: Kalle Valo <[email protected]>
    Link: https://msgid.link/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

wifi: mac80211: fix NULL dereference at band check in starting tx ba session [+ + +]
Author: Zong-Zhe Yang <[email protected]>
Date:   Mon Jun 17 19:52:17 2024 +0800

    wifi: mac80211: fix NULL dereference at band check in starting tx ba session
    
    [ Upstream commit 021d53a3d87eeb9dbba524ac515651242a2a7e3b ]
    
    In MLD connection, link_data/link_conf are dynamically allocated. They
    don't point to vif->bss_conf. So, there will be no chanreq assigned to
    vif->bss_conf and then the chan will be NULL. Tweak the code to check
    ht_supported/vht_supported/has_he/has_eht on sta deflink.
    
    Crash log (with rtw89 version under MLO development):
    [ 9890.526087] BUG: kernel NULL pointer dereference, address: 0000000000000000
    [ 9890.526102] #PF: supervisor read access in kernel mode
    [ 9890.526105] #PF: error_code(0x0000) - not-present page
    [ 9890.526109] PGD 0 P4D 0
    [ 9890.526114] Oops: 0000 [#1] PREEMPT SMP PTI
    [ 9890.526119] CPU: 2 PID: 6367 Comm: kworker/u16:2 Kdump: loaded Tainted: G           OE      6.9.0 #1
    [ 9890.526123] Hardware name: LENOVO 2356AD1/2356AD1, BIOS G7ETB3WW (2.73 ) 11/28/2018
    [ 9890.526126] Workqueue: phy2 rtw89_core_ba_work [rtw89_core]
    [ 9890.526203] RIP: 0010:ieee80211_start_tx_ba_session (net/mac80211/agg-tx.c:618 (discriminator 1)) mac80211
    [ 9890.526279] Code: f7 e8 d5 93 3e ea 48 83 c4 28 89 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc 49 8b 84 24 e0 f1 ff ff 48 8b 80 90 1b 00 00 <83> 38 03 0f 84 37 fe ff ff bb ea ff ff ff eb cc 49 8b 84 24 10 f3
    All code
    ========
       0:   f7 e8                   imul   %eax
       2:   d5                      (bad)
       3:   93                      xchg   %eax,%ebx
       4:   3e ea                   ds (bad)
       6:   48 83 c4 28             add    $0x28,%rsp
       a:   89 d8                   mov    %ebx,%eax
       c:   5b                      pop    %rbx
       d:   41 5c                   pop    %r12
       f:   41 5d                   pop    %r13
      11:   41 5e                   pop    %r14
      13:   41 5f                   pop    %r15
      15:   5d                      pop    %rbp
      16:   c3                      retq
      17:   cc                      int3
      18:   cc                      int3
      19:   cc                      int3
      1a:   cc                      int3
      1b:   49 8b 84 24 e0 f1 ff    mov    -0xe20(%r12),%rax
      22:   ff
      23:   48 8b 80 90 1b 00 00    mov    0x1b90(%rax),%rax
      2a:*  83 38 03                cmpl   $0x3,(%rax)              <-- trapping instruction
      2d:   0f 84 37 fe ff ff       je     0xfffffffffffffe6a
      33:   bb ea ff ff ff          mov    $0xffffffea,%ebx
      38:   eb cc                   jmp    0x6
      3a:   49                      rex.WB
      3b:   8b                      .byte 0x8b
      3c:   84 24 10                test   %ah,(%rax,%rdx,1)
      3f:   f3                      repz
    
    Code starting with the faulting instruction
    ===========================================
       0:   83 38 03                cmpl   $0x3,(%rax)
       3:   0f 84 37 fe ff ff       je     0xfffffffffffffe40
       9:   bb ea ff ff ff          mov    $0xffffffea,%ebx
       e:   eb cc                   jmp    0xffffffffffffffdc
      10:   49                      rex.WB
      11:   8b                      .byte 0x8b
      12:   84 24 10                test   %ah,(%rax,%rdx,1)
      15:   f3                      repz
    [ 9890.526285] RSP: 0018:ffffb8db09013d68 EFLAGS: 00010246
    [ 9890.526291] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff9308e0d656c8
    [ 9890.526295] RDX: 0000000000000000 RSI: ffffffffab99460b RDI: ffffffffab9a7685
    [ 9890.526300] RBP: ffffb8db09013db8 R08: 0000000000000000 R09: 0000000000000873
    [ 9890.526304] R10: ffff9308e0d64800 R11: 0000000000000002 R12: ffff9308e5ff6e70
    [ 9890.526308] R13: ffff930952500e20 R14: ffff9309192a8c00 R15: 0000000000000000
    [ 9890.526313] FS:  0000000000000000(0000) GS:ffff930b4e700000(0000) knlGS:0000000000000000
    [ 9890.526316] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 9890.526318] CR2: 0000000000000000 CR3: 0000000391c58005 CR4: 00000000001706f0
    [ 9890.526321] Call Trace:
    [ 9890.526324]  <TASK>
    [ 9890.526327] ? show_regs (arch/x86/kernel/dumpstack.c:479)
    [ 9890.526335] ? __die (arch/x86/kernel/dumpstack.c:421 arch/x86/kernel/dumpstack.c:434)
    [ 9890.526340] ? page_fault_oops (arch/x86/mm/fault.c:713)
    [ 9890.526347] ? search_module_extables (kernel/module/main.c:3256 (discriminator 3))
    [ 9890.526353] ? ieee80211_start_tx_ba_session (net/mac80211/agg-tx.c:618 (discriminator 1)) mac80211
    
    Signed-off-by: Zong-Zhe Yang <[email protected]>
    Link: https://patch.msgid.link/[email protected]
    Signed-off-by: Johannes Berg <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

wifi: nl80211: disallow setting special AP channel widths [+ + +]
Author: Johannes Berg <[email protected]>
Date:   Wed May 15 14:16:00 2024 +0200

    wifi: nl80211: disallow setting special AP channel widths
    
    [ Upstream commit 23daf1b4c91db9b26f8425cc7039cf96d22ccbfe ]
    
    Setting the AP channel width is meant for use with the normal
    20/40/... MHz channel width progression, and switching around
    in S1G or narrow channels isn't supported. Disallow that.
    
    Reported-by: [email protected]
    Link: https://msgid.link/20240515141600.d4a9590bfe32.I19a32d60097e81b527eafe6b0924f6c5fbb2dc45@changeid
    Signed-off-by: Johannes Berg <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

wifi: nl80211: don't give key data to userspace [+ + +]
Author: Johannes Berg <[email protected]>
Date:   Thu Jun 27 10:44:11 2024 +0200

    wifi: nl80211: don't give key data to userspace
    
    [ Upstream commit a7e5793035792cc46a1a4b0a783655ffa897dfe9 ]
    
    When a key is requested by userspace, there's really no need
    to include the key data, the sequence counter is really what
    userspace needs in this case. The fact that it's included is
    just a historic quirk.
    
    Remove the key data.
    
    Reviewed-by: Miriam Rachel Korenblit <[email protected]>
    Link: https://patch.msgid.link/20240627104411.b6a4f097e4ea.I7e6cc976cb9e8a80ef25a3351330f313373b4578@changeid
    Signed-off-by: Johannes Berg <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

wifi: rtlwifi: handle return value of usb init TX/RX [+ + +]
Author: Ping-Ke Shih <[email protected]>
Date:   Fri May 24 08:32:48 2024 +0800

    wifi: rtlwifi: handle return value of usb init TX/RX
    
    [ Upstream commit 9c4fde42cce05719120cf892a44b76ff61d908c7 ]
    
    Handle error code to cause failed to USB probe result from unexpected
    USB EP number, otherwise when USB disconnect skb_dequeue() an uninitialized
    skb list and cause warnings below.
    
    usb 2-1: USB disconnect, device number 76
    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.
    CPU: 0 PID: 54060 Comm: kworker/0:1 Not tainted 6.9.0-rc7 #1
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014
    Workqueue: usb_hub_wq hub_event
    Call Trace:
     <TASK>
     __dump_stack lib/dump_stack.c:88 [inline]
     dump_stack_lvl+0x116/0x1b0 lib/dump_stack.c:114
     assign_lock_key kernel/locking/lockdep.c:976 [inline]
     register_lock_class+0xc18/0xfa0 kernel/locking/lockdep.c:1289
     __lock_acquire+0x108/0x3bc0 kernel/locking/lockdep.c:5014
     lock_acquire kernel/locking/lockdep.c:5754 [inline]
     lock_acquire+0x1b0/0x550 kernel/locking/lockdep.c:5719
     __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
     _raw_spin_lock_irqsave+0x3d/0x60 kernel/locking/spinlock.c:162
     skb_dequeue+0x20/0x180 net/core/skbuff.c:3846
     rtl_usb_cleanup drivers/net/wireless/realtek/rtlwifi/usb.c:706 [inline]
     rtl_usb_deinit drivers/net/wireless/realtek/rtlwifi/usb.c:721 [inline]
     rtl_usb_disconnect+0x4a4/0x850 drivers/net/wireless/realtek/rtlwifi/usb.c:1051
     usb_unbind_interface+0x1e8/0x980 drivers/usb/core/driver.c:461
     device_remove drivers/base/dd.c:568 [inline]
     device_remove+0x122/0x170 drivers/base/dd.c:560
     __device_release_driver drivers/base/dd.c:1270 [inline]
     device_release_driver_internal+0x443/0x620 drivers/base/dd.c:1293
     bus_remove_device+0x22f/0x420 drivers/base/bus.c:574
     device_del+0x395/0x9f0 drivers/base/core.c:3909
     usb_disable_device+0x360/0x7b0 drivers/usb/core/message.c:1418
     usb_disconnect+0x2db/0x930 drivers/usb/core/hub.c:2305
     hub_port_connect drivers/usb/core/hub.c:5362 [inline]
     hub_port_connect_change drivers/usb/core/hub.c:5662 [inline]
     port_event drivers/usb/core/hub.c:5822 [inline]
     hub_event+0x1e39/0x4ce0 drivers/usb/core/hub.c:5904
     process_one_work+0x97b/0x1a90 kernel/workqueue.c:3267
     process_scheduled_works kernel/workqueue.c:3348 [inline]
     worker_thread+0x680/0xf00 kernel/workqueue.c:3429
     kthread+0x2c7/0x3b0 kernel/kthread.c:388
     ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
     ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
     </TASK>
    
    Reported-by: Shichao Lai <[email protected]>
    Closes: https://lore.kernel.org/linux-wireless/CAEk6kZuuezkH1dVRJf3EAVZK-83=OpTz62qCugkpTkswj8JF6w@mail.gmail.com/T/#u
    Tested-by: Shichao Lai <[email protected]>
    Signed-off-by: Ping-Ke Shih <[email protected]>
    Link: https://msgid.link/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

wifi: rtw89: pci: fix RX tag race condition resulting in wrong RX length [+ + +]
Author: Ping-Ke Shih <[email protected]>
Date:   Tue Jun 11 10:19:01 2024 +0800

    wifi: rtw89: pci: fix RX tag race condition resulting in wrong RX length
    
    [ Upstream commit 94298477f81a1701fc4e1b5a0ce9672acab5dcb2 ]
    
    Read 32 bits RX info to a local variable to fix race condition between
    reading RX length and RX tag.
    
    Another solution is to get RX tag at first statement, but adopted solution
    can save some memory read, and also save 15 bytes binary code.
    
    RX tag, a sequence number, is used to ensure that RX data has been DMA to
    memory completely, so driver must check sequence number is expected before
    reading other data.
    
    This potential problem happens only after enabling 36-bit DMA.
    
    Signed-off-by: Ping-Ke Shih <[email protected]>
    Link: https://msgid.link/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
x86/mm: Fix pti_clone_entry_text() for i386 [+ + +]
Author: Peter Zijlstra <[email protected]>
Date:   Thu Aug 1 12:42:25 2024 +0200

    x86/mm: Fix pti_clone_entry_text() for i386
    
    [ Upstream commit 3db03fb4995ef85fc41e86262ead7b4852f4bcf0 ]
    
    While x86_64 has PMD aligned text sections, i386 does not have this
    luxery. Notably ALIGN_ENTRY_TEXT_END is empty and _etext has PAGE
    alignment.
    
    This means that text on i386 can be page granular at the tail end,
    which in turn means that the PTI text clones should consistently
    account for this.
    
    Make pti_clone_entry_text() consistent with pti_clone_kernel_text().
    
    Fixes: 16a3fe634f6a ("x86/mm/pti: Clone kernel-image on PTE level for 32 bit")
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>

x86/mm: Fix pti_clone_pgtable() alignment assumption [+ + +]
Author: Peter Zijlstra <[email protected]>
Date:   Wed Jul 31 18:31:05 2024 +0200

    x86/mm: Fix pti_clone_pgtable() alignment assumption
    
    [ Upstream commit 41e71dbb0e0a0fe214545fe64af031303a08524c ]
    
    Guenter reported dodgy crashes on an i386-nosmp build using GCC-11
    that had the form of endless traps until entry stack exhaust and then
    #DF from the stack guard.
    
    It turned out that pti_clone_pgtable() had alignment assumptions on
    the start address, notably it hard assumes start is PMD aligned. This
    is true on x86_64, but very much not true on i386.
    
    These assumptions can cause the end condition to malfunction, leading
    to a 'short' clone. Guess what happens when the user mapping has a
    short copy of the entry text?
    
    Use the correct increment form for addr to avoid alignment
    assumptions.
    
    Fixes: 16a3fe634f6a ("x86/mm/pti: Clone kernel-image on PTE level for 32 bit")
    Reported-by: Guenter Roeck <[email protected]>
    Tested-by: Guenter Roeck <[email protected]>
    Suggested-by: Thomas Gleixner <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Link: https://lkml.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <[email protected]>

 
x86/mtrr: Check if fixed MTRRs exist before saving them [+ + +]
Author: Andi Kleen <[email protected]>
Date:   Wed Aug 7 17:02:44 2024 -0700

    x86/mtrr: Check if fixed MTRRs exist before saving them
    
    commit 919f18f961c03d6694aa726c514184f2311a4614 upstream.
    
    MTRRs have an obsolete fixed variant for fine grained caching control
    of the 640K-1MB region that uses separate MSRs. This fixed variant has
    a separate capability bit in the MTRR capability MSR.
    
    So far all x86 CPUs which support MTRR have this separate bit set, so it
    went unnoticed that mtrr_save_state() does not check the capability bit
    before accessing the fixed MTRR MSRs.
    
    Though on a CPU that does not support the fixed MTRR capability this
    results in a #GP.  The #GP itself is harmless because the RDMSR fault is
    handled gracefully, but results in a WARN_ON().
    
    Add the missing capability check to prevent this.
    
    Fixes: 2b1f6278d77c ("[PATCH] x86: Save the MTRRs of the BSP before booting an AP")
    Signed-off-by: Andi Kleen <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
x86/paravirt: Fix incorrect virt spinlock setting on bare metal [+ + +]
Author: Chen Yu <[email protected]>
Date:   Tue Aug 6 19:22:07 2024 +0800

    x86/paravirt: Fix incorrect virt spinlock setting on bare metal
    
    commit e639222a51196c69c70b49b67098ce2f9919ed08 upstream.
    
    The kernel can change spinlock behavior when running as a guest. But this
    guest-friendly behavior causes performance problems on bare metal.
    
    The kernel uses a static key to switch between the two modes.
    
    In theory, the static key is enabled by default (run in guest mode) and
    should be disabled for bare metal (and in some guests that want native
    behavior or paravirt spinlock).
    
    A performance drop is reported when running encode/decode workload and
    BenchSEE cache sub-workload.
    
    Bisect points to commit ce0a1b608bfc ("x86/paravirt: Silence unused
    native_pv_lock_init() function warning"). When CONFIG_PARAVIRT_SPINLOCKS is
    disabled the virt_spin_lock_key is incorrectly set to true on bare
    metal. The qspinlock degenerates to test-and-set spinlock, which decreases
    the performance on bare metal.
    
    Set the default value of virt_spin_lock_key to false. If booting in a VM,
    enable this key. Later during the VM initialization, if other
    high-efficient spinlock is preferred (e.g. paravirt-spinlock), or the user
    wants the native qspinlock (via nopvspin boot commandline), the
    virt_spin_lock_key is disabled accordingly.
    
    This results in the following decision matrix:
    
    X86_FEATURE_HYPERVISOR         Y    Y       Y     N
    CONFIG_PARAVIRT_SPINLOCKS      Y    Y       N     Y/N
    PV spinlock                    Y    N       N     Y/N
    
    virt_spin_lock_key             N    Y/N     Y     N
    
    Fixes: ce0a1b608bfc ("x86/paravirt: Silence unused native_pv_lock_init() function warning")
    Reported-by: Prem Nath Dey <[email protected]>
    Reported-by: Xiaoping Zhou <[email protected]>
    Suggested-by: Dave Hansen <[email protected]>
    Suggested-by: Qiuxu Zhuo <[email protected]>
    Suggested-by: Nikolay Borisov <[email protected]>
    Signed-off-by: Chen Yu <[email protected]>
    Signed-off-by: Thomas Gleixner <[email protected]>
    Reviewed-by: Nikolay Borisov <[email protected]>
    Cc: [email protected]
    Link: https://lore.kernel.org/all/[email protected]
    Signed-off-by: Greg Kroah-Hartman <[email protected]>

 
xen: privcmd: Switch from mutex to spinlock for irqfds [+ + +]
Author: Viresh Kumar <[email protected]>
Date:   Tue Jun 18 15:12:28 2024 +0530

    xen: privcmd: Switch from mutex to spinlock for irqfds
    
    [ Upstream commit 1c682593096a487fd9aebc079a307ff7a6d054a3 ]
    
    irqfd_wakeup() gets EPOLLHUP, when it is called by
    eventfd_release() by way of wake_up_poll(&ctx->wqh, EPOLLHUP), which
    gets called under spin_lock_irqsave(). We can't use a mutex here as it
    will lead to a deadlock.
    
    Fix it by switching over to a spin lock.
    
    Reported-by: Al Viro <[email protected]>
    Signed-off-by: Viresh Kumar <[email protected]>
    Reviewed-by: Juergen Gross <[email protected]>
    Link: https://lore.kernel.org/r/a66d7a7a9001424d432f52a9fc3931a1f345464f.1718703669.git.viresh.kumar@linaro.org
    Signed-off-by: Juergen Gross <[email protected]>
    Signed-off-by: Sasha Levin <[email protected]>