commit df659ebe5d2fd64d679bb2f955db570125c1883c
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue Feb 8 18:35:20 2022 +0100

    Linux 5.16.8
    
    Link: https://lore.kernel.org/r/20220207103804.053675072@linuxfoundation.org
    Link: https://lore.kernel.org/r/20220207133856.644483064@linuxfoundation.org
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Justin M. Forbes <jforbes@fedoraproject.org>
    Tested-by: Ronald Warsow <rwarsow@gmx.de>
    Tested-by: Zan Aziz <zanaziz313@gmail.com>
    Tested-by: Florian Fainelli <f.fainelli@gmail.com>
    Tested-by: Slade Watkins <slade@sladewatkins.com>
    Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Ron Economos <re@w6rz.net>
    Tested-by: Rudi Heitbaum <rudi@heitbaum.com>
    Tested-by: Scott Bruce <smbruce@gmail.com>
    Tested-by: Fox Chen <foxhlchen@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0efb43eb32a19a28f61b3543a11dc33ef43419e0
Author: Florian Westphal <fw@strlen.de>
Date:   Mon Jan 24 22:09:15 2022 +0100

    selftests: netfilter: check stateless nat udp checksum fixup
    
    commit aad51ca71ad83273e8826d6cfdcf53c98748d1fa upstream.
    
    Add a test that sends large udp packet (which is fragmented)
    via a stateless nft nat rule, i.e. 'ip saddr set 10.2.3.4'
    and check that the datagram is received by peer.
    
    On kernels without
    commit 4e1860a38637 ("netfilter: nft_payload: do not update layer 4 checksum when mangling fragments")',
    this will fail with:
    
    cmp: EOF on /tmp/tmp.V1q0iXJyQF which is empty
    -rw------- 1 root root 4096 Jan 24 22:03 /tmp/tmp.Aaqnq4rBKS
    -rw------- 1 root root    0 Jan 24 22:03 /tmp/tmp.V1q0iXJyQF
    ERROR: in and output file mismatch when checking udp with stateless nat
    FAIL: nftables v1.0.0 (Fearless Fosdick #2)
    
    On patched kernels, this will show:
    PASS: IP statless for ns2-PFp89amx
    
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aa8fa75e15b29cd8fe8d76b7958c4bd6b3136e0b
Author: Florian Westphal <fw@strlen.de>
Date:   Wed Jan 26 12:54:54 2022 +0100

    selftests: nft_concat_range: add test for reload with no element add/del
    
    commit eda0cf1202acf1ef47f93d8f92d4839213431424 upstream.
    
    Add a specific test for the reload issue fixed with
    commit 23c54263efd7cb ("netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone").
    
    Add to set, then flush set content + restore without other add/remove in
    the transaction.
    
    On kernels before the fix, this test case fails:
      net,mac with reload    [FAIL]
    
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bc3d8a98c0c8a505eb6d81a812ac5647b9a08292
Author: Yang Li <yang.lee@linux.alibaba.com>
Date:   Wed Jan 19 09:04:32 2022 +0800

    gpio: mpc8xxx: Fix an ignored error return from platform_get_irq()
    
    commit 9f51ce0b9e73f83bab2442b36d5e247a81bd3401 upstream.
    
    The return from the call to platform_get_irq() is int, it can be
    a negative error code, however this is being assigned to an unsigned
    int variable 'irqn', so making 'irqn' an int.
    
    Eliminate the following coccicheck warning:
    ./drivers/gpio/gpio-mpc8xxx.c:391:5-21: WARNING: Unsigned expression
    compared with zero: mpc8xxx_gc -> irqn < 0
    
    Reported-by: Abaci Robot <abaci@linux.alibaba.com>
    Fixes: 0b39536cc699 ("gpio: mpc8xxx: Fix IRQ check in mpc8xxx_probe")
    Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
    Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 54e8d33ea77d2df2b734f28cebbf5af826b3745f
Author: Yang Li <yang.lee@linux.alibaba.com>
Date:   Wed Jan 19 09:04:31 2022 +0800

    gpio: idt3243x: Fix an ignored error return from platform_get_irq()
    
    commit 7c1cf55577782725ea2bc24687767c8fe8e57486 upstream.
    
    The return from the call to platform_get_irq() is int, it can be
    a negative error code, however this is being assigned to an unsigned
    int variable 'parent_irq', so making 'parent_irq' an int.
    
    Eliminate the following coccicheck warning:
    ./drivers/gpio/gpio-idt3243x.c:167:6-16: WARNING: Unsigned expression
    compared with zero: parent_irq < 0
    
    Reported-by: Abaci Robot <abaci@linux.alibaba.com>
    Fixes: 30fee1d7462a ("gpio: idt3243x: Fix IRQ check in idt_gpio_probe")
    Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
    Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 410696817b1555aa1b0abeef91acc5af59233dae
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Wed Feb 12 11:04:23 2020 -0300

    tools include UAPI: Sync sound/asound.h copy with the kernel sources
    
    commit 4f2492731ada9d702ffdfaa6ec1ff64820a1664c upstream.
    
    Picking the changes from:
    
      06feec6005c9d950 ("ASoC: hdmi-codec: Fix OOB memory accesses")
    
    Which entails no changes in the tooling side as it doesn't introduce new
    SNDRV_PCM_IOCTL_ ioctls.
    
    To silence this perf tools build warning:
    
      Warning: Kernel ABI header at 'tools/include/uapi/sound/asound.h' differs from latest version at 'include/uapi/sound/asound.h'
      diff -u tools/include/uapi/sound/asound.h include/uapi/sound/asound.h
    
    Cc: Dmitry Osipenko <digetx@gmail.com>
    Cc: Mark Brown <broonie@kernel.org>
    Cc: Takashi Iwai <tiwai@suse.de>
    Link: https://lore.kernel.org/lkml/Yf+6OT+2eMrYDEeX@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bd69089ce5b1ad1b7ad443e95a903b6241e206e3
Author: Waiman Long <longman@redhat.com>
Date:   Wed Feb 2 22:31:03 2022 -0500

    cgroup/cpuset: Fix "suspicious RCU usage" lockdep warning
    
    commit 2bdfd2825c9662463371e6691b1a794e97fa36b4 upstream.
    
    It was found that a "suspicious RCU usage" lockdep warning was issued
    with the rcu_read_lock() call in update_sibling_cpumasks().  It is
    because the update_cpumasks_hier() function may sleep. So we have
    to release the RCU lock, call update_cpumasks_hier() and reacquire
    it afterward.
    
    Also add a percpu_rwsem_assert_held() in update_sibling_cpumasks()
    instead of stating that in the comment.
    
    Fixes: 4716909cc5c5 ("cpuset: Track cpusets that use parent's effective_cpus")
    Signed-off-by: Waiman Long <longman@redhat.com>
    Tested-by: Phil Auld <pauld@redhat.com>
    Reviewed-by: Phil Auld <pauld@redhat.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6506bb5b1c4496829032e461202a2cd4e49ed2bc
Author: Arınç ÜNAL <arinc.unal@arinc9.com>
Date:   Sat Jan 29 09:27:04 2022 +0300

    net: dsa: mt7530: make NET_DSA_MT7530 select MEDIATEK_GE_PHY
    
    commit 4223f86512877b04c932e7203648b37eec931731 upstream.
    
    Make MediaTek MT753x DSA driver enable MediaTek Gigabit PHYs driver to
    properly control MT7530 and MT7531 switch PHYs.
    
    A noticeable change is that the behaviour of switchport interfaces going
    up-down-up-down is no longer there.
    
    Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
    Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
    Link: https://lore.kernel.org/r/20220129062703.595-1-arinc.unal@arinc9.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a17cde2d2e751bb9c236c02e26ea4ddbecf71005
Author: Xin Yin <yinxin.x@bytedance.com>
Date:   Wed Jan 26 14:31:46 2022 +0800

    ext4: fix incorrect type issue during replay_del_range
    
    commit 8fca8a2b0a822f7936130af7299d2fd7f0a66714 upstream.
    
    should not use fast commit log data directly, add le32_to_cpu().
    
    Reported-by: kernel test robot <lkp@intel.com>
    Fixes: 0b5b5a62b945 ("ext4: use ext4_ext_remove_space() for fast commit replay delete range")
    Cc: stable@kernel.org
    Signed-off-by: Xin Yin <yinxin.x@bytedance.com>
    Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
    Link: https://lore.kernel.org/r/20220126063146.2302-1-yinxin.x@bytedance.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 14aa3f49c7fc6424763f4323bfbc3a807b0727dc
Author: Ritesh Harjani <riteshh@linux.ibm.com>
Date:   Mon Jan 17 17:41:49 2022 +0530

    ext4: fix error handling in ext4_fc_record_modified_inode()
    
    commit cdce59a1549190b66f8e3fe465c2b2f714b98a94 upstream.
    
    Current code does not fully takes care of krealloc() error case, which
    could lead to silent memory corruption or a kernel bug.  This patch
    fixes that.
    
    Also it cleans up some duplicated error handling logic from various
    functions in fast_commit.c file.
    
    Reported-by: luo penghao <luo.penghao@zte.com.cn>
    Suggested-by: Lukas Czerner <lczerner@redhat.com>
    Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/62e8b6a1cce9359682051deb736a3c0953c9d1e9.1642416995.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 627b44cf5543c13f04130083a054298f80e2a5ba
Author: Ritesh Harjani <riteshh@linux.ibm.com>
Date:   Mon Jan 17 17:41:47 2022 +0530

    ext4: fix error handling in ext4_restore_inline_data()
    
    commit 897026aaa73eb2517dfea8d147f20ddb0b813044 upstream.
    
    While running "./check -I 200 generic/475" it sometimes gives below
    kernel BUG(). Ideally we should not call ext4_write_inline_data() if
    ext4_create_inline_data() has failed.
    
    <log snip>
    [73131.453234] kernel BUG at fs/ext4/inline.c:223!
    
    <code snip>
     212 static void ext4_write_inline_data(struct inode *inode, struct ext4_iloc *iloc,
     213                                    void *buffer, loff_t pos, unsigned int len)
     214 {
    <...>
     223         BUG_ON(!EXT4_I(inode)->i_inline_off);
     224         BUG_ON(pos + len > EXT4_I(inode)->i_inline_size);
    
    This patch handles the error and prints out a emergency msg saying potential
    data loss for the given inode (since we couldn't restore the original
    inline_data due to some previous error).
    
    [ 9571.070313] EXT4-fs (dm-0): error restoring inline_data for inode -- potential data loss! (inode 1703982, error -30)
    
    Reported-by: Eric Whitney <enwlinux@gmail.com>
    Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/9f4cd7dfd54fa58ff27270881823d94ddf78dd07.1642416995.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3ecbe2f8eb27b3ff65d7d32f424cfca7b6dd6bc4
Author: Xin Yin <yinxin.x@bytedance.com>
Date:   Mon Jan 10 11:51:41 2022 +0800

    ext4: modify the logic of ext4_mb_new_blocks_simple
    
    commit 31a074a0c62dc0d2bfb9b543142db4fe27f9e5eb upstream.
    
    For now in ext4_mb_new_blocks_simple, if we found a block which
    should be excluded then will switch to next group, this may
    probably cause 'group' run out of range.
    
    Change to check next block in the same group when get a block should
    be excluded. Also change the search range to EXT4_CLUSTERS_PER_GROUP
    and add error checking.
    
    Signed-off-by: Xin Yin <yinxin.x@bytedance.com>
    Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
    Link: https://lore.kernel.org/r/20220110035141.1980-3-yinxin.x@bytedance.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 33fb59317cd2021c3f5b95ba57fdf7c43f864b68
Author: Xin Yin <yinxin.x@bytedance.com>
Date:   Mon Jan 10 11:51:40 2022 +0800

    ext4: prevent used blocks from being allocated during fast commit replay
    
    commit 599ea31d13617c5484c40cdf50d88301dc351cfc upstream.
    
    During fast commit replay procedure, we clear inode blocks bitmap in
    ext4_ext_clear_bb(), this may cause ext4_mb_new_blocks_simple() allocate
    blocks still in use.
    
    Make ext4_fc_record_regions() also record physical disk regions used by
    inodes during replay procedure. Then ext4_mb_new_blocks_simple() can
    excludes these blocks in use.
    
    Signed-off-by: Xin Yin <yinxin.x@bytedance.com>
    Link: https://lore.kernel.org/r/20220110035141.1980-2-yinxin.x@bytedance.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 11dfe20342f0befa5a9083f6761552d7688adb92
Author: Sergey Shtylyov <s.shtylyov@omp.ru>
Date:   Mon Jan 24 21:55:03 2022 +0300

    EDAC/xgene: Fix deferred probing
    
    commit dfd0dfb9a7cc04acf93435b440dd34c2ca7b4424 upstream.
    
    The driver overrides error codes returned by platform_get_irq_optional()
    to -EINVAL for some strange reason, so if it returns -EPROBE_DEFER, the
    driver will fail the probe permanently instead of the deferred probing.
    Switch to propagating the proper error codes to platform driver code
    upwards.
    
      [ bp: Massage commit message. ]
    
    Fixes: 0d4429301c4a ("EDAC: Add APM X-Gene SoC EDAC driver")
    Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220124185503.6720-3-s.shtylyov@omp.ru
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9a258cb569364c28d8ff6fed7fe75f4ecda7ecd5
Author: Sergey Shtylyov <s.shtylyov@omp.ru>
Date:   Mon Jan 24 21:55:02 2022 +0300

    EDAC/altera: Fix deferred probing
    
    commit 279eb8575fdaa92c314a54c0d583c65e26229107 upstream.
    
    The driver overrides the error codes returned by platform_get_irq() to
    -ENODEV for some strange reason, so if it returns -EPROBE_DEFER, the
    driver will fail the probe permanently instead of the deferred probing.
    Switch to propagating the proper error codes to platform driver code
    upwards.
    
      [ bp: Massage commit message. ]
    
    Fixes: 71bcada88b0f ("edac: altera: Add Altera SDRAM EDAC support")
    Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Acked-by: Dinh Nguyen <dinguyen@kernel.org>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220124185503.6720-2-s.shtylyov@omp.ru
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a90f9f3e0a2a43f0814909ab8e6e9b265cd0c675
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Thu Jan 27 12:32:51 2022 +0100

    x86/perf: Default set FREEZE_ON_SMI for all
    
    commit a01994f5e5c79d3a35e5e8cf4252c7f2147323c3 upstream.
    
    Kyle reported that rr[0] has started to malfunction on Comet Lake and
    later CPUs due to EFI starting to make use of CPL3 [1] and the PMU
    event filtering not distinguishing between regular CPL3 and SMM CPL3.
    
    Since this is a privilege violation, default disable SMM visibility
    where possible.
    
    Administrators wanting to observe SMM cycles can easily change this
    using the sysfs attribute while regular users don't have access to
    this file.
    
    [0] https://rr-project.org/
    
    [1] See the Intel white paper "Trustworthy SMM on the Intel vPro Platform"
    at https://bugzilla.kernel.org/attachment.cgi?id=300300, particularly the
    end of page 5.
    
    Reported-by: Kyle Huey <me@kylehuey.com>
    Suggested-by: Andrew Cooper <Andrew.Cooper3@citrix.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@kernel.org
    Link: https://lkml.kernel.org/r/YfKChjX61OW4CkYm@hirez.programming.kicks-ass.net
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit feffb6ae2c80b9a8206450cdef90f5943baced99
Author: Tristan Hume <tristan@thume.ca>
Date:   Thu Jan 27 17:08:06 2022 -0500

    perf/x86/intel/pt: Fix crash with stop filters in single-range mode
    
    commit 1d9093457b243061a9bba23543c38726e864a643 upstream.
    
    Add a check for !buf->single before calling pt_buffer_region_size in a
    place where a missing check can cause a kernel crash.
    
    Fixes a bug introduced by commit 670638477aed ("perf/x86/intel/pt:
    Opportunistically use single range output mode"), which added a
    support for PT single-range output mode. Since that commit if a PT
    stop filter range is hit while tracing, the kernel will crash because
    of a null pointer dereference in pt_handle_status due to calling
    pt_buffer_region_size without a ToPA configured.
    
    The commit which introduced single-range mode guarded almost all uses of
    the ToPA buffer variables with checks of the buf->single variable, but
    missed the case where tracing was stopped by the PT hardware, which
    happens when execution hits a configured stop filter.
    
    Tested that hitting a stop filter while PT recording successfully
    records a trace with this patch but crashes without this patch.
    
    Fixes: 670638477aed ("perf/x86/intel/pt: Opportunistically use single range output mode")
    Signed-off-by: Tristan Hume <tristan@thume.ca>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@kernel.org
    Link: https://lkml.kernel.org/r/20220127220806.73664-1-tristan@thume.ca
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c5d62c82be1d75ff71d0e58f06bbd45afa878c1a
Author: Ian Rogers <irogers@google.com>
Date:   Fri Feb 4 17:09:41 2022 -0800

    perf stat: Fix display of grouped aliased events
    
    [ Upstream commit b2b1aa73ade982c175ac926a1fd34e76ad628b94 ]
    
    An event may have a number of uncore aliases that when added to the
    evlist are consecutive.
    
    If there are multiple uncore events in a group then
    parse_events__set_leader_for_uncore_aliase will reorder the evlist so
    that events on the same PMU are adjacent.
    
    The collect_all_aliases function assumes that aliases are in blocks so
    that only the first counter is printed and all others are marked merged.
    
    The reordering for groups breaks the assumption and so all counts are
    printed.
    
    This change removes the assumption from collect_all_aliases
    that the events are in blocks and instead processes the entire evlist.
    
    Before:
    
      ```
      $ perf stat -e '{UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE,UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE},duration_time' -a -A -- sleep 1
    
       Performance counter stats for 'system wide':
    
      CPU0                  256,866      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 494,413      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      967      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,738      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  285,161      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 429,920      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,443      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  310,753      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 416,657      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,231      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,573      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  416,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 405,966      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,481      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,447      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  312,911      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 408,154      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,086      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,380      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  333,994      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 370,349      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,287      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,335      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  188,107      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 302,423      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      701      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,070      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  307,221      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 383,642      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,036      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,158      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  318,479      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 821,545      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,028      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   2,550      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  227,618      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 372,272      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      903      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  376,783      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 419,827      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,406      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,453      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  286,583      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 429,956      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      999      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,436      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  313,867      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 370,159      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,114      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  342,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 409,111      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,399      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,684      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  365,828      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 376,037      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,378      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,411      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  382,456      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 621,743      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,232      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  342,316      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 385,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,176      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,268      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  373,588      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 386,163      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,394      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,464      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  381,206      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 546,891      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,266      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,712      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  221,176      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 392,069      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      831      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  355,401      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 705,595      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,235      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   2,216      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  371,436      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 428,103      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,306      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,442      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  384,352      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 504,200      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,468      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,860      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  228,856      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 287,976      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      832      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,060      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  215,121      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 334,162      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      681      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,026      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  296,179      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 436,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,084      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,525      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  262,296      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 416,573      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      986      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,533      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  285,852      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 359,842      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,073      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,326      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  303,379      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 367,222      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,008      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,156      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  273,487      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 425,449      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                      932      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,367      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  297,596      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 414,793      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,140      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,601      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  342,365      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 360,422      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,342      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  327,196      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 580,858      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,122      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   2,014      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  296,564      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 452,817      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,087      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,694      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  375,002      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 389,393      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,478      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   1,540      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0                  365,213      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36                 594,685      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                    1,401      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                   2,222      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0            1,000,749,060 ns   duration_time
    
             1.000749060 seconds time elapsed
      ```
    
    After:
    
      ```
       Performance counter stats for 'system wide':
    
      CPU0               20,547,434      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU36              45,202,862      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
      CPU0                   82,001      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU36                 159,688      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
      CPU0            1,000,464,828 ns   duration_time
    
             1.000464828 seconds time elapsed
      ```
    
    Fixes: 3cdc5c2cb924acb4 ("perf parse-events: Handle uncore event aliases in small groups properly")
    Reviewed-by: Andi Kleen <ak@linux.intel.com>
    Signed-off-by: Ian Rogers <irogers@google.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
    Cc: Asaf Yaffe <asaf.yaffe@intel.com>
    Cc: Caleb Biggers <caleb.biggers@intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: James Clark <james.clark@arm.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: John Garry <john.garry@huawei.com>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Perry Taylor <perry.taylor@intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Vineet Singh <vineet.singh@intel.com>
    Cc: Zhengjun Xing <zhengjun.xing@linux.intel.com>
    Link: https://lore.kernel.org/r/20220205010941.1065469-1-irogers@google.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8ee67e3c34bc23f611073630d7f7e3543c609eb8
Author: Marco Elver <elver@google.com>
Date:   Mon Jan 31 11:34:05 2022 +0100

    perf: Copy perf_event_attr::sig_data on modification
    
    [ Upstream commit 3c25fc97f5590060464cabfa25710970ecddbc96 ]
    
    The intent has always been that perf_event_attr::sig_data should also be
    modifiable along with PERF_EVENT_IOC_MODIFY_ATTRIBUTES, because it is
    observable by user space if SIGTRAP on events is requested.
    
    Currently only PERF_TYPE_BREAKPOINT is modifiable, and explicitly copies
    relevant breakpoint-related attributes in hw_breakpoint_copy_attr().
    This misses copying perf_event_attr::sig_data.
    
    Since sig_data is not specific to PERF_TYPE_BREAKPOINT, introduce a
    helper to copy generic event-type-independent attributes on
    modification.
    
    Fixes: 97ba62b27867 ("perf: Add support for SIGTRAP on perf events")
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: Marco Elver <elver@google.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
    Link: https://lore.kernel.org/r/20220131103407.1971678-1-elver@google.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5f780b1435f55fee4adf9fb18533724cb41c6c0b
Author: Mark Rutland <mark.rutland@arm.com>
Date:   Tue Feb 1 13:29:23 2022 +0000

    kvm/arm64: rework guest entry logic
    
    [ Upstream commit 8cfe148a7136bc60452a5c6b7ac2d9d15c36909b ]
    
    In kvm_arch_vcpu_ioctl_run() we enter an RCU extended quiescent state
    (EQS) by calling guest_enter_irqoff(), and unmasked IRQs prior to
    exiting the EQS by calling guest_exit(). As the IRQ entry code will not
    wake RCU in this case, we may run the core IRQ code and IRQ handler
    without RCU watching, leading to various potential problems.
    
    Additionally, we do not inform lockdep or tracing that interrupts will
    be enabled during guest execution, which caan lead to misleading traces
    and warnings that interrupts have been enabled for overly-long periods.
    
    This patch fixes these issues by using the new timing and context
    entry/exit helpers to ensure that interrupts are handled during guest
    vtime but with RCU watching, with a sequence:
    
            guest_timing_enter_irqoff();
    
            guest_state_enter_irqoff();
            < run the vcpu >
            guest_state_exit_irqoff();
    
            < take any pending IRQs >
    
            guest_timing_exit_irqoff();
    
    Since instrumentation may make use of RCU, we must also ensure that no
    instrumented code is run during the EQS. I've split out the critical
    section into a new kvm_arm_enter_exit_vcpu() helper which is marked
    noinstr.
    
    Fixes: 1b3d546daf85ed2b ("arm/arm64: KVM: Properly account for guest CPU time")
    Reported-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
    Cc: Alexandru Elisei <alexandru.elisei@arm.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Frederic Weisbecker <frederic@kernel.org>
    Cc: James Morse <james.morse@arm.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Paul E. McKenney <paulmck@kernel.org>
    Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Message-Id: <20220201132926.3301912-3-mark.rutland@arm.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bfa75faeb7ea4ab6d34339c56a5bbfc0f990ce45
Author: Mark Rutland <mark.rutland@arm.com>
Date:   Tue Feb 1 13:29:22 2022 +0000

    kvm: add guest_state_{enter,exit}_irqoff()
    
    commit ef9989afda73332df566852d6e9ca695c05f10ce upstream.
    
    When transitioning to/from guest mode, it is necessary to inform
    lockdep, tracing, and RCU in a specific order, similar to the
    requirements for transitions to/from user mode. Additionally, it is
    necessary to perform vtime accounting for a window around running the
    guest, with RCU enabled, such that timer interrupts taken from the guest
    can be accounted as guest time.
    
    Most architectures don't handle all the necessary pieces, and a have a
    number of common bugs, including unsafe usage of RCU during the window
    between guest_enter() and guest_exit().
    
    On x86, this was dealt with across commits:
    
      87fa7f3e98a1310e ("x86/kvm: Move context tracking where it belongs")
      0642391e2139a2c1 ("x86/kvm/vmx: Add hardirq tracing to guest enter/exit")
      9fc975e9efd03e57 ("x86/kvm/svm: Add hardirq tracing on guest enter/exit")
      3ebccdf373c21d86 ("x86/kvm/vmx: Move guest enter/exit into .noinstr.text")
      135961e0a7d555fc ("x86/kvm/svm: Move guest enter/exit into .noinstr.text")
      160457140187c5fb ("KVM: x86: Defer vtime accounting 'til after IRQ handling")
      bc908e091b326467 ("KVM: x86: Consolidate guest enter/exit logic to common helpers")
    
    ... but those fixes are specific to x86, and as the resulting logic
    (while correct) is split across generic helper functions and
    x86-specific helper functions, it is difficult to see that the
    entry/exit accounting is balanced.
    
    This patch adds generic helpers which architectures can use to handle
    guest entry/exit consistently and correctly. The guest_{enter,exit}()
    helpers are split into guest_timing_{enter,exit}() to perform vtime
    accounting, and guest_context_{enter,exit}() to perform the necessary
    context tracking and RCU management. The existing guest_{enter,exit}()
    heleprs are left as wrappers of these.
    
    Atop this, new guest_state_enter_irqoff() and guest_state_exit_irqoff()
    helpers are added to handle the ordering of lockdep, tracing, and RCU
    manageent. These are inteneded to mirror exit_to_user_mode() and
    enter_from_user_mode().
    
    Subsequent patches will migrate architectures over to the new helpers,
    following a sequence:
    
            guest_timing_enter_irqoff();
    
            guest_state_enter_irqoff();
            < run the vcpu >
            guest_state_exit_irqoff();
    
            < take any pending IRQs >
    
            guest_timing_exit_irqoff();
    
    This sequences handles all of the above correctly, and more clearly
    balances the entry and exit portions, making it easier to understand.
    
    The existing helpers are marked as deprecated, and will be removed once
    all architectures have been converted.
    
    There should be no functional change as a result of this patch.
    
    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
    Reviewed-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
    Message-Id: <20220201132926.3301912-2-mark.rutland@arm.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f5b14654ae1bd1eec3b4d0ead11ad08eec4ac783
Author: Sergei Trofimovich <slyich@gmail.com>
Date:   Thu Jan 20 23:37:48 2022 +0000

    objtool: Fix truncated string warning
    
    [ Upstream commit 82880283d7fcd0a1d20964a56d6d1a5cc0df0713 ]
    
    On GCC 12, the build fails due to a possible truncated string:
    
        check.c: In function 'validate_call':
        check.c:2865:58: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
         2865 |                 snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
              |                                                          ^~
    
    In theory it's a valid bug:
    
        static char pvname[16];
        int idx;
        ...
        idx = (rel->addend / sizeof(void *));
        snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
    
    There are only 7 chars for %d while it could take up to 9, so the
    printed "pv_ops[%d]" string could get truncated.
    
    In reality the bug should never happen, because pv_ops only has ~80
    entries, so 7 chars for the integer is more than enough.  Still, it's
    worth fixing.  Bump the buffer size by 2 bytes to silence the warning.
    
    [ jpoimboe: changed size to 19; massaged changelog ]
    
    Fixes: db2b0c5d7b6f ("objtool: Support pv_opsindirect calls for noinstr")
    Reported-by: Adam Borowski <kilobyte@angband.pl>
    Reported-by: Martin Liška <mliska@suse.cz>
    Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
    Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Link: https://lore.kernel.org/r/20220120233748.2062559-1-slyich@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d0a9662105c18a233af1df853facc7e6fa18e2f8
Author: Riwen Lu <luriwen@kylinos.cn>
Date:   Thu Jan 6 16:46:09 2022 +0800

    rtc: cmos: Evaluate century appropriate
    
    commit ff164ae39b82ee483b24579c8e22a13a8ce5bd04 upstream.
    
    There's limiting the year to 2069. When setting the rtc year to 2070,
    reading it returns 1970. Evaluate century starting from 19 to count the
    correct year.
    
    $ sudo date -s 20700106
    Mon 06 Jan 2070 12:00:00 AM CST
    $ sudo hwclock -w
    $ sudo hwclock -r
    1970-01-06 12:00:49.604968+08:00
    
    Fixes: 2a4daadd4d3e5071 ("rtc: cmos: ignore bogus century byte")
    
    Signed-off-by: Riwen Lu <luriwen@kylinos.cn>
    Acked-by: Eric Wong <e@80x24.org>
    Reviewed-by: Mateusz Jończyk <mat.jonczyk@o2.pl>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn
    Signed-off-by: Mateusz Jończyk <mat.jonczyk@o2.pl> # preparation for stable
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f96cdab322998b776c3be3ee515620bbb82f8d46
Author: Sasha Neftin <sasha.neftin@intel.com>
Date:   Tue Dec 7 13:23:06 2021 +0200

    e1000e: Separate ADP board type from TGP
    
    commit 68defd528f94ed1cf11f49a75cc1875dccd781fa upstream.
    
    We have the same LAN controller on different PCH's. Separate ADP board
    type from a TGP which will allow for specific fixes to be applied for
    ADP platforms.
    
    Suggested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Suggested-by: Dima Ruinskiy <dima.ruinskiy@intel.com>
    Signed-off-by: Sasha Neftin <sasha.neftin@intel.com>
    Tested-by: Nechama Kraus <nechamax.kraus@linux.intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fbc83aeccd8070cb31e462245bca8bf2bed88329
Author: Nathan Chancellor <nathan@kernel.org>
Date:   Tue Feb 1 14:25:04 2022 -0700

    tools/resolve_btfids: Do not print any commands when building silently
    
    commit 7f3bdbc3f13146eb9d07de81ea71f551587a384b upstream.
    
    When building with 'make -s', there is some output from resolve_btfids:
    
    $ make -sj"$(nproc)" oldconfig prepare
      MKDIR     .../tools/bpf/resolve_btfids/libbpf/
      MKDIR     .../tools/bpf/resolve_btfids//libsubcmd
      LINK     resolve_btfids
    
    Silent mode means that no information should be emitted about what is
    currently being done. Use the $(silent) variable from Makefile.include
    to avoid defining the msg macro so that there is no information printed.
    
    Fixes: fbbb68de80a4 ("bpf: Add resolve_btfids tool to resolve BTF IDs in ELF object")
    Signed-off-by: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20220201212503.731732-1-nathan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e2242343ba198a7c739a275a76051e0884e60bad
Author: Muhammad Usama Anjum <usama.anjum@collabora.com>
Date:   Thu Jan 27 22:44:46 2022 +0500

    selftests: futex: Use variable MAKE instead of make
    
    commit b9199181a9ef8252e47e207be8c23e1f50662620 upstream.
    
    Recursive make commands should always use the variable MAKE, not the
    explicit command name ‘make’. This has benefits and removes the
    following warning when multiple jobs are used for the build:
    
    make[2]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
    
    Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
    Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
    Reviewed-by: André Almeida <andrealmeid@collabora.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 191edea5db19f711d4d887471874c891fd2be45a
Author: Muhammad Usama Anjum <usama.anjum@collabora.com>
Date:   Thu Jan 27 21:33:45 2022 +0500

    selftests/exec: Remove pipe from TEST_GEN_FILES
    
    commit 908a26e139e8cf21093acc56d8e90ddad2ad1eff upstream.
    
    pipe named FIFO special file is being created in execveat.c to perform
    some tests. Makefile doesn't need to do anything with the pipe. When it
    isn't found, Makefile generates the following build error:
    
    make: *** No rule to make target
    '../tools/testing/selftests/exec/pipe', needed by 'all'.  Stop.
    
    pipe is created and removed during test run-time.
    
    Amended change log to add pipe remove info:
    Shuah Khan <skhan@linuxfoundation.org>
    
    Fixes: 61016db15b8e ("selftests/exec: Verify execve of non-regular files fail")
    Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
    Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d578933f6226d5419af9306746efa1c693cbaf9c
Author: Hou Tao <hotforest@gmail.com>
Date:   Wed Feb 2 14:01:58 2022 +0800

    bpf: Use VM_MAP instead of VM_ALLOC for ringbuf
    
    commit b293dcc473d22a62dc6d78de2b15e4f49515db56 upstream.
    
    After commit 2fd3fb0be1d1 ("kasan, vmalloc: unpoison VM_ALLOC pages
    after mapping"), non-VM_ALLOC mappings will be marked as accessible
    in __get_vm_area_node() when KASAN is enabled. But now the flag for
    ringbuf area is VM_ALLOC, so KASAN will complain out-of-bound access
    after vmap() returns. Because the ringbuf area is created by mapping
    allocated pages, so use VM_MAP instead.
    
    After the change, info in /proc/vmallocinfo also changes from
      [start]-[end]   24576 ringbuf_map_alloc+0x171/0x290 vmalloc user
    to
      [start]-[end]   24576 ringbuf_map_alloc+0x171/0x290 vmap user
    
    Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it")
    Reported-by: syzbot+5ad567a418794b9b5983@syzkaller.appspotmail.com
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20220202060158.6260-1-houtao1@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7d9c470134104dfecb753b7b4add7037a7403c6e
Author: Haiyue Wang <haiyue.wang@intel.com>
Date:   Fri Jan 28 18:47:14 2022 +0800

    gve: fix the wrong AdminQ buffer queue index check
    
    commit 1f84a9450d75e08af70d9e2f2d5e1c0ac0c881d2 upstream.
    
    The 'tail' and 'head' are 'unsigned int' type free-running count, when
    'head' is overflow, the 'int i (= tail) < u32 head' will be false:
    
    Only '- loop 0: idx = 63' result is shown, so it needs to use 'int' type
    to compare, it can handle the overflow correctly.
    
    typedef uint32_t u32;
    
    int main()
    {
            u32 tail, head;
            int stail, shead;
            int i, loop;
    
            tail = 0xffffffff;
            head = 0x00000000;
    
            for (i = tail, loop = 0; i < head; i++) {
                    unsigned int idx = i & 63;
    
                    printf("+ loop %d: idx = %u\n", loop++, idx);
            }
    
            stail = tail;
            shead = head;
            for (i = stail, loop = 0; i < shead; i++) {
                    unsigned int idx = i & 63;
    
                    printf("- loop %d: idx = %u\n", loop++, idx);
            }
    
            return 0;
    }
    
    Fixes: 5cdad90de62c ("gve: Batch AQ commands for creating and destroying queues.")
    Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7e7e81aa81e0a7f6daf2b6475cd09dae21a51408
Author: Dai Ngo <dai.ngo@oracle.com>
Date:   Wed Jan 26 13:13:38 2022 -0800

    nfsd: nfsd4_setclientid_confirm mistakenly expires confirmed client.
    
    commit ab451ea952fe9d7afefae55ddb28943a148247fe upstream.
    
    From RFC 7530 Section 16.34.5:
    
    o  The server has not recorded an unconfirmed { v, x, c, *, * } and
       has recorded a confirmed { v, x, c, *, s }.  If the principals of
       the record and of SETCLIENTID_CONFIRM do not match, the server
       returns NFS4ERR_CLID_INUSE without removing any relevant leased
       client state, and without changing recorded callback and
       callback_ident values for client { x }.
    
    The current code intends to do what the spec describes above but
    it forgot to set 'old' to NULL resulting to the confirmed client
    to be expired.
    
    Fixes: 2b63482185e6 ("nfsd: fix clid_inuse on mount with security change")
    Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
    Reviewed-by: Bruce Fields <bfields@fieldses.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2d24336c7214b281b51860e54783dfc65f1248df
Author: John Meneghini <jmeneghi@redhat.com>
Date:   Mon Jan 24 09:51:10 2022 -0500

    scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe
    
    commit 936bd03405fc83ba039d42bc93ffd4b88418f1d3 upstream.
    
    Running tests with a debug kernel shows that bnx2fc_recv_frame() is
    modifying the per_cpu lport stats counters in a non-mpsafe way.  Just boot
    a debug kernel and run the bnx2fc driver with the hardware enabled.
    
    [ 1391.699147] BUG: using smp_processor_id() in preemptible [00000000] code: bnx2fc_
    [ 1391.699160] caller is bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc]
    [ 1391.699174] CPU: 2 PID: 4355 Comm: bnx2fc_l2_threa Kdump: loaded Tainted: G    B
    [ 1391.699180] Hardware name: HP ProLiant DL120 G7, BIOS J01 07/01/2013
    [ 1391.699183] Call Trace:
    [ 1391.699188]  dump_stack_lvl+0x57/0x7d
    [ 1391.699198]  check_preemption_disabled+0xc8/0xd0
    [ 1391.699205]  bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc]
    [ 1391.699215]  ? do_raw_spin_trylock+0xb5/0x180
    [ 1391.699221]  ? bnx2fc_npiv_create_vports.isra.0+0x4e0/0x4e0 [bnx2fc]
    [ 1391.699229]  ? bnx2fc_l2_rcv_thread+0xb7/0x3a0 [bnx2fc]
    [ 1391.699240]  bnx2fc_l2_rcv_thread+0x1af/0x3a0 [bnx2fc]
    [ 1391.699250]  ? bnx2fc_ulp_init+0xc0/0xc0 [bnx2fc]
    [ 1391.699258]  kthread+0x364/0x420
    [ 1391.699263]  ? _raw_spin_unlock_irq+0x24/0x50
    [ 1391.699268]  ? set_kthread_struct+0x100/0x100
    [ 1391.699273]  ret_from_fork+0x22/0x30
    
    Restore the old get_cpu/put_cpu code with some modifications to reduce the
    size of the critical section.
    
    Link: https://lore.kernel.org/r/20220124145110.442335-1-jmeneghi@redhat.com
    Fixes: d576a5e80cd0 ("bnx2fc: Improve stats update mechanism")
    Tested-by: Guangwu Zhang <guazhang@redhat.com>
    Acked-by: Saurav Kashyap <skashyap@marvell.com>
    Signed-off-by: John Meneghini <jmeneghi@redhat.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 676c0f155ad26be37a0859376e316d21cb6b7d4f
Author: Tom Rix <trix@redhat.com>
Date:   Fri Jan 21 05:45:22 2022 -0800

    btrfs: fix use of uninitialized variable at rm device ioctl
    
    commit 37b4599547e324589e011c20f74b021d6d25cb7f upstream.
    
    Clang static analysis reports this problem
    ioctl.c:3333:8: warning: 3rd function call argument is an
      uninitialized value
        ret = exclop_start_or_cancel_reloc(fs_info,
    
    cancel is only set in one branch of an if-check and is always used.  So
    initialize to false.
    
    Fixes: 1a15eb724aae ("btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls")
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: Anand Jain <anand.jain@oracle.com>
    Signed-off-by: Tom Rix <trix@redhat.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit be064d88cdd462eaf66fa57d9558208455a7cf4d
Author: Florian Fainelli <f.fainelli@gmail.com>
Date:   Thu Jan 27 13:50:31 2022 -0800

    pinctrl: bcm2835: Fix a few error paths
    
    commit 5297c693d8c8e08fa742e3112cf70723f7a04da2 upstream.
    
    After commit 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio
    hogs") a few error paths would not unwind properly the registration of
    gpio ranges. Correct that by assigning a single error label and goto it
    whenever we encounter a fatal error.
    
    Fixes: 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs")
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Link: https://lore.kernel.org/r/20220127215033.267227-1-f.fainelli@gmail.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4519e6fc71749811cd7e09d36bd8ffd6e079f32f
Author: Łukasz Bartosik <lb@semihalf.com>
Date:   Mon Jan 24 13:55:29 2022 +0100

    pinctrl: intel: fix unexpected interrupt
    
    commit e986f0e602f19ecb7880b04dd1db415ed9bca3f6 upstream.
    
    ASUS Chromebook C223 with Celeron N3350 crashes sometimes during
    cold booot. Inspection of the kernel log showed that it gets into
    an inifite loop logging the following message:
    
    ->handle_irq():  000000009cdb51e8, handle_bad_irq+0x0/0x251
    ->irq_data.chip(): 000000005ec212a7, 0xffffa043009d8e7
    ->action(): 00000
       IRQ_NOPROBE set
    unexpected IRQ trap at vector 7c
    
    The issue happens during cold boot but only if cold boot happens
    at most several dozen seconds after Chromebook is powered off. For
    longer intervals between power off and power on (cold boot) the issue
    does not reproduce. The unexpected interrupt is sourced from INT3452
    GPIO pin which is used for SD card detect. Investigation relevealed
    that when the interval between power off and power on (cold boot)
    is less than several dozen seconds then values of INT3452 GPIO interrupt
    enable and interrupt pending registers survive power off and power
    on sequence and interrupt for SD card detect pin is enabled and pending
    during probe of SD controller which causes the unexpected IRQ message.
    "Intel Pentium and Celeron Processor N- and J- Series" volume 3 doc
    mentions that GPIO interrupt enable and status registers default
    value is 0x0.
    The fix clears INT3452 GPIO interrupt enabled and interrupt pending
    registers in its probe function.
    
    Fixes: 7981c0015af2 ("pinctrl: intel: Add Intel Sunrisepoint pin controller and GPIO support")
    Signed-off-by: Łukasz Bartosik <lb@semihalf.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d0e869bcdfe9e2a5b29f24725580ac4335c34fa4
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Wed Jan 19 20:19:15 2022 +0200

    pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line
    
    commit e12963c453263d5321a2c610e98cbc731233b685 upstream.
    
    The commit af7e3eeb84e2 ("pinctrl: intel: Disable input and output buffer
    when switching to GPIO") hadn't taken into account an update of the IRQ
    flags scenario.
    
    When updating the IRQ flags on the preconfigured line the ->irq_set_type()
    is called again. In such case the sequential Rx buffer configuration
    changes may trigger a falling or rising edge interrupt that may lead,
    on some platforms, to an undesired event.
    
    This may happen because each of intel_gpio_set_gpio_mode() and
    __intel_gpio_set_direction() updates the pad configuration with a different
    value of the GPIORXDIS bit. Notable, that the intel_gpio_set_gpio_mode() is
    called only for the pads that are configured as an input. Due to this fact,
    integrate the logic of __intel_gpio_set_direction() call into the
    intel_gpio_set_gpio_mode() so that the Rx buffer won't be disabled and
    immediately re-enabled.
    
    Fixes: af7e3eeb84e2 ("pinctrl: intel: Disable input and output buffer when switching to GPIO")
    Reported-by: Kane Chen <kane.chen@intel.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Tested-by: Grace Kao <grace.kao@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 68b70ac68a916d46d2b8681565e3a83c92fb2180
Author: Andre Przywara <andre.przywara@arm.com>
Date:   Wed Jan 5 17:29:52 2022 +0000

    pinctrl: sunxi: Fix H616 I2S3 pin data
    
    commit 1fd6bb5b47a65eacb063b37e6fa6df2b8fa92959 upstream.
    
    Two bugs have sneaked in the H616 pinctrl data:
    - PH9 uses the mux value of 0x3 twice (one should be 0x5 instead)
    - PH8 and PH9 use the "i2s3" function name twice in each pin
    
    For the double pin name we use the same trick we pulled for i2s0: append
    the pin function to the group name to designate the special function.
    
    Fixes: 25adc29407fb ("pinctrl: sunxi: Add support for the Allwinner H616 pin controller")
    Reported-by: SASANO Takayoshi <uaa@mx5.nisiq.net>
    Signed-off-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
    Reviewed-by: Samuel Holland <samuel@sholland.org>
    Link: https://lore.kernel.org/r/20220105172952.23347-1-andre.przywara@arm.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 83775594b45000056f744f00f991bdd15146bea2
Author: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Date:   Wed Jan 26 11:35:49 2022 +0000

    ASoC: qdsp6: q6apm-dai: only stop graphs that are started
    
    commit 8f2e5c65ec7534cce6d315fccf2c3aef023f68f0 upstream.
    
    Its possible that the sound card is just opened and closed without actually
    playing stream, ex: if the audio file itself is missing.
    
    Even in such cases we do call stop on graphs that are not yet started.
    DSP can throw errors in such cases, so add a check to see if the graph
    was started before stopping it.
    
    Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support")
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Link: https://lore.kernel.org/r/20220126113549.8853-5-srinivas.kandagatla@linaro.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8a2812b4aea1a1725fdb32767e868909b8b2a27c
Author: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Date:   Wed Jan 26 11:35:48 2022 +0000

    ASoC: codecs: wcd938x: fix return value of mixer put function
    
    commit bd2347fd67d8da0fa76296507cc556da0a233bcb upstream.
    
    wcd938x_ear_pa_put_gain, wcd938x_set_swr_port and  wcd938x_set_compander
    currently returns zero eventhough it changes the value.
    Fix this, so that change notifications are sent correctly.
    
    Fixes: e8ba1e05bdc01 ("ASoC: codecs: wcd938x: add basic controls")
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Link: https://lore.kernel.org/r/20220126113549.8853-4-srinivas.kandagatla@linaro.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4bb0bd2e7936aff3300d5f37edd911b0ea856d11
Author: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Date:   Wed Jan 26 11:35:47 2022 +0000

    ASoC: codecs: lpass-rx-macro: fix sidetone register offsets
    
    commit fca041a3ab70a099a6d5519ecb689b6279bd04f3 upstream.
    
    For some reason we ended up with incorrect register offfset calcuations
    for sidetone. regmap clearly throw errors when accessing these incorrect
    registers as these do not belong to any read/write ranges.
    so fix them to point to correct register offsets.
    
    Fixes: f3ce6f3c9a99 ("ASoC: codecs: lpass-rx-macro: add iir widgets")
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Link: https://lore.kernel.org/r/20220126113549.8853-3-srinivas.kandagatla@linaro.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9167f2712dc8c24964840a4d1e2ebf130e846b95
Author: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Date:   Wed Jan 26 11:35:46 2022 +0000

    ASoC: codecs: wcd938x: fix incorrect used of portid
    
    commit c5c1546a654f613e291a7c5d6f3660fc1eb6d0c7 upstream.
    
    Mixer controls have the channel id in mixer->reg, which is not same
    as port id. port id should be derived from chan_info array.
    So fix this. Without this, its possible that we could corrupt
    struct wcd938x_sdw_priv by accessing port_map array out of range
    with channel id instead of port id.
    
    Fixes: e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls")
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Link: https://lore.kernel.org/r/20220126113549.8853-2-srinivas.kandagatla@linaro.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f114fd6165dfb52520755cc4d1c1dfbd447b88b6
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Jan 19 15:31:01 2022 +0300

    ASoC: max9759: fix underflow in speaker_gain_control_put()
    
    commit 4c907bcd9dcd233da6707059d777ab389dcbd964 upstream.
    
    Check for negative values of "priv->gain" to prevent an out of bounds
    access.  The concern is that these might come from the user via:
      -> snd_ctl_elem_write_user()
        -> snd_ctl_elem_write()
          -> kctl->put()
    
    Fixes: fa8d915172b8 ("ASoC: max9759: Add Amplifier Driver")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Link: https://lore.kernel.org/r/20220119123101.GA9509@kili
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c6ede1d4455e73e5e18514cd90a45ac634c2af28
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Tue Jan 11 10:50:48 2022 +0800

    ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name
    
    commit f7a6021aaf02088870559f82fc13c58cda7fea1a upstream.
    
    If the device does not exist, of_get_child_by_name() will return NULL
    pointer.
    And devm_snd_soc_register_component() does not check it.
    Also, I have noticed that cpcap_codec_driver has not been used yet.
    Therefore, it should be better to check it in order to avoid the future
    dereference of the NULL pointer.
    
    Fixes: f6cdf2d3445d ("ASoC: cpcap: new codec")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Link: https://lore.kernel.org/r/20220111025048.524134-1-jiasheng@iscas.ac.cn
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6a2ae1bc2ccd22fd0dfe7c054e4b1372dd164ea3
Author: Robert Hancock <robert.hancock@calian.com>
Date:   Fri Jan 7 15:47:10 2022 -0600

    ASoC: simple-card: fix probe failure on platform component
    
    commit a64067f4cecaaa4deed8e33d3266bc0bcc189142 upstream.
    
    A previous change to simple-card resulted in asoc_simple_parse_dai
    attempting to retrieve the dai_name for platform components, which are
    unlikely to have a valid DAI name. This caused simple-card to fail to
    probe when using the xlnx_formatter_pcm as the platform component, since
    it does not register any DAI components.
    
    Since the dai_name is not used for platform components, just skip trying
    to retrieve it for those.
    
    Fixes: f107294c6422 ("ASoC: simple-card: support snd_soc_dai_link_component style for cpu")
    Signed-off-by: Robert Hancock <robert.hancock@calian.com>
    Link: https://lore.kernel.org/r/20220107214711.1100162-6-robert.hancock@calian.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aa610c4f17714d4042381df380bccb754e4716b9
Author: Robert Hancock <robert.hancock@calian.com>
Date:   Fri Jan 7 15:47:06 2022 -0600

    ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes
    
    commit e958b5884725dac86d36c1e7afe5a55f31feb0b2 upstream.
    
    This patch is based on one in the Xilinx kernel tree, "ASoc: xlnx: Make
    buffer bytes multiple of period bytes" by Devarsh Thakkar. The same
    issue exists in the mainline version of the driver. The original
    patch description is as follows:
    
    "The Xilinx Audio Formatter IP has a constraint on period
    bytes to be multiple of 64. This leads to driver changing
    the period size to suitable frames such that period bytes
    are multiple of 64.
    
    Now since period bytes and period size are updated but not
    the buffer bytes, this may make the buffer bytes unaligned
    and not multiple of period bytes.
    
    When this happens we hear popping noise as while DMA is being
    done the buffer bytes are not enough to complete DMA access
    for last period of frame within the application buffer boundary.
    
    To avoid this, align buffer bytes too as multiple of 64, and
    set another constraint to always enforce number of periods as
    integer. Now since, there is already a rule in alsa core
    to enforce Buffer size = Number of Periods * Period Size
    this automatically aligns buffer bytes as multiple of period
    bytes."
    
    Fixes: 6f6c3c36f091 ("ASoC: xlnx: add pcm formatter platform driver")
    Cc: Devarsh Thakkar <devarsh.thakkar@xilinx.com>
    Signed-off-by: Robert Hancock <robert.hancock@calian.com>
    Link: https://lore.kernel.org/r/20220107214711.1100162-2-robert.hancock@calian.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f5cfb8c53926577c2401e7e97c29ffebb2dd30d1
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Thu Jan 27 13:13:34 2022 +0000

    ASoC: fsl: Add missing error handling in pcm030_fabric_probe
    
    commit fb25621da5702c104ce0a48de5b174ced09e5b4e upstream.
    
    Add the missing platform_device_put() and platform_device_del()
    before return from pcm030_fabric_probe in the error handling case.
    
    Fixes: c912fa913446 ("ASoC: fsl: register the wm9712-codec")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220127131336.30214-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a2b79c1594c49838eaae3675d7f616b83d94a6b7
Author: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Date:   Wed Jan 26 12:03:25 2022 +0200

    ASoC: rt5682: Fix deadlock on resume
    
    commit 4045daf0fa87846a27f56329fddad2deeb5ca354 upstream.
    
    On resume from suspend the following chain of events can happen:
    A rt5682_resume() -> mod_delayed_work() for jack_detect_work
    B DAPM sequence starts ( DAPM is locked now)
    
    A1. rt5682_jack_detect_handler() scheduled
     - Takes both jdet_mutex and calibrate_mutex
     - Calls in to rt5682_headset_detect() which tries to take DAPM lock, it
       starts to wait for it as B path took it already.
    B1. DAPM sequence reaches the "HP Amp", rt5682_hp_event() tries to take
        the jdet_mutex, but it is locked in A1, so it waits.
    
    Deadlock.
    
    To solve the deadlock, drop the jdet_mutex, use the jack_detect_work to do
    the jack removal handling, move the dapm lock up one level to protect the
    most of the rt5682_jack_detect_handler(), but not the jack reporting as it
    might trigger a DAPM sequence.
    The rt5682_headset_detect() can be changed to static as well.
    
    Fixes: 8deb34a90f063 ("ASoC: rt5682: fix the wrong jack type detected")
    Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
    Link: https://lore.kernel.org/r/20220126100325.16513-1-peter.ujfalusi@linux.intel.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bd741337c284ac5f2747227b3950660a2404b58e
Author: Mario Limonciello <mario.limonciello@amd.com>
Date:   Tue Jan 25 21:46:58 2022 -0600

    drm/amd: avoid suspend on dGPUs w/ s2idle support when runtime PM enabled
    
    commit e55a3aea418269266d84f426b3bd70794d3389c8 upstream.
    
    dGPUs connected to Intel systems configured for suspend to idle
    will not have the power rails cut at suspend and resetting the GPU
    may lead to problematic behaviors.
    
    Fixes: e25443d2765f4 ("drm/amdgpu: add a dev_pm_ops prepare callback (v2)")
    Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1879
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 855f1528f4c5a0f0b237916572bf1e0b5e74e771
Author: Matthew Brost <matthew.brost@intel.com>
Date:   Tue Jan 11 08:39:29 2022 -0800

    drm/i915: Lock timeline mutex directly in error path of eb_pin_timeline
    
    commit 5ae13c305ef8cb54efc4f0ba4565709b9f320fed upstream.
    
    Don't use the interruptable version of the timeline mutex lock in the
    error path of eb_pin_timeline as the cleanup must always happen.
    
    v2:
     (John Harrison)
      - Don't check for interrupt during mutex lock
    v3:
     (Tvrtko)
      - A comment explaining why lock helper isn't used
    
    Fixes: 544460c33821 ("drm/i915: Multi-BB execbuf")
    Signed-off-by: Matthew Brost <matthew.brost@intel.com>
    Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
    Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220111163929.14017-1-matthew.brost@intel.com
    (cherry picked from commit cb935c4618bd2ff9058feee4af7088446da6a763)
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 76aad713eb86c934dce5f8ae518bf65edb57d0c5
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Mon Jan 24 15:24:09 2022 +0300

    drm/i915/overlay: Prevent divide by zero bugs in scaling
    
    commit 90a3d22ff02b196d5884e111f39271a1d4ee8e3e upstream.
    
    Smatch detected a divide by zero bug in check_overlay_scaling().
    
        drivers/gpu/drm/i915/display/intel_overlay.c:976 check_overlay_scaling()
        error: potential divide by zero bug '/ rec->dst_height'.
        drivers/gpu/drm/i915/display/intel_overlay.c:980 check_overlay_scaling()
        error: potential divide by zero bug '/ rec->dst_width'.
    
    Prevent this by ensuring that the dst height and width are non-zero.
    
    Fixes: 02e792fbaadb ("drm/i915: implement drmmode overlay support v4")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220124122409.GA31673@kili
    (cherry picked from commit cf5b64f7f10b28bebb9b7c9d25e7aee5cbe43918)
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cb64de55ed110f05ea774e46ce9e857fce975436
Author: Anitha Chrisanthus <anitha.chrisanthus@intel.com>
Date:   Thu Jan 27 10:45:46 2022 -0800

    drm/kmb: Fix for build errors with Warray-bounds
    
    commit 43f2517955875be5d96b641fba33d73097fe3cd9 upstream.
    
    This fixes the following build error
    
    drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable':
    drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
      165 |                 kmb->plane_status[plane_id].ctrl =
      LCD_CTRL_GL2_ENABLE;
      |                 ~~~~~~~~~~~~~~~~~^~~~~~~~~~
      In file included from drivers/gpu/drm/kmb/kmb_plane.c:17:
      drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_status'
      61 |         struct layer_status  plane_status[KMB_MAX_PLANES];
      |                                         ^~~~~~~~~~~~
      drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array subscript 2 is above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
      162 |  kmb->plane_status[plane_id].ctrl =  LCD_CTRL_GL1_ENABLE;
      |                 ~~~~~~~~~~~~~~~~~^~~~~~~~~~
      In file included from
      drivers/gpu/drm/kmb/kmb_plane.c:17:
      drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_status'
      61 |         struct layer_status  plane_status[KMB_MAX_PLANES];
      |
      ^~~~~~~~~~~~
    
    Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display")
    Signed-off-by: Anitha Chrisanthus <anitha.chrisanthus@intel.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220127194227.2213608-1-anitha.chrisanthus@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6f9267e01cca749137349d8ffb0d0ebbadf567f4
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Wed Feb 2 09:17:55 2022 +0100

    drm: mxsfb: Fix NULL pointer dereference
    
    commit 622c9a3a7868e1eeca39c55305ca3ebec4742b64 upstream.
    
    mxsfb should not ever dereference the NULL pointer which
    drm_atomic_get_new_bridge_state is allowed to return.
    Assume a fixed format instead.
    
    Fixes: b776b0f00f24 ("drm: mxsfb: Use bus_format from the nearest bridge if present")
    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Signed-off-by: Marek Vasut <marex@denx.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220202081755.145716-3-alexander.stein@ew.tq-group.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c16fb9ebbc521b7c5a44f5df6ba06bc1183dcf9b
Author: Yannick Vignon <yannick.vignon@nxp.com>
Date:   Thu Feb 3 17:00:25 2022 +0100

    net: stmmac: ensure PTP time register reads are consistent
    
    commit 80d4609008e6d696a279e39ae7458c916fcd44c1 upstream.
    
    Even if protected from preemption and interrupts, a small time window
    remains when the 2 register reads could return inconsistent values,
    each time the "seconds" register changes. This could lead to an about
    1-second error in the reported time.
    
    Add logic to ensure the "seconds" and "nanoseconds" values are consistent.
    
    Fixes: 92ba6888510c ("stmmac: add the support for PTP hw clock driver")
    Signed-off-by: Yannick Vignon <yannick.vignon@nxp.com>
    Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Link: https://lore.kernel.org/r/20220203160025.750632-1-yannick.vignon@oss.nxp.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 203a35ebb49cdce377416b0690215d3ce090d364
Author: Daniel Borkmann <daniel@iogearbox.net>
Date:   Tue Feb 1 20:39:42 2022 +0100

    net, neigh: Do not trigger immediate probes on NUD_FAILED from neigh_managed_work
    
    commit 4a81f6da9cb2d1ef911131a6fd8bd15cb61fc772 upstream.
    
    syzkaller was able to trigger a deadlock for NTF_MANAGED entries [0]:
    
      kworker/0:16/14617 is trying to acquire lock:
      ffffffff8d4dd370 (&tbl->lock){++-.}-{2:2}, at: ___neigh_create+0x9e1/0x2990 net/core/neighbour.c:652
      [...]
      but task is already holding lock:
      ffffffff8d4dd370 (&tbl->lock){++-.}-{2:2}, at: neigh_managed_work+0x35/0x250 net/core/neighbour.c:1572
    
    The neighbor entry turned to NUD_FAILED state, where __neigh_event_send()
    triggered an immediate probe as per commit cd28ca0a3dd1 ("neigh: reduce
    arp latency") via neigh_probe() given table lock was held.
    
    One option to fix this situation is to defer the neigh_probe() back to
    the neigh_timer_handler() similarly as pre cd28ca0a3dd1. For the case
    of NTF_MANAGED, this deferral is acceptable given this only happens on
    actual failure state and regular / expected state is NUD_VALID with the
    entry already present.
    
    The fix adds a parameter to __neigh_event_send() in order to communicate
    whether immediate probe is allowed or disallowed. Existing call-sites
    of neigh_event_send() default as-is to immediate probe. However, the
    neigh_managed_work() disables it via use of neigh_event_send_probe().
    
    [0] <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
      print_deadlock_bug kernel/locking/lockdep.c:2956 [inline]
      check_deadlock kernel/locking/lockdep.c:2999 [inline]
      validate_chain kernel/locking/lockdep.c:3788 [inline]
      __lock_acquire.cold+0x149/0x3ab kernel/locking/lockdep.c:5027
      lock_acquire kernel/locking/lockdep.c:5639 [inline]
      lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5604
      __raw_write_lock_bh include/linux/rwlock_api_smp.h:202 [inline]
      _raw_write_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:334
      ___neigh_create+0x9e1/0x2990 net/core/neighbour.c:652
      ip6_finish_output2+0x1070/0x14f0 net/ipv6/ip6_output.c:123
      __ip6_finish_output net/ipv6/ip6_output.c:191 [inline]
      __ip6_finish_output+0x61e/0xe90 net/ipv6/ip6_output.c:170
      ip6_finish_output+0x32/0x200 net/ipv6/ip6_output.c:201
      NF_HOOK_COND include/linux/netfilter.h:296 [inline]
      ip6_output+0x1e4/0x530 net/ipv6/ip6_output.c:224
      dst_output include/net/dst.h:451 [inline]
      NF_HOOK include/linux/netfilter.h:307 [inline]
      ndisc_send_skb+0xa99/0x17f0 net/ipv6/ndisc.c:508
      ndisc_send_ns+0x3a9/0x840 net/ipv6/ndisc.c:650
      ndisc_solicit+0x2cd/0x4f0 net/ipv6/ndisc.c:742
      neigh_probe+0xc2/0x110 net/core/neighbour.c:1040
      __neigh_event_send+0x37d/0x1570 net/core/neighbour.c:1201
      neigh_event_send include/net/neighbour.h:470 [inline]
      neigh_managed_work+0x162/0x250 net/core/neighbour.c:1574
      process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307
      worker_thread+0x657/0x1110 kernel/workqueue.c:2454
      kthread+0x2e9/0x3a0 kernel/kthread.c:377
      ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
      </TASK>
    
    Fixes: 7482e3841d52 ("net, neigh: Add NTF_MANAGED flag for managed neighbor entries")
    Reported-by: syzbot+5239d0e1778a500d477a@syzkaller.appspotmail.com
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Eric Dumazet <edumazet@google.com>
    Cc: Roopa Prabhu <roopa@nvidia.com>
    Tested-by: syzbot+5239d0e1778a500d477a@syzkaller.appspotmail.com
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Link: https://lore.kernel.org/r/20220201193942.5055-1-daniel@iogearbox.net
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 40d20d9a025701728bfffe6614bdbe14ba22d195
Author: Camel Guo <camelg@axis.com>
Date:   Mon Jan 31 09:38:40 2022 +0100

    net: stmmac: dump gmac4 DMA registers correctly
    
    commit 7af037c39b600bac2c716dd1228e8ddbe149573f upstream.
    
    Unlike gmac100, gmac1000, gmac4 has 27 DMA registers and they are
    located at DMA_CHAN_BASE_ADDR (0x1100). In order for ethtool to dump
    gmac4 DMA registers correctly, this commit checks if a net_device has
    gmac4 and uses different logic to dump its DMA registers.
    
    This fixes the following KASAN warning, which can normally be triggered
    by a command similar like "ethtool -d eth0":
    
    BUG: KASAN: vmalloc-out-of-bounds in dwmac4_dump_dma_regs+0x6d4/0xb30
    Write of size 4 at addr ffffffc010177100 by task ethtool/1839
     kasan_report+0x200/0x21c
     __asan_report_store4_noabort+0x34/0x60
     dwmac4_dump_dma_regs+0x6d4/0xb30
     stmmac_ethtool_gregs+0x110/0x204
     ethtool_get_regs+0x200/0x4b0
     dev_ethtool+0x1dac/0x3800
     dev_ioctl+0x7c0/0xb50
     sock_ioctl+0x298/0x6c4
     ...
    
    Fixes: fbf68229ffe7 ("net: stmmac: unify registers dumps methods")
    Signed-off-by: Camel Guo <camelg@axis.com>
    Link: https://lore.kernel.org/r/20220131083841.3346801-1-camel.guo@axis.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 40c80a3fd42b59de026354669eab20cf1cdf407c
Author: Lior Nahmanson <liorna@nvidia.com>
Date:   Sun Jan 30 13:37:52 2022 +0200

    net: macsec: Verify that send_sci is on when setting Tx sci explicitly
    
    commit d0cfa548dbde354de986911d3913897b5448faad upstream.
    
    When setting Tx sci explicit, the Rx side is expected to use this
    sci and not recalculate it from the packet.However, in case of Tx sci
    is explicit and send_sci is off, the receiver is wrongly recalculate
    the sci from the source MAC address which most likely be different
    than the explicit sci.
    
    Fix by preventing such configuration when macsec newlink is established
    and return EINVAL error code on such cases.
    
    Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
    Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
    Reviewed-by: Raed Salem <raeds@nvidia.com>
    Signed-off-by: Raed Salem <raeds@nvidia.com>
    Link: https://lore.kernel.org/r/1643542672-29403-1-git-send-email-raeds@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8299be160aad8548071d080518712dec0df92bd5
Author: Lior Nahmanson <liorna@nvidia.com>
Date:   Sun Jan 30 13:29:01 2022 +0200

    net: macsec: Fix offload support for NETDEV_UNREGISTER event
    
    commit 9cef24c8b76c1f6effe499d2f131807c90f7ce9a upstream.
    
    Current macsec netdev notify handler handles NETDEV_UNREGISTER event by
    releasing relevant SW resources only, this causes resources leak in case
    of macsec HW offload, as the underlay driver was not notified to clean
    it's macsec offload resources.
    
    Fix by calling the underlay driver to clean it's relevant resources
    by moving offload handling from macsec_dellink() to macsec_common_dellink()
    when handling NETDEV_UNREGISTER event.
    
    Fixes: 3cf3227a21d1 ("net: macsec: hardware offloading infrastructure")
    Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
    Reviewed-by: Raed Salem <raeds@nvidia.com>
    Signed-off-by: Raed Salem <raeds@nvidia.com>
    Reviewed-by: Antoine Tenart <atenart@kernel.org>
    Link: https://lore.kernel.org/r/1643542141-28956-1-git-send-email-raeds@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5dc4be3b9ae35acd3aec198152bcb54efa68c417
Author: Jisheng Zhang <jszhang@kernel.org>
Date:   Fri Jan 28 22:15:50 2022 +0800

    net: stmmac: properly handle with runtime pm in stmmac_dvr_remove()
    
    commit 6449520391dfc3d2cef134f11a91251a054ff7d0 upstream.
    
    There are two issues with runtime pm handling in stmmac_dvr_remove():
    
    1. the mac is runtime suspended before stopping dma and rx/tx. We
    need to ensure the device is properly resumed back.
    
    2. the stmmaceth clk enable/disable isn't balanced in both exit and
    error handling code path. Take the exit code path for example, when we
    unbind the driver or rmmod the driver module, the mac is runtime
    suspended as said above, so the stmmaceth clk is disabled, but
            stmmac_dvr_remove()
              stmmac_remove_config_dt()
                clk_disable_unprepare()
    CCF will complain this time. The error handling code path suffers
    from the similar situtaion.
    
    Here are kernel warnings in error handling code path on Allwinner D1
    platform:
    
    [    1.604695] ------------[ cut here ]------------
    [    1.609328] bus-emac already disabled
    [    1.613015] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:952 clk_core_disable+0xcc/0xec
    [    1.621039] CPU: 0 PID: 38 Comm: kworker/u2:1 Not tainted 5.14.0-rc4#1
    [    1.627653] Hardware name: Allwinner D1 NeZha (DT)
    [    1.632443] Workqueue: events_unbound deferred_probe_work_func
    [    1.638286] epc : clk_core_disable+0xcc/0xec
    [    1.642561]  ra : clk_core_disable+0xcc/0xec
    [    1.646835] epc : ffffffff8023c2ec ra : ffffffff8023c2ec sp : ffffffd00411bb10
    [    1.654054]  gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : ffffffff80ed6a6f
    [    1.661272]  t1 : ffffffff80ed6a60 t2 : 0000000000000000 s0 : ffffffe001509e00
    [    1.668489]  s1 : 0000000000000001 a0 : 0000000000000019 a1 : ffffffff80e80bd8
    [    1.675707]  a2 : 00000000ffffefff a3 : 00000000000000f4 a4 : 0000000000000002
    [    1.682924]  a5 : 0000000000000001 a6 : 0000000000000030 a7 : 00000000028f5c29
    [    1.690141]  s2 : 0000000000000800 s3 : ffffffe001375000 s4 : ffffffe01fdf7a80
    [    1.697358]  s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffffffffff
    [    1.704577]  s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001b80000
    [    1.711794]  s11: ffffffe001b80760 t3 : 0000000000000062 t4 : ffffffffffffffff
    [    1.719012]  t5 : ffffffff80e0f6d8 t6 : ffffffd00411b8f0
    [    1.724321] status: 8000000201800100 badaddr: 0000000000000000 cause: 0000000000000003
    [    1.732233] [<ffffffff8023c2ec>] clk_core_disable+0xcc/0xec
    [    1.737810] [<ffffffff80240430>] clk_disable+0x38/0x78
    [    1.742956] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
    [    1.748451] [<ffffffff8031a500>] stmmac_remove_config_dt+0x1c/0x4c
    [    1.754646] [<ffffffff8031c8ec>] sun8i_dwmac_probe+0x378/0x82c
    [    1.760484] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
    [    1.765975] [<ffffffff8029a6c8>] platform_probe+0x64/0xf0
    [    1.771382] [<ffffffff8029833c>] really_probe.part.0+0x8c/0x30c
    [    1.777305] [<ffffffff8029865c>] __driver_probe_device+0xa0/0x148
    [    1.783402] [<ffffffff8029873c>] driver_probe_device+0x38/0x138
    [    1.789324] [<ffffffff802989cc>] __device_attach_driver+0xd0/0x170
    [    1.795508] [<ffffffff802988f8>] __driver_attach_async_helper+0xbc/0xc0
    [    1.802125] [<ffffffff802965ac>] bus_for_each_drv+0x68/0xb4
    [    1.807701] [<ffffffff80298d1c>] __device_attach+0xd8/0x184
    [    1.813277] [<ffffffff802967b0>] bus_probe_device+0x98/0xbc
    [    1.818852] [<ffffffff80297904>] deferred_probe_work_func+0x90/0xd4
    [    1.825122] [<ffffffff8001f8b8>] process_one_work+0x1e4/0x390
    [    1.830872] [<ffffffff8001fd80>] worker_thread+0x31c/0x4d8
    [    1.836362] [<ffffffff80026bf4>] kthreadd+0x94/0x188
    [    1.841335] [<ffffffff80026bf4>] kthreadd+0x94/0x188
    [    1.846304] [<ffffffff8001fa60>] process_one_work+0x38c/0x390
    [    1.852054] [<ffffffff80026564>] kthread+0x124/0x160
    [    1.857021] [<ffffffff8002643c>] set_kthread_struct+0x5c/0x60
    [    1.862770] [<ffffffff80001f08>] ret_from_syscall_rejected+0x8/0xc
    [    1.868956] ---[ end trace 8d5c6046255f84a0 ]---
    [    1.873675] ------------[ cut here ]------------
    [    1.878366] bus-emac already unprepared
    [    1.882378] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:810 clk_core_unprepare+0xe4/0x168
    [    1.890673] CPU: 0 PID: 38 Comm: kworker/u2:1 Tainted: G        W    5.14.0-rc4 #1
    [    1.898674] Hardware name: Allwinner D1 NeZha (DT)
    [    1.903464] Workqueue: events_unbound deferred_probe_work_func
    [    1.909305] epc : clk_core_unprepare+0xe4/0x168
    [    1.913840]  ra : clk_core_unprepare+0xe4/0x168
    [    1.918375] epc : ffffffff8023d6cc ra : ffffffff8023d6cc sp : ffffffd00411bb10
    [    1.925593]  gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : 0000000000000002
    [    1.932811]  t1 : ffffffe01f743be0 t2 : 0000000000000040 s0 : ffffffe001509e00
    [    1.940029]  s1 : 0000000000000001 a0 : 000000000000001b a1 : ffffffe00143a800
    [    1.947246]  a2 : 0000000000000000 a3 : 00000000000000f4 a4 : 0000000000000001
    [    1.954463]  a5 : 0000000000000000 a6 : 0000000005fce2a5 a7 : 0000000000000001
    [    1.961680]  s2 : 0000000000000800 s3 : ffffffff80afeb90 s4 : ffffffe01fdf7a80
    [    1.968898]  s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffffffffff
    [    1.976115]  s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001b80000
    [    1.983333]  s11: ffffffe001b80760 t3 : ffffffff80b39120 t4 : 0000000000000001
    [    1.990550]  t5 : 0000000000000000 t6 : ffffffe001600002
    [    1.995859] status: 8000000201800120 badaddr: 0000000000000000 cause: 0000000000000003
    [    2.003771] [<ffffffff8023d6cc>] clk_core_unprepare+0xe4/0x168
    [    2.009609] [<ffffffff802403a0>] clk_unprepare+0x24/0x3c
    [    2.014929] [<ffffffff8031a508>] stmmac_remove_config_dt+0x24/0x4c
    [    2.021125] [<ffffffff8031c8ec>] sun8i_dwmac_probe+0x378/0x82c
    [    2.026965] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
    [    2.032463] [<ffffffff8029a6c8>] platform_probe+0x64/0xf0
    [    2.037871] [<ffffffff8029833c>] really_probe.part.0+0x8c/0x30c
    [    2.043795] [<ffffffff8029865c>] __driver_probe_device+0xa0/0x148
    [    2.049892] [<ffffffff8029873c>] driver_probe_device+0x38/0x138
    [    2.055815] [<ffffffff802989cc>] __device_attach_driver+0xd0/0x170
    [    2.061999] [<ffffffff802988f8>] __driver_attach_async_helper+0xbc/0xc0
    [    2.068616] [<ffffffff802965ac>] bus_for_each_drv+0x68/0xb4
    [    2.074193] [<ffffffff80298d1c>] __device_attach+0xd8/0x184
    [    2.079769] [<ffffffff802967b0>] bus_probe_device+0x98/0xbc
    [    2.085345] [<ffffffff80297904>] deferred_probe_work_func+0x90/0xd4
    [    2.091616] [<ffffffff8001f8b8>] process_one_work+0x1e4/0x390
    [    2.097367] [<ffffffff8001fd80>] worker_thread+0x31c/0x4d8
    [    2.102858] [<ffffffff80026bf4>] kthreadd+0x94/0x188
    [    2.107830] [<ffffffff80026bf4>] kthreadd+0x94/0x188
    [    2.112800] [<ffffffff8001fa60>] process_one_work+0x38c/0x390
    [    2.118551] [<ffffffff80026564>] kthread+0x124/0x160
    [    2.123520] [<ffffffff8002643c>] set_kthread_struct+0x5c/0x60
    [    2.129268] [<ffffffff80001f08>] ret_from_syscall_rejected+0x8/0xc
    [    2.135455] ---[ end trace 8d5c6046255f84a1 ]---
    
    Fixes: 5ec55823438e ("net: stmmac: add clocks management for gmac driver")
    Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 262c05aae6c4c3f4bdeb44a362700d96401fe13d
Author: Yuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>
Date:   Thu Jan 27 21:17:14 2022 +0900

    net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpected speed request.
    
    commit 928d6fe996f69330ded6b887baf4534c5fac7988 upstream.
    
    Variable clk_sel_val is not initialized in the default case of the first switch statement.
    In that case, the function should return immediately without any changes to the hardware.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Fixes: b38dd98ff8d0 ("net: stmmac: Add Toshiba Visconti SoCs glue driver")
    Signed-off-by: Yuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>
    Reviewed-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 504078fbe9dd570d685361b57784a6050bc40aaa
Author: Wen Gu <guwen@linux.alibaba.com>
Date:   Wed Jan 26 23:33:04 2022 +0800

    net/smc: Forward wakeup to smc socket waitqueue after fallback
    
    commit 341adeec9adad0874f29a0a1af35638207352a39 upstream.
    
    When we replace TCP with SMC and a fallback occurs, there may be
    some socket waitqueue entries remaining in smc socket->wq, such
    as eppoll_entries inserted by userspace applications.
    
    After the fallback, data flows over TCP/IP and only clcsocket->wq
    will be woken up. Applications can't be notified by the entries
    which were inserted in smc socket->wq before fallback. So we need
    a mechanism to wake up smc socket->wq at the same time if some
    entries remaining in it.
    
    The current workaround is to transfer the entries from smc socket->wq
    to clcsock->wq during the fallback. But this may cause a crash
    like this:
    
     general protection fault, probably for non-canonical address 0xdead000000000100: 0000 [#1] PREEMPT SMP PTI
     CPU: 3 PID: 0 Comm: swapper/3 Kdump: loaded Tainted: G E     5.16.0+ #107
     RIP: 0010:__wake_up_common+0x65/0x170
     Call Trace:
      <IRQ>
      __wake_up_common_lock+0x7a/0xc0
      sock_def_readable+0x3c/0x70
      tcp_data_queue+0x4a7/0xc40
      tcp_rcv_established+0x32f/0x660
      ? sk_filter_trim_cap+0xcb/0x2e0
      tcp_v4_do_rcv+0x10b/0x260
      tcp_v4_rcv+0xd2a/0xde0
      ip_protocol_deliver_rcu+0x3b/0x1d0
      ip_local_deliver_finish+0x54/0x60
      ip_local_deliver+0x6a/0x110
      ? tcp_v4_early_demux+0xa2/0x140
      ? tcp_v4_early_demux+0x10d/0x140
      ip_sublist_rcv_finish+0x49/0x60
      ip_sublist_rcv+0x19d/0x230
      ip_list_rcv+0x13e/0x170
      __netif_receive_skb_list_core+0x1c2/0x240
      netif_receive_skb_list_internal+0x1e6/0x320
      napi_complete_done+0x11d/0x190
      mlx5e_napi_poll+0x163/0x6b0 [mlx5_core]
      __napi_poll+0x3c/0x1b0
      net_rx_action+0x27c/0x300
      __do_softirq+0x114/0x2d2
      irq_exit_rcu+0xb4/0xe0
      common_interrupt+0xba/0xe0
      </IRQ>
      <TASK>
    
    The crash is caused by privately transferring waitqueue entries from
    smc socket->wq to clcsock->wq. The owners of these entries, such as
    epoll, have no idea that the entries have been transferred to a
    different socket wait queue and still use original waitqueue spinlock
    (smc socket->wq.wait.lock) to make the entries operation exclusive,
    but it doesn't work. The operations to the entries, such as removing
    from the waitqueue (now is clcsock->wq after fallback), may cause a
    crash when clcsock waitqueue is being iterated over at the moment.
    
    This patch tries to fix this by no longer transferring wait queue
    entries privately, but introducing own implementations of clcsock's
    callback functions in fallback situation. The callback functions will
    forward the wakeup to smc socket->wq if clcsock->wq is actually woken
    up and smc socket->wq has remaining entries.
    
    Fixes: 2153bd1e3d3d ("net/smc: Transfer remaining wait queue entries during fallback")
    Suggested-by: Karsten Graul <kgraul@linux.ibm.com>
    Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
    Acked-by: Karsten Graul <kgraul@linux.ibm.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e2e9d2e7c891ca9fd253910beb4e8e4dfcffd5d3
Author: Miquel Raynal <miquel.raynal@bootlin.com>
Date:   Tue Jan 25 13:14:25 2022 +0100

    net: ieee802154: Return meaningful error codes from the netlink helpers
    
    commit 79c37ca73a6e9a33f7b2b7783ba6af07a448c8a9 upstream.
    
    Returning -1 does not indicate anything useful.
    
    Use a standard and meaningful error code instead.
    
    Fixes: a26c5fd7622d ("nl802154: add support for security layer")
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Acked-by: Alexander Aring <aahringo@redhat.com>
    Link: https://lore.kernel.org/r/20220125121426.848337-6-miquel.raynal@bootlin.com
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d2295407c11fb1ee6102fd86761e392bdf266128
Author: Phil Sutter <phil@nwl.cc>
Date:   Tue Jan 25 20:06:03 2022 +0100

    netfilter: nft_reject_bridge: Fix for missing reply from prerouting
    
    commit aeac4554eb549037ff2f719200c0a9c1c25e7eaa upstream.
    
    Prior to commit fa538f7cf05aa ("netfilter: nf_reject: add reject skbuff
    creation helpers"), nft_reject_bridge did not assign to nskb->dev before
    passing nskb on to br_forward(). The shared skbuff creation helpers
    introduced in above commit do which seems to confuse br_forward() as
    reject statements in prerouting hook won't emit a packet anymore.
    
    Fix this by simply passing NULL instead of 'dev' to the helpers - they
    use the pointer for just that assignment, nothing else.
    
    Fixes: fa538f7cf05aa ("netfilter: nf_reject: add reject skbuff creation helpers")
    Signed-off-by: Phil Sutter <phil@nwl.cc>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 21feb6df3967541931242c427fe0958276af81cc
Author: Miquel Raynal <miquel.raynal@bootlin.com>
Date:   Tue Jan 25 13:14:24 2022 +0100

    net: ieee802154: ca8210: Stop leaking skb's
    
    commit 621b24b09eb61c63f262da0c9c5f0e93348897e5 upstream.
    
    Upon error the ieee802154_xmit_complete() helper is not called. Only
    ieee802154_wake_queue() is called manually. We then leak the skb
    structure.
    
    Free the skb structure upon error before returning.
    
    Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Acked-by: Alexander Aring <aahringo@redhat.com>
    Link: https://lore.kernel.org/r/20220125121426.848337-5-miquel.raynal@bootlin.com
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 81704045967caa6887dd80cc35420d193a886804
Author: Miquel Raynal <miquel.raynal@bootlin.com>
Date:   Tue Jan 25 13:14:22 2022 +0100

    net: ieee802154: mcr20a: Fix lifs/sifs periods
    
    commit d753c4004820a888ec007dd88b271fa9c3172c5c upstream.
    
    These periods are expressed in time units (microseconds) while 40 and 12
    are the number of symbol durations these periods will last. We need to
    multiply them both with phy->symbol_duration in order to get these
    values in microseconds.
    
    Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Acked-by: Alexander Aring <aahringo@redhat.com>
    Link: https://lore.kernel.org/r/20220125121426.848337-3-miquel.raynal@bootlin.com
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 03b0f8590ad158e42bce544dbfe5e1d9d2af6cd2
Author: Miquel Raynal <miquel.raynal@bootlin.com>
Date:   Tue Jan 25 13:14:21 2022 +0100

    net: ieee802154: hwsim: Ensure proper channel selection at probe time
    
    commit 1293fccc9e892712d910ec96079d3717307f1d2d upstream.
    
    Drivers are expected to set the PHY current_channel and current_page
    according to their default state. The hwsim driver is advertising being
    configured on channel 13 by default but that is not reflected in its own
    internal pib structure. In order to ensure that this driver consider the
    current channel as being 13 internally, we at least need to set the
    pib->channel field to 13.
    
    Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    [stefan@datenfreihafen.org: fixed assigment from page to channel]
    Acked-by: Alexander Aring <aahringo@redhat.com>
    Link: https://lore.kernel.org/r/20220125121426.848337-2-miquel.raynal@bootlin.com
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8e3b022d3d4ea98779c8daeaee47449af26932b3
Author: Mark Zhang <markzhang@nvidia.com>
Date:   Wed Jan 19 10:37:55 2022 +0200

    IB/cm: Release previously acquired reference counter in the cm_id_priv
    
    commit b856101a1774b5f1c8c99e8dfdef802856520732 upstream.
    
    In failure flow, the reference counter acquired was not released,
    and the following error was reported:
    
      drivers/infiniband/core/cm.c:3373 cm_lap_handler() warn: inconsistent
                            refcounting 'cm_id_priv->refcount.refs.counter':
    
    Fixes: 7345201c3963 ("IB/cm: Improve the calling of cm_init_av_for_lap and cm_init_av_by_path")
    Link: https://lore.kernel.org/r/7615f23bbb5c5b66d03f6fa13e1c99d51dae6916.1642581448.git.leonro@nvidia.com
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Mark Zhang <markzhang@nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c2f79ff2180d6c4cf1e621f682b845297f2eae44
Author: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Date:   Sat Jan 15 18:02:36 2022 -0500

    IB/hfi1: Fix tstats alloc and dealloc
    
    commit e5cce44aff3be9ad2cd52f63f35edbd706181d50 upstream.
    
    The tstats allocation is done in the accelerated ndo_init function but the
    allocation is not tested to succeed.
    
    The deallocation is not done in the accelerated ndo_uninit function.
    
    Resolve issues by testing for an allocation failure and adding the
    free_percpu in the uninit function.
    
    Fixes: aa0616a9bd52 ("IB/hfi1: switch to core handling of rx/tx byte/packet counters")
    Link: https://lore.kernel.org/r/1642287756-182313-5-git-send-email-mike.marciniszyn@cornelisnetworks.com
    Reviewed-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Signed-off-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 447c3d4046d7b54052d07d8b27e15e6edea5662c
Author: Xin Xiong <xiongx18@fudan.edu.cn>
Date:   Tue Jan 25 18:12:15 2022 +0800

    spi: uniphier: fix reference count leak in uniphier_spi_probe()
    
    commit 37c2c83ca4f1ef4b6908181ac98e18360af89b42 upstream.
    
    The issue happens in several error paths in uniphier_spi_probe().
    When either dma_get_slave_caps() or devm_spi_register_master() returns
    an error code, the function forgets to decrease the refcount of both
    `dma_rx` and `dma_tx` objects, which may lead to refcount leaks.
    
    Fix it by decrementing the reference count of specific objects in
    those error paths.
    
    Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
    Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
    Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
    Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
    Fixes: 28d1dddc59f6 ("spi: uniphier: Add DMA transfer mode support")
    Link: https://lore.kernel.org/r/20220125101214.35677-1-xiongx18@fudan.edu.cn
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit af6825eb7da83e599c443ce2e0eb9220d194edb3
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed Jan 26 11:04:47 2022 +0000

    spi: meson-spicc: add IRQ check in meson_spicc_probe
    
    commit e937440f7fc444a3e3f1fb75ea65292d6f433a44 upstream.
    
    This check misses checking for  platform_get_irq()'s call and may passes
    the negative error codes to devm_request_irq(), which takes unsigned IRQ #,
    causing it to fail with -EINVAL, overriding an original error code.
    Stop calling devm_request_irq() with invalid IRQ #s.
    
    Fixes: 454fa271bc4e ("spi: Add Meson SPICC driver")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220126110447.24549-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a05b7dff542e8a7b5f832f6e46e785e644cdf511
Author: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Date:   Mon Jan 31 15:17:08 2022 +0100

    spi: mediatek: Avoid NULL pointer crash in interrupt
    
    commit f83a96e5f033fbbd21764705cb9c04234b96218e upstream.
    
    In some case, like after a transfer timeout, master->cur_msg pointer
    is NULL which led to a kernel crash when trying to use master->cur_msg->spi.
    mtk_spi_can_dma(), pointed by master->can_dma, doesn't use this parameter
    avoid the problem by setting NULL as second parameter.
    
    Fixes: a568231f46322 ("spi: mediatek: Add spi bus for Mediatek MT8173")
    Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
    Link: https://lore.kernel.org/r/20220131141708.888710-1-benjamin.gaignard@collabora.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6279623e4e0acc1da45e3d702d3e8e67f1e8ebaf
Author: Kamal Dasu <kdasu.kdev@gmail.com>
Date:   Thu Jan 27 13:53:59 2022 -0500

    spi: bcm-qspi: check for valid cs before applying chip select
    
    commit 2cbd27267ffe020af1442b95ec57f59a157ba85c upstream.
    
    Apply only valid chip select value. This change fixes case where chip
    select is set to initial value of '-1' during probe and  PM supend and
    subsequent resume can try to use the value with undefined behaviour.
    Also in case where gpio based chip select, the check in
    bcm_qspi_chip_select() shall prevent undefined behaviour on resume.
    
    Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver")
    Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
    Acked-by: Florian Fainelli <f.fainelli@gmail.com>
    Link: https://lore.kernel.org/r/20220127185359.27322-1-kdasu.kdev@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0be365dbdcda854078f7c8cc2e6095a85450517b
Author: Joerg Roedel <jroedel@suse.de>
Date:   Fri Feb 4 12:55:37 2022 +0100

    iommu/amd: Fix loop timeout issue in iommu_ga_log_enable()
    
    commit 9b45a7738eec52bf0f5d8d3d54e822962781c5f2 upstream.
    
    The polling loop for the register change in iommu_ga_log_enable() needs
    to have a udelay() in it.  Otherwise the CPU might be faster than the
    IOMMU hardware and wrongly trigger the WARN_ON() further down the code
    stream. Use a 10us for udelay(), has there is some hardware where
    activation of the GA log can take more than a 100ms.
    
    A future optimization should move the activation check of the GA log
    to the point where it gets used for the first time. But that is a
    bigger change and not suitable for a fix.
    
    Fixes: 8bda0cfbdc1a ("iommu/amd: Detect and initialize guest vAPIC log")
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Link: https://lore.kernel.org/r/20220204115537.3894-1-joro@8bytes.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b62eceb5f8f08815fe3f945fc55bbf997c344ecd
Author: Guoqing Jiang <guoqing.jiang@linux.dev>
Date:   Fri Jan 28 11:10:02 2022 +0800

    iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping()
    
    commit 99e675d473eb8cf2deac1376a0f840222fc1adcf upstream.
    
    After commit e3beca48a45b ("irqdomain/treewide: Keep firmware node
    unconditionally allocated"). For tear down scenario, fn is only freed
    after fail to allocate ir_domain, though it also should be freed in case
    dmar_enable_qi returns error.
    
    Besides free fn, irq_domain and ir_msi_domain need to be removed as well
    if intel_setup_irq_remapping fails to enable queued invalidation.
    
    Improve the rewinding path by add out_free_ir_domain and out_free_fwnode
    lables per Baolu's suggestion.
    
    Fixes: e3beca48a45b ("irqdomain/treewide: Keep firmware node unconditionally allocated")
    Suggested-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
    Link: https://lore.kernel.org/r/20220119063640.16864-1-guoqing.jiang@linux.dev
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Link: https://lore.kernel.org/r/20220128031002.2219155-3-baolu.lu@linux.intel.com
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f2c290e7f081197da4ef6a925b1b12255ecb5981
Author: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Date:   Tue Feb 1 13:21:44 2022 +0200

    ALSA: hda: Skip codec shutdown in case the codec is not registered
    
    commit 1c7f0e349aa5f8f80b1cac3d4917405332e14cdf upstream.
    
    If the codec->registered is not set then it means that pm_runtime is
    not yet enabled and the codec->pcm_list_head has not been initialized.
    
    The access to the not initialized pcm_list_head will lead a kernel crash
    during shutdown.
    
    Reported-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
    Tested-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    Fixes: b98444ed597d ("ALSA: hda: Suspend codec at shutdown")
    Link: https://lore.kernel.org/r/20220201112144.29411-1-peter.ujfalusi@linux.intel.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 806943fe72e362af2def50b4554d43cea69a0595
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Jan 27 14:57:17 2022 +0100

    ALSA: hda: Fix signedness of sscanf() arguments
    
    commit 0444f82766f0b5b9c8302ad802dafa5dd0e722d0 upstream.
    
    The %x format of sscanf() takes an unsigned int pointer, while we pass
    a signed int pointer.  Practically it's OK, but this may result in a
    compile warning.  Let's fix it.
    
    Fixes: a235d5b8e550 ("ALSA: hda: Allow model option to specify PCI SSID alias")
    Reported-by: kernel test robot <lkp@intel.com>
    Link: https://lore.kernel.org/r/20220127135717.31751-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 95cb31766018e362ea772218699b296ad7b67af4
Author: Tom Rix <trix@redhat.com>
Date:   Wed Jan 26 10:21:42 2022 -0800

    ALSA: usb-audio: initialize variables that could ignore errors
    
    commit 3da4b7403db87d39bc2613cfd790de1de99a70ab upstream.
    
    clang static analysis reports this representative issue
    mixer.c:1548:35: warning: Assigned value is garbage or undefined
            ucontrol->value.integer.value[0] = val;
                                             ^ ~~~
    
    The filter_error() macro allows errors to be ignored.
    If errors can be ignored, initialize variables
    so garbage will not be used.
    
    Fixes: 48cc42973509 ("ALSA: usb-audio: Filter error from connector kctl ops, too")
    Signed-off-by: Tom Rix <trix@redhat.com>
    Link: https://lore.kernel.org/r/20220126182142.1184819-1-trix@redhat.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6c6c2b03076cdb8bf5e5916f39c96b1b6c208255
Author: Leon Romanovsky <leon@kernel.org>
Date:   Mon Jan 31 11:45:26 2022 +0200

    RDMA/mlx4: Don't continue event handler after memory allocation failure
    
    commit f3136c4ce7acf64bee43135971ca52a880572e32 upstream.
    
    The failure to allocate memory during MLX4_DEV_EVENT_PORT_MGMT_CHANGE
    event handler will cause skip the assignment logic, but
    ib_dispatch_event() will be called anyway.
    
    Fix it by calling to return instead of break after memory allocation
    failure.
    
    Fixes: 00f5ce99dc6e ("mlx4: Use port management change event instead of smp_snoop")
    Link: https://lore.kernel.org/r/12a0e83f18cfad4b5f62654f141e240d04915e10.1643622264.git.leonro@nvidia.com
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Reviewed-by: HÃ¥kon Bugge <haakon.bugge@oracle.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2702b466c204b23a7195fe43c27cfd819399e1b3
Author: Bernard Metzler <bmt@zurich.ibm.com>
Date:   Sun Jan 30 18:08:15 2022 +0100

    RDMA/siw: Fix broken RDMA Read Fence/Resume logic.
    
    commit b43a76f423aa304037603fd6165c4a534d2c09a7 upstream.
    
    Code unconditionally resumed fenced SQ processing after next RDMA Read
    completion, even if other RDMA Read responses are still outstanding, or
    ORQ is full. Also adds comments for better readability of fence
    processing, and removes orq_get_tail() helper, which is not needed
    anymore.
    
    Fixes: 8b6a361b8c48 ("rdma/siw: receive path")
    Fixes: a531975279f3 ("rdma/siw: main include file")
    Link: https://lore.kernel.org/r/20220130170815.1940-1-bmt@zurich.ibm.com
    Reported-by: Jared Holzman <jared.holzman@excelero.com>
    Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8218ef38aefb4b2fabb6e58d2023aaa3738be9e7
Author: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Date:   Wed Jan 19 04:28:09 2022 -0500

    IB/rdmavt: Validate remote_addr during loopback atomic tests
    
    commit 4028bccb003cf67e46632dee7f97ddc5d7b6e685 upstream.
    
    The rdma-core test suite sends an unaligned remote address and expects a
    failure.
    
    ERROR: test_atomic_non_aligned_addr (tests.test_atomic.AtomicTest)
    
    The qib/hfi1 rc handling validates properly, but the test has the client
    and server on the same system.
    
    The loopback of these operations is a distinct code path.
    
    Fix by syntaxing the proposed remote address in the loopback code path.
    
    Fixes: 15703461533a ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt")
    Link: https://lore.kernel.org/r/1642584489-141005-1-git-send-email-mike.marciniszyn@cornelisnetworks.com
    Reviewed-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Signed-off-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fa3b844a50845c817660146c27c0fc29b08d3116
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Jan 18 12:11:04 2022 +0300

    RDMA/siw: Fix refcounting leak in siw_create_qp()
    
    commit a75badebfdc0b3823054bedf112edb54d6357c75 upstream.
    
    The atomic_inc() needs to be paired with an atomic_dec() on the error
    path.
    
    Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
    Link: https://lore.kernel.org/r/20220118091104.GA11671@kili
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ee2477e8ccd3d978eeac0dc5a981b286d9bb7b0a
Author: Leon Romanovsky <leon@kernel.org>
Date:   Tue Jan 18 09:35:01 2022 +0200

    RDMA/ucma: Protect mc during concurrent multicast leaves
    
    commit 36e8169ec973359f671f9ec7213547059cae972e upstream.
    
    Partially revert the commit mentioned in the Fixes line to make sure that
    allocation and erasing multicast struct are locked.
    
      BUG: KASAN: use-after-free in ucma_cleanup_multicast drivers/infiniband/core/ucma.c:491 [inline]
      BUG: KASAN: use-after-free in ucma_destroy_private_ctx+0x914/0xb70 drivers/infiniband/core/ucma.c:579
      Read of size 8 at addr ffff88801bb74b00 by task syz-executor.1/25529
      CPU: 0 PID: 25529 Comm: syz-executor.1 Not tainted 5.16.0-rc7-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
       print_address_description.constprop.0.cold+0x8d/0x320 mm/kasan/report.c:247
       __kasan_report mm/kasan/report.c:433 [inline]
       kasan_report.cold+0x83/0xdf mm/kasan/report.c:450
       ucma_cleanup_multicast drivers/infiniband/core/ucma.c:491 [inline]
       ucma_destroy_private_ctx+0x914/0xb70 drivers/infiniband/core/ucma.c:579
       ucma_destroy_id+0x1e6/0x280 drivers/infiniband/core/ucma.c:614
       ucma_write+0x25c/0x350 drivers/infiniband/core/ucma.c:1732
       vfs_write+0x28e/0xae0 fs/read_write.c:588
       ksys_write+0x1ee/0x250 fs/read_write.c:643
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    Currently the xarray search can touch a concurrently freeing mc as the
    xa_for_each() is not surrounded by any lock. Rather than hold the lock for
    a full scan hold it only for the effected items, which is usually an empty
    list.
    
    Fixes: 95fe51096b7a ("RDMA/ucma: Remove mc_list and rely on xarray")
    Link: https://lore.kernel.org/r/1cda5fabb1081e8d16e39a48d3a4f8160cea88b8.1642491047.git.leonro@nvidia.com
    Reported-by: syzbot+e3f96c43d19782dd14a7@syzkaller.appspotmail.com
    Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
    Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3365f9daa2a7060309979d55105f0a1c12354683
Author: Maor Gottlieb <maorg@nvidia.com>
Date:   Tue Jan 18 09:35:00 2022 +0200

    RDMA/cma: Use correct address when leaving multicast group
    
    commit d9e410ebbed9d091b97bdf45b8a3792e2878dc48 upstream.
    
    In RoCE we should use cma_iboe_set_mgid() and not cma_set_mgid to generate
    the mgid, otherwise we will generate an IGMP for an incorrect address.
    
    Fixes: b5de0c60cc30 ("RDMA/cma: Fix use after free race in roce multicast join")
    Link: https://lore.kernel.org/r/913bc6783fd7a95fe71ad9454e01653ee6fb4a9a.1642491047.git.leonro@nvidia.com
    Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a64abe188bc5167539a151d40348ee5881b3207e
Author: Anshuman Khandual <anshuman.khandual@arm.com>
Date:   Tue Jan 25 19:50:31 2022 +0530

    arm64: Add Cortex-A510 CPU part definition
    
    commit 53960faf2b731dd2f9ed6e1334634b8ba6286850 upstream.
    
    Add the CPU Partnumbers for the new Arm designs.
    
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Cc: Suzuki Poulose <suzuki.poulose@arm.com>
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-kernel@vger.kernel.org
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Acked-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
    Link: https://lore.kernel.org/r/1643120437-14352-2-git-send-email-anshuman.khandual@arm.com
    Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 50fefe7077e9008a491372cbd3573b669d417d57
Author: James Morse <james.morse@arm.com>
Date:   Thu Jan 27 12:20:51 2022 +0000

    KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs
    
    commit 1229630af88620f6e3a621a1ebd1ca14d9340df7 upstream.
    
    Prior to commit defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to
    HYP"), when an SError is synchronised due to another exception, KVM
    handles the SError first. If the guest survives, the instruction that
    triggered the original exception is re-exectued to handle the first
    exception. HVC is treated as a special case as the instruction wouldn't
    normally be re-exectued, as its not a trap.
    
    Commit defe21f49bc9 didn't preserve the behaviour of the 'return 1'
    that skips the rest of handle_exit().
    
    Since commit defe21f49bc9, KVM will try to handle the SError and the
    original exception at the same time. When the exception was an HVC,
    fixup_guest_exit() has already rolled back ELR_EL2, meaning if the
    guest has virtual SError masked, it will execute and handle the HVC
    twice.
    
    Restore the original behaviour.
    
    Fixes: defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to HYP")
    Cc: stable@vger.kernel.org
    Signed-off-by: James Morse <james.morse@arm.com>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20220127122052.1584324-4-james.morse@arm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 57e2986c3b25092691a6e3d6ee9168caf8978932
Author: James Morse <james.morse@arm.com>
Date:   Thu Jan 27 12:20:50 2022 +0000

    KVM: arm64: Avoid consuming a stale esr value when SError occur
    
    commit 1c71dbc8a179d99dd9bb7e7fc1888db613cf85de upstream.
    
    When any exception other than an IRQ occurs, the CPU updates the ESR_EL2
    register with the exception syndrome. An SError may also become pending,
    and will be synchronised by KVM. KVM notes the exception type, and whether
    an SError was synchronised in exit_code.
    
    When an exception other than an IRQ occurs, fixup_guest_exit() updates
    vcpu->arch.fault.esr_el2 from the hardware register. When an SError was
    synchronised, the vcpu esr value is used to determine if the exception
    was due to an HVC. If so, ELR_EL2 is moved back one instruction. This
    is so that KVM can process the SError first, and re-execute the HVC if
    the guest survives the SError.
    
    But if an IRQ synchronises an SError, the vcpu's esr value is stale.
    If the previous non-IRQ exception was an HVC, KVM will corrupt ELR_EL2,
    causing an unrelated guest instruction to be executed twice.
    
    Check ARM_EXCEPTION_CODE() before messing with ELR_EL2, IRQs don't
    update this register so don't need to check.
    
    Fixes: defe21f49bc9 ("KVM: arm64: Move PC rollback on SError to HYP")
    Cc: stable@vger.kernel.org
    Reported-by: Steven Price <steven.price@arm.com>
    Signed-off-by: James Morse <james.morse@arm.com>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20220127122052.1584324-3-james.morse@arm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5e7161c9d671bf18d6c67b9f064d0ebf6319b3f5
Author: Mayuresh Chitale <mchitale@ventanamicro.com>
Date:   Mon Jan 31 16:33:07 2022 +0530

    RISC-V: KVM: make CY, TM, and IR counters accessible in VU mode
    
    commit de1d7b6a51dab546160d252e47baa54adf104d4a upstream.
    
    Those applications that run in VU mode and access the time CSR cause
    a virtual instruction trap as Guest kernel currently does not
    initialize the scounteren CSR.
    
    To fix this, we should make CY, TM, and IR counters accessibile
    by default in VU mode (similar to OpenSBI).
    
    Fixes: a33c72faf2d73 ("RISC-V: KVM: Implement VCPU create, init and
    destroy functions")
    Cc: stable@vger.kernel.org
    Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
    Signed-off-by: Anup Patel <anup@brainfault.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 086daee38087b53349f2399b795ea6ad00ac4796
Author: Guenter Roeck <linux@roeck-us.net>
Date:   Fri Feb 4 17:47:55 2022 -0800

    Revert "ASoC: mediatek: Check for error clk pointer"
    
    This reverts commit e0bf3c9e05ca6837ac756ec7d9de70b44603da12 which is
    commit 9de2b9286a6dd16966959b3cb34fc2ddfd39213e upstream
    
    With this patch in the tree, Chromebooks running the affected hardware
    no longer boot. Bisect points to this patch, and reverting it fixes
    the problem.
    
    An analysis of the code with this patch applied shows:
    
            ret = init_clks(pdev, clk);
            if (ret)
                    return ERR_PTR(ret);
    ...
                    for (j = 0; j < MAX_CLKS && data->clk_id[j]; j++) {
                            struct clk *c = clk[data->clk_id[j]];
    
                            if (IS_ERR(c)) {
                                    dev_err(&pdev->dev, "%s: clk unavailable\n",
                                            data->name);
                                    return ERR_CAST(c);
                            }
    
                            scpd->clk[j] = c;
                    }
    
    Not all clocks in the clk_names array have to be present. Only the clocks
    in the data->clk_id array are actually needed. The code already checks if
    the required clocks are available and bails out if not. The assumption that
    all clocks have to be present is wrong, and commit 9de2b9286a6d needs to be
    reverted.
    
    Fixes: 9de2b9286a6d ("ASoC: mediatek: Check for error clk pointer")
    Cc: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Cc: Mark Brown <broonie@kernel.org>
    Cc: James Liao <jamesjj.liao@mediatek.com>
    Cc: Kevin Hilman <khilman@baylibre.com>
    Cc: Matthias Brugger <matthias.bgg@gmail.com
    Cc: Frank Wunderlich <frank-w@public-files.de>
    Cc: Daniel Golle <daniel@makrotopia.org>
    Link: https://lore.kernel.org/lkml/20220205014755.699603-1-linux@roeck-us.net/
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 089068470e6ab64e8994f4df0a2ccf8a75fa5797
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Thu Jan 20 16:35:27 2022 -0800

    mptcp: fix msk traversal in mptcp_nl_cmd_set_flags()
    
    commit 8e9eacad7ec7a9cbf262649ebf1fa6e6f6cc7d82 upstream.
    
    The MPTCP endpoint list is under RCU protection, guarded by the
    pernet spinlock. mptcp_nl_cmd_set_flags() traverses the list
    without acquiring the spin-lock nor under the RCU critical section.
    
    This change addresses the issue performing the lookup and the endpoint
    update under the pernet spinlock.
    
    [The upstream commit had to handle a lookup_by_id variable that is only
     present in 5.17. This version of the patch removes that variable, so
     the __lookup_addr() function only handles the lookup as it is
     implemented in 5.15 and 5.16. It also removes one 'const' keyword to
     prevent a warning due to differing const-ness in the 5.17 version of
     addresses_equal().]
    
    Fixes: 0f9f696a502e ("mptcp: add set_flags command in PM netlink")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 72c4cec1d21ab6fa1b7b6ed5a60a85b421028b89
Author: Helge Deller <deller@gmx.de>
Date:   Wed Feb 2 14:55:31 2022 +0100

    fbcon: Add option to enable legacy hardware acceleration
    
    commit a3f781a9d6114c1d1e01defb7aa234dec45d2a5f upstream.
    
    Add a config option CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION to
    enable bitblt and fillrect hardware acceleration in the framebuffer
    console. If disabled, such acceleration will not be used, even if it is
    supported by the graphics hardware driver.
    
    If you plan to use DRM as your main graphics output system, you should
    disable this option since it will prevent compiling in code which isn't
    used later on when DRM takes over.
    
    For all other configurations, e.g. if none of your graphic cards support
    DRM (yet), DRM isn't available for your architecture, or you can't be
    sure that the graphic card in the target system will support DRM, you
    most likely want to enable this option.
    
    In the non-accelerated case (e.g. when DRM is used), the inlined
    fb_scrollmode() function is hardcoded to return SCROLL_REDRAW and as such the
    compiler is able to optimize much unneccesary code away.
    
    In this v3 patch version I additionally changed the GETVYRES() and GETVXRES()
    macros to take a pointer to the fbcon_display struct. This fixes the build when
    console rotation is enabled and helps the compiler again to optimize out code.
    
    Signed-off-by: Helge Deller <deller@gmx.de>
    Cc: stable@vger.kernel.org # v5.10+
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-4-deller@gmx.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ba724328faffc640b7772c953bd061bf6c4d39cd
Author: Helge Deller <deller@gmx.de>
Date:   Wed Feb 2 14:55:30 2022 +0100

    Revert "fbcon: Disable accelerated scrolling"
    
    commit 87ab9f6b7417349aa197a6c7098d4fdd4beebb74 upstream.
    
    This reverts commit 39aead8373b3c20bb5965c024dfb51a94e526151.
    
    Revert the first (of 2) commits which disabled scrolling acceleration in
    fbcon/fbdev.  It introduced a regression for fbdev-supported graphic cards
    because of the performance penalty by doing screen scrolling by software
    instead of using the existing graphic card 2D hardware acceleration.
    
    Console scrolling acceleration was disabled by dropping code which
    checked at runtime the driver hardware capabilities for the
    BINFO_HWACCEL_COPYAREA or FBINFO_HWACCEL_FILLRECT flags and if set, it
    enabled scrollmode SCROLL_MOVE which uses hardware acceleration to move
    screen contents.  After dropping those checks scrollmode was hard-wired
    to SCROLL_REDRAW instead, which forces all graphic cards to redraw every
    character at the new screen position when scrolling.
    
    This change effectively disabled all hardware-based scrolling acceleration for
    ALL drivers, because now all kind of 2D hardware acceleration (bitblt,
    fillrect) in the drivers isn't used any longer.
    
    The original commit message mentions that only 3 DRM drivers (nouveau, omapdrm
    and gma500) used hardware acceleration in the past and thus code for checking
    and using scrolling acceleration is obsolete.
    
    This statement is NOT TRUE, because beside the DRM drivers there are around 35
    other fbdev drivers which depend on fbdev/fbcon and still provide hardware
    acceleration for fbdev/fbcon.
    
    The original commit message also states that syzbot found lots of bugs in fbcon
    and thus it's "often the solution to just delete code and remove features".
    This is true, and the bugs - which actually affected all users of fbcon,
    including DRM - were fixed, or code was dropped like e.g. the support for
    software scrollback in vgacon (commit 973c096f6a85).
    
    So to further analyze which bugs were found by syzbot, I've looked through all
    patches in drivers/video which were tagged with syzbot or syzkaller back to
    year 2005. The vast majority fixed the reported issues on a higher level, e.g.
    when screen is to be resized, or when font size is to be changed. The few ones
    which touched driver code fixed a real driver bug, e.g. by adding a check.
    
    But NONE of those patches touched code of either the SCROLL_MOVE or the
    SCROLL_REDRAW case.
    
    That means, there was no real reason why SCROLL_MOVE had to be ripped-out and
    just SCROLL_REDRAW had to be used instead. The only reason I can imagine so far
    was that SCROLL_MOVE wasn't used by DRM and as such it was assumed that it
    could go away. That argument completely missed the fact that SCROLL_MOVE is
    still heavily used by fbdev (non-DRM) drivers.
    
    Some people mention that using memcpy() instead of the hardware acceleration is
    pretty much the same speed. But that's not true, at least not for older graphic
    cards and machines where we see speed decreases by factor 10 and more and thus
    this change leads to console responsiveness way worse than before.
    
    That's why the original commit is to be reverted. By reverting we
    reintroduce hardware-based scrolling acceleration and fix the
    performance regression for fbdev drivers.
    
    There isn't any impact on DRM when reverting those patches.
    
    Signed-off-by: Helge Deller <deller@gmx.de>
    Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Acked-by: Sven Schnelle <svens@stackframe.org>
    Cc: stable@vger.kernel.org # v5.10+
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-3-deller@gmx.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0e90cb3f319c61b0d110e353615c87b53df419e6
Author: Helge Deller <deller@gmx.de>
Date:   Wed Feb 2 14:55:29 2022 +0100

    Revert "fbdev: Garbage collect fbdev scrolling acceleration, part 1 (from TODO list)"
    
    commit 1148836fd3226c20de841084aba24184d4fbbe77 upstream.
    
    This reverts commit b3ec8cdf457e5e63d396fe1346cc788cf7c1b578.
    
    Revert the second (of 2) commits which disabled scrolling acceleration
    in fbcon/fbdev.  It introduced a regression for fbdev-supported graphic
    cards because of the performance penalty by doing screen scrolling by
    software instead of using the existing graphic card 2D hardware
    acceleration.
    
    Console scrolling acceleration was disabled by dropping code which
    checked at runtime the driver hardware capabilities for the
    BINFO_HWACCEL_COPYAREA or FBINFO_HWACCEL_FILLRECT flags and if set, it
    enabled scrollmode SCROLL_MOVE which uses hardware acceleration to move
    screen contents.  After dropping those checks scrollmode was hard-wired
    to SCROLL_REDRAW instead, which forces all graphic cards to redraw every
    character at the new screen position when scrolling.
    
    This change effectively disabled all hardware-based scrolling acceleration for
    ALL drivers, because now all kind of 2D hardware acceleration (bitblt,
    fillrect) in the drivers isn't used any longer.
    
    The original commit message mentions that only 3 DRM drivers (nouveau, omapdrm
    and gma500) used hardware acceleration in the past and thus code for checking
    and using scrolling acceleration is obsolete.
    
    This statement is NOT TRUE, because beside the DRM drivers there are around 35
    other fbdev drivers which depend on fbdev/fbcon and still provide hardware
    acceleration for fbdev/fbcon.
    
    The original commit message also states that syzbot found lots of bugs in fbcon
    and thus it's "often the solution to just delete code and remove features".
    This is true, and the bugs - which actually affected all users of fbcon,
    including DRM - were fixed, or code was dropped like e.g. the support for
    software scrollback in vgacon (commit 973c096f6a85).
    
    So to further analyze which bugs were found by syzbot, I've looked through all
    patches in drivers/video which were tagged with syzbot or syzkaller back to
    year 2005. The vast majority fixed the reported issues on a higher level, e.g.
    when screen is to be resized, or when font size is to be changed. The few ones
    which touched driver code fixed a real driver bug, e.g. by adding a check.
    
    But NONE of those patches touched code of either the SCROLL_MOVE or the
    SCROLL_REDRAW case.
    
    That means, there was no real reason why SCROLL_MOVE had to be ripped-out and
    just SCROLL_REDRAW had to be used instead. The only reason I can imagine so far
    was that SCROLL_MOVE wasn't used by DRM and as such it was assumed that it
    could go away. That argument completely missed the fact that SCROLL_MOVE is
    still heavily used by fbdev (non-DRM) drivers.
    
    Some people mention that using memcpy() instead of the hardware acceleration is
    pretty much the same speed. But that's not true, at least not for older graphic
    cards and machines where we see speed decreases by factor 10 and more and thus
    this change leads to console responsiveness way worse than before.
    
    That's why the original commit is to be reverted. By reverting we
    reintroduce hardware-based scrolling acceleration and fix the
    performance regression for fbdev drivers.
    
    There isn't any impact on DRM when reverting those patches.
    
    Signed-off-by: Helge Deller <deller@gmx.de>
    Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Acked-by: Sven Schnelle <svens@stackframe.org>
    Cc: stable@vger.kernel.org # v5.16+
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-2-deller@gmx.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1899c3cad265c4583658aed5293d02e8af84276b
Author: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Date:   Sat Jan 15 18:02:35 2022 -0500

    IB/hfi1: Fix AIP early init panic
    
    commit 5f8f55b92edd621f056bdf09e572092849fabd83 upstream.
    
    An early failure in hfi1_ipoib_setup_rn() can lead to the following panic:
    
      BUG: unable to handle kernel NULL pointer dereference at 00000000000001b0
      PGD 0 P4D 0
      Oops: 0002 [#1] SMP NOPTI
      Workqueue: events work_for_cpu_fn
      RIP: 0010:try_to_grab_pending+0x2b/0x140
      Code: 1f 44 00 00 41 55 41 54 55 48 89 d5 53 48 89 fb 9c 58 0f 1f 44 00 00 48 89 c2 fa 66 0f 1f 44 00 00 48 89 55 00 40 84 f6 75 77 <f0> 48 0f ba 2b 00 72 09 31 c0 5b 5d 41 5c 41 5d c3 48 89 df e8 6c
      RSP: 0018:ffffb6b3cf7cfa48 EFLAGS: 00010046
      RAX: 0000000000000246 RBX: 00000000000001b0 RCX: 0000000000000000
      RDX: 0000000000000246 RSI: 0000000000000000 RDI: 00000000000001b0
      RBP: ffffb6b3cf7cfa70 R08: 0000000000000f09 R09: 0000000000000001
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000
      R13: ffffb6b3cf7cfa90 R14: ffffffff9b2fbfc0 R15: ffff8a4fdf244690
      FS:  0000000000000000(0000) GS:ffff8a527f400000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000000001b0 CR3: 00000017e2410003 CR4: 00000000007706f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      PKRU: 55555554
      Call Trace:
       __cancel_work_timer+0x42/0x190
       ? dev_printk_emit+0x4e/0x70
       iowait_cancel_work+0x15/0x30 [hfi1]
       hfi1_ipoib_txreq_deinit+0x5a/0x220 [hfi1]
       ? dev_err+0x6c/0x90
       hfi1_ipoib_netdev_dtor+0x15/0x30 [hfi1]
       hfi1_ipoib_setup_rn+0x10e/0x150 [hfi1]
       rdma_init_netdev+0x5a/0x80 [ib_core]
       ? hfi1_ipoib_free_rdma_netdev+0x20/0x20 [hfi1]
       ipoib_intf_init+0x6c/0x350 [ib_ipoib]
       ipoib_intf_alloc+0x5c/0xc0 [ib_ipoib]
       ipoib_add_one+0xbe/0x300 [ib_ipoib]
       add_client_context+0x12c/0x1a0 [ib_core]
       enable_device_and_get+0xdc/0x1d0 [ib_core]
       ib_register_device+0x572/0x6b0 [ib_core]
       rvt_register_device+0x11b/0x220 [rdmavt]
       hfi1_register_ib_device+0x6b4/0x770 [hfi1]
       do_init_one.isra.20+0x3e3/0x680 [hfi1]
       local_pci_probe+0x41/0x90
       work_for_cpu_fn+0x16/0x20
       process_one_work+0x1a7/0x360
       ? create_worker+0x1a0/0x1a0
       worker_thread+0x1cf/0x390
       ? create_worker+0x1a0/0x1a0
       kthread+0x116/0x130
       ? kthread_flush_work_fn+0x10/0x10
       ret_from_fork+0x1f/0x40
    
    The panic happens in hfi1_ipoib_txreq_deinit() because there is a NULL
    deref when hfi1_ipoib_netdev_dtor() is called in this error case.
    
    hfi1_ipoib_txreq_init() and hfi1_ipoib_rxq_init() are self unwinding so
    fix by adjusting the error paths accordingly.
    
    Other changes:
    - hfi1_ipoib_free_rdma_netdev() is deleted including the free_netdev()
      since the netdev core code deletes calls free_netdev()
    - The switch to the accelerated entrances is moved to the success path.
    
    Cc: stable@vger.kernel.org
    Fixes: d99dc602e2a5 ("IB/hfi1: Add functions to transmit datagram ipoib packets")
    Link: https://lore.kernel.org/r/1642287756-182313-4-git-send-email-mike.marciniszyn@cornelisnetworks.com
    Reviewed-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Signed-off-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2d0587a70e5356e42c8427eb8e954c129bd97ece
Author: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Date:   Sat Jan 15 18:02:34 2022 -0500

    IB/hfi1: Fix alloc failure with larger txqueuelen
    
    commit b1151b74ff68cc83c2a8e1a618efe7d056e4f237 upstream.
    
    The following allocation with large txqueuelen will result in the
    following warning:
    
      Call Trace:
       __alloc_pages_nodemask+0x283/0x2c0
       kmalloc_large_node+0x3c/0xa0
       __kmalloc_node+0x22a/0x2f0
       hfi1_ipoib_txreq_init+0x19f/0x330 [hfi1]
       hfi1_ipoib_setup_rn+0xd3/0x1a0 [hfi1]
       rdma_init_netdev+0x5a/0x80 [ib_core]
       ipoib_intf_init+0x6c/0x350 [ib_ipoib]
       ipoib_intf_alloc+0x5c/0xc0 [ib_ipoib]
       ipoib_add_one+0xbe/0x300 [ib_ipoib]
       add_client_context+0x12c/0x1a0 [ib_core]
       ib_register_client+0x147/0x190 [ib_core]
       ipoib_init_module+0xdd/0x132 [ib_ipoib]
       do_one_initcall+0x46/0x1c3
       do_init_module+0x5a/0x220
       load_module+0x14c5/0x17f0
       __do_sys_init_module+0x13b/0x180
       do_syscall_64+0x5b/0x1a0
       entry_SYSCALL_64_after_hwframe+0x65/0xca
    
    For ipoib, the txqueuelen is modified with the module parameter
    send_queue_size.
    
    Fix by changing to use kv versions of the same allocator to handle the
    large allocations.  The allocation embeds a hdr struct that is dma mapped.
    Change that struct to a pointer to a kzalloced struct.
    
    Cc: stable@vger.kernel.org
    Fixes: d99dc602e2a5 ("IB/hfi1: Add functions to transmit datagram ipoib packets")
    Link: https://lore.kernel.org/r/1642287756-182313-3-git-send-email-mike.marciniszyn@cornelisnetworks.com
    Reviewed-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Signed-off-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1530d84fba1e459ba55f46aa42649b88773210e7
Author: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Date:   Sat Jan 15 18:02:33 2022 -0500

    IB/hfi1: Fix panic with larger ipoib send_queue_size
    
    commit 8c83d39cc730378bbac64d67a551897b203a606e upstream.
    
    When the ipoib send_queue_size is increased from the default the following
    panic happens:
    
      RIP: 0010:hfi1_ipoib_drain_tx_ring+0x45/0xf0 [hfi1]
      Code: 31 e4 eb 0f 8b 85 c8 02 00 00 41 83 c4 01 44 39 e0 76 60 8b 8d cc 02 00 00 44 89 e3 be 01 00 00 00 d3 e3 48 03 9d c0 02 00 00 <c7> 83 18 01 00 00 00 00 00 00 48 8b bb 30 01 00 00 e8 25 af a7 e0
      RSP: 0018:ffffc9000798f4a0 EFLAGS: 00010286
      RAX: 0000000000008000 RBX: ffffc9000aa0f000 RCX: 000000000000000f
      RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
      RBP: ffff88810ff08000 R08: ffff88889476d900 R09: 0000000000000101
      R10: 0000000000000000 R11: ffffc90006590ff8 R12: 0000000000000200
      R13: ffffc9000798fba8 R14: 0000000000000000 R15: 0000000000000001
      FS:  00007fd0f79cc3c0(0000) GS:ffff88885fb00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: ffffc9000aa0f118 CR3: 0000000889c84001 CR4: 00000000001706e0
      Call Trace:
       <TASK>
       hfi1_ipoib_napi_tx_disable+0x45/0x60 [hfi1]
       hfi1_ipoib_dev_stop+0x18/0x80 [hfi1]
       ipoib_ib_dev_stop+0x1d/0x40 [ib_ipoib]
       ipoib_stop+0x48/0xc0 [ib_ipoib]
       __dev_close_many+0x9e/0x110
       __dev_change_flags+0xd9/0x210
       dev_change_flags+0x21/0x60
       do_setlink+0x31c/0x10f0
       ? __nla_validate_parse+0x12d/0x1a0
       ? __nla_parse+0x21/0x30
       ? inet6_validate_link_af+0x5e/0xf0
       ? cpumask_next+0x1f/0x20
       ? __snmp6_fill_stats64.isra.53+0xbb/0x140
       ? __nla_validate_parse+0x47/0x1a0
       __rtnl_newlink+0x530/0x910
       ? pskb_expand_head+0x73/0x300
       ? __kmalloc_node_track_caller+0x109/0x280
       ? __nla_put+0xc/0x20
       ? cpumask_next_and+0x20/0x30
       ? update_sd_lb_stats.constprop.144+0xd3/0x820
       ? _raw_spin_unlock_irqrestore+0x25/0x37
       ? __wake_up_common_lock+0x87/0xc0
       ? kmem_cache_alloc_trace+0x3d/0x3d0
       rtnl_newlink+0x43/0x60
    
    The issue happens when the shift that should have been a function of the
    txq item size mistakenly used the ring size.
    
    Fix by using the item size.
    
    Cc: stable@vger.kernel.org
    Fixes: d47dfc2b00e6 ("IB/hfi1: Remove cache and embed txreq in ring")
    Link: https://lore.kernel.org/r/1642287756-182313-2-git-send-email-mike.marciniszyn@cornelisnetworks.com
    Reviewed-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Signed-off-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cc8f7940d9c2d45f67b3d1a2f2b7a829ca561bed
Author: Jordy Zomer <jordy@pwning.systems>
Date:   Sat Jan 29 16:06:04 2022 +0100

    dma-buf: heaps: Fix potential spectre v1 gadget
    
    commit 92c4cfaee6872038563c5b6f2e8e613f9d84d47d upstream.
    
    It appears like nr could be a Spectre v1 gadget as it's supplied by a
    user and used as an array index. Prevent the contents
    of kernel memory from being leaked to userspace via speculative
    execution by using array_index_nospec.
    
    Signed-off-by: Jordy Zomer <jordy@pwning.systems>
    Fixes: c02a81fba74f ("dma-buf: Add dma-buf heaps framework")
    Cc: <stable@vger.kernel.org> # v5.6+
    Acked-by: John Stultz <john.stultz@linaro.org>
    Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
     [sumits: added fixes and cc: stable tags]
    Link: https://patchwork.freedesktop.org/patch/msgid/20220129150604.3461652-1-jordy@pwning.systems
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6b064a42060f6bb3d471c065b28d7b39a068358f
Author: Ryan Bair <ryandbair@gmail.com>
Date:   Wed Dec 22 11:04:05 2021 -0500

    cifs: fix workstation_name for multiuser mounts
    
    commit d3b331fb51f326d5b5326010bf2b5841bb86cdc6 upstream.
    
    Set workstation_name from the master_tcon for multiuser mounts.
    
    Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name.
    
    Fixes: 49bd49f983b5 ("cifs: send workstation name during ntlmssp session setup")
    Cc: stable@vger.kernel.org # 5.16
    Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
    Signed-off-by: Ryan Bair <ryandbair@gmail.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 464b609dc9371e4c4f11005a9e03680c0af81986
Author: Martin K. Petersen <martin.petersen@oracle.com>
Date:   Thu Feb 3 22:42:09 2022 -0500

    block: bio-integrity: Advance seed correctly for larger interval sizes
    
    commit b13e0c71856817fca67159b11abac350e41289f5 upstream.
    
    Commit 309a62fa3a9e ("bio-integrity: bio_integrity_advance must update
    integrity seed") added code to update the integrity seed value when
    advancing a bio. However, it failed to take into account that the
    integrity interval might be larger than the 512-byte block layer
    sector size. This broke bio splitting on PI devices with 4KB logical
    blocks.
    
    The seed value should be advanced by bio_integrity_intervals() and not
    the number of sectors.
    
    Cc: Dmitry Monakhov <dmonakhov@openvz.org>
    Cc: stable@vger.kernel.org
    Fixes: 309a62fa3a9e ("bio-integrity: bio_integrity_advance must update integrity seed")
    Tested-by: Dmitry Ivanov <dmitry.ivanov2@hpe.com>
    Reported-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Link: https://lore.kernel.org/r/20220204034209.4193-1-martin.petersen@oracle.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cebb0aceb21ad91429617a40e3a17444fabf1529
Author: Lang Yu <lang.yu@amd.com>
Date:   Thu Feb 3 20:49:37 2022 -0800

    mm/kmemleak: avoid scanning potential huge holes
    
    commit c10a0f877fe007021d70f9cada240f42adc2b5db upstream.
    
    When using devm_request_free_mem_region() and devm_memremap_pages() to
    add ZONE_DEVICE memory, if requested free mem region's end pfn were
    huge(e.g., 0x400000000), the node_end_pfn() will be also huge (see
    move_pfn_range_to_zone()).  Thus it creates a huge hole between
    node_start_pfn() and node_end_pfn().
    
    We found on some AMD APUs, amdkfd requested such a free mem region and
    created a huge hole.  In such a case, following code snippet was just
    doing busy test_bit() looping on the huge hole.
    
      for (pfn = start_pfn; pfn < end_pfn; pfn++) {
            struct page *page = pfn_to_online_page(pfn);
                    if (!page)
                            continue;
            ...
      }
    
    So we got a soft lockup:
    
      watchdog: BUG: soft lockup - CPU#6 stuck for 26s! [bash:1221]
      CPU: 6 PID: 1221 Comm: bash Not tainted 5.15.0-custom #1
      RIP: 0010:pfn_to_online_page+0x5/0xd0
      Call Trace:
        ? kmemleak_scan+0x16a/0x440
        kmemleak_write+0x306/0x3a0
        ? common_file_perm+0x72/0x170
        full_proxy_write+0x5c/0x90
        vfs_write+0xb9/0x260
        ksys_write+0x67/0xe0
        __x64_sys_write+0x1a/0x20
        do_syscall_64+0x3b/0xc0
        entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    I did some tests with the patch.
    
    (1) amdgpu module unloaded
    
    before the patch:
    
      real    0m0.976s
      user    0m0.000s
      sys     0m0.968s
    
    after the patch:
    
      real    0m0.981s
      user    0m0.000s
      sys     0m0.973s
    
    (2) amdgpu module loaded
    
    before the patch:
    
      real    0m35.365s
      user    0m0.000s
      sys     0m35.354s
    
    after the patch:
    
      real    0m1.049s
      user    0m0.000s
      sys     0m1.042s
    
    Link: https://lkml.kernel.org/r/20211108140029.721144-1-lang.yu@amd.com
    Signed-off-by: Lang Yu <lang.yu@amd.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Acked-by: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Oscar Salvador <osalvador@suse.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d52d73af59b1990d378beff7832dac9aae9abeea
Author: Mike Rapoport <rppt@kernel.org>
Date:   Thu Feb 3 20:49:29 2022 -0800

    mm/pgtable: define pte_index so that preprocessor could recognize it
    
    commit 314c459a6fe0957b5885fbc65c53d51444092880 upstream.
    
    Since commit 974b9b2c68f3 ("mm: consolidate pte_index() and
    pte_offset_*() definitions") pte_index is a static inline and there is
    no define for it that can be recognized by the preprocessor.  As a
    result, vm_insert_pages() uses slower loop over vm_insert_page() instead
    of insert_pages() that amortizes the cost of spinlock operations when
    inserting multiple pages.
    
    Link: https://lkml.kernel.org/r/20220111145457.20748-1-rppt@kernel.org
    Fixes: 974b9b2c68f3 ("mm: consolidate pte_index() and pte_offset_*() definitions")
    Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
    Reported-by: Christian Dietrich <stettberger@dokucode.de>
    Reviewed-by: Khalid Aziz <khalid.aziz@oracle.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29183f6dbcd185d3b7504171e6e840c380cb85c9
Author: Pasha Tatashin <pasha.tatashin@soleen.com>
Date:   Thu Feb 3 20:49:10 2022 -0800

    mm/debug_vm_pgtable: remove pte entry from the page table
    
    commit fb5222aae64fe25e5f3ebefde8214dcf3ba33ca5 upstream.
    
    Patch series "page table check fixes and cleanups", v5.
    
    This patch (of 4):
    
    The pte entry that is used in pte_advanced_tests() is never removed from
    the page table at the end of the test.
    
    The issue is detected by page_table_check, to repro compile kernel with
    the following configs:
    
    CONFIG_DEBUG_VM_PGTABLE=y
    CONFIG_PAGE_TABLE_CHECK=y
    CONFIG_PAGE_TABLE_CHECK_ENFORCED=y
    
    During the boot the following BUG is printed:
    
      debug_vm_pgtable: [debug_vm_pgtable         ]: Validating architecture page table helpers
      ------------[ cut here ]------------
      kernel BUG at mm/page_table_check.c:162!
      invalid opcode: 0000 [#1] PREEMPT SMP PTI
      CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.16.0-11413-g2c271fe77d52 #3
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014
      ...
    
    The entry should be properly removed from the page table before the page
    is released to the free list.
    
    Link: https://lkml.kernel.org/r/20220131203249.2832273-1-pasha.tatashin@soleen.com
    Link: https://lkml.kernel.org/r/20220131203249.2832273-2-pasha.tatashin@soleen.com
    Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers")
    Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
    Reviewed-by: Zi Yan <ziy@nvidia.com>
    Tested-by: Zi Yan <ziy@nvidia.com>
    Acked-by: David Rientjes <rientjes@google.com>
    Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
    Cc: Paul Turner <pjt@google.com>
    Cc: Wei Xu <weixugc@google.com>
    Cc: Greg Thelen <gthelen@google.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Will Deacon <will@kernel.org>
    Cc: Mike Rapoport <rppt@kernel.org>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Cc: Jiri Slaby <jirislaby@kernel.org>
    Cc: Muchun Song <songmuchun@bytedance.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: <stable@vger.kernel.org>    [5.9+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 73fad64378e58d8e21f986df176e7d73d14fb933
Author: Uday Shankar <ushankar@purestorage.com>
Date:   Thu Jan 20 12:17:37 2022 -0800

    nvme-fabrics: fix state check in nvmf_ctlr_matches_baseopts()
    
    commit 6a51abdeb259a56d95f13cc67e3a0838bcda0377 upstream.
    
    Controller deletion/reset, immediately followed by or concurrent with
    a reconnect, is hard failing the connect attempt resulting in a
    complete loss of connectivity to the controller.
    
    In the connect request, fabrics looks for an existing controller with
    the same address components and aborts the connect if a controller
    already exists and the duplicate connect option isn't set. The match
    routine filters out controllers that are dead or dying, so they don't
    interfere with the new connect request.
    
    When NVME_CTRL_DELETING_NOIO was added, it missed updating the state
    filters in the nvmf_ctlr_matches_baseopts() routine. Thus, when in this
    new state, it's seen as a live controller and fails the connect request.
    
    Correct by adding the DELETING_NIO state to the match checks.
    
    Fixes: ecca390e8056 ("nvme: fix deadlock in disconnect during scan_work and/or ana_work")
    Cc: <stable@vger.kernel.org> # v5.7+
    Signed-off-by: Uday Shankar <ushankar@purestorage.com>
    Reviewed-by: James Smart <jsmart2021@gmail.com>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8e34ac596242991a4c1c24119b1cd727ad0872c0
Author: Aun-Ali Zaidi <admin@kodeit.net>
Date:   Sat Jan 29 05:49:55 2022 +0000

    drm/amd/display: Force link_rate as LINK_RATE_RBR2 for 2018 15" Apple Retina panels
    
    commit 30fbce374745a9c6af93c775a5ac49a97f822fda upstream.
    
    The eDP link rate reported by the DP_MAX_LINK_RATE dpcd register (0xa) is
    contradictory to the highest rate supported reported by
    EDID (0xc = LINK_RATE_RBR2). The effects of this compounded with commit
    '4a8ca46bae8a ("drm/amd/display: Default max bpc to 16 for eDP")' results
    in no display modes being found and a dark panel.
    
    For now, simply force the maximum supported link rate for the eDP attached
    2018 15" Apple Retina panels.
    
    Additionally, we must also check the firmware revision since the device ID
    reported by the DPCD is identical to that of the more capable 16,1,
    incorrectly quirking it. We also use said firmware check to quirk the
    refreshed 15,1 models with Vega graphics as they use a slightly newer
    firmware version.
    
    Tested-by: Aun-Ali Zaidi <admin@kodeit.net>
    Reviewed-by: Harry Wentland <harry.wentland@amd.com>
    Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
    Signed-off-by: Aditya Garg <gargaditya08@live.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f4b4b70ba1e7069fa4c30ac75d698e7e6ea933c0
Author: Paul Hsieh <paul.hsieh@amd.com>
Date:   Fri Jan 28 22:03:57 2022 +0800

    drm/amd/display: watermark latencies is not enough on DCN31
    
    commit f5fa54f45ab41cbb1f99b1208f49554132ffb207 upstream.
    
    [Why]
    The original latencies were causing underflow in some modes.
    Resolution: 2880x1620@60p when HDR enable
    
    [How]
    1. Replace with the up-to-date watermark values based on new measurments
    2. Correct the ddr_wm_table name to DDR5 on DCN31
    
    Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
    Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
    Acked-by: Stylon Wang <stylon.wang@amd.com>
    Signed-off-by: Paul Hsieh <paul.hsieh@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bd6e1b930e12dd8f5d1d84f4d9729c2cce441ebb
Author: Agustin Gutierrez <agustin.gutierrez@amd.com>
Date:   Fri Jan 28 17:51:53 2022 -0500

    drm/amd/display: Update watermark values for DCN301
    
    commit 2d8ae25d233767171942a9fba5fd8f4a620996be upstream.
    
    [Why]
    There is underflow / visual corruption DCN301, for high
    bandwidth MST DSC configurations such as 2x1440p144 or 2x4k60.
    
    [How]
    Use up-to-date watermark values for DCN301.
    
    Reviewed-by: Zhan Liu <zhan.liu@amd.com>
    Signed-off-by: Agustin Gutierrez <agustin.gutierrez@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b39841ec54b5ad08836b4c7d52233d5541ade76b
Author: Evan Quan <evan.quan@amd.com>
Date:   Mon Jan 24 13:40:35 2022 +0800

    drm/amd/pm: correct the MGpuFanBoost support for Beige Goby
    
    commit 3ec5586b4699cfb75cdfa09425e11d121db40773 upstream.
    
    The existing way cannot handle Beige Goby well as a different
    PPTable data structure(PPTable_beige_goby_t instead of PPTable_t)
    is used there.
    
    Signed-off-by: Evan Quan <evan.quan@amd.com>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c51c6f12af5df2dc300852da442a5c59751e384c
Author: Lang Yu <Lang.Yu@amd.com>
Date:   Fri Jan 28 18:24:53 2022 +0800

    drm/amdgpu: fix a potential GPU hang on cyan skillfish
    
    commit bca52455a3c07922ee976714b00563a13a29ab15 upstream.
    
    We observed a GPU hang when querying GMC CG state(i.e.,
    cat amdgpu_pm_info) on cyan skillfish. Acctually, cyan
    skillfish doesn't support any CG features.
    
    Just prevent it from accessing GMC CG registers.
    
    Signed-off-by: Lang Yu <Lang.Yu@amd.com>
    Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 273832450f592a6f7b7aa60cb0180843d4f970df
Author: Imre Deak <imre.deak@intel.com>
Date:   Wed Jan 26 12:43:56 2022 +0200

    drm/i915/adlp: Fix TypeC PHY-ready status readout
    
    commit 3c6f13ad723e7206f03bb2752b01d18202b7fc9d upstream.
    
    The TCSS_DDI_STATUS register is indexed by tc_port not by the FIA port
    index, fix this up. This only caused an issue on TC#3/4 ports in legacy
    mode, as in all other cases the two indices either match (on TC#1/2) or
    the TCSS_DDI_STATUS_READY flag is set regardless of something being
    connected or not (on TC#1/2/3/4 in dp-alt and tbt-alt modes).
    
    Reported-and-tested-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>
    Fixes: 55ce306c2aa1 ("drm/i915/adl_p: Implement TC sequences")
    Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/4698
    Cc: José Roberto de Souza <jose.souza@intel.com>
    Cc: <stable@vger.kernel.org> # v5.14+
    Signed-off-by: Imre Deak <imre.deak@intel.com>
    Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220126104356.2022975-1-imre.deak@intel.com
    (cherry picked from commit 516b33460c5bee78b2055637b0547bdb0e6af754)
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e7c36fa8a1e63b08312162179c78a0c7795ea369
Author: Nick Lopez <github@glowingmonkey.org>
Date:   Sat Jan 22 01:19:06 2022 -0700

    drm/nouveau: fix off by one in BIOS boundary checking
    
    commit 1b777d4d9e383d2744fc9b3a09af6ec1893c8b1a upstream.
    
    Bounds checking when parsing init scripts embedded in the BIOS reject
    access to the last byte. This causes driver initialization to fail on
    Apple eMac's with GeForce 2 MX GPUs, leaving the system with no working
    console.
    
    This is probably only seen on OpenFirmware machines like PowerPC Macs
    because the BIOS image provided by OF is only the used parts of the ROM,
    not a power-of-two blocks read from PCI directly so PCs always have
    empty bytes at the end that are never accessed.
    
    Signed-off-by: Nick Lopez <github@glowingmonkey.org>
    Fixes: 4d4e9907ff572 ("drm/nouveau/bios: guard against out-of-bounds accesses to image")
    Cc: <stable@vger.kernel.org> # v4.10+
    Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
    Reviewed-by: Karol Herbst <kherbst@redhat.com>
    Signed-off-by: Karol Herbst <kherbst@redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220122081906.2633061-1-github@glowingmonkey.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d99d14b169a11a1b7635d81d8139d2e3a75a0ec2
Author: Dominique Martinet <asmadeus@codewreck.org>
Date:   Sat Jan 29 18:42:59 2022 +0900

    Revert "fs/9p: search open fids first"
    
    commit 22e424feb6658c5d6789e45121830357809c59cb upstream.
    
    This reverts commit 478ba09edc1f2f2ee27180a06150cb2d1a686f9c.
    
    That commit was meant as a fix for setattrs with by fd (e.g. ftruncate)
    to use an open fid instead of the first fid it found on lookup.
    The proper fix for that is to use the fid associated with the open file
    struct, available in iattr->ia_file for such operations, and was
    actually done just before in 66246641609b ("9p: retrieve fid from file
    when file instance exist.")
    As such, this commit is no longer required.
    
    Furthermore, changing lookup to return open fids first had unwanted side
    effects, as it turns out the protocol forbids the use of open fids for
    further walks (e.g. clone_fid) and we broke mounts for some servers
    enforcing this rule.
    
    Note this only reverts to the old working behaviour, but it's still
    possible for lookup to return open fids if dentry->d_fsdata is not set,
    so more work is needed to make sure we respect this rule in the future,
    for example by adding a flag to the lookup functions to only match
    certain fid open modes depending on caller requirements.
    
    Link: https://lkml.kernel.org/r/20220130130651.712293-1-asmadeus@codewreck.org
    Fixes: 478ba09edc1f ("fs/9p: search open fids first")
    Cc: stable@vger.kernel.org # v5.11+
    Reported-by: ron minnich <rminnich@gmail.com>
    Reported-by: ng@0x80.stream
    Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9372fa1d73da5f1673921e365d0cd2c27ec7adc2
Author: Filipe Manana <fdmanana@suse.com>
Date:   Fri Jan 21 15:44:39 2022 +0000

    btrfs: fix use-after-free after failure to create a snapshot
    
    commit 28b21c558a3753171097193b6f6602a94169093a upstream.
    
    At ioctl.c:create_snapshot(), we allocate a pending snapshot structure and
    then attach it to the transaction's list of pending snapshots. After that
    we call btrfs_commit_transaction(), and if that returns an error we jump
    to 'fail' label, where we kfree() the pending snapshot structure. This can
    result in a later use-after-free of the pending snapshot:
    
    1) We allocated the pending snapshot and added it to the transaction's
       list of pending snapshots;
    
    2) We call btrfs_commit_transaction(), and it fails either at the first
       call to btrfs_run_delayed_refs() or btrfs_start_dirty_block_groups().
       In both cases, we don't abort the transaction and we release our
       transaction handle. We jump to the 'fail' label and free the pending
       snapshot structure. We return with the pending snapshot still in the
       transaction's list;
    
    3) Another task commits the transaction. This time there's no error at
       all, and then during the transaction commit it accesses a pointer
       to the pending snapshot structure that the snapshot creation task
       has already freed, resulting in a user-after-free.
    
    This issue could actually be detected by smatch, which produced the
    following warning:
    
      fs/btrfs/ioctl.c:843 create_snapshot() warn: '&pending_snapshot->list' not removed from list
    
    So fix this by not having the snapshot creation ioctl directly add the
    pending snapshot to the transaction's list. Instead add the pending
    snapshot to the transaction handle, and then at btrfs_commit_transaction()
    we add the snapshot to the list only when we can guarantee that any error
    returned after that point will result in a transaction abort, in which
    case the ioctl code can safely free the pending snapshot and no one can
    access it anymore.
    
    CC: stable@vger.kernel.org # 5.10+
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 31198e58c09e21d4f65c49d2361f76b87aca4c3f
Author: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Date:   Thu Jan 20 20:09:16 2022 +0900

    btrfs: fix deadlock between quota disable and qgroup rescan worker
    
    commit e804861bd4e69cc5fe1053eedcb024982dde8e48 upstream.
    
    Quota disable ioctl starts a transaction before waiting for the qgroup
    rescan worker completes. However, this wait can be infinite and results
    in deadlock because of circular dependency among the quota disable
    ioctl, the qgroup rescan worker and the other task with transaction such
    as block group relocation task.
    
    The deadlock happens with the steps following:
    
    1) Task A calls ioctl to disable quota. It starts a transaction and
       waits for qgroup rescan worker completes.
    2) Task B such as block group relocation task starts a transaction and
       joins to the transaction that task A started. Then task B commits to
       the transaction. In this commit, task B waits for a commit by task A.
    3) Task C as the qgroup rescan worker starts its job and starts a
       transaction. In this transaction start, task C waits for completion
       of the transaction that task A started and task B committed.
    
    This deadlock was found with fstests test case btrfs/115 and a zoned
    null_blk device. The test case enables and disables quota, and the
    block group reclaim was triggered during the quota disable by chance.
    The deadlock was also observed by running quota enable and disable in
    parallel with 'btrfs balance' command on regular null_blk devices.
    
    An example report of the deadlock:
    
      [372.469894] INFO: task kworker/u16:6:103 blocked for more than 122 seconds.
      [372.479944]       Not tainted 5.16.0-rc8 #7
      [372.485067] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [372.493898] task:kworker/u16:6   state:D stack:    0 pid:  103 ppid:     2 flags:0x00004000
      [372.503285] Workqueue: btrfs-qgroup-rescan btrfs_work_helper [btrfs]
      [372.510782] Call Trace:
      [372.514092]  <TASK>
      [372.521684]  __schedule+0xb56/0x4850
      [372.530104]  ? io_schedule_timeout+0x190/0x190
      [372.538842]  ? lockdep_hardirqs_on+0x7e/0x100
      [372.547092]  ? _raw_spin_unlock_irqrestore+0x3e/0x60
      [372.555591]  schedule+0xe0/0x270
      [372.561894]  btrfs_commit_transaction+0x18bb/0x2610 [btrfs]
      [372.570506]  ? btrfs_apply_pending_changes+0x50/0x50 [btrfs]
      [372.578875]  ? free_unref_page+0x3f2/0x650
      [372.585484]  ? finish_wait+0x270/0x270
      [372.591594]  ? release_extent_buffer+0x224/0x420 [btrfs]
      [372.599264]  btrfs_qgroup_rescan_worker+0xc13/0x10c0 [btrfs]
      [372.607157]  ? lock_release+0x3a9/0x6d0
      [372.613054]  ? btrfs_qgroup_account_extent+0xda0/0xda0 [btrfs]
      [372.620960]  ? do_raw_spin_lock+0x11e/0x250
      [372.627137]  ? rwlock_bug.part.0+0x90/0x90
      [372.633215]  ? lock_is_held_type+0xe4/0x140
      [372.639404]  btrfs_work_helper+0x1ae/0xa90 [btrfs]
      [372.646268]  process_one_work+0x7e9/0x1320
      [372.652321]  ? lock_release+0x6d0/0x6d0
      [372.658081]  ? pwq_dec_nr_in_flight+0x230/0x230
      [372.664513]  ? rwlock_bug.part.0+0x90/0x90
      [372.670529]  worker_thread+0x59e/0xf90
      [372.676172]  ? process_one_work+0x1320/0x1320
      [372.682440]  kthread+0x3b9/0x490
      [372.687550]  ? _raw_spin_unlock_irq+0x24/0x50
      [372.693811]  ? set_kthread_struct+0x100/0x100
      [372.700052]  ret_from_fork+0x22/0x30
      [372.705517]  </TASK>
      [372.709747] INFO: task btrfs-transacti:2347 blocked for more than 123 seconds.
      [372.729827]       Not tainted 5.16.0-rc8 #7
      [372.745907] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [372.767106] task:btrfs-transacti state:D stack:    0 pid: 2347 ppid:     2 flags:0x00004000
      [372.787776] Call Trace:
      [372.801652]  <TASK>
      [372.812961]  __schedule+0xb56/0x4850
      [372.830011]  ? io_schedule_timeout+0x190/0x190
      [372.852547]  ? lockdep_hardirqs_on+0x7e/0x100
      [372.871761]  ? _raw_spin_unlock_irqrestore+0x3e/0x60
      [372.886792]  schedule+0xe0/0x270
      [372.901685]  wait_current_trans+0x22c/0x310 [btrfs]
      [372.919743]  ? btrfs_put_transaction+0x3d0/0x3d0 [btrfs]
      [372.938923]  ? finish_wait+0x270/0x270
      [372.959085]  ? join_transaction+0xc75/0xe30 [btrfs]
      [372.977706]  start_transaction+0x938/0x10a0 [btrfs]
      [372.997168]  transaction_kthread+0x19d/0x3c0 [btrfs]
      [373.013021]  ? btrfs_cleanup_transaction.isra.0+0xfc0/0xfc0 [btrfs]
      [373.031678]  kthread+0x3b9/0x490
      [373.047420]  ? _raw_spin_unlock_irq+0x24/0x50
      [373.064645]  ? set_kthread_struct+0x100/0x100
      [373.078571]  ret_from_fork+0x22/0x30
      [373.091197]  </TASK>
      [373.105611] INFO: task btrfs:3145 blocked for more than 123 seconds.
      [373.114147]       Not tainted 5.16.0-rc8 #7
      [373.120401] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [373.130393] task:btrfs           state:D stack:    0 pid: 3145 ppid:  3141 flags:0x00004000
      [373.140998] Call Trace:
      [373.145501]  <TASK>
      [373.149654]  __schedule+0xb56/0x4850
      [373.155306]  ? io_schedule_timeout+0x190/0x190
      [373.161965]  ? lockdep_hardirqs_on+0x7e/0x100
      [373.168469]  ? _raw_spin_unlock_irqrestore+0x3e/0x60
      [373.175468]  schedule+0xe0/0x270
      [373.180814]  wait_for_commit+0x104/0x150 [btrfs]
      [373.187643]  ? test_and_set_bit+0x20/0x20 [btrfs]
      [373.194772]  ? kmem_cache_free+0x124/0x550
      [373.201191]  ? btrfs_put_transaction+0x69/0x3d0 [btrfs]
      [373.208738]  ? finish_wait+0x270/0x270
      [373.214704]  ? __btrfs_end_transaction+0x347/0x7b0 [btrfs]
      [373.222342]  btrfs_commit_transaction+0x44d/0x2610 [btrfs]
      [373.230233]  ? join_transaction+0x255/0xe30 [btrfs]
      [373.237334]  ? btrfs_record_root_in_trans+0x4d/0x170 [btrfs]
      [373.245251]  ? btrfs_apply_pending_changes+0x50/0x50 [btrfs]
      [373.253296]  relocate_block_group+0x105/0xc20 [btrfs]
      [373.260533]  ? mutex_lock_io_nested+0x1270/0x1270
      [373.267516]  ? btrfs_wait_nocow_writers+0x85/0x180 [btrfs]
      [373.275155]  ? merge_reloc_roots+0x710/0x710 [btrfs]
      [373.283602]  ? btrfs_wait_ordered_extents+0xd30/0xd30 [btrfs]
      [373.291934]  ? kmem_cache_free+0x124/0x550
      [373.298180]  btrfs_relocate_block_group+0x35c/0x930 [btrfs]
      [373.306047]  btrfs_relocate_chunk+0x85/0x210 [btrfs]
      [373.313229]  btrfs_balance+0x12f4/0x2d20 [btrfs]
      [373.320227]  ? lock_release+0x3a9/0x6d0
      [373.326206]  ? btrfs_relocate_chunk+0x210/0x210 [btrfs]
      [373.333591]  ? lock_is_held_type+0xe4/0x140
      [373.340031]  ? rcu_read_lock_sched_held+0x3f/0x70
      [373.346910]  btrfs_ioctl_balance+0x548/0x700 [btrfs]
      [373.354207]  btrfs_ioctl+0x7f2/0x71b0 [btrfs]
      [373.360774]  ? lockdep_hardirqs_on_prepare+0x410/0x410
      [373.367957]  ? lockdep_hardirqs_on_prepare+0x410/0x410
      [373.375327]  ? btrfs_ioctl_get_supported_features+0x20/0x20 [btrfs]
      [373.383841]  ? find_held_lock+0x2c/0x110
      [373.389993]  ? lock_release+0x3a9/0x6d0
      [373.395828]  ? mntput_no_expire+0xf7/0xad0
      [373.402083]  ? lock_is_held_type+0xe4/0x140
      [373.408249]  ? vfs_fileattr_set+0x9f0/0x9f0
      [373.414486]  ? selinux_file_ioctl+0x349/0x4e0
      [373.420938]  ? trace_raw_output_lock+0xb4/0xe0
      [373.427442]  ? selinux_inode_getsecctx+0x80/0x80
      [373.434224]  ? lockdep_hardirqs_on+0x7e/0x100
      [373.440660]  ? force_qs_rnp+0x2a0/0x6b0
      [373.446534]  ? lock_is_held_type+0x9b/0x140
      [373.452763]  ? __blkcg_punt_bio_submit+0x1b0/0x1b0
      [373.459732]  ? security_file_ioctl+0x50/0x90
      [373.466089]  __x64_sys_ioctl+0x127/0x190
      [373.472022]  do_syscall_64+0x3b/0x90
      [373.477513]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [373.484823] RIP: 0033:0x7f8f4af7e2bb
      [373.490493] RSP: 002b:00007ffcbf936178 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      [373.500197] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f8f4af7e2bb
      [373.509451] RDX: 00007ffcbf936220 RSI: 00000000c4009420 RDI: 0000000000000003
      [373.518659] RBP: 00007ffcbf93774a R08: 0000000000000013 R09: 00007f8f4b02d4e0
      [373.527872] R10: 00007f8f4ae87740 R11: 0000000000000246 R12: 0000000000000001
      [373.537222] R13: 00007ffcbf936220 R14: 0000000000000000 R15: 0000000000000002
      [373.546506]  </TASK>
      [373.550878] INFO: task btrfs:3146 blocked for more than 123 seconds.
      [373.559383]       Not tainted 5.16.0-rc8 #7
      [373.565748] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [373.575748] task:btrfs           state:D stack:    0 pid: 3146 ppid:  2168 flags:0x00000000
      [373.586314] Call Trace:
      [373.590846]  <TASK>
      [373.595121]  __schedule+0xb56/0x4850
      [373.600901]  ? __lock_acquire+0x23db/0x5030
      [373.607176]  ? io_schedule_timeout+0x190/0x190
      [373.613954]  schedule+0xe0/0x270
      [373.619157]  schedule_timeout+0x168/0x220
      [373.625170]  ? usleep_range_state+0x150/0x150
      [373.631653]  ? mark_held_locks+0x9e/0xe0
      [373.637767]  ? do_raw_spin_lock+0x11e/0x250
      [373.643993]  ? lockdep_hardirqs_on_prepare+0x17b/0x410
      [373.651267]  ? _raw_spin_unlock_irq+0x24/0x50
      [373.657677]  ? lockdep_hardirqs_on+0x7e/0x100
      [373.664103]  wait_for_completion+0x163/0x250
      [373.670437]  ? bit_wait_timeout+0x160/0x160
      [373.676585]  btrfs_quota_disable+0x176/0x9a0 [btrfs]
      [373.683979]  ? btrfs_quota_enable+0x12f0/0x12f0 [btrfs]
      [373.691340]  ? down_write+0xd0/0x130
      [373.696880]  ? down_write_killable+0x150/0x150
      [373.703352]  btrfs_ioctl+0x3945/0x71b0 [btrfs]
      [373.710061]  ? find_held_lock+0x2c/0x110
      [373.716192]  ? lock_release+0x3a9/0x6d0
      [373.722047]  ? __handle_mm_fault+0x23cd/0x3050
      [373.728486]  ? btrfs_ioctl_get_supported_features+0x20/0x20 [btrfs]
      [373.737032]  ? set_pte+0x6a/0x90
      [373.742271]  ? do_raw_spin_unlock+0x55/0x1f0
      [373.748506]  ? lock_is_held_type+0xe4/0x140
      [373.754792]  ? vfs_fileattr_set+0x9f0/0x9f0
      [373.761083]  ? selinux_file_ioctl+0x349/0x4e0
      [373.767521]  ? selinux_inode_getsecctx+0x80/0x80
      [373.774247]  ? __up_read+0x182/0x6e0
      [373.780026]  ? count_memcg_events.constprop.0+0x46/0x60
      [373.787281]  ? up_write+0x460/0x460
      [373.792932]  ? security_file_ioctl+0x50/0x90
      [373.799232]  __x64_sys_ioctl+0x127/0x190
      [373.805237]  do_syscall_64+0x3b/0x90
      [373.810947]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [373.818102] RIP: 0033:0x7f1383ea02bb
      [373.823847] RSP: 002b:00007fffeb4d71f8 EFLAGS: 00000202 ORIG_RAX: 0000000000000010
      [373.833641] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1383ea02bb
      [373.842961] RDX: 00007fffeb4d7210 RSI: 00000000c0109428 RDI: 0000000000000003
      [373.852179] RBP: 0000000000000003 R08: 0000000000000003 R09: 0000000000000078
      [373.861408] R10: 00007f1383daec78 R11: 0000000000000202 R12: 00007fffeb4d874a
      [373.870647] R13: 0000000000493099 R14: 0000000000000001 R15: 0000000000000000
      [373.879838]  </TASK>
      [373.884018]
                   Showing all locks held in the system:
      [373.894250] 3 locks held by kworker/4:1/58:
      [373.900356] 1 lock held by khungtaskd/63:
      [373.906333]  #0: ffffffff8945ff60 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x53/0x260
      [373.917307] 3 locks held by kworker/u16:6/103:
      [373.923938]  #0: ffff888127b4f138 ((wq_completion)btrfs-qgroup-rescan){+.+.}-{0:0}, at: process_one_work+0x712/0x1320
      [373.936555]  #1: ffff88810b817dd8 ((work_completion)(&work->normal_work)){+.+.}-{0:0}, at: process_one_work+0x73f/0x1320
      [373.951109]  #2: ffff888102dd4650 (sb_internal#2){.+.+}-{0:0}, at: btrfs_qgroup_rescan_worker+0x1f6/0x10c0 [btrfs]
      [373.964027] 2 locks held by less/1803:
      [373.969982]  #0: ffff88813ed56098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x24/0x80
      [373.981295]  #1: ffffc90000b3b2e8 (&ldata->atomic_read_lock){+.+.}-{3:3}, at: n_tty_read+0x9e2/0x1060
      [373.992969] 1 lock held by btrfs-transacti/2347:
      [373.999893]  #0: ffff88813d4887a8 (&fs_info->transaction_kthread_mutex){+.+.}-{3:3}, at: transaction_kthread+0xe3/0x3c0 [btrfs]
      [374.015872] 3 locks held by btrfs/3145:
      [374.022298]  #0: ffff888102dd4460 (sb_writers#18){.+.+}-{0:0}, at: btrfs_ioctl_balance+0xc3/0x700 [btrfs]
      [374.034456]  #1: ffff88813d48a0a0 (&fs_info->reclaim_bgs_lock){+.+.}-{3:3}, at: btrfs_balance+0xfe5/0x2d20 [btrfs]
      [374.047646]  #2: ffff88813d488838 (&fs_info->cleaner_mutex){+.+.}-{3:3}, at: btrfs_relocate_block_group+0x354/0x930 [btrfs]
      [374.063295] 4 locks held by btrfs/3146:
      [374.069647]  #0: ffff888102dd4460 (sb_writers#18){.+.+}-{0:0}, at: btrfs_ioctl+0x38b1/0x71b0 [btrfs]
      [374.081601]  #1: ffff88813d488bb8 (&fs_info->subvol_sem){+.+.}-{3:3}, at: btrfs_ioctl+0x38fd/0x71b0 [btrfs]
      [374.094283]  #2: ffff888102dd4650 (sb_internal#2){.+.+}-{0:0}, at: btrfs_quota_disable+0xc8/0x9a0 [btrfs]
      [374.106885]  #3: ffff88813d489800 (&fs_info->qgroup_ioctl_lock){+.+.}-{3:3}, at: btrfs_quota_disable+0xd5/0x9a0 [btrfs]
    
      [374.126780] =============================================
    
    To avoid the deadlock, wait for the qgroup rescan worker to complete
    before starting the transaction for the quota disable ioctl. Clear
    BTRFS_FS_QUOTA_ENABLE flag before the wait and the transaction to
    request the worker to complete. On transaction start failure, set the
    BTRFS_FS_QUOTA_ENABLE flag again. These BTRFS_FS_QUOTA_ENABLE flag
    changes can be done safely since the function btrfs_quota_disable is not
    called concurrently because of fs_info->subvol_sem.
    
    Also check the BTRFS_FS_QUOTA_ENABLE flag in qgroup_rescan_init to avoid
    another qgroup rescan worker to start after the previous qgroup worker
    completed.
    
    CC: stable@vger.kernel.org # 5.4+
    Suggested-by: Nikolay Borisov <nborisov@suse.com>
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 65acdfdedc8b0e7b36d0dec8c8ac1fb437cac7df
Author: Qu Wenruo <wqu@suse.com>
Date:   Thu Dec 16 19:47:35 2021 +0800

    btrfs: don't start transaction for scrub if the fs is mounted read-only
    
    commit 2d192fc4c1abeb0d04d1c8cd54405ff4a0b0255b upstream.
    
    [BUG]
    The following super simple script would crash btrfs at unmount time, if
    CONFIG_BTRFS_ASSERT() is set.
    
     mkfs.btrfs -f $dev
     mount $dev $mnt
     xfs_io -f -c "pwrite 0 4k" $mnt/file
     umount $mnt
     mount -r ro $dev $mnt
     btrfs scrub start -Br $mnt
     umount $mnt
    
    This will trigger the following ASSERT() introduced by commit
    0a31daa4b602 ("btrfs: add assertion for empty list of transactions at
    late stage of umount").
    
    That patch is definitely not the cause, it just makes enough noise for
    developers.
    
    [CAUSE]
    We will start transaction for the following call chain during scrub:
    
      scrub_enumerate_chunks()
      |- btrfs_inc_block_group_ro()
         |- btrfs_join_transaction()
    
    However for RO mount, there is no running transaction at all, thus
    btrfs_join_transaction() will start a new transaction.
    
    Furthermore, since it's read-only mount, btrfs_sync_fs() will not call
    btrfs_commit_super() to commit the new but empty transaction.
    
    And leads to the ASSERT().
    
    The bug has been there for a long time. Only the new ASSERT() makes it
    noisy enough to be noticed.
    
    [FIX]
    For read-only scrub on read-only mount, there is no need to start a
    transaction nor to allocate new chunks in btrfs_inc_block_group_ro().
    
    Just do extra read-only mount check in btrfs_inc_block_group_ro(), and
    if it's read-only, skip all chunk allocation and go inc_block_group_ro()
    directly.
    
    CC: stable@vger.kernel.org # 5.4+
    Signed-off-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02b554bd2f30294924b00d385eac79bcfc2aaa1c
Author: Anton Lundin <glance@acc.umu.se>
Date:   Thu Feb 3 10:41:35 2022 +0100

    ata: libata-core: Introduce ATA_HORKAGE_NO_LOG_DIR horkage
    
    commit ac9f0c810684a1b161c18eb4b91ce84cbc13c91d upstream.
    
    06f6c4c6c3e8 ("ata: libata: add missing ata_identify_page_supported() calls")
    introduced additional calls to ata_identify_page_supported(), thus also
    adding indirectly accesses to the device log directory log page through
    ata_log_supported(). Reading this log page causes SATADOM-ML 3ME devices
    to lock up.
    
    Introduce the horkage flag ATA_HORKAGE_NO_LOG_DIR to prevent accesses to
    the log directory in ata_log_supported() and add a blacklist entry
    with this flag for "SATADOM-ML 3ME" devices.
    
    Fixes: 636f6e2af4fb ("libata: add horkage for missing Identify Device log")
    Cc: stable@vger.kernel.org # v5.10+
    Signed-off-by: Anton Lundin <glance@acc.umu.se>
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e100d548069f1a52b1ff356c3a7545566933500a
Author: Christian Lachner <gladiac@gmail.com>
Date:   Sat Jan 29 12:32:43 2022 +0100

    ALSA: hda/realtek: Fix silent output on Gigabyte X570 Aorus Xtreme after reboot from Windows
    
    commit ea3541961376f733373839cc90493aafa8a7f733 upstream.
    
    This commit switches the Gigabyte X570 Aorus Xtreme from using the
    ALC1220_FIXUP_CLEVO_P950 to the ALC1220_FIXUP_GB_X570 quirk. This fixes
    the no-audio after reboot from windows problem.
    
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205275
    Signed-off-by: Christian Lachner <gladiac@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220129113243.93068-4-gladiac@gmail.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 123be366483697859cfea5b15e0d5234300bc3f1
Author: Christian Lachner <gladiac@gmail.com>
Date:   Sat Jan 29 12:32:42 2022 +0100

    ALSA: hda/realtek: Fix silent output on Gigabyte X570S Aorus Master (newer chipset)
    
    commit 41a8601302ecbe704ac970552c33dc942300fc37 upstream.
    
    Newer versions of the X570 Master come with a newer revision of the
    mainboard chipset - the X570S. These boards have the same ALC1220 codec
    but seem to initialize the codec with a different parameter in Coef 0x7
    which causes the output audio to be very low. We therefore write a
    known-good value to Coef 0x7 to fix that. As the value is the exact same
    as on the other X570(non-S) boards the same quirk-function can be shared
    between both generations.
    
    This commit adds the Gigabyte X570S Aorus Master to the list of boards
    using the ALC1220_FIXUP_GB_X570 quirk. This fixes both, the silent output
    and the no-audio after reboot from windows problems.
    
    This work has been tested by the folks over at the level1techs forum here:
    https://forum.level1techs.com/t/has-anybody-gotten-audio-working-in-linux-on-aorus-x570-master/154072
    
    Signed-off-by: Christian Lachner <gladiac@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220129113243.93068-3-gladiac@gmail.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a41a88de0a36fe47489dfc312181a8d9532aa93a
Author: Christian Lachner <gladiac@gmail.com>
Date:   Sat Jan 29 12:32:41 2022 +0100

    ALSA: hda/realtek: Add missing fixup-model entry for Gigabyte X570 ALC1220 quirks
    
    commit 63394a16086fc2152869d7902621e2525e14bc40 upstream.
    
    The initial commit of the new Gigabyte X570 ALC1220 quirks lacked the
    fixup-model entry in alc882_fixup_models[]. It seemed not to cause any ill
    effects but for completeness sake this commit makes up for that.
    
    Signed-off-by: Christian Lachner <gladiac@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220129113243.93068-2-gladiac@gmail.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 558d4b1b88bd98b94b4b7637bfd7fe6d8051f25f
Author: Albert Geantă <albertgeanta@gmail.com>
Date:   Mon Jan 31 03:05:23 2022 +0200

    ALSA: hda/realtek: Add quirk for ASUS GU603
    
    commit 94db9cc8f8fa2d5426ce79ec4ca16028f7084224 upstream.
    
    The ASUS GU603 (Zephyrus M16 - SSID 1043:16b2) requires a quirk similar to
    other ASUS devices for correctly routing the 4 integrated speakers. This
    fixes it by adding a corresponding quirk entry, which connects the bass
    speakers to the proper DAC.
    
    Signed-off-by: Albert Geantă <albertgeanta@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220131010523.546386-1-albertgeanta@gmail.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1dcfc5eeaba3d87a77bc6f2e77a3e13782be15f3
Author: Takashi Iwai <tiwai@suse.de>
Date:   Mon Jan 31 08:57:38 2022 +0100

    ALSA: hda: realtek: Fix race at concurrent COEF updates
    
    commit b837a9f5ab3bdfab9233c9f98a6bef717673a3e5 upstream.
    
    The COEF access is done with two steps: setting the index then read or
    write the data.  When multiple COEF accesses are performed
    concurrently, the index and data might be paired unexpectedly.
    In most cases, this isn't a big problem as the COEF setup is done at
    the initialization, but some dynamic changes like the mute LED may hit
    such a race.
    
    For avoiding the racy COEF accesses, this patch introduces a new
    mutex coef_mutex to alc_spec, and wrap the COEF accessing functions
    with it.
    
    Reported-by: Alexander Sergeyev <sergeev917@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220111195229.a77wrpjclqwrx4bx@localhost.localdomain
    Link: https://lore.kernel.org/r/20220131075738.24323-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 813e9f3e06d22e29872d4fd51b54992d89cf66c8
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Jan 26 15:50:11 2022 +0100

    ALSA: hda: Fix UAF of leds class devs at unbinding
    
    commit 549f8ffc7b2f7561bea7f90930b6c5104318e87b upstream.
    
    The LED class devices that are created by HD-audio codec drivers are
    registered via devm_led_classdev_register() and associated with the
    HD-audio codec device.  Unfortunately, it turned out that the devres
    release doesn't work for this case; namely, since the codec resource
    release happens before the devm call chain, it triggers a NULL
    dereference or a UAF for a stale set_brightness_delay callback.
    
    For fixing the bug, this patch changes the LED class device register
    and unregister in a manual manner without devres, keeping the
    instances in hda_gen_spec.
    
    Reported-by: Alexander Sergeyev <sergeev917@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220111195229.a77wrpjclqwrx4bx@localhost.localdomain
    Link: https://lore.kernel.org/r/20220126145011.16728-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 343799268777cc2a32728f78365cdefba29e189f
Author: Jonas Hahnfeld <hahnjo@hahnjo.de>
Date:   Mon Jan 31 19:35:16 2022 +0100

    ALSA: usb-audio: Correct quirk for VF0770
    
    commit 4ee02e20893d2f9e951c7888f2284fa608ddaa35 upstream.
    
    This device provides both audio and video. The original quirk added in
    commit 48827e1d6af5 ("ALSA: usb-audio: Add quirk for VF0770") used
    USB_DEVICE to match the vendor and product ID. Depending on module order,
    if snd-usb-audio was asked first, it would match the entire device and
    uvcvideo wouldn't get to see it. Change the matching to USB_AUDIO_DEVICE
    to restore uvcvideo matching in all cases.
    
    Fixes: 48827e1d6af5 ("ALSA: usb-audio: Add quirk for VF0770")
    Reported-by: Jukka Heikintalo <heikintalo.jukka@gmail.com>
    Tested-by: Jukka Heikintalo <heikintalo.jukka@gmail.com>
    Reported-by: Paweł Susicki <pawel.susicki@gmail.com>
    Tested-by: Paweł Susicki <pawel.susicki@gmail.com>
    Cc: <stable@vger.kernel.org> # 5.4, 5.10, 5.14, 5.15
    Signed-off-by: Jonas Hahnfeld <hahnjo@hahnjo.de>
    Link: https://lore.kernel.org/r/20220131183516.61191-1-hahnjo@hahnjo.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e09cf398e8c6db69c620b6d8073abc4377a07af5
Author: Mark Brown <broonie@kernel.org>
Date:   Mon Jan 24 15:32:53 2022 +0000

    ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx()
    
    commit 4cf28e9ae6e2e11a044be1bcbcfa1b0d8675fe4d upstream.
    
    We don't currently validate that the values being set are within the range
    we advertised to userspace as being valid, do so and reject any values
    that are out of range.
    
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20220124153253.3548853-4-broonie@kernel.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ef6cd9eeb38062a145802b7b56be7ae1090e165e
Author: Mark Brown <broonie@kernel.org>
Date:   Mon Jan 24 15:32:52 2022 +0000

    ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()
    
    commit 4f1e50d6a9cf9c1b8c859d449b5031cacfa8404e upstream.
    
    We don't currently validate that the values being set are within the range
    we advertised to userspace as being valid, do so and reject any values
    that are out of range.
    
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20220124153253.3548853-3-broonie@kernel.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bb72d2dda85564c66d909108ea6903937a41679d
Author: Mark Brown <broonie@kernel.org>
Date:   Mon Jan 24 15:32:51 2022 +0000

    ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()
    
    commit 817f7c9335ec01e0f5e8caffc4f1dcd5e458a4c0 upstream.
    
    We don't currently validate that the values being set are within the range
    we advertised to userspace as being valid, do so and reject any values
    that are out of range.
    
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20220124153253.3548853-2-broonie@kernel.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1552e66be325a21d7eff49f46013fb402165a0ac
Author: Dmitry Osipenko <digetx@gmail.com>
Date:   Wed Jan 12 22:50:39 2022 +0300

    ASoC: hdmi-codec: Fix OOB memory accesses
    
    commit 06feec6005c9d9500cd286ec440aabf8b2ddd94d upstream.
    
    Correct size of iec_status array by changing it to the size of status
    array of the struct snd_aes_iec958. This fixes out-of-bounds slab
    read accesses made by memcpy() of the hdmi-codec driver. This problem
    is reported by KASAN.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
    Link: https://lore.kernel.org/r/20220112195039.1329-1-digetx@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 049b27e185e960488ecd4fadc15f9e1c98b7838b
Author: Patrice Chotard <patrice.chotard@foss.st.com>
Date:   Mon Jan 17 13:17:44 2022 +0100

    spi: stm32-qspi: Update spi registering
    
    commit e4d63473d3110afd170e6e0e48494d3789d26136 upstream.
    
    Some device driver need to communicate to qspi device during the remove
    process, qspi controller must be functional when spi_unregister_master()
    is called.
    
    To ensure this, replace devm_spi_register_master() by spi_register_master()
    and spi_unregister_master() is called directly in .remove callback before
    stopping the qspi controller.
    
    This issue was put in evidence using kernel v5.11 and later
    with a spi-nor which supports the software reset feature introduced
    by commit d73ee7534cc5 ("mtd: spi-nor: core: perform a Soft Reset on
    shutdown")
    
    Fixes: c530cd1d9d5e ("spi: spi-mem: add stm32 qspi controller")
    
    Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
    Cc: <stable@vger.kernel.org> # 5.8.x
    Reviewed-by: Lukas Wunner <lukas@wunner.de>
    Link: https://lore.kernel.org/r/20220117121744.29729-1-patrice.chotard@foss.st.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3b6b7cbe466da765b22b9a47628f69df62d24372
Author: Minghao Chi <chi.minghao@zte.com.cn>
Date:   Thu Feb 3 20:49:33 2022 -0800

    ipc/sem: do not sleep with a spin lock held
    
    commit 520ba724061cef59763e2b6f5b26e8387c2e5822 upstream.
    
    We can't call kvfree() with a spin lock held, so defer it.
    
    Link: https://lkml.kernel.org/r/20211223031207.556189-1-chi.minghao@zte.com.cn
    Fixes: fc37a3b8b438 ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation")
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
    Reviewed-by: Shakeel Butt <shakeelb@google.com>
    Reviewed-by: Manfred Spraul <manfred@colorfullife.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Yang Guang <cgel.zte@gmail.com>
    Cc: Davidlohr Bueso <dbueso@suse.de>
    Cc: Randy Dunlap <rdunlap@infradead.org>
    Cc: Bhaskar Chowdhury <unixbhaskar@gmail.com>
    Cc: Vasily Averin <vvs@virtuozzo.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2e45c87df3899708f167efef75095f0e3458fd7a
Author: Paul Moore <paul@paul-moore.com>
Date:   Thu Jan 13 18:54:38 2022 -0500

    audit: improve audit queue handling when "audit=1" on cmdline
    
    commit f26d04331360d42dbd6b58448bd98e4edbfbe1c5 upstream.
    
    When an admin enables audit at early boot via the "audit=1" kernel
    command line the audit queue behavior is slightly different; the
    audit subsystem goes to greater lengths to avoid dropping records,
    which unfortunately can result in problems when the audit daemon is
    forcibly stopped for an extended period of time.
    
    This patch makes a number of changes designed to improve the audit
    queuing behavior so that leaving the audit daemon in a stopped state
    for an extended period does not cause a significant impact to the
    system.
    
    - kauditd_send_queue() is now limited to looping through the
      passed queue only once per call.  This not only prevents the
      function from looping indefinitely when records are returned
      to the current queue, it also allows any recovery handling in
      kauditd_thread() to take place when kauditd_send_queue()
      returns.
    
    - Transient netlink send errors seen as -EAGAIN now cause the
      record to be returned to the retry queue instead of going to
      the hold queue.  The intention of the hold queue is to store,
      perhaps for an extended period of time, the events which led
      up to the audit daemon going offline.  The retry queue remains
      a temporary queue intended to protect against transient issues
      between the kernel and the audit daemon.
    
    - The retry queue is now limited by the audit_backlog_limit
      setting, the same as the other queues.  This allows admins
      to bound the size of all of the audit queues on the system.
    
    - kauditd_rehold_skb() now returns records to the end of the
      hold queue to ensure ordering is preserved in the face of
      recent changes to kauditd_send_queue().
    
    Cc: stable@vger.kernel.org
    Fixes: 5b52330bbfe63 ("audit: fix auditd/kernel connection state tracking")
    Fixes: f4b3ee3c85551 ("audit: improve robustness of the audit queue handling")
    Reported-by: Gaosheng Cui <cuigaosheng1@huawei.com>
    Tested-by: Gaosheng Cui <cuigaosheng1@huawei.com>
    Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7ed9cbf7ac0d4ed86b356e1b944304ae9ee450d4
Author: Vratislav Bendel <vbendel@redhat.com>
Date:   Wed Feb 2 12:25:11 2022 +0100

    selinux: fix double free of cond_list on error paths
    
    commit 186edf7e368c40d06cf727a1ad14698ea67b74ad upstream.
    
    On error path from cond_read_list() and duplicate_policydb_cond_list()
    the cond_list_destroy() gets called a second time in caller functions,
    resulting in NULL pointer deref.  Fix this by resetting the
    cond_list_len to 0 in cond_list_destroy(), making subsequent calls a
    noop.
    
    Also consistently reset the cond_list pointer to NULL after freeing.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Vratislav Bendel <vbendel@redhat.com>
    [PM: fix line lengths in the description]
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8c7fa170e47fbb278429fed35356d837c9f866b0
Author: Ville Syrjälä <ville.syrjala@linux.intel.com>
Date:   Thu Oct 14 21:18:56 2021 +0300

    drm/i915: Disable DSB usage for now
    
    commit 99510e1afb4863a225207146bd988064c5fd0629 upstream.
    
    Turns out the DSB has trouble correctly loading the gamma LUT.
    From a cursory look maybe like some entries do not load
    properly, or they get loaded with some gibberish. Unfortunately
    our current kms_color/etc. tests do not seem to catch this.
    
    I had a brief look at the generated DSB batch and it looked
    correct. Tried a few quick tricks like writing the index
    register twice/etc. but didn't see any improvement.
    Also tried switching to the 10bit gamma mode in case
    there is yet another issue with the multi-segment mode, but
    even the 10bit mode was showing issues.
    
    Switching to mmio fixes all of it. I suppose one theory is that
    maybe the DSB bangs on the LUT too quickly and it can't keep up
    and instead some data either gets dropped or corrupted. To confirm
    that someone should try to slow down the DSB's progress a bit.
    Another thought was that maybe the LUT has crappy dual porting
    and you get contention if you try to load it during active
    scanout. But why then would the mmio path work, unless it's
    just sufficiently slow?
    
    Whatever the case, this is currently busted so let's disable
    it until we get to the root of the problem.
    
    Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3916
    Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211014181856.17581-2-ville.syrjala@linux.intel.com
    Reviewed-by: Uma Shankar <uma.shankar@intel.com>
    Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>