commit 4ea3dcf9ab3b162ab4a5ecbb8d9c32f9fe0309ba
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Nov 3 23:52:34 2022 +0900

    Linux 4.19.264
    
    Link: https://lore.kernel.org/r/20221102022052.895556444@linuxfoundation.org
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 98de6b78047ea7acea512c9706dba4c37a773c95
Author: Biju Das <biju.das.jz@bp.renesas.com>
Date:   Tue Oct 25 16:56:55 2022 +0100

    can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
    
    commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.
    
    We are seeing an IRQ storm on the global receive IRQ line under heavy
    CAN bus load conditions with both CAN channels enabled.
    
    Conditions:
    
    The global receive IRQ line is shared between can0 and can1, either of
    the channels can trigger interrupt while the other channel's IRQ line
    is disabled (RFIE).
    
    When global a receive IRQ interrupt occurs, we mask the interrupt in
    the IRQ handler. Clearing and unmasking of the interrupt is happening
    in rx_poll(). There is a race condition where rx_poll() unmasks the
    interrupt, but the next IRQ handler does not mask the IRQ due to
    NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
    can1 is triggering RX interrupt, the delay in rx_poll() processing
    results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.
    
    This patch fixes the issue by checking IRQ active and enabled before
    handling the IRQ on a particular channel.
    
    Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
    Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
    Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
    Cc: stable@vger.kernel.org
    [mkl: adjust commit message]
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    [biju: removed gpriv from RCANFD_RFCC_RFIE macro]
    Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ae3c8503a44b965fcb74ce4017fa0ea26f452d70
Author: Hyong Youb Kim <hyonkim@cisco.com>
Date:   Wed Oct 26 14:51:39 2022 +0100

    net/mlx5e: Do not increment ESN when updating IPsec ESN state
    
    [ Upstream commit 888be6b279b7257b5f6e4c9527675bff0a335596 ]
    
    An offloaded SA stops receiving after about 2^32 + replay_window
    packets. For example, when SA reaches <seq-hi 0x1, seq 0x2c>, all
    subsequent packets get dropped with SA-icv-failure (integrity_failed).
    
    To reproduce the bug:
    - ConnectX-6 Dx with crypto enabled (FW 22.30.1004)
    - ipsec.conf:
      nic-offload = yes
      replay-window = 32
      esn = yes
      salifetime=24h
    - Run netperf for a long time to send more than 2^32 packets
      netperf -H <device-under-test> -t TCP_STREAM -l 20000
    
    When 2^32 + replay_window packets are received, the replay window
    moves from the 2nd half of subspace (overlap=1) to the 1st half
    (overlap=0). The driver then updates the 'esn' value in NIC
    (i.e. seq_hi) as follows.
    
     seq_hi = xfrm_replay_seqhi(seq_bottom)
     new esn in NIC = seq_hi + 1
    
    The +1 increment is wrong, as seq_hi already contains the correct
    seq_hi. For example, when seq_hi=1, the driver actually tells NIC to
    use seq_hi=2 (esn). This incorrect esn value causes all subsequent
    packets to fail integrity checks (SA-icv-failure). So, do not
    increment.
    
    Fixes: cb01008390bb ("net/mlx5: IPSec, Add support for ESN")
    Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
    Acked-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Link: https://lore.kernel.org/r/20221026135153.154807-2-saeed@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 94ebf02ea981fce28b250f9e4df132db6e448b52
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Tue Oct 25 21:00:11 2022 +0800

    net: ehea: fix possible memory leak in ehea_register_port()
    
    [ Upstream commit 0e7ce23a917a9cc83ca3c779fbba836bca3bcf1e ]
    
    If of_device_register() returns error, the of node and the
    name allocated in dev_set_name() is leaked, call put_device()
    to give up the reference that was set in device_initialize(),
    so that of node is put in logical_port_release() and the name
    is freed in kobject_cleanup().
    
    Fixes: 1acf2318dd13 ("ehea: dynamic add / remove port")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221025130011.1071357-1-yangyingliang@huawei.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9f9f051ddf8acf7ef4bd901ff182406a53641df0
Author: Aaron Conole <aconole@redhat.com>
Date:   Tue Oct 25 06:50:17 2022 -0400

    openvswitch: switch from WARN to pr_warn
    
    [ Upstream commit fd954cc1919e35cb92f78671cab6e42d661945a3 ]
    
    As noted by Paolo Abeni, pr_warn doesn't generate any splat and can still
    preserve the warning to the user that feature downgrade occurred.  We
    likely cannot introduce other kinds of checks / enforcement here because
    syzbot can generate different genl versions to the datapath.
    
    Reported-by: syzbot+31cde0bef4bbf8ba2d86@syzkaller.appspotmail.com
    Fixes: 44da5ae5fbea ("openvswitch: Drop user features if old user space attempted to create datapath")
    Cc: Thomas Graf <tgraf@suug.ch>
    Signed-off-by: Aaron Conole <aconole@redhat.com>
    Acked-by: Ilya Maximets <i.maximets@ovn.org>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 96e4b1fe3e334a7815716b21f74d55e4602b4d9d
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Oct 27 08:52:33 2022 +0200

    ALSA: aoa: Fix I2S device accounting
    
    [ Upstream commit f1fae475f10a26b7e34da4ff2e2f19b7feb3548e ]
    
    i2sbus_add_dev() is supposed to return the number of probed devices,
    i.e. either 1 or 0.  However, i2sbus_add_dev() has one error handling
    that returns -ENODEV; this will screw up the accumulation number
    counted in the caller, i2sbus_probe().
    
    Fix the return value to 0 and add the comment for better understanding
    for readers.
    
    Fixes: f3d9478b2ce4 ("[ALSA] snd-aoa: add snd-aoa")
    Link: https://lore.kernel.org/r/20221027065233.13292-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 027fee10e3a400cf6f3237374a1248da1082807b
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Thu Oct 27 09:34:38 2022 +0800

    ALSA: aoa: i2sbus: fix possible memory leak in i2sbus_add_dev()
    
    [ Upstream commit 4a4c8482e370d697738a78dcd7bf2780832cb712 ]
    
    dev_set_name() in soundbus_add_one() allocates memory for name, it need be
    freed when of_device_register() fails, call soundbus_dev_put() to give up
    the reference that hold in device_initialize(), so that it can be freed in
    kobject_cleanup() when the refcount hit to 0. And other resources are also
    freed in i2sbus_release_dev(), so it can return 0 directly.
    
    Fixes: f3d9478b2ce4 ("[ALSA] snd-aoa: add snd-aoa")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221027013438.991920-1-yangyingliang@huawei.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b254c81df2624934350c77433d0665771163ed9c
Author: Sudeep Holla <sudeep.holla@arm.com>
Date:   Tue Oct 25 13:34:32 2022 +0100

    PM: domains: Fix handling of unavailable/disabled idle states
    
    [ Upstream commit e0c57a5c70c13317238cb19a7ded0eab4a5f7de5 ]
    
    Platforms can provide the information about the availability of each
    idle states via status flag. Platforms may have to disable one or more
    idle states for various reasons like broken firmware or other unmet
    dependencies.
    
    Fix handling of such unavailable/disabled idle states by ignoring them
    while parsing the states.
    
    Fixes: a3381e3a65cb ("PM / domains: Fix up domain-idle-states OF parsing")
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 034d7f171918a816cf105a59285a77adbb2c9608
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Mon Oct 24 21:13:38 2022 +0800

    net: ksz884x: fix missing pci_disable_device() on error in pcidev_init()
    
    [ Upstream commit 5da6d65590a0698199df44d095e54b0ed1708178 ]
    
    pci_disable_device() need be called while module exiting, switch to use
    pcim_enable(), pci_disable_device() will be called in pcim_release()
    while unbinding device.
    
    Fixes: 8ca86fd83eae ("net: Micrel KSZ8841/2 PCI Ethernet driver")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221024131338.2848959-1-yangyingliang@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c62669585e6cfc25fbbccd34d206c550606b8379
Author: Slawomir Laba <slawomirx.laba@intel.com>
Date:   Mon Oct 24 03:05:26 2022 -0700

    i40e: Fix flow-type by setting GL_HASH_INSET registers
    
    [ Upstream commit 3b32c9932853e11d71f9db012d69e92e4669ba23 ]
    
    Fix setting bits for specific flow_type for GLQF_HASH_INSET register.
    In previous version all of the bits were set only in hena register, while
    in inset only one bit was set. In order for this working correctly on all
    types of cards these bits needs to be set correctly for both hena and inset
    registers.
    
    Fixes: eb0dd6e4a3b3 ("i40e: Allow RSS Hash set with less than four parameters")
    Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
    Signed-off-by: Michal Jaron <michalx.jaron@intel.com>
    Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
    Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
    Link: https://lore.kernel.org/r/20221024100526.1874914-3-jacob.e.keller@intel.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 76ed715836c6994bac29d9638e9314e6e3b08651
Author: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Date:   Mon Oct 24 03:05:25 2022 -0700

    i40e: Fix VF hang when reset is triggered on another VF
    
    [ Upstream commit 52424f974bc53c26ba3f00300a00e9de9afcd972 ]
    
    When a reset was triggered on one VF with i40e_reset_vf
    global PF state __I40E_VF_DISABLE was set on a PF until
    the reset finished. If immediately after triggering reset
    on one VF there is a request to reset on another
    it will cause a hang on VF side because VF will be notified
    of incoming reset but the reset will never happen because
    of this global state, we will get such error message:
    
    [  +4.890195] iavf 0000:86:02.1: Never saw reset
    
    and VF will hang waiting for the reset to be triggered.
    
    Fix this by introducing new VF state I40E_VF_STATE_RESETTING
    that will be set on a VF if it is currently resetting instead of
    the global __I40E_VF_DISABLE PF state.
    
    Fixes: 3ba9bcb4b68f ("i40e: add locking around VF reset")
    Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
    Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
    Link: https://lore.kernel.org/r/20221024100526.1874914-2-jacob.e.keller@intel.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b8ccef8e9cd1653e8c1b67fdfae145dd5b00118f
Author: Slawomir Laba <slawomirx.laba@intel.com>
Date:   Mon Oct 24 03:05:24 2022 -0700

    i40e: Fix ethtool rx-flow-hash setting for X722
    
    [ Upstream commit 54b5af5a438076082d482cab105b1bd484ab5074 ]
    
    When enabling flow type for RSS hash via ethtool:
    
    ethtool -N $pf rx-flow-hash tcp4|tcp6|udp4|udp6 s|d
    
    the driver would fail to setup this setting on X722
    device since it was using the mask on the register
    dedicated for X710 devices.
    
    Apply a different mask on the register when setting the
    RSS hash for the X722 device.
    
    When displaying the flow types enabled via ethtool:
    
    ethtool -n $pf rx-flow-hash tcp4|tcp6|udp4|udp6
    
    the driver would print wrong values for X722 device.
    
    Fix this issue by testing masks for X722 device in
    i40e_get_rss_hash_opts function.
    
    Fixes: eb0dd6e4a3b3 ("i40e: Allow RSS Hash set with less than four parameters")
    Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
    Signed-off-by: Michal Jaron <michalx.jaron@intel.com>
    Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
    Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
    Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
    Link: https://lore.kernel.org/r/20221024100526.1874914-1-jacob.e.keller@intel.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 438ec9e2cca53002a681ed6fe8fd12e54cb60bf9
Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:   Wed Oct 12 16:46:17 2022 +0100

    media: videodev2.h: V4L2_DV_BT_BLANKING_HEIGHT should check 'interlaced'
    
    [ Upstream commit 8da7f0976b9071b528c545008de9d10cc81883b1 ]
    
    If it is a progressive (non-interlaced) format, then ignore the
    interlaced timing values.
    
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Fixes: 7f68127fa11f ([media] videodev2.h: defines to calculate blanking and frame sizes)
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9cf9211635b68e8e0c8cb88d43ca7dc83e4632aa
Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:   Thu Oct 13 09:00:34 2022 +0100

    media: v4l2-dv-timings: add sanity checks for blanking values
    
    [ Upstream commit 4b6d66a45ed34a15721cb9e11492fa1a24bc83df ]
    
    Add sanity checks to v4l2_valid_dv_timings() to ensure that the provided
    blanking values are reasonable.
    
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Fixes: b18787ed1ce3 ([media] v4l2-dv-timings: add new helper module)
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 29385e601f3420cfe46550271714b6685719eb33
Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:   Thu Oct 13 15:18:46 2022 +0100

    media: vivid: dev->bitmap_cap wasn't freed in all cases
    
    [ Upstream commit 1f65ea411cc7b6ff128d82a3493d7b5648054e6f ]
    
    Whenever the compose width/height values change, the dev->bitmap_cap
    vmalloc'ed array must be freed and dev->bitmap_cap set to NULL.
    
    This was done in some places, but not all. This is only an issue if
    overlay support is enabled and the bitmap clipping is used.
    
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Fixes: ef834f7836ec ([media] vivid: add the video capture and output parts)
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c106967b34725dfb1c76a914b6c2e2773936323f
Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:   Wed Oct 12 15:32:28 2022 +0100

    media: vivid: s_fbuf: add more sanity checks
    
    [ Upstream commit f8bcaf714abfc94818dff8c0db84d750433984f4 ]
    
    VIDIOC_S_FBUF is by definition a scary ioctl, which is why only root
    can use it. But at least check if the framebuffer parameters match that
    of one of the framebuffer created by vivid, and reject anything else.
    
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Fixes: ef834f7836ec ([media] vivid: add the video capture and output parts)
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d7758c23a6e1938458243fb5c4b5230352a89db8
Author: Mario Limonciello <mario.limonciello@amd.com>
Date:   Wed Oct 12 22:50:17 2022 -0500

    PM: hibernate: Allow hybrid sleep to work with s2idle
    
    [ Upstream commit 85850af4fc47132f3f2f0dd698b90f67906600b4 ]
    
    Hybrid sleep is currently hardcoded to only operate with S3 even
    on systems that might not support it.
    
    Instead of assuming this mode is what the user wants to use, for
    hybrid sleep follow the setting of `mem_sleep_current` which
    will respect mem_sleep_default kernel command line and policy
    decisions made by the presence of the FADT low power idle bit.
    
    Fixes: 81d45bdf8913 ("PM / hibernate: Untangle power_down()")
    Reported-and-tested-by: kolAflash <kolAflash@kolahilft.de>
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216574
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 83a2e465f58ac66a19c24c6550d5144ba7659e17
Author: Dongliang Mu <dzm91@hust.edu.cn>
Date:   Mon Oct 24 19:48:07 2022 +0800

    can: mscan: mpc5xxx: mpc5xxx_can_probe(): add missing put_clock() in error path
    
    [ Upstream commit 3e5b3418827cefb5e1cc658806f02965791b8f07 ]
    
    The commit 1149108e2fbf ("can: mscan: improve clock API use") only
    adds put_clock() in mpc5xxx_can_remove() function, forgetting to add
    put_clock() in the error handling code.
    
    Fix this bug by adding put_clock() in the error handling code.
    
    Fixes: 1149108e2fbf ("can: mscan: improve clock API use")
    Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
    Link: https://lore.kernel.org/all/20221024133828.35881-1-mkl@pengutronix.de
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 633da7b30b240000b1d9b690e43848406a0d060f
Author: Neal Cardwell <ncardwell@google.com>
Date:   Fri Oct 21 17:08:21 2022 +0000

    tcp: fix indefinite deferral of RTO with SACK reneging
    
    [ Upstream commit 3d2af9cce3133b3bc596a9d065c6f9d93419ccfb ]
    
    This commit fixes a bug that can cause a TCP data sender to repeatedly
    defer RTOs when encountering SACK reneging.
    
    The bug is that when we're in fast recovery in a scenario with SACK
    reneging, every time we get an ACK we call tcp_check_sack_reneging()
    and it can note the apparent SACK reneging and rearm the RTO timer for
    srtt/2 into the future. In some SACK reneging scenarios that can
    happen repeatedly until the receive window fills up, at which point
    the sender can't send any more, the ACKs stop arriving, and the RTO
    fires at srtt/2 after the last ACK. But that can take far too long
    (O(10 secs)), since the connection is stuck in fast recovery with a
    low cwnd that cannot grow beyond ssthresh, even if more bandwidth is
    available.
    
    This fix changes the logic in tcp_check_sack_reneging() to only rearm
    the RTO timer if data is cumulatively ACKed, indicating forward
    progress. This avoids this kind of nearly infinite loop of RTO timer
    re-arming. In addition, this meets the goals of
    tcp_check_sack_reneging() in handling Windows TCP behavior that looks
    temporarily like SACK reneging but is not really.
    
    Many thanks to Jakub Kicinski and Neil Spring, who reported this issue
    and provided critical packet traces that enabled root-causing this
    issue. Also, many thanks to Jakub Kicinski for testing this fix.
    
    Fixes: 5ae344c949e7 ("tcp: reduce spurious retransmits due to transient SACK reneging")
    Reported-by: Jakub Kicinski <kuba@kernel.org>
    Reported-by: Neil Spring <ntspring@fb.com>
    Signed-off-by: Neal Cardwell <ncardwell@google.com>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Cc: Yuchung Cheng <ycheng@google.com>
    Tested-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20221021170821.1093930-1-ncardwell.kernel@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1513f0c5c9cb39cfddeeba56a12e33effed18662
Author: Zhang Changzhong <zhangchangzhong@huawei.com>
Date:   Fri Oct 21 09:32:24 2022 +0800

    net: lantiq_etop: don't free skb when returning NETDEV_TX_BUSY
    
    [ Upstream commit 9c1eaa27ec599fcc25ed4970c0b73c247d147a2b ]
    
    The ndo_start_xmit() method must not free skb when returning
    NETDEV_TX_BUSY, since caller is going to requeue freed skb.
    
    Fixes: 504d4721ee8e ("MIPS: Lantiq: Add ethernet driver")
    Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5a2ea549be94924364f6911227d99be86e8cf34a
Author: Zhengchao Shao <shaozhengchao@huawei.com>
Date:   Thu Oct 20 10:42:13 2022 +0800

    net: fix UAF issue in nfqnl_nf_hook_drop() when ops_init() failed
    
    [ Upstream commit d266935ac43d57586e311a087510fe6a084af742 ]
    
    When the ops_init() interface is invoked to initialize the net, but
    ops->init() fails, data is released. However, the ptr pointer in
    net->gen is invalid. In this case, when nfqnl_nf_hook_drop() is invoked
    to release the net, invalid address access occurs.
    
    The process is as follows:
    setup_net()
            ops_init()
                    data = kzalloc(...)   ---> alloc "data"
                    net_assign_generic()  ---> assign "date" to ptr in net->gen
                    ...
                    ops->init()           ---> failed
                    ...
                    kfree(data);          ---> ptr in net->gen is invalid
            ...
            ops_exit_list()
                    ...
                    nfqnl_nf_hook_drop()
                            *q = nfnl_queue_pernet(net) ---> q is invalid
    
    The following is the Call Trace information:
    BUG: KASAN: use-after-free in nfqnl_nf_hook_drop+0x264/0x280
    Read of size 8 at addr ffff88810396b240 by task ip/15855
    Call Trace:
    <TASK>
    dump_stack_lvl+0x8e/0xd1
    print_report+0x155/0x454
    kasan_report+0xba/0x1f0
    nfqnl_nf_hook_drop+0x264/0x280
    nf_queue_nf_hook_drop+0x8b/0x1b0
    __nf_unregister_net_hook+0x1ae/0x5a0
    nf_unregister_net_hooks+0xde/0x130
    ops_exit_list+0xb0/0x170
    setup_net+0x7ac/0xbd0
    copy_net_ns+0x2e6/0x6b0
    create_new_namespaces+0x382/0xa50
    unshare_nsproxy_namespaces+0xa6/0x1c0
    ksys_unshare+0x3a4/0x7e0
    __x64_sys_unshare+0x2d/0x40
    do_syscall_64+0x35/0x80
    entry_SYSCALL_64_after_hwframe+0x46/0xb0
    </TASK>
    
    Allocated by task 15855:
    kasan_save_stack+0x1e/0x40
    kasan_set_track+0x21/0x30
    __kasan_kmalloc+0xa1/0xb0
    __kmalloc+0x49/0xb0
    ops_init+0xe7/0x410
    setup_net+0x5aa/0xbd0
    copy_net_ns+0x2e6/0x6b0
    create_new_namespaces+0x382/0xa50
    unshare_nsproxy_namespaces+0xa6/0x1c0
    ksys_unshare+0x3a4/0x7e0
    __x64_sys_unshare+0x2d/0x40
    do_syscall_64+0x35/0x80
    entry_SYSCALL_64_after_hwframe+0x46/0xb0
    
    Freed by task 15855:
    kasan_save_stack+0x1e/0x40
    kasan_set_track+0x21/0x30
    kasan_save_free_info+0x2a/0x40
    ____kasan_slab_free+0x155/0x1b0
    slab_free_freelist_hook+0x11b/0x220
    __kmem_cache_free+0xa4/0x360
    ops_init+0xb9/0x410
    setup_net+0x5aa/0xbd0
    copy_net_ns+0x2e6/0x6b0
    create_new_namespaces+0x382/0xa50
    unshare_nsproxy_namespaces+0xa6/0x1c0
    ksys_unshare+0x3a4/0x7e0
    __x64_sys_unshare+0x2d/0x40
    do_syscall_64+0x35/0x80
    entry_SYSCALL_64_after_hwframe+0x46/0xb0
    
    Fixes: f875bae06533 ("net: Automatically allocate per namespace data.")
    Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f1f7122bb2ef056afc6f91ce4c35ab6df1207c8d
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Oct 20 22:45:12 2022 +0000

    kcm: annotate data-races around kcm->rx_wait
    
    [ Upstream commit 0c745b5141a45a076f1cb9772a399f7ebcb0948a ]
    
    kcm->rx_psock can be read locklessly in kcm_rfree().
    Annotate the read and writes accordingly.
    
    syzbot reported:
    
    BUG: KCSAN: data-race in kcm_rcv_strparser / kcm_rfree
    
    write to 0xffff88810784e3d0 of 1 bytes by task 1823 on cpu 1:
    reserve_rx_kcm net/kcm/kcmsock.c:283 [inline]
    kcm_rcv_strparser+0x250/0x3a0 net/kcm/kcmsock.c:363
    __strp_recv+0x64c/0xd20 net/strparser/strparser.c:301
    strp_recv+0x6d/0x80 net/strparser/strparser.c:335
    tcp_read_sock+0x13e/0x5a0 net/ipv4/tcp.c:1703
    strp_read_sock net/strparser/strparser.c:358 [inline]
    do_strp_work net/strparser/strparser.c:406 [inline]
    strp_work+0xe8/0x180 net/strparser/strparser.c:415
    process_one_work+0x3d3/0x720 kernel/workqueue.c:2289
    worker_thread+0x618/0xa70 kernel/workqueue.c:2436
    kthread+0x1a9/0x1e0 kernel/kthread.c:376
    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
    
    read to 0xffff88810784e3d0 of 1 bytes by task 17869 on cpu 0:
    kcm_rfree+0x121/0x220 net/kcm/kcmsock.c:181
    skb_release_head_state+0x8e/0x160 net/core/skbuff.c:841
    skb_release_all net/core/skbuff.c:852 [inline]
    __kfree_skb net/core/skbuff.c:868 [inline]
    kfree_skb_reason+0x5c/0x260 net/core/skbuff.c:891
    kfree_skb include/linux/skbuff.h:1216 [inline]
    kcm_recvmsg+0x226/0x2b0 net/kcm/kcmsock.c:1161
    ____sys_recvmsg+0x16c/0x2e0
    ___sys_recvmsg net/socket.c:2743 [inline]
    do_recvmmsg+0x2f1/0x710 net/socket.c:2837
    __sys_recvmmsg net/socket.c:2916 [inline]
    __do_sys_recvmmsg net/socket.c:2939 [inline]
    __se_sys_recvmmsg net/socket.c:2932 [inline]
    __x64_sys_recvmmsg+0xde/0x160 net/socket.c:2932
    do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
    entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    value changed: 0x01 -> 0x00
    
    Reported by Kernel Concurrency Sanitizer on:
    CPU: 0 PID: 17869 Comm: syz-executor.2 Not tainted 6.1.0-rc1-syzkaller-00010-gbb1a1146467a-dirty #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
    
    Fixes: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module")
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1b8a5692ab25db4ef1c2cc8e5d21f7a65dc3d079
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Oct 20 22:45:11 2022 +0000

    kcm: annotate data-races around kcm->rx_psock
    
    [ Upstream commit 15e4dabda11b0fa31d510a915d1a580f47dfc92e ]
    
    kcm->rx_psock can be read locklessly in kcm_rfree().
    Annotate the read and writes accordingly.
    
    We do the same for kcm->rx_wait in the following patch.
    
    syzbot reported:
    BUG: KCSAN: data-race in kcm_rfree / unreserve_rx_kcm
    
    write to 0xffff888123d827b8 of 8 bytes by task 2758 on cpu 1:
    unreserve_rx_kcm+0x72/0x1f0 net/kcm/kcmsock.c:313
    kcm_rcv_strparser+0x2b5/0x3a0 net/kcm/kcmsock.c:373
    __strp_recv+0x64c/0xd20 net/strparser/strparser.c:301
    strp_recv+0x6d/0x80 net/strparser/strparser.c:335
    tcp_read_sock+0x13e/0x5a0 net/ipv4/tcp.c:1703
    strp_read_sock net/strparser/strparser.c:358 [inline]
    do_strp_work net/strparser/strparser.c:406 [inline]
    strp_work+0xe8/0x180 net/strparser/strparser.c:415
    process_one_work+0x3d3/0x720 kernel/workqueue.c:2289
    worker_thread+0x618/0xa70 kernel/workqueue.c:2436
    kthread+0x1a9/0x1e0 kernel/kthread.c:376
    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
    
    read to 0xffff888123d827b8 of 8 bytes by task 5859 on cpu 0:
    kcm_rfree+0x14c/0x220 net/kcm/kcmsock.c:181
    skb_release_head_state+0x8e/0x160 net/core/skbuff.c:841
    skb_release_all net/core/skbuff.c:852 [inline]
    __kfree_skb net/core/skbuff.c:868 [inline]
    kfree_skb_reason+0x5c/0x260 net/core/skbuff.c:891
    kfree_skb include/linux/skbuff.h:1216 [inline]
    kcm_recvmsg+0x226/0x2b0 net/kcm/kcmsock.c:1161
    ____sys_recvmsg+0x16c/0x2e0
    ___sys_recvmsg net/socket.c:2743 [inline]
    do_recvmmsg+0x2f1/0x710 net/socket.c:2837
    __sys_recvmmsg net/socket.c:2916 [inline]
    __do_sys_recvmmsg net/socket.c:2939 [inline]
    __se_sys_recvmmsg net/socket.c:2932 [inline]
    __x64_sys_recvmmsg+0xde/0x160 net/socket.c:2932
    do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
    entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    value changed: 0xffff88812971ce00 -> 0x0000000000000000
    
    Reported by Kernel Concurrency Sanitizer on:
    CPU: 0 PID: 5859 Comm: syz-executor.3 Not tainted 6.0.0-syzkaller-12189-g19d17ab7c68b-dirty #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
    
    Fixes: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module")
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4c03f159d1afa4724d7cf615ce88b57fb9da2d61
Author: Raju Rangoju <Raju.Rangoju@amd.com>
Date:   Thu Oct 20 12:12:15 2022 +0530

    amd-xgbe: add the bit rate quirk for Molex cables
    
    [ Upstream commit 170a9e341a3b02c0b2ea0df16ef14a33a4f41de8 ]
    
    The offset 12 (bit-rate) of EEPROM SFP DAC (passive) cables is expected
    to be in the range 0x64 to 0x68. However, the 5 meter and 7 meter Molex
    passive cables have the rate ceiling 0x78 at offset 12.
    
    Add a quirk for Molex passive cables to extend the rate ceiling to 0x78.
    
    Fixes: abf0a1c2b26a ("amd-xgbe: Add support for SFP+ modules")
    Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
    Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ff79bd38de80bbb2fe5ffcdb5fd58c8f5083f496
Author: Raju Rangoju <Raju.Rangoju@amd.com>
Date:   Thu Oct 20 12:12:14 2022 +0530

    amd-xgbe: fix the SFP compliance codes check for DAC cables
    
    [ Upstream commit 09c5f6bf11ac98874339e55f4f5f79a9dbc9b375 ]
    
    The current XGBE code assumes that offset 6 of EEPROM SFP DAC (passive)
    cables is NULL. However, some cables (the 5 meter and 7 meter Molex
    passive cables) have non-zero data at offset 6. Fix the logic by moving
    the passive cable check above the active checks, so as not to be
    improperly identified as an active cable. This will fix the issue for
    any passive cable that advertises 1000Base-CX in offset 6.
    
    Fixes: abf0a1c2b26a ("amd-xgbe: Add support for SFP+ modules")
    Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
    Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 47be012700bc731dd83d2f2d72114591ed713573
Author: Chen Zhongjin <chenzhongjin@huawei.com>
Date:   Wed Jul 27 11:15:06 2022 +0800

    x86/unwind/orc: Fix unreliable stack dump with gcov
    
    [ Upstream commit 230db82413c091bc16acee72650f48d419cebe49 ]
    
    When a console stack dump is initiated with CONFIG_GCOV_PROFILE_ALL
    enabled, show_trace_log_lvl() gets out of sync with the ORC unwinder,
    causing the stack trace to show all text addresses as unreliable:
    
      # echo l > /proc/sysrq-trigger
      [  477.521031] sysrq: Show backtrace of all active CPUs
      [  477.523813] NMI backtrace for cpu 0
      [  477.524492] CPU: 0 PID: 1021 Comm: bash Not tainted 6.0.0 #65
      [  477.525295] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-1.fc36 04/01/2014
      [  477.526439] Call Trace:
      [  477.526854]  <TASK>
      [  477.527216]  ? dump_stack_lvl+0xc7/0x114
      [  477.527801]  ? dump_stack+0x13/0x1f
      [  477.528331]  ? nmi_cpu_backtrace.cold+0xb5/0x10d
      [  477.528998]  ? lapic_can_unplug_cpu+0xa0/0xa0
      [  477.529641]  ? nmi_trigger_cpumask_backtrace+0x16a/0x1f0
      [  477.530393]  ? arch_trigger_cpumask_backtrace+0x1d/0x30
      [  477.531136]  ? sysrq_handle_showallcpus+0x1b/0x30
      [  477.531818]  ? __handle_sysrq.cold+0x4e/0x1ae
      [  477.532451]  ? write_sysrq_trigger+0x63/0x80
      [  477.533080]  ? proc_reg_write+0x92/0x110
      [  477.533663]  ? vfs_write+0x174/0x530
      [  477.534265]  ? handle_mm_fault+0x16f/0x500
      [  477.534940]  ? ksys_write+0x7b/0x170
      [  477.535543]  ? __x64_sys_write+0x1d/0x30
      [  477.536191]  ? do_syscall_64+0x6b/0x100
      [  477.536809]  ? entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [  477.537609]  </TASK>
    
    This happens when the compiled code for show_stack() has a single word
    on the stack, and doesn't use a tail call to show_stack_log_lvl().
    (CONFIG_GCOV_PROFILE_ALL=y is the only known case of this.)  Then the
    __unwind_start() skip logic hits an off-by-one bug and fails to unwind
    all the way to the intended starting frame.
    
    Fix it by reverting the following commit:
    
      f1d9a2abff66 ("x86/unwind/orc: Don't skip the first frame for inactive tasks")
    
    The original justification for that commit no longer exists.  That
    original issue was later fixed in a different way, with the following
    commit:
    
      f2ac57a4c49d ("x86/unwind/orc: Fix inactive tasks with stack pointer in %sp on GCC 10 compiled kernels")
    
    Fixes: f1d9a2abff66 ("x86/unwind/orc: Don't skip the first frame for inactive tasks")
    Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
    [jpoimboe: rewrite commit log]
    Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
    Signed-off-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 728884b22d83148a330b23f9472f1e118b589211
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Wed Oct 19 14:41:04 2022 +0800

    net: netsec: fix error handling in netsec_register_mdio()
    
    [ Upstream commit 94423589689124e8cd145b38a1034be7f25835b2 ]
    
    If phy_device_register() fails, phy_device_free() need be called to
    put refcount, so memory of phy device and device name can be freed
    in callback function.
    
    If get_phy_device() fails, mdiobus_unregister() need be called,
    or it will cause warning in mdiobus_free() and kobject is leaked.
    
    Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221019064104.3228892-1-yangyingliang@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ce69bdac2310152bb70845024d5d704c52aabfc3
Author: Xin Long <lucien.xin@gmail.com>
Date:   Tue Oct 18 15:19:50 2022 -0400

    tipc: fix a null-ptr-deref in tipc_topsrv_accept
    
    [ Upstream commit 82cb4e4612c633a9ce320e1773114875604a3cce ]
    
    syzbot found a crash in tipc_topsrv_accept:
    
      KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
      Workqueue: tipc_rcv tipc_topsrv_accept
      RIP: 0010:kernel_accept+0x22d/0x350 net/socket.c:3487
      Call Trace:
       <TASK>
       tipc_topsrv_accept+0x197/0x280 net/tipc/topsrv.c:460
       process_one_work+0x991/0x1610 kernel/workqueue.c:2289
       worker_thread+0x665/0x1080 kernel/workqueue.c:2436
       kthread+0x2e4/0x3a0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
    
    It was caused by srv->listener that might be set to null by
    tipc_topsrv_stop() in net .exit whereas it's still used in
    tipc_topsrv_accept() worker.
    
    srv->listener is protected by srv->idr_lock in tipc_topsrv_stop(), so add
    a check for srv->listener under srv->idr_lock in tipc_topsrv_accept() to
    avoid the null-ptr-deref. To ensure the lsock is not released during the
    tipc_topsrv_accept(), move sock_release() after tipc_topsrv_work_stop()
    where it's waiting until the tipc_topsrv_accept worker to be done.
    
    Note that sk_callback_lock is used to protect sk->sk_user_data instead of
    srv->listener, and it should check srv in tipc_topsrv_listener_data_ready()
    instead. This also ensures that no more tipc_topsrv_accept worker will be
    started after tipc_conn_close() is called in tipc_topsrv_stop() where it
    sets sk->sk_user_data to null.
    
    Fixes: 0ef897be12b8 ("tipc: separate topology server listener socket from subcsriber sockets")
    Reported-by: syzbot+c5ce866a8d30f4be0651@syzkaller.appspotmail.com
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Jon Maloy <jmaloy@redhat.com>
    Link: https://lore.kernel.org/r/4eee264380c409c61c6451af1059b7fb271a7e7b.1666120790.git.lucien.xin@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ee8bf0946f62ef00e5db4b613a9f664ac567259a
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Wed Oct 19 17:30:25 2022 +0800

    ALSA: ac97: fix possible memory leak in snd_ac97_dev_register()
    
    [ Upstream commit 4881bda5ea05c8c240fc8afeaa928e2bc43f61fa ]
    
    If device_register() fails in snd_ac97_dev_register(), it should
    call put_device() to give up reference, or the name allocated in
    dev_set_name() is leaked.
    
    Fixes: 0ca06a00e206 ("[ALSA] AC97 bus interface for ad-hoc drivers")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221019093025.1179475-1-yangyingliang@huawei.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 13626e56d2f74a5803077cf76ac8ed71d5f7707a
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Sun Oct 9 19:28:46 2022 -0700

    arc: iounmap() arg is volatile
    
    [ Upstream commit c44f15c1c09481d50fd33478ebb5b8284f8f5edb ]
    
    Add 'volatile' to iounmap()'s argument to prevent build warnings.
    This make it the same as other major architectures.
    
    Placates these warnings: (12 such warnings)
    
    ../drivers/video/fbdev/riva/fbdev.c: In function 'rivafb_probe':
    ../drivers/video/fbdev/riva/fbdev.c:2067:42: error: passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type [-Werror=discarded-qualifiers]
     2067 |                 iounmap(default_par->riva.PRAMIN);
    
    Fixes: 1162b0701b14b ("ARC: I/O and DMA Mappings")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Cc: Vineet Gupta <vgupta@kernel.org>
    Cc: linux-snps-arc@lists.infradead.org
    Cc: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Vineet Gupta <vgupta@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5642da89365d6a64700f9b469a235149c79ad1e2
Author: Nathan Huckleberry <nhuck@google.com>
Date:   Tue Sep 13 13:55:48 2022 -0700

    drm/msm: Fix return type of mdp4_lvds_connector_mode_valid
    
    [ Upstream commit 0b33a33bd15d5bab73b87152b220a8d0153a4587 ]
    
    The mode_valid field in drm_connector_helper_funcs is expected to be of
    type:
    enum drm_mode_status (* mode_valid) (struct drm_connector *connector,
                                         struct drm_display_mode *mode);
    
    The mismatched return type breaks forward edge kCFI since the underlying
    function definition does not match the function hook definition.
    
    The return type of mdp4_lvds_connector_mode_valid should be changed from
    int to enum drm_mode_status.
    
    Reported-by: Dan Carpenter <error27@gmail.com>
    Link: https://github.com/ClangBuiltLinux/linux/issues/1703
    Cc: llvm@lists.linux.dev
    Signed-off-by: Nathan Huckleberry <nhuck@google.com>
    Fixes: 3e87599b68e7 ("drm/msm/mdp4: add LVDS panel support")
    Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Reviewed-by: Nathan Chancellor <nathan@kernel.org>
    Patchwork: https://patchwork.freedesktop.org/patch/502878/
    Link: https://lore.kernel.org/r/20220913205551.155128-1-nhuck@google.com
    Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7bce13b40f9fce61c3a8233b100b29d160c5940a
Author: Wei Yongjun <weiyongjun1@huawei.com>
Date:   Mon Sep 19 16:08:30 2022 +0000

    net: ieee802154: fix error return code in dgram_bind()
    
    commit 444d8ad4916edec8a9fc684e841287db9b1e999f upstream.
    
    Fix to return error code -EINVAL from the error handling
    case instead of 0, as done elsewhere in this function.
    
    Fixes: 94160108a70c ("net/ieee802154: fix uninit value bug in dgram_sendmsg")
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
    Link: https://lore.kernel.org/r/20220919160830.1436109-1-weiyongjun@huaweicloud.com
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2b35432d324898ec41beb27031d2a1a864a4d40e
Author: Rik van Riel <riel@surriel.com>
Date:   Mon Oct 17 20:25:05 2022 -0400

    mm,hugetlb: take hugetlb_lock before decrementing h->resv_huge_pages
    
    commit 12df140f0bdfae5dcfc81800970dd7f6f632e00c upstream.
    
    The h->*_huge_pages counters are protected by the hugetlb_lock, but
    alloc_huge_page has a corner case where it can decrement the counter
    outside of the lock.
    
    This could lead to a corrupted value of h->resv_huge_pages, which we have
    observed on our systems.
    
    Take the hugetlb_lock before decrementing h->resv_huge_pages to avoid a
    potential race.
    
    Link: https://lkml.kernel.org/r/20221017202505.0e6a4fcd@imladris.surriel.com
    Fixes: a88c76954804 ("mm: hugetlb: fix hugepage memory leak caused by wrong reserve count")
    Signed-off-by: Rik van Riel <riel@surriel.com>
    Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    Cc: Glen McCready <gkmccready@meta.com>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Muchun Song <songmuchun@bytedance.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cb1ccfe7655380f77a58b340072f5f40bc285902
Author: M. Vefa Bicakci <m.v.b@runbox.com>
Date:   Sun Oct 2 18:20:05 2022 -0400

    xen/gntdev: Prevent leaking grants
    
    commit 0991028cd49567d7016d1b224fe0117c35059f86 upstream.
    
    Prior to this commit, if a grant mapping operation failed partially,
    some of the entries in the map_ops array would be invalid, whereas all
    of the entries in the kmap_ops array would be valid. This in turn would
    cause the following logic in gntdev_map_grant_pages to become invalid:
    
      for (i = 0; i < map->count; i++) {
        if (map->map_ops[i].status == GNTST_okay) {
          map->unmap_ops[i].handle = map->map_ops[i].handle;
          if (!use_ptemod)
            alloced++;
        }
        if (use_ptemod) {
          if (map->kmap_ops[i].status == GNTST_okay) {
            if (map->map_ops[i].status == GNTST_okay)
              alloced++;
            map->kunmap_ops[i].handle = map->kmap_ops[i].handle;
          }
        }
      }
      ...
      atomic_add(alloced, &map->live_grants);
    
    Assume that use_ptemod is true (i.e., the domain mapping the granted
    pages is a paravirtualized domain). In the code excerpt above, note that
    the "alloced" variable is only incremented when both kmap_ops[i].status
    and map_ops[i].status are set to GNTST_okay (i.e., both mapping
    operations are successful).  However, as also noted above, there are
    cases where a grant mapping operation fails partially, breaking the
    assumption of the code excerpt above.
    
    The aforementioned causes map->live_grants to be incorrectly set. In
    some cases, all of the map_ops mappings fail, but all of the kmap_ops
    mappings succeed, meaning that live_grants may remain zero. This in turn
    makes it impossible to unmap the successfully grant-mapped pages pointed
    to by kmap_ops, because unmap_grant_pages has the following snippet of
    code at its beginning:
    
      if (atomic_read(&map->live_grants) == 0)
        return; /* Nothing to do */
    
    In other cases where only some of the map_ops mappings fail but all
    kmap_ops mappings succeed, live_grants is made positive, but when the
    user requests unmapping the grant-mapped pages, __unmap_grant_pages_done
    will then make map->live_grants negative, because the latter function
    does not check if all of the pages that were requested to be unmapped
    were actually unmapped, and the same function unconditionally subtracts
    "data->count" (i.e., a value that can be greater than map->live_grants)
    from map->live_grants. The side effects of a negative live_grants value
    have not been studied.
    
    The net effect of all of this is that grant references are leaked in one
    of the above conditions. In Qubes OS v4.1 (which uses Xen's grant
    mechanism extensively for X11 GUI isolation), this issue manifests
    itself with warning messages like the following to be printed out by the
    Linux kernel in the VM that had granted pages (that contain X11 GUI
    window data) to dom0: "g.e. 0x1234 still pending", especially after the
    user rapidly resizes GUI VM windows (causing some grant-mapping
    operations to partially or completely fail, due to the fact that the VM
    unshares some of the pages as part of the window resizing, making the
    pages impossible to grant-map from dom0).
    
    The fix for this issue involves counting all successful map_ops and
    kmap_ops mappings separately, and then adding the sum to live_grants.
    During unmapping, only the number of successfully unmapped grants is
    subtracted from live_grants. The code is also modified to check for
    negative live_grants values after the subtraction and warn the user.
    
    Link: https://github.com/QubesOS/qubes-issues/issues/7631
    Fixes: dbe97cff7dd9 ("xen/gntdev: Avoid blocking in unmap_grant_pages()")
    Cc: stable@vger.kernel.org
    Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>
    Acked-by: Demi Marie Obenour <demi@invisiblethingslab.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Link: https://lore.kernel.org/r/20221002222006.2077-2-m.v.b@runbox.com
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fce19bd9681061fef518164de670bb73a42653b3
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Sep 17 08:13:08 2021 +0200

    Xen/gntdev: don't ignore kernel unmapping error
    
    commit f28347cc66395e96712f5c2db0a302ee75bafce6 upstream.
    
    While working on XSA-361 and its follow-ups, I failed to spot another
    place where the kernel mapping part of an operation was not treated the
    same as the user space part. Detect and propagate errors and add a 2nd
    pr_debug().
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Link: https://lore.kernel.org/r/c2513395-74dc-aea3-9192-fd265aa44e35@suse.com
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
    Co-authored-by: Demi Marie Obenour <demi@invisiblethingslab.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e2efdae04da4163f7143802c161fa3338a3d49d7
Author: Heiko Carstens <hca@linux.ibm.com>
Date:   Tue Oct 18 13:44:11 2022 +0200

    s390/futex: add missing EX_TABLE entry to __futex_atomic_op()
    
    commit a262d3ad6a433e4080cecd0a8841104a5906355e upstream.
    
    For some exception types the instruction address points behind the
    instruction that caused the exception. Take that into account and add
    the missing exception table entry.
    
    Cc: <stable@vger.kernel.org>
    Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 24051c7bc7ea76145e7e84398c998a57679d7c66
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Wed Oct 26 10:27:36 2022 +0300

    perf auxtrace: Fix address filter symbol name match for modules
    
    commit cba04f3136b658583adb191556f99d087589c1cc upstream.
    
    For modules, names from kallsyms__parse() contain the module name which
    meant that module symbols did not match exactly by name.
    
    Fix by matching the name string up to the separating tab character.
    
    Fixes: 1b36c03e356936d6 ("perf record: Add support for using symbols in address filters")
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20221026072736.2982-1-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 028cf780743eea79abffa7206b9dcfc080ad3546
Author: Christian A. Ehrhardt <lk@c--e.de>
Date:   Tue Sep 13 14:17:23 2022 +0200

    kernfs: fix use-after-free in __kernfs_remove
    
    commit 4abc99652812a2ddf932f137515d5c5a04723538 upstream.
    
    Syzkaller managed to trigger concurrent calls to
    kernfs_remove_by_name_ns() for the same file resulting in
    a KASAN detected use-after-free. The race occurs when the root
    node is freed during kernfs_drain().
    
    To prevent this acquire an additional reference for the root
    of the tree that is removed before calling __kernfs_remove().
    
    Found by syzkaller with the following reproducer (slab_nomerge is
    required):
    
    syz_mount_image$ext4(0x0, &(0x7f0000000100)='./file0\x00', 0x100000, 0x0, 0x0, 0x0, 0x0)
    r0 = openat(0xffffffffffffff9c, &(0x7f0000000080)='/proc/self/exe\x00', 0x0, 0x0)
    close(r0)
    pipe2(&(0x7f0000000140)={0xffffffffffffffff, <r1=>0xffffffffffffffff}, 0x800)
    mount$9p_fd(0x0, &(0x7f0000000040)='./file0\x00', &(0x7f00000000c0), 0x408, &(0x7f0000000280)={'trans=fd,', {'rfdno', 0x3d, r0}, 0x2c, {'wfdno', 0x3d, r1}, 0x2c, {[{@cache_loose}, {@mmap}, {@loose}, {@loose}, {@mmap}], [{@mask={'mask', 0x3d, '^MAY_EXEC'}}, {@fsmagic={'fsmagic', 0x3d, 0x10001}}, {@dont_hash}]}})
    
    Sample report:
    
    ==================================================================
    BUG: KASAN: use-after-free in kernfs_type include/linux/kernfs.h:335 [inline]
    BUG: KASAN: use-after-free in kernfs_leftmost_descendant fs/kernfs/dir.c:1261 [inline]
    BUG: KASAN: use-after-free in __kernfs_remove.part.0+0x843/0x960 fs/kernfs/dir.c:1369
    Read of size 2 at addr ffff8880088807f0 by task syz-executor.2/857
    
    CPU: 0 PID: 857 Comm: syz-executor.2 Not tainted 6.0.0-rc3-00363-g7726d4c3e60b #5
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
    Call Trace:
     <TASK>
     __dump_stack lib/dump_stack.c:88 [inline]
     dump_stack_lvl+0x6e/0x91 lib/dump_stack.c:106
     print_address_description mm/kasan/report.c:317 [inline]
     print_report.cold+0x5e/0x5e5 mm/kasan/report.c:433
     kasan_report+0xa3/0x130 mm/kasan/report.c:495
     kernfs_type include/linux/kernfs.h:335 [inline]
     kernfs_leftmost_descendant fs/kernfs/dir.c:1261 [inline]
     __kernfs_remove.part.0+0x843/0x960 fs/kernfs/dir.c:1369
     __kernfs_remove fs/kernfs/dir.c:1356 [inline]
     kernfs_remove_by_name_ns+0x108/0x190 fs/kernfs/dir.c:1589
     sysfs_slab_add+0x133/0x1e0 mm/slub.c:5943
     __kmem_cache_create+0x3e0/0x550 mm/slub.c:4899
     create_cache mm/slab_common.c:229 [inline]
     kmem_cache_create_usercopy+0x167/0x2a0 mm/slab_common.c:335
     p9_client_create+0xd4d/0x1190 net/9p/client.c:993
     v9fs_session_init+0x1e6/0x13c0 fs/9p/v9fs.c:408
     v9fs_mount+0xb9/0xbd0 fs/9p/vfs_super.c:126
     legacy_get_tree+0xf1/0x200 fs/fs_context.c:610
     vfs_get_tree+0x85/0x2e0 fs/super.c:1530
     do_new_mount fs/namespace.c:3040 [inline]
     path_mount+0x675/0x1d00 fs/namespace.c:3370
     do_mount fs/namespace.c:3383 [inline]
     __do_sys_mount fs/namespace.c:3591 [inline]
     __se_sys_mount fs/namespace.c:3568 [inline]
     __x64_sys_mount+0x282/0x300 fs/namespace.c:3568
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x63/0xcd
    RIP: 0033:0x7f725f983aed
    Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
    RSP: 002b:00007f725f0f7028 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
    RAX: ffffffffffffffda RBX: 00007f725faa3f80 RCX: 00007f725f983aed
    RDX: 00000000200000c0 RSI: 0000000020000040 RDI: 0000000000000000
    RBP: 00007f725f9f419c R08: 0000000020000280 R09: 0000000000000000
    R10: 0000000000000408 R11: 0000000000000246 R12: 0000000000000000
    R13: 0000000000000006 R14: 00007f725faa3f80 R15: 00007f725f0d7000
     </TASK>
    
    Allocated by task 855:
     kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
     kasan_set_track mm/kasan/common.c:45 [inline]
     set_alloc_info mm/kasan/common.c:437 [inline]
     __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:470
     kasan_slab_alloc include/linux/kasan.h:224 [inline]
     slab_post_alloc_hook mm/slab.h:727 [inline]
     slab_alloc_node mm/slub.c:3243 [inline]
     slab_alloc mm/slub.c:3251 [inline]
     __kmem_cache_alloc_lru mm/slub.c:3258 [inline]
     kmem_cache_alloc+0xbf/0x200 mm/slub.c:3268
     kmem_cache_zalloc include/linux/slab.h:723 [inline]
     __kernfs_new_node+0xd4/0x680 fs/kernfs/dir.c:593
     kernfs_new_node fs/kernfs/dir.c:655 [inline]
     kernfs_create_dir_ns+0x9c/0x220 fs/kernfs/dir.c:1010
     sysfs_create_dir_ns+0x127/0x290 fs/sysfs/dir.c:59
     create_dir lib/kobject.c:63 [inline]
     kobject_add_internal+0x24a/0x8d0 lib/kobject.c:223
     kobject_add_varg lib/kobject.c:358 [inline]
     kobject_init_and_add+0x101/0x160 lib/kobject.c:441
     sysfs_slab_add+0x156/0x1e0 mm/slub.c:5954
     __kmem_cache_create+0x3e0/0x550 mm/slub.c:4899
     create_cache mm/slab_common.c:229 [inline]
     kmem_cache_create_usercopy+0x167/0x2a0 mm/slab_common.c:335
     p9_client_create+0xd4d/0x1190 net/9p/client.c:993
     v9fs_session_init+0x1e6/0x13c0 fs/9p/v9fs.c:408
     v9fs_mount+0xb9/0xbd0 fs/9p/vfs_super.c:126
     legacy_get_tree+0xf1/0x200 fs/fs_context.c:610
     vfs_get_tree+0x85/0x2e0 fs/super.c:1530
     do_new_mount fs/namespace.c:3040 [inline]
     path_mount+0x675/0x1d00 fs/namespace.c:3370
     do_mount fs/namespace.c:3383 [inline]
     __do_sys_mount fs/namespace.c:3591 [inline]
     __se_sys_mount fs/namespace.c:3568 [inline]
     __x64_sys_mount+0x282/0x300 fs/namespace.c:3568
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    Freed by task 857:
     kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
     kasan_set_track+0x21/0x30 mm/kasan/common.c:45
     kasan_set_free_info+0x20/0x40 mm/kasan/generic.c:370
     ____kasan_slab_free mm/kasan/common.c:367 [inline]
     ____kasan_slab_free mm/kasan/common.c:329 [inline]
     __kasan_slab_free+0x108/0x190 mm/kasan/common.c:375
     kasan_slab_free include/linux/kasan.h:200 [inline]
     slab_free_hook mm/slub.c:1754 [inline]
     slab_free_freelist_hook mm/slub.c:1780 [inline]
     slab_free mm/slub.c:3534 [inline]
     kmem_cache_free+0x9c/0x340 mm/slub.c:3551
     kernfs_put.part.0+0x2b2/0x520 fs/kernfs/dir.c:547
     kernfs_put+0x42/0x50 fs/kernfs/dir.c:521
     __kernfs_remove.part.0+0x72d/0x960 fs/kernfs/dir.c:1407
     __kernfs_remove fs/kernfs/dir.c:1356 [inline]
     kernfs_remove_by_name_ns+0x108/0x190 fs/kernfs/dir.c:1589
     sysfs_slab_add+0x133/0x1e0 mm/slub.c:5943
     __kmem_cache_create+0x3e0/0x550 mm/slub.c:4899
     create_cache mm/slab_common.c:229 [inline]
     kmem_cache_create_usercopy+0x167/0x2a0 mm/slab_common.c:335
     p9_client_create+0xd4d/0x1190 net/9p/client.c:993
     v9fs_session_init+0x1e6/0x13c0 fs/9p/v9fs.c:408
     v9fs_mount+0xb9/0xbd0 fs/9p/vfs_super.c:126
     legacy_get_tree+0xf1/0x200 fs/fs_context.c:610
     vfs_get_tree+0x85/0x2e0 fs/super.c:1530
     do_new_mount fs/namespace.c:3040 [inline]
     path_mount+0x675/0x1d00 fs/namespace.c:3370
     do_mount fs/namespace.c:3383 [inline]
     __do_sys_mount fs/namespace.c:3591 [inline]
     __se_sys_mount fs/namespace.c:3568 [inline]
     __x64_sys_mount+0x282/0x300 fs/namespace.c:3568
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    The buggy address belongs to the object at ffff888008880780
     which belongs to the cache kernfs_node_cache of size 128
    The buggy address is located 112 bytes inside of
     128-byte region [ffff888008880780, ffff888008880800)
    
    The buggy address belongs to the physical page:
    page:00000000732833f8 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x8880
    flags: 0x100000000000200(slab|node=0|zone=1)
    raw: 0100000000000200 0000000000000000 dead000000000122 ffff888001147280
    raw: 0000000000000000 0000000000150015 00000001ffffffff 0000000000000000
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff888008880680: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
     ffff888008880700: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
    >ffff888008880780: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                 ^
     ffff888008880800: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
     ffff888008880880: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
    ==================================================================
    
    Acked-by: Tejun Heo <tj@kernel.org>
    Cc: stable <stable@kernel.org> # -rc3
    Signed-off-by: Christian A. Ehrhardt <lk@c--e.de>
    Link: https://lore.kernel.org/r/20220913121723.691454-1-lk@c--e.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1fb79478695d92bab1c120ad3dad05252b02a29d
Author: Matthew Ma <mahongwei@zeku.com>
Date:   Fri Oct 14 11:49:51 2022 +0800

    mmc: core: Fix kernel panic when remove non-standard SDIO card
    
    commit 9972e6b404884adae9eec7463e30d9b3c9a70b18 upstream.
    
    SDIO tuple is only allocated for standard SDIO card, especially it causes
    memory corruption issues when the non-standard SDIO card has removed, which
    is because the card device's reference counter does not increase for it at
    sdio_init_func(), but all SDIO card device reference counter gets decreased
    at sdio_release_func().
    
    Fixes: 6f51be3d37df ("sdio: allow non-standard SDIO cards")
    Signed-off-by: Matthew Ma <mahongwei@zeku.com>
    Reviewed-by: Weizhao Ouyang <ouyangweizhao@zeku.com>
    Reviewed-by: John Wang <wangdayu@zeku.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20221014034951.2300386-1-ouyangweizhao@zeku.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3c43f3ec731c233eb84b66199ee76dbf3ec6ecae
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Tue Sep 13 10:53:14 2022 +0200

    drm/msm/hdmi: fix memory corruption with too many bridges
    
    commit 4c1294da6aed1f16d47a417dcfe6602833c3c95c upstream.
    
    Add the missing sanity check on the bridge counter to avoid corrupting
    data beyond the fixed-sized bridge array in case there are ever more
    than eight bridges.
    
    Fixes: a3376e3ec81c ("drm/msm: convert to drm_bridge")
    Cc: stable@vger.kernel.org      # 3.12
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Tested-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
    Reviewed-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/502670/
    Link: https://lore.kernel.org/r/20220913085320.8577-5-johan+linaro@kernel.org
    Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4e5587cddb334f7a5bb1c49ea8bbfc966fafe1b8
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Tue Sep 13 10:53:13 2022 +0200

    drm/msm/dsi: fix memory corruption with too many bridges
    
    commit 2e786eb2f9cebb07e317226b60054df510b60c65 upstream.
    
    Add the missing sanity check on the bridge counter to avoid corrupting
    data beyond the fixed-sized bridge array in case there are ever more
    than eight bridges.
    
    Fixes: a689554ba6ed ("drm/msm: Initial add DSI connector support")
    Cc: stable@vger.kernel.org      # 4.1
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Tested-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
    Reviewed-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
    Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Patchwork: https://patchwork.freedesktop.org/patch/502668/
    Link: https://lore.kernel.org/r/20220913085320.8577-4-johan+linaro@kernel.org
    Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4f1a7bd9b39a41373ed797ff0732bf14d45da772
Author: Miquel Raynal <miquel.raynal@bootlin.com>
Date:   Thu Oct 20 16:25:35 2022 +0200

    mac802154: Fix LQI recording
    
    commit 5a5c4e06fd03b595542d5590f2bc05a6b7fc5c2b upstream.
    
    Back in 2014, the LQI was saved in the skb control buffer (skb->cb, or
    mac_cb(skb)) without any actual reset of this area prior to its use.
    
    As part of a useful rework of the use of this region, 32edc40ae65c
    ("ieee802154: change _cb handling slightly") introduced mac_cb_init() to
    basically memset the cb field to 0. In particular, this new function got
    called at the beginning of mac802154_parse_frame_start(), right before
    the location where the buffer got actually filled.
    
    What went through unnoticed however, is the fact that the very first
    helper called by device drivers in the receive path already used this
    area to save the LQI value for later extraction. Resetting the cb field
    "so late" led to systematically zeroing the LQI.
    
    If we consider the reset of the cb field needed, we can make it as soon
    as we get an skb from a device driver, right before storing the LQI,
    as is the very first time we need to write something there.
    
    Cc: stable@vger.kernel.org
    Fixes: 32edc40ae65c ("ieee802154: change _cb handling slightly")
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Acked-by: Alexander Aring <aahringo@redhat.com>
    Link: https://lore.kernel.org/r/20221020142535.1038885-1-miquel.raynal@bootlin.com
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 70faf9d9b6cc74418716bbf76fe75bd2da10ad4a
Author: Hyunwoo Kim <imv4bel@gmail.com>
Date:   Thu Oct 20 18:15:44 2022 -0700

    fbdev: smscufx: Fix several use-after-free bugs
    
    commit cc67482c9e5f2c80d62f623bcc347c29f9f648e1 upstream.
    
    Several types of UAFs can occur when physically removing a USB device.
    
    Adds ufx_ops_destroy() function to .fb_destroy of fb_ops, and
    in this function, there is kref_put() that finally calls ufx_free().
    
    This fix prevents multiple UAFs.
    
    Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
    Link: https://lore.kernel.org/linux-fbdev/20221011153436.GA4446@ubuntu/
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 971a76b98ba2c1fa75292995d35e981d2f084e39
Author: Shreeya Patel <shreeya.patel@collabora.com>
Date:   Fri Aug 26 17:53:52 2022 +0530

    iio: light: tsl2583: Fix module unloading
    
    commit 0dec4d2f2636b9e54d9d29f17afc7687c5407f78 upstream.
    
    tsl2583 probe() uses devm_iio_device_register() and calling
    iio_device_unregister() causes the unregister to occur twice. s
    Switch to iio_device_register() instead of devm_iio_device_register()
    in probe to avoid the device managed cleanup.
    
    Fixes: 371894f5d1a0 ("iio: tsl2583: add runtime power management support")
    Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
    Link: https://lore.kernel.org/r/20220826122352.288438-1-shreeya.patel@collabora.com
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 37ecf8cbda4f344e998c01a3a0cb838fa92c63fc
Author: Matti Vaittinen <mazziesaccount@gmail.com>
Date:   Thu Oct 13 15:04:04 2022 +0300

    tools: iio: iio_utils: fix digit calculation
    
    commit 72b2aa38191bcba28389b0e20bf6b4f15017ff2b upstream.
    
    The iio_utils uses a digit calculation in order to know length of the
    file name containing a buffer number. The digit calculation does not
    work for number 0.
    
    This leads to allocation of one character too small buffer for the
    file-name when file name contains value '0'. (Eg. buffer0).
    
    Fix digit calculation by returning one digit to be present for number
    '0'.
    
    Fixes: 096f9b862e60 ("tools:iio:iio_utils: implement digit calculation")
    Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
    Link: https://lore.kernel.org/r/Y0f+tKCz+ZAIoroQ@dc75zzyyyyyyyyyyyyycy-3.rev.dnainternet.fi
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cebbc8d335d6bcc1316584f779c08f80287c6af8
Author: Mathias Nyman <mathias.nyman@linux.intel.com>
Date:   Mon Oct 24 17:27:20 2022 +0300

    xhci: Remove device endpoints from bandwidth list when freeing the device
    
    commit 5aed5b7c2430ce318a8e62f752f181e66f0d1053 upstream.
    
    Endpoints are normally deleted from the bandwidth list when they are
    dropped, before the virt device is freed.
    
    If xHC host is dying or being removed then the endpoints aren't dropped
    cleanly due to functions returning early to avoid interacting with a
    non-accessible host controller.
    
    So check and delete endpoints that are still on the bandwidth list when
    freeing the virt device.
    
    Solves a list_del corruption kernel crash when unbinding xhci-pci,
    caused by xhci_mem_cleanup() when it later tried to delete already freed
    endpoints from the bandwidth list.
    
    This only affects hosts that use software bandwidth checking, which
    currenty is only the xHC in intel Panther Point PCH (Ivy Bridge)
    
    Cc: stable@vger.kernel.org
    Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Link: https://lore.kernel.org/r/20221024142720.4122053-5-mathias.nyman@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e72168e056f8ee984622a0a225e921bcc21dc4cc
Author: Jens Glathe <jens.glathe@oldschoolsolutions.biz>
Date:   Mon Oct 24 17:27:17 2022 +0300

    usb: xhci: add XHCI_SPURIOUS_SUCCESS to ASM1042 despite being a V0.96 controller
    
    commit 4f547472380136718b56064ea5689a61e135f904 upstream.
    
    This appears to fix the error:
    "xhci_hcd <address>; ERROR Transfer event TRB DMA ptr not part of
    current TD ep_index 2 comp_code 13" that appear spuriously (or pretty
    often) when using a r8152 USB3 ethernet adapter with integrated hub.
    
    ASM1042 reports as a 0.96 controller, but appears to behave more like 1.0
    
    Inspired by this email thread: https://markmail.org/thread/7vzqbe7t6du6qsw3
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Jens Glathe <jens.glathe@oldschoolsolutions.biz>
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Link: https://lore.kernel.org/r/20221024142720.4122053-2-mathias.nyman@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 71316fe2ec23cd56129a453e518087b525738d25
Author: Justin Chen <justinpopo6@gmail.com>
Date:   Wed Oct 5 12:13:55 2022 -0700

    usb: bdc: change state when port disconnected
    
    commit fb8f60dd1b67520e0e0d7978ef17d015690acfc1 upstream.
    
    When port is connected and then disconnected, the state stays as
    configured. Which is incorrect as the port is no longer configured,
    but in a not attached state.
    
    Signed-off-by: Justin Chen <justinpopo6@gmail.com>
    Acked-by: Florian Fainelli <f.fainelli@gmail.com>
    Fixes: efed421a94e6 ("usb: gadget: Add UDC driver for Broadcom USB3.0 device controller IP BDC")
    Cc: stable <stable@kernel.org>
    Link: https://lore.kernel.org/r/1664997235-18198-1-git-send-email-justinpopo6@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 370827107fe49dde38255db2420be67239ee3eba
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Tue Oct 25 15:10:20 2022 -0700

    usb: dwc3: gadget: Don't set IMI for no_interrupt
    
    commit 308c316d16cbad99bb834767382baa693ac42169 upstream.
    
    The gadget driver may have a certain expectation of how the request
    completion flow should be from to its configuration. Make sure the
    controller driver respect that. That is, don't set IMI (Interrupt on
    Missed Isoc) when usb_request->no_interrupt is set. Also, the driver
    should only set IMI to the last TRB of a chain.
    
    Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
    Cc: stable@vger.kernel.org
    Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Reviewed-by: Jeff Vanhoof <jdv1029@gmail.com>
    Tested-by: Jeff Vanhoof <jdv1029@gmail.com>
    Link: https://lore.kernel.org/r/ced336c84434571340c07994e3667a0ee284fefe.1666735451.git.Thinh.Nguyen@synopsys.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5a8fe9a5e0e26ae13ff82d122ed2d7f3ea6ed2a2
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Tue Oct 25 15:10:14 2022 -0700

    usb: dwc3: gadget: Stop processing more requests on IMI
    
    commit f78961f8380b940e0cfc7e549336c21a2ad44f4d upstream.
    
    When servicing a transfer completion event, the dwc3 driver will reclaim
    TRBs of started requests up to the request associated with the interrupt
    event. Currently we don't check for interrupt due to missed isoc, and
    the driver may attempt to reclaim TRBs beyond the associated event. This
    causes invalid memory access when the hardware still owns the TRB. If
    there's a missed isoc TRB with IMI (interrupt on missed isoc), make sure
    to stop servicing further.
    
    Note that only the last TRB of chained TRBs has its status updated with
    missed isoc.
    
    Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
    Cc: stable@vger.kernel.org
    Reported-by: Jeff Vanhoof <jdv1029@gmail.com>
    Reported-by: Dan Vacura <w36195@motorola.com>
    Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Reviewed-by: Jeff Vanhoof <jdv1029@gmail.com>
    Tested-by: Jeff Vanhoof <jdv1029@gmail.com>
    Link: https://lore.kernel.org/r/b29acbeab531b666095dfdafd8cb5c7654fbb3e1.1666735451.git.Thinh.Nguyen@synopsys.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 126b0a2dc0a69c8130217903b17d9d575c704900
Author: Hannu Hartikainen <hannu@hrtk.in>
Date:   Mon Sep 19 20:16:10 2022 +0300

    USB: add RESET_RESUME quirk for NVIDIA Jetson devices in RCM
    
    commit fc4ade55c617dc73c7e9756b57f3230b4ff24540 upstream.
    
    NVIDIA Jetson devices in Force Recovery mode (RCM) do not support
    suspending, ie. flashing fails if the device has been suspended. The
    devices are still visible in lsusb and seem to work otherwise, making
    the issue hard to debug. This has been discovered in various forum
    posts, eg. [1].
    
    The patch has been tested on NVIDIA Jetson AGX Xavier, but I'm adding
    all the Jetson models listed in [2] on the assumption that they all
    behave similarly.
    
    [1]: https://forums.developer.nvidia.com/t/flashing-not-working/72365
    [2]: https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3271/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/quick_start.html
    
    Signed-off-by: Hannu Hartikainen <hannu@hrtk.in>
    Cc: stable <stable@kernel.org>  # after 6.1-rc3
    Link: https://lore.kernel.org/r/20220919171610.30484-1-hannu@hrtk.in
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bcecbec20b0ea5612602a42d67a0b80695e805ba
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Mon Oct 24 18:29:29 2022 +0200

    ALSA: au88x0: use explicitly signed char
    
    commit ee03c0f200eb0d9f22dd8732d9fb7956d91019c2 upstream.
    
    With char becoming unsigned by default, and with `char` alone being
    ambiguous and based on architecture, signed chars need to be marked
    explicitly as such. This fixes warnings like:
    
    sound/pci/au88x0/au88x0_core.c:2029 vortex_adb_checkinout() warn: signedness bug returning '(-22)'
    sound/pci/au88x0/au88x0_core.c:2046 vortex_adb_checkinout() warn: signedness bug returning '(-12)'
    sound/pci/au88x0/au88x0_core.c:2125 vortex_adb_allocroute() warn: 'vortex_adb_checkinout(vortex, (0), en, 0)' is unsigned
    sound/pci/au88x0/au88x0_core.c:2170 vortex_adb_allocroute() warn: 'vortex_adb_checkinout(vortex, stream->resources, en, 4)' is unsigned
    
    As well, since one function returns errnos, return an `int` rather than
    a `signed char`.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20221024162929.536004-1-Jason@zx2c4.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 904209ea21b3cdd82589e6ec7ab7136a1d0bc72d
Author: Steven Rostedt (Google) <rostedt@goodmis.org>
Date:   Wed Oct 26 23:12:36 2022 -0400

    ALSA: Use del_timer_sync() before freeing timer
    
    commit f0a868788fcbf63cdab51f5adcf73b271ede8164 upstream.
    
    The current code for freeing the emux timer is extremely dangerous:
    
      CPU0                          CPU1
      ----                          ----
    snd_emux_timer_callback()
                                snd_emux_free()
                                  spin_lock(&emu->voice_lock)
                                  del_timer(&emu->tlist); <-- returns immediately
                                  spin_unlock(&emu->voice_lock);
                                  [..]
                                  kfree(emu);
    
      spin_lock(&emu->voice_lock);
    
     [BOOM!]
    
    Instead just use del_timer_sync() which will wait for the timer to finish
    before continuing. No need to check if the timer is active or not when
    doing so.
    
    This doesn't fix the race of a possible re-arming of the timer, but at
    least it won't use the data that has just been freed.
    
    [ Fixed unused variable warning by tiwai ]
    
    Cc: stable@vger.kernel.org
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20221026231236.6834b551@gandalf.local.home
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit db226f39c213e57269fc21b63abfc6c8b468ec79
Author: Anssi Hannula <anssi.hannula@bitwise.fi>
Date:   Mon Oct 10 20:52:27 2022 +0200

    can: kvaser_usb: Fix possible completions during init_completion
    
    commit 2871edb32f4622c3a25ce4b3977bad9050b91974 upstream.
    
    kvaser_usb uses completions to signal when a response event is received
    for outgoing commands.
    
    However, it uses init_completion() to reinitialize the start_comp and
    stop_comp completions before sending the start/stop commands.
    
    In case the device sends the corresponding response just before the
    actual command is sent, complete() may be called concurrently with
    init_completion() which is not safe.
    
    This might be triggerable even with a properly functioning device by
    stopping the interface (CMD_STOP_CHIP) just after it goes bus-off (which
    also causes the driver to send CMD_STOP_CHIP when restart-ms is off),
    but that was not tested.
    
    Fix the issue by using reinit_completion() instead.
    
    Fixes: 080f40a6fa28 ("can: kvaser_usb: Add support for Kvaser CAN/USB devices")
    Tested-by: Jimmy Assarsson <extja@kvaser.com>
    Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
    Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
    Link: https://lore.kernel.org/all/20221010185237.319219-2-extja@kvaser.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dbe863bce7679c7f5ec0e993d834fe16c5e687b5
Author: Seth Jenkins <sethjenkins@google.com>
Date:   Thu Oct 27 11:36:52 2022 -0400

    mm: /proc/pid/smaps_rollup: fix no vma's null-deref
    
    Commit 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value
    seq_file") introduced a null-deref if there are no vma's in the task in
    show_smaps_rollup.
    
    Fixes: 258f669e7e88 ("mm: /proc/pid/smaps_rollup: convert to single value seq_file")
    Signed-off-by: Seth Jenkins <sethjenkins@google.com>
    Reviewed-by: Alexey Dobriyan <adobriyan@gmail.com>
    Tested-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0f10976b62f814ac91400546a298313a85a4cf79
Author: Gaurav Kohli <gauravkohli@linux.microsoft.com>
Date:   Wed Oct 5 22:52:59 2022 -0700

    hv_netvsc: Fix race between VF offering and VF association message from host
    
    commit 365e1ececb2905f94cc10a5817c5b644a32a3ae2 upstream.
    
    During vm boot, there might be possibility that vf registration
    call comes before the vf association from host to vm.
    
    And this might break netvsc vf path, To prevent the same block
    vf registration until vf bind message comes from host.
    
    Cc: stable@vger.kernel.org
    Fixes: 00d7ddba11436 ("hv_netvsc: pair VF based on serial number")
    Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
    Signed-off-by: Gaurav Kohli <gauravkohli@linux.microsoft.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b442ad833037a9b6528d6c6a950aea9f2032338b
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Mon Oct 24 13:34:14 2022 -0700

    Makefile.debug: re-enable debug info for .S files
    
    This is _not_ an upstream commit and just for 4.19.y only. It is based
    on commit 32ef9e5054ec0321b9336058c58ec749e9c6b0fe upstream.
    
    Alexey reported that the fraction of unknown filename instances in
    kallsyms grew from ~0.3% to ~10% recently; Bill and Greg tracked it down
    to assembler defined symbols, which regressed as a result of:
    
    commit b8a9092330da ("Kbuild: do not emit debug info for assembly with LLVM_IAS=1")
    
    In that commit, I allude to restoring debug info for assembler defined
    symbols in a follow up patch, but it seems I forgot to do so in
    
    commit a66049e2cf0e ("Kbuild: make DWARF version a choice")
    
    Fixes: b8a9092330da ("Kbuild: do not emit debug info for assembly with LLVM_IAS=1")
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e0eaf41b1dcb24ac96de8c1dcc3053ee49f05a02
Author: Werner Sembach <wse@tuxedocomputers.com>
Date:   Wed Oct 26 17:22:46 2022 +0200

    ACPI: video: Force backlight native for more TongFang devices
    
    commit 3dbc80a3e4c55c4a5b89ef207bed7b7de36157b4 upstream.
    
    This commit is very different from the upstream commit! It fixes the same
    issue by adding more quirks, rather then the general fix from the 6.1
    kernel, because the general fix from the 6.1 kernel is part of a larger
    refactoring of the backlight code which is not suitable for the stable
    series.
    
    As described in "ACPI: video: Drop NL5x?U, PF4NU1F and PF5?U??
    acpi_backlight=native quirks" (10212754a0d2) the upstream commit "ACPI:
    video: Make backlight class device registration a separate step (v2)"
    (3dbc80a3e4c5) makes these quirks unnecessary. However as mentioned in this
    bugtracker ticket https://bugzilla.kernel.org/show_bug.cgi?id=215683#c17
    the upstream fix is part of a larger patchset that is overall too complex
    for stable.
    
    The TongFang GKxNRxx, GMxNGxx, GMxZGxx, and GMxRGxx / TUXEDO
    Stellaris/Polaris Gen 1-4, have the same problem as the Clevo NL5xRU and
    NL5xNU / TUXEDO Aura 15 Gen1 and Gen2:
    They have a working native and video interface for screen backlight.
    However the default detection mechanism first registers the video interface
    before unregistering it again and switching to the native interface during
    boot. This results in a dangling SBIOS request for backlight change for
    some reason, causing the backlight to switch to ~2% once per boot on the
    first power cord connect or disconnect event. Setting the native interface
    explicitly circumvents this buggy behaviour by avoiding the unregistering
    process.
    
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 95c4751705f7eef0f16a245e121259857f867c4a
Author: Chen-Yu Tsai <wenst@chromium.org>
Date:   Thu Dec 9 17:38:03 2021 +0100

    media: v4l2-mem2mem: Apply DST_QUEUE_OFF_BASE on MMAP buffers across ioctls
    
    commit 8310ca94075e784bbb06593cd6c068ee6b6e4ca6 upstream.
    
    DST_QUEUE_OFF_BASE is applied to offset/mem_offset on MMAP capture buffers
    only for the VIDIOC_QUERYBUF ioctl, while the userspace fields (including
    offset/mem_offset) are filled in for VIDIOC_{QUERY,PREPARE,Q,DQ}BUF
    ioctls. This leads to differences in the values presented to userspace.
    If userspace attempts to mmap the capture buffer directly using values
    from DQBUF, it will fail.
    
    Move the code that applies the magic offset into a helper, and call
    that helper from all four ioctl entry points.
    
    [hverkuil: drop unnecessary '= 0' in v4l2_m2m_querybuf() for ret]
    
    Fixes: 7f98639def42 ("V4L/DVB: add memory-to-memory device helper framework for videobuf")
    Fixes: 908a0d7c588e ("[media] v4l: mem2mem: port to videobuf2")
    Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    [OP: adjusted return logic for 4.19]
    Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5cecfe151874b835331efe086bbdcaeaf64f6b90
Author: Jerry Snitselaar <jsnitsel@redhat.com>
Date:   Wed Oct 19 08:44:47 2022 +0800

    iommu/vt-d: Clean up si_domain in the init_dmars() error path
    
    [ Upstream commit 620bf9f981365c18cc2766c53d92bf8131c63f32 ]
    
    A splat from kmem_cache_destroy() was seen with a kernel prior to
    commit ee2653bbe89d ("iommu/vt-d: Remove domain and devinfo mempool")
    when there was a failure in init_dmars(), because the iommu_domain
    cache still had objects. While the mempool code is now gone, there
    still is a leak of the si_domain memory if init_dmars() fails. So
    clean up si_domain in the init_dmars() error path.
    
    Cc: Lu Baolu <baolu.lu@linux.intel.com>
    Cc: Joerg Roedel <joro@8bytes.org>
    Cc: Will Deacon <will@kernel.org>
    Cc: Robin Murphy <robin.murphy@arm.com>
    Fixes: 86080ccc223a ("iommu/vt-d: Allocate si_domain in init_dmars()")
    Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
    Link: https://lore.kernel.org/r/20221010144842.308890-1-jsnitsel@redhat.com
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7ae1345f6ad715acbcdc9e1ac28153684fd498bb
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Tue Oct 18 20:24:51 2022 +0800

    net: hns: fix possible memory leak in hnae_ae_register()
    
    [ Upstream commit ff2f5ec5d009844ec28f171123f9e58750cef4bf ]
    
    Inject fault while probing module, if device_register() fails,
    but the refcount of kobject is not decreased to 0, the name
    allocated in dev_set_name() is leaked. Fix this by calling
    put_device(), so that name can be freed in callback function
    kobject_cleanup().
    
    unreferenced object 0xffff00c01aba2100 (size 128):
      comm "systemd-udevd", pid 1259, jiffies 4294903284 (age 294.152s)
      hex dump (first 32 bytes):
        68 6e 61 65 30 00 00 00 18 21 ba 1a c0 00 ff ff  hnae0....!......
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      backtrace:
        [<0000000034783f26>] slab_post_alloc_hook+0xa0/0x3e0
        [<00000000748188f2>] __kmem_cache_alloc_node+0x164/0x2b0
        [<00000000ab0743e8>] __kmalloc_node_track_caller+0x6c/0x390
        [<000000006c0ffb13>] kvasprintf+0x8c/0x118
        [<00000000fa27bfe1>] kvasprintf_const+0x60/0xc8
        [<0000000083e10ed7>] kobject_set_name_vargs+0x3c/0xc0
        [<000000000b87affc>] dev_set_name+0x7c/0xa0
        [<000000003fd8fe26>] hnae_ae_register+0xcc/0x190 [hnae]
        [<00000000fe97edc9>] hns_dsaf_ae_init+0x9c/0x108 [hns_dsaf]
        [<00000000c36ff1eb>] hns_dsaf_probe+0x548/0x748 [hns_dsaf]
    
    Fixes: 6fe6611ff275 ("net: add Hisilicon Network Subsystem hnae framework support")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Link: https://lore.kernel.org/r/20221018122451.1749171-1-yangyingliang@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 86aa1390898146f1de277bb6d2a8ed7fc7a43f12
Author: Zhengchao Shao <shaozhengchao@huawei.com>
Date:   Tue Oct 18 14:31:59 2022 +0800

    net: sched: cake: fix null pointer access issue when cake_init() fails
    
    [ Upstream commit 51f9a8921ceacd7bf0d3f47fa867a64988ba1dcb ]
    
    When the default qdisc is cake, if the qdisc of dev_queue fails to be
    inited during mqprio_init(), cake_reset() is invoked to clear
    resources. In this case, the tins is NULL, and it will cause gpf issue.
    
    The process is as follows:
    qdisc_create_dflt()
            cake_init()
                    q->tins = kvcalloc(...)        --->failed, q->tins is NULL
            ...
            qdisc_put()
                    ...
                    cake_reset()
                            ...
                            cake_dequeue_one()
                                    b = &q->tins[...]   --->q->tins is NULL
    
    The following is the Call Trace information:
    general protection fault, probably for non-canonical address
    0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN
    KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
    RIP: 0010:cake_dequeue_one+0xc9/0x3c0
    Call Trace:
    <TASK>
    cake_reset+0xb1/0x140
    qdisc_reset+0xed/0x6f0
    qdisc_destroy+0x82/0x4c0
    qdisc_put+0x9e/0xb0
    qdisc_create_dflt+0x2c3/0x4a0
    mqprio_init+0xa71/0x1760
    qdisc_create+0x3eb/0x1000
    tc_modify_qdisc+0x408/0x1720
    rtnetlink_rcv_msg+0x38e/0xac0
    netlink_rcv_skb+0x12d/0x3a0
    netlink_unicast+0x4a2/0x740
    netlink_sendmsg+0x826/0xcc0
    sock_sendmsg+0xc5/0x100
    ____sys_sendmsg+0x583/0x690
    ___sys_sendmsg+0xe8/0x160
    __sys_sendmsg+0xbf/0x160
    do_syscall_64+0x35/0x80
    entry_SYSCALL_64_after_hwframe+0x46/0xb0
    RIP: 0033:0x7f89e5122d04
    </TASK>
    
    Fixes: 046f6fd5daef ("sched: Add Common Applications Kept Enhanced (cake) qdisc")
    Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
    Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c5f762b60cd9ae7c766376a94d9c41f4ed613d9f
Author: Xiaobo Liu <cppcoffee@gmail.com>
Date:   Fri Oct 14 10:05:40 2022 +0800

    net/atm: fix proc_mpc_write incorrect return value
    
    [ Upstream commit d8bde3bf7f82dac5fc68a62c2816793a12cafa2a ]
    
    Then the input contains '\0' or '\n', proc_mpc_write has read them,
    so the return value needs +1.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 31294deb75b59bf22517b16f4c3fc5dbed15b183
Author: José Expósito <jose.exposito89@gmail.com>
Date:   Sun Oct 9 20:27:47 2022 +0200

    HID: magicmouse: Do not set BTN_MOUSE on double report
    
    [ Upstream commit bb5f0c855dcfc893ae5ed90e4c646bde9e4498bf ]
    
    Under certain conditions the Magic Trackpad can group 2 reports in a
    single packet. The packet is split and the raw event function is
    invoked recursively for each part.
    
    However, after processing each part, the BTN_MOUSE status is updated,
    sending multiple click events. [1]
    
    Return after processing double reports to avoid this issue.
    
    Link: https://gitlab.freedesktop.org/libinput/libinput/-/issues/811  # [1]
    Fixes: a462230e16ac ("HID: magicmouse: enable Magic Trackpad support")
    Reported-by: Nulo <git@nulo.in>
    Signed-off-by: José Expósito <jose.exposito89@gmail.com>
    Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
    Link: https://lore.kernel.org/r/20221009182747.90730-1-jose.exposito89@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3d1b83ff7b6575a4e41283203e6b2e25ea700cd7
Author: Alexander Potapenko <glider@google.com>
Date:   Wed Oct 12 17:25:14 2022 +0200

    tipc: fix an information leak in tipc_topsrv_kern_subscr
    
    [ Upstream commit 777ecaabd614d47c482a5c9031579e66da13989a ]
    
    Use a 8-byte write to initialize sub.usr_handle in
    tipc_topsrv_kern_subscr(), otherwise four bytes remain uninitialized
    when issuing setsockopt(..., SOL_TIPC, ...).
    This resulted in an infoleak reported by KMSAN when the packet was
    received:
    
      =====================================================
      BUG: KMSAN: kernel-infoleak in copyout+0xbc/0x100 lib/iov_iter.c:169
       instrument_copy_to_user ./include/linux/instrumented.h:121
       copyout+0xbc/0x100 lib/iov_iter.c:169
       _copy_to_iter+0x5c0/0x20a0 lib/iov_iter.c:527
       copy_to_iter ./include/linux/uio.h:176
       simple_copy_to_iter+0x64/0xa0 net/core/datagram.c:513
       __skb_datagram_iter+0x123/0xdc0 net/core/datagram.c:419
       skb_copy_datagram_iter+0x58/0x200 net/core/datagram.c:527
       skb_copy_datagram_msg ./include/linux/skbuff.h:3903
       packet_recvmsg+0x521/0x1e70 net/packet/af_packet.c:3469
       ____sys_recvmsg+0x2c4/0x810 net/socket.c:?
       ___sys_recvmsg+0x217/0x840 net/socket.c:2743
       __sys_recvmsg net/socket.c:2773
       __do_sys_recvmsg net/socket.c:2783
       __se_sys_recvmsg net/socket.c:2780
       __x64_sys_recvmsg+0x364/0x540 net/socket.c:2780
       do_syscall_x64 arch/x86/entry/common.c:50
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd arch/x86/entry/entry_64.S:120
    
      ...
    
      Uninit was stored to memory at:
       tipc_sub_subscribe+0x42d/0xb50 net/tipc/subscr.c:156
       tipc_conn_rcv_sub+0x246/0x620 net/tipc/topsrv.c:375
       tipc_topsrv_kern_subscr+0x2e8/0x400 net/tipc/topsrv.c:579
       tipc_group_create+0x4e7/0x7d0 net/tipc/group.c:190
       tipc_sk_join+0x2a8/0x770 net/tipc/socket.c:3084
       tipc_setsockopt+0xae5/0xe40 net/tipc/socket.c:3201
       __sys_setsockopt+0x87f/0xdc0 net/socket.c:2252
       __do_sys_setsockopt net/socket.c:2263
       __se_sys_setsockopt net/socket.c:2260
       __x64_sys_setsockopt+0xe0/0x160 net/socket.c:2260
       do_syscall_x64 arch/x86/entry/common.c:50
       do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd arch/x86/entry/entry_64.S:120
    
      Local variable sub created at:
       tipc_topsrv_kern_subscr+0x57/0x400 net/tipc/topsrv.c:562
       tipc_group_create+0x4e7/0x7d0 net/tipc/group.c:190
    
      Bytes 84-87 of 88 are uninitialized
      Memory access of size 88 starts at ffff88801ed57cd0
      Data copied to user address 0000000020000400
      ...
      =====================================================
    
    Signed-off-by: Alexander Potapenko <glider@google.com>
    Fixes: 026321c6d056a5 ("tipc: rename tipc_server to tipc_topsrv")
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d62e0f037e482f2fbb671496a797ff807f292dd6
Author: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
Date:   Mon Oct 10 15:46:13 2022 +1300

    tipc: Fix recognition of trial period
    
    [ Upstream commit 28be7ca4fcfd69a2d52aaa331adbf9dbe91f9e6e ]
    
    The trial period exists until jiffies is after addr_trial_end. But as
    jiffies will eventually overflow, just using time_after will eventually
    give incorrect results. As the node address is set once the trial period
    ends, this can be used to know that we are not in the trial period.
    
    Fixes: e415577f57f4 ("tipc: correct discovery message handling during address trial period")
    Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0e15c89f5b27398e707ab8f865ad7995cb4fb8fa
Author: Tony Luck <tony.luck@intel.com>
Date:   Mon Oct 10 13:34:23 2022 -0700

    ACPI: extlog: Handle multiple records
    
    [ Upstream commit f6ec01da40e4139b41179f046044ee7c4f6370dc ]
    
    If there is no user space consumer of extlog_mem trace records, then
    Linux properly handles multiple error records in an ELOG block
    
            extlog_print()
              print_extlog_rcd()
                __print_extlog_rcd()
                  cper_estatus_print()
                    apei_estatus_for_each_section()
    
    But the other code path hard codes looking for a single record to
    output a trace record.
    
    Fix by using the same apei_estatus_for_each_section() iterator
    to step over all records.
    
    Fixes: 2dfb7d51a61d ("trace, RAS: Add eMCA trace event interface")
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a1d94c7739da19bc2cf06f506a958567094add74
Author: Filipe Manana <fdmanana@suse.com>
Date:   Tue Oct 11 13:16:52 2022 +0100

    btrfs: fix processing of delayed tree block refs during backref walking
    
    [ Upstream commit 943553ef9b51db303ab2b955c1025261abfdf6fb ]
    
    During backref walking, when processing a delayed reference with a type of
    BTRFS_TREE_BLOCK_REF_KEY, we have two bugs there:
    
    1) We are accessing the delayed references extent_op, and its key, without
       the protection of the delayed ref head's lock;
    
    2) If there's no extent op for the delayed ref head, we end up with an
       uninitialized key in the stack, variable 'tmp_op_key', and then pass
       it to add_indirect_ref(), which adds the reference to the indirect
       refs rb tree.
    
       This is wrong, because indirect references should have a NULL key
       when we don't have access to the key, and in that case they should be
       added to the indirect_missing_keys rb tree and not to the indirect rb
       tree.
    
       This means that if have BTRFS_TREE_BLOCK_REF_KEY delayed ref resulting
       from freeing an extent buffer, therefore with a count of -1, it will
       not cancel out the corresponding reference we have in the extent tree
       (with a count of 1), since both references end up in different rb
       trees.
    
       When using fiemap, where we often need to check if extents are shared
       through shared subtrees resulting from snapshots, it means we can
       incorrectly report an extent as shared when it's no longer shared.
       However this is temporary because after the transaction is committed
       the extent is no longer reported as shared, as running the delayed
       reference results in deleting the tree block reference from the extent
       tree.
    
       Outside the fiemap context, the result is unpredictable, as the key was
       not initialized but it's used when navigating the rb trees to insert
       and search for references (prelim_ref_compare()), and we expect all
       references in the indirect rb tree to have valid keys.
    
    The following reproducer triggers the second bug:
    
       $ cat test.sh
       #!/bin/bash
    
       DEV=/dev/sdj
       MNT=/mnt/sdj
    
       mkfs.btrfs -f $DEV
       mount -o compress $DEV $MNT
    
       # With a compressed 128M file we get a tree height of 2 (level 1 root).
       xfs_io -f -c "pwrite -b 1M 0 128M" $MNT/foo
    
       btrfs subvolume snapshot $MNT $MNT/snap
    
       # Fiemap should output 0x2008 in the flags column.
       # 0x2000 means shared extent
       # 0x8 means encoded extent (because it's compressed)
       echo
       echo "fiemap after snapshot, range [120M, 120M + 128K):"
       xfs_io -c "fiemap -v 120M 128K" $MNT/foo
       echo
    
       # Overwrite one extent and fsync to flush delalloc and COW a new path
       # in the snapshot's tree.
       #
       # After this we have a BTRFS_DROP_DELAYED_REF delayed ref of type
       # BTRFS_TREE_BLOCK_REF_KEY with a count of -1 for every COWed extent
       # buffer in the path.
       #
       # In the extent tree we have inline references of type
       # BTRFS_TREE_BLOCK_REF_KEY, with a count of 1, for the same extent
       # buffers, so they should cancel each other, and the extent buffers in
       # the fs tree should no longer be considered as shared.
       #
       echo "Overwriting file range [120M, 120M + 128K)..."
       xfs_io -c "pwrite -b 128K 120M 128K" $MNT/snap/foo
       xfs_io -c "fsync" $MNT/snap/foo
    
       # Fiemap should output 0x8 in the flags column. The extent in the range
       # [120M, 120M + 128K) is no longer shared, it's now exclusive to the fs
       # tree.
       echo
       echo "fiemap after overwrite range [120M, 120M + 128K):"
       xfs_io -c "fiemap -v 120M 128K" $MNT/foo
       echo
    
       umount $MNT
    
    Running it before this patch:
    
       $ ./test.sh
       (...)
       wrote 134217728/134217728 bytes at offset 0
       128 MiB, 128 ops; 0.1152 sec (1.085 GiB/sec and 1110.5809 ops/sec)
       Create a snapshot of '/mnt/sdj' in '/mnt/sdj/snap'
    
       fiemap after snapshot, range [120M, 120M + 128K):
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [245760..246015]: 34304..34559       256 0x2008
    
       Overwriting file range [120M, 120M + 128K)...
       wrote 131072/131072 bytes at offset 125829120
       128 KiB, 1 ops; 0.0001 sec (683.060 MiB/sec and 5464.4809 ops/sec)
    
       fiemap after overwrite range [120M, 120M + 128K):
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [245760..246015]: 34304..34559       256 0x2008
    
    The extent in the range [120M, 120M + 128K) is still reported as shared
    (0x2000 bit set) after overwriting that range and flushing delalloc, which
    is not correct - an entire path was COWed in the snapshot's tree and the
    extent is now only referenced by the original fs tree.
    
    Running it after this patch:
    
       $ ./test.sh
       (...)
       wrote 134217728/134217728 bytes at offset 0
       128 MiB, 128 ops; 0.1198 sec (1.043 GiB/sec and 1068.2067 ops/sec)
       Create a snapshot of '/mnt/sdj' in '/mnt/sdj/snap'
    
       fiemap after snapshot, range [120M, 120M + 128K):
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [245760..246015]: 34304..34559       256 0x2008
    
       Overwriting file range [120M, 120M + 128K)...
       wrote 131072/131072 bytes at offset 125829120
       128 KiB, 1 ops; 0.0001 sec (694.444 MiB/sec and 5555.5556 ops/sec)
    
       fiemap after overwrite range [120M, 120M + 128K):
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [245760..246015]: 34304..34559       256   0x8
    
    Now the extent is not reported as shared anymore.
    
    So fix this by passing a NULL key pointer to add_indirect_ref() when
    processing a delayed reference for a tree block if there's no extent op
    for our delayed ref head with a defined key. Also access the extent op
    only after locking the delayed ref head's lock.
    
    The reproducer will be converted later to a test case for fstests.
    
    Fixes: 86d5f994425252 ("btrfs: convert prelimary reference tracking to use rbtrees")
    Fixes: a6dbceafb915e8 ("btrfs: Remove unused op_key var from add_delayed_refs")
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 62287f9b513b45c6cc0e543ec4ec247260737ac9
Author: Filipe Manana <fdmanana@suse.com>
Date:   Tue Oct 11 13:16:51 2022 +0100

    btrfs: fix processing of delayed data refs during backref walking
    
    [ Upstream commit 4fc7b57228243d09c0d878873bf24fa64a90fa01 ]
    
    When processing delayed data references during backref walking and we are
    using a share context (we are being called through fiemap), whenever we
    find a delayed data reference for an inode different from the one we are
    interested in, then we immediately exit and consider the data extent as
    shared. This is wrong, because:
    
    1) This might be a DROP reference that will cancel out a reference in the
       extent tree;
    
    2) Even if it's an ADD reference, it may be followed by a DROP reference
       that cancels it out.
    
    In either case we should not exit immediately.
    
    Fix this by never exiting when we find a delayed data reference for
    another inode - instead add the reference and if it does not cancel out
    other delayed reference, we will exit early when we call
    extent_is_shared() after processing all delayed references. If we find
    a drop reference, then signal the code that processes references from
    the extent tree (add_inline_refs() and add_keyed_refs()) to not exit
    immediately if it finds there a reference for another inode, since we
    have delayed drop references that may cancel it out. In this later case
    we exit once we don't have references in the rb trees that cancel out
    each other and have two references for different inodes.
    
    Example reproducer for case 1):
    
       $ cat test-1.sh
       #!/bin/bash
    
       DEV=/dev/sdj
       MNT=/mnt/sdj
    
       mkfs.btrfs -f $DEV
       mount $DEV $MNT
    
       xfs_io -f -c "pwrite 0 64K" $MNT/foo
       cp --reflink=always $MNT/foo $MNT/bar
    
       echo
       echo "fiemap after cloning:"
       xfs_io -c "fiemap -v" $MNT/foo
    
       rm -f $MNT/bar
       echo
       echo "fiemap after removing file bar:"
       xfs_io -c "fiemap -v" $MNT/foo
    
       umount $MNT
    
    Running it before this patch, the extent is still listed as shared, it has
    the flag 0x2000 (FIEMAP_EXTENT_SHARED) set:
    
       $ ./test-1.sh
       fiemap after cloning:
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [0..127]:        26624..26751       128 0x2001
    
       fiemap after removing file bar:
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [0..127]:        26624..26751       128 0x2001
    
    Example reproducer for case 2):
    
       $ cat test-2.sh
       #!/bin/bash
    
       DEV=/dev/sdj
       MNT=/mnt/sdj
    
       mkfs.btrfs -f $DEV
       mount $DEV $MNT
    
       xfs_io -f -c "pwrite 0 64K" $MNT/foo
       cp --reflink=always $MNT/foo $MNT/bar
    
       # Flush delayed references to the extent tree and commit current
       # transaction.
       sync
    
       echo
       echo "fiemap after cloning:"
       xfs_io -c "fiemap -v" $MNT/foo
    
       rm -f $MNT/bar
       echo
       echo "fiemap after removing file bar:"
       xfs_io -c "fiemap -v" $MNT/foo
    
       umount $MNT
    
    Running it before this patch, the extent is still listed as shared, it has
    the flag 0x2000 (FIEMAP_EXTENT_SHARED) set:
    
       $ ./test-2.sh
       fiemap after cloning:
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [0..127]:        26624..26751       128 0x2001
    
       fiemap after removing file bar:
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [0..127]:        26624..26751       128 0x2001
    
    After this patch, after deleting bar in both tests, the extent is not
    reported with the 0x2000 flag anymore, it gets only the flag 0x1
    (which is FIEMAP_EXTENT_LAST):
    
       $ ./test-1.sh
       fiemap after cloning:
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [0..127]:        26624..26751       128 0x2001
    
       fiemap after removing file bar:
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [0..127]:        26624..26751       128   0x1
    
       $ ./test-2.sh
       fiemap after cloning:
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [0..127]:        26624..26751       128 0x2001
    
       fiemap after removing file bar:
       /mnt/sdj/foo:
        EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
          0: [0..127]:        26624..26751       128   0x1
    
    These tests will later be converted to a test case for fstests.
    
    Fixes: dc046b10c8b7d4 ("Btrfs: make fiemap not blow when you have lots of snapshots")
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f353aa7d4ddf6aa2dad094948111aec3fe20a054
Author: Jean-Francois Le Fillatre <jflf_kernel@gmx.com>
Date:   Wed Aug 24 21:14:36 2022 +0200

    r8152: add PID for the Lenovo OneLink+ Dock
    
    commit 1bd3a383075c64d638e65d263c9267b08ee7733c upstream.
    
    The Lenovo OneLink+ Dock contains an RTL8153 controller that behaves as
    a broken CDC device by default. Add the custom Lenovo PID to the r8152
    driver to support it properly.
    
    Also, systems compatible with this dock provide a BIOS option to enable
    MAC address passthrough (as per Lenovo document "ThinkPad Docking
    Solutions 2017"). Add the custom PID to the MAC passthrough list too.
    
    Tested on a ThinkPad 13 1st gen with the expected results:
    
    passthrough disabled: Invalid header when reading pass-thru MAC addr
    passthrough enabled:  Using pass-thru MAC addr XX:XX:XX:XX:XX:XX
    
    Signed-off-by: Jean-Francois Le Fillatre <jflf_kernel@gmx.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8f513afabebc46900120badb3d4e858395b6f08f
Author: James Morse <james.morse@arm.com>
Date:   Thu Jul 14 17:15:23 2022 +0100

    arm64: errata: Remove AES hwcap for COMPAT tasks
    
    commit 44b3834b2eed595af07021b1c64e6f9bc396398b upstream.
    
    Cortex-A57 and Cortex-A72 have an erratum where an interrupt that
    occurs between a pair of AES instructions in aarch32 mode may corrupt
    the ELR. The task will subsequently produce the wrong AES result.
    
    The AES instructions are part of the cryptographic extensions, which are
    optional. User-space software will detect the support for these
    instructions from the hwcaps. If the platform doesn't support these
    instructions a software implementation should be used.
    
    Remove the hwcap bits on affected parts to indicate user-space should
    not use the AES instructions.
    
    Acked-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: James Morse <james.morse@arm.com>
    Link: https://lore.kernel.org/r/20220714161523.279570-3-james.morse@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    [florian: resolved conflicts in arch/arm64/tools/cpucaps and cpu_errata.c]
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0eac1d3b5f8f0630d247c7e6dc62906d528b6fea
Author: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Date:   Tue Jul 26 04:14:54 2022 +0200

    media: venus: dec: Handle the case where find_format fails
    
    commit 06a2da340f762addc5935bf851d95b14d4692db2 upstream.
    
    Debugging the decoder on msm8916 I noticed the vdec probe was crashing if
    the fmt pointer was NULL.
    
    A similar fix from Colin Ian King found by Coverity was implemented for the
    encoder. Implement the same fix on the decoder.
    
    Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files")
    Cc: stable@vger.kernel.org  # v4.13+
    Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
    Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 87f4765c7e1d4776f74e5197d941a92cd7440d30
Author: Eric Ren <renzhengeek@gmail.com>
Date:   Sat Oct 15 11:19:28 2022 +0800

    KVM: arm64: vgic: Fix exit condition in scan_its_table()
    
    commit c000a2607145d28b06c697f968491372ea56c23a upstream.
    
    With some PCIe topologies, restoring a guest fails while
    parsing the ITS device tables.
    
    Reproducer hints:
    1. Create ARM virt VM with pxb-pcie bus which adds
       extra host bridges, with qemu command like:
    
    ```
      -device pxb-pcie,bus_nr=8,id=pci.x,numa_node=0,bus=pcie.0 \
      -device pcie-root-port,..,bus=pci.x \
      ...
      -device pxb-pcie,bus_nr=37,id=pci.y,numa_node=1,bus=pcie.0 \
      -device pcie-root-port,..,bus=pci.y \
      ...
    
    ```
    2. Ensure the guest uses 2-level device table
    3. Perform VM migration which calls save/restore device tables
    
    In that setup, we get a big "offset" between 2 device_ids,
    which makes unsigned "len" round up a big positive number,
    causing the scan loop to continue with a bad GPA. For example:
    
    1. L1 table has 2 entries;
    2. and we are now scanning at L2 table entry index 2075 (pointed
       to by L1 first entry)
    3. if next device id is 9472, we will get a big offset: 7397;
    4. with unsigned 'len', 'len -= offset * esz', len will underflow to a
       positive number, mistakenly into next iteration with a bad GPA;
       (It should break out of the current L2 table scanning, and jump
       into the next L1 table entry)
    5. that bad GPA fails the guest read.
    
    Fix it by stopping the L2 table scan when the next device id is
    outside of the current table, allowing the scan to continue from
    the next L1 table entry.
    
    Thanks to Eric Auger for the fix suggestion.
    
    Fixes: 920a7a8fa92a ("KVM: arm64: vgic-its: Add infrastructure for tableookup")
    Suggested-by: Eric Auger <eric.auger@redhat.com>
    Signed-off-by: Eric Ren <renzhengeek@gmail.com>
    [maz: commit message tidy-up]
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/d9c3a564af9e2c5bf63f48a7dcbf08cd593c5c0b.1665802985.git.renzhengeek@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 67a00c299c5c143817c948fbc7de1a2fa1af38fb
Author: Kai-Heng Feng <kai.heng.feng@canonical.com>
Date:   Tue Oct 11 10:46:17 2022 +0800

    ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS
    
    commit 1e41e693f458eef2d5728207dbd327cd3b16580a upstream.
    
    UBSAN complains about array-index-out-of-bounds:
    [ 1.980703] kernel: UBSAN: array-index-out-of-bounds in /build/linux-9H675w/linux-5.15.0/drivers/ata/libahci.c:968:41
    [ 1.980709] kernel: index 15 is out of range for type 'ahci_em_priv [8]'
    [ 1.980713] kernel: CPU: 0 PID: 209 Comm: scsi_eh_8 Not tainted 5.15.0-25-generic #25-Ubuntu
    [ 1.980716] kernel: Hardware name: System manufacturer System Product Name/P5Q3, BIOS 1102 06/11/2010
    [ 1.980718] kernel: Call Trace:
    [ 1.980721] kernel: <TASK>
    [ 1.980723] kernel: show_stack+0x52/0x58
    [ 1.980729] kernel: dump_stack_lvl+0x4a/0x5f
    [ 1.980734] kernel: dump_stack+0x10/0x12
    [ 1.980736] kernel: ubsan_epilogue+0x9/0x45
    [ 1.980739] kernel: __ubsan_handle_out_of_bounds.cold+0x44/0x49
    [ 1.980742] kernel: ahci_qc_issue+0x166/0x170 [libahci]
    [ 1.980748] kernel: ata_qc_issue+0x135/0x240
    [ 1.980752] kernel: ata_exec_internal_sg+0x2c4/0x580
    [ 1.980754] kernel: ? vprintk_default+0x1d/0x20
    [ 1.980759] kernel: ata_exec_internal+0x67/0xa0
    [ 1.980762] kernel: sata_pmp_read+0x8d/0xc0
    [ 1.980765] kernel: sata_pmp_read_gscr+0x3c/0x90
    [ 1.980768] kernel: sata_pmp_attach+0x8b/0x310
    [ 1.980771] kernel: ata_eh_revalidate_and_attach+0x28c/0x4b0
    [ 1.980775] kernel: ata_eh_recover+0x6b6/0xb30
    [ 1.980778] kernel: ? ahci_do_hardreset+0x180/0x180 [libahci]
    [ 1.980783] kernel: ? ahci_stop_engine+0xb0/0xb0 [libahci]
    [ 1.980787] kernel: ? ahci_do_softreset+0x290/0x290 [libahci]
    [ 1.980792] kernel: ? trace_event_raw_event_ata_eh_link_autopsy_qc+0xe0/0xe0
    [ 1.980795] kernel: sata_pmp_eh_recover.isra.0+0x214/0x560
    [ 1.980799] kernel: sata_pmp_error_handler+0x23/0x40
    [ 1.980802] kernel: ahci_error_handler+0x43/0x80 [libahci]
    [ 1.980806] kernel: ata_scsi_port_error_handler+0x2b1/0x600
    [ 1.980810] kernel: ata_scsi_error+0x9c/0xd0
    [ 1.980813] kernel: scsi_error_handler+0xa1/0x180
    [ 1.980817] kernel: ? scsi_unjam_host+0x1c0/0x1c0
    [ 1.980820] kernel: kthread+0x12a/0x150
    [ 1.980823] kernel: ? set_kthread_struct+0x50/0x50
    [ 1.980826] kernel: ret_from_fork+0x22/0x30
    [ 1.980831] kernel: </TASK>
    
    This happens because sata_pmp_init_links() initialize link->pmp up to
    SATA_PMP_MAX_PORTS while em_priv is declared as 8 elements array.
    
    I can't find the maximum Enclosure Management ports specified in AHCI
    spec v1.3.1, but "12.2.1 LED message type" states that "Port Multiplier
    Information" can utilize 4 bits, which implies it can support up to 16
    ports. Hence, use SATA_PMP_MAX_PORTS as EM_MAX_SLOTS to resolve the
    issue.
    
    BugLink: https://bugs.launchpad.net/bugs/1970074
    Cc: stable@vger.kernel.org
    Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e3e2bcd51ad0d90aa7bfab7e3046e18abe3da273
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Wed Oct 12 15:11:05 2022 +0200

    ata: ahci-imx: Fix MODULE_ALIAS
    
    commit 979556f1521a835a059de3b117b9c6c6642c7d58 upstream.
    
    'ahci:' is an invalid prefix, preventing the module from autoloading.
    Fix this by using the 'platform:' prefix and DRV_NAME.
    
    Fixes: 9e54eae23bc9 ("ahci_imx: add ahci sata support on imx platforms")
    Cc: stable@vger.kernel.org
    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Reviewed-by: Fabio Estevam <festevam@gmail.com>
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4f9dcadc55c21b39b072bb0882362c7edc4340bc
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Fri Oct 14 17:01:45 2022 +0800

    hwmon/coretemp: Handle large core ID value
    
    commit 7108b80a542b9d65e44b36d64a700a83658c0b73 upstream.
    
    The coretemp driver supports up to a hard-coded limit of 128 cores.
    
    Today, the driver can not support a core with an ID above that limit.
    Yet, the encoding of core ID's is arbitrary (BIOS APIC-ID) and so they
    may be sparse and they may be large.
    
    Update the driver to map arbitrary core ID numbers into appropriate
    array indexes so that 128 cores can be supported, no matter the encoding
    of core ID's.
    
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Acked-by: Len Brown <len.brown@intel.com>
    Acked-by: Guenter Roeck <linux@roeck-us.net>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20221014090147.1836-3-rui.zhang@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1723dd167d75139dc991a50d49a6e2363c9ca050
Author: Borislav Petkov <bp@suse.de>
Date:   Wed Oct 5 12:00:08 2022 +0200

    x86/microcode/AMD: Apply the patch early on every logical thread
    
    commit e7ad18d1169c62e6c78c01ff693fd362d9d65278 upstream.
    
    Currently, the patch application logic checks whether the revision
    needs to be applied on each logical CPU (SMT thread). Therefore, on SMT
    designs where the microcode engine is shared between the two threads,
    the application happens only on one of them as that is enough to update
    the shared microcode engine.
    
    However, there are microcode patches which do per-thread modification,
    see Link tag below.
    
    Therefore, drop the revision check and try applying on each thread. This
    is what the BIOS does too so this method is very much tested.
    
    Btw, change only the early paths. On the late loading paths, there's no
    point in doing per-thread modification because if is it some case like
    in the bugzilla below - removing a CPUID flag - the kernel cannot go and
    un-use features it has detected are there early. For that, one should
    use early loading anyway.
    
      [ bp: Fixes does not contain the oldest commit which did check for
        equality but that is good enough. ]
    
    Fixes: 8801b3fcb574 ("x86/microcode/AMD: Rework container parsing")
    Reported-by:  Ștefan Talpalaru <stefantalpalaru@yahoo.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Tested-by:  Ștefan Talpalaru <stefantalpalaru@yahoo.com>
    Cc: <stable@vger.kernel.org>
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216211
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1739f56956370b60e0cbc90bb94d71ec43ee2425
Author: Joseph Qi <joseph.qi@linux.alibaba.com>
Date:   Mon Oct 17 21:02:26 2022 +0800

    ocfs2: fix BUG when iput after ocfs2_mknod fails
    
    commit 759a7c6126eef5635506453e9b9d55a6a3ac2084 upstream.
    
    Commit b1529a41f777 "ocfs2: should reclaim the inode if
    '__ocfs2_mknod_locked' returns an error" tried to reclaim the claimed
    inode if __ocfs2_mknod_locked() fails later.  But this introduce a race,
    the freed bit may be reused immediately by another thread, which will
    update dinode, e.g.  i_generation.  Then iput this inode will lead to BUG:
    inode->i_generation != le32_to_cpu(fe->i_generation)
    
    We could make this inode as bad, but we did want to do operations like
    wipe in some cases.  Since the claimed inode bit can only affect that an
    dinode is missing and will return back after fsck, it seems not a big
    problem.  So just leave it as is by revert the reclaim logic.
    
    Link: https://lkml.kernel.org/r/20221017130227.234480-1-joseph.qi@linux.alibaba.com
    Fixes: b1529a41f777 ("ocfs2: should reclaim the inode if '__ocfs2_mknod_locked' returns an error")
    Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
    Reported-by: Yan Wang <wangyan122@huawei.com>
    Cc: Mark Fasheh <mark@fasheh.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Junxiao Bi <junxiao.bi@oracle.com>
    Cc: Changwei Ge <gechangwei@live.cn>
    Cc: Gang He <ghe@suse.com>
    Cc: Jun Piao <piaojun@huawei.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2f121a7dd46f4e613d2f962784ea9a8ed37792a4
Author: Joseph Qi <joseph.qi@linux.alibaba.com>
Date:   Mon Oct 17 21:02:27 2022 +0800

    ocfs2: clear dinode links count in case of error
    
    commit 28f4821b1b53e0649706912e810c6c232fc506f9 upstream.
    
    In ocfs2_mknod(), if error occurs after dinode successfully allocated,
    ocfs2 i_links_count will not be 0.
    
    So even though we clear inode i_nlink before iput in error handling, it
    still won't wipe inode since we'll refresh inode from dinode during inode
    lock.  So just like clear inode i_nlink, we clear ocfs2 i_links_count as
    well.  Also do the same change for ocfs2_symlink().
    
    Link: https://lkml.kernel.org/r/20221017130227.234480-2-joseph.qi@linux.alibaba.com
    Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
    Reported-by: Yan Wang <wangyan122@huawei.com>
    Cc: Mark Fasheh <mark@fasheh.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Junxiao Bi <junxiao.bi@oracle.com>
    Cc: Changwei Ge <gechangwei@live.cn>
    Cc: Gang He <ghe@suse.com>
    Cc: Jun Piao <piaojun@huawei.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>