commit e548869f356fead9fdcb3562f52d2226574f4f41
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Aug 25 11:11:37 2022 +0200

    Linux 4.14.291
    
    Link: https://lore.kernel.org/r/20220823080053.202747790@linuxfoundation.org
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f280dfe6c39bf257fd62b56997ff5522f848980d
Author: Nathan Chancellor <nathan@kernel.org>
Date:   Tue Aug 2 10:59:36 2022 -0700

    MIPS: tlbex: Explicitly compare _PAGE_NO_EXEC against 0
    
    [ Upstream commit 74de14fe05dd6b151d73cb0c73c8ec874cbdcde6 ]
    
    When CONFIG_XPA is enabled, Clang warns:
    
      arch/mips/mm/tlbex.c:629:24: error: converting the result of '<<' to a boolean; did you mean '(1 << _PAGE_NO_EXEC_SHIFT) != 0'? [-Werror,-Wint-in-bool-context]
              if (cpu_has_rixi && !!_PAGE_NO_EXEC) {
                                  ^
      arch/mips/include/asm/pgtable-bits.h:174:28: note: expanded from macro '_PAGE_NO_EXEC'
      # define _PAGE_NO_EXEC          (1 << _PAGE_NO_EXEC_SHIFT)
                                         ^
      arch/mips/mm/tlbex.c:2568:24: error: converting the result of '<<' to a boolean; did you mean '(1 << _PAGE_NO_EXEC_SHIFT) != 0'? [-Werror,-Wint-in-bool-context]
              if (!cpu_has_rixi || !_PAGE_NO_EXEC) {
                                    ^
      arch/mips/include/asm/pgtable-bits.h:174:28: note: expanded from macro '_PAGE_NO_EXEC'
      # define _PAGE_NO_EXEC          (1 << _PAGE_NO_EXEC_SHIFT)
                                         ^
      2 errors generated.
    
    _PAGE_NO_EXEC can be '0' or '1 << _PAGE_NO_EXEC_SHIFT' depending on the
    build and runtime configuration, which is what the negation operators
    are trying to convey. To silence the warning, explicitly compare against
    0 so the result of the '<<' operator is not implicitly converted to a
    boolean.
    
    According to its documentation, GCC enables -Wint-in-bool-context with
    -Wall but this warning is not visible when building the same
    configuration with GCC. It appears GCC only warns when compiling C++,
    not C, although the documentation makes no note of this:
    https://godbolt.org/z/x39q3brxf
    
    Reported-by: Sudip Mukherjee (Codethink) <sudipm.mukherjee@gmail.com>
    Signed-off-by: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 656689cb03ada4650016c153346939a1c334b1ae
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Wed Aug 3 17:24:19 2022 +0800

    video: fbdev: i740fb: Check the argument of i740_calc_vclk()
    
    [ Upstream commit 40bf722f8064f50200b8c4f8946cd625b441dda9 ]
    
    Since the user can control the arguments of the ioctl() from the user
    space, under special arguments that may result in a divide-by-zero bug.
    
    If the user provides an improper 'pixclock' value that makes the argumet
    of i740_calc_vclk() less than 'I740_RFREQ_FIX', it will cause a
    divide-by-zero bug in:
        drivers/video/fbdev/i740fb.c:353 p_best = min(15, ilog2(I740_MAX_VCO_FREQ / (freq / I740_RFREQ_FIX)));
    
    The following log can reveal it:
    
    divide error: 0000 [#1] PREEMPT SMP KASAN PTI
    RIP: 0010:i740_calc_vclk drivers/video/fbdev/i740fb.c:353 [inline]
    RIP: 0010:i740fb_decode_var drivers/video/fbdev/i740fb.c:646 [inline]
    RIP: 0010:i740fb_set_par+0x163f/0x3b70 drivers/video/fbdev/i740fb.c:742
    Call Trace:
     fb_set_var+0x604/0xeb0 drivers/video/fbdev/core/fbmem.c:1034
     do_fb_ioctl+0x234/0x670 drivers/video/fbdev/core/fbmem.c:1110
     fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1189
    
    Fix this by checking the argument of i740_calc_vclk() first.
    
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8992141cb88f1d99fd11580f4423634700a99240
Author: Zhouyi Zhou <zhouzhouyi@gmail.com>
Date:   Tue Jul 26 09:57:47 2022 +0800

    powerpc/64: Init jump labels before parse_early_param()
    
    [ Upstream commit ca829e05d3d4f728810cc5e4b468d9ebc7745eb3 ]
    
    On 64-bit, calling jump_label_init() in setup_feature_keys() is too
    late because static keys may be used in subroutines of
    parse_early_param() which is again subroutine of early_init_devtree().
    
    For example booting with "threadirqs":
    
      static_key_enable_cpuslocked(): static key '0xc000000002953260' used before call to jump_label_init()
      WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:166 static_key_enable_cpuslocked+0xfc/0x120
      ...
      NIP static_key_enable_cpuslocked+0xfc/0x120
      LR  static_key_enable_cpuslocked+0xf8/0x120
      Call Trace:
        static_key_enable_cpuslocked+0xf8/0x120 (unreliable)
        static_key_enable+0x30/0x50
        setup_forced_irqthreads+0x28/0x40
        do_early_param+0xa0/0x108
        parse_args+0x290/0x4e0
        parse_early_options+0x48/0x5c
        parse_early_param+0x58/0x84
        early_init_devtree+0xd4/0x518
        early_setup+0xb4/0x214
    
    So call jump_label_init() just before parse_early_param() in
    early_init_devtree().
    
    Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
    [mpe: Add call trace to change log and minor wording edits.]
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220726015747.11754-1-zhouzhouyi@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b8ba8e22c5134f648f6f9f33f82c70ab6d710199
Author: Steve French <stfrench@microsoft.com>
Date:   Tue Jul 12 11:43:44 2022 -0500

    smb3: check xattr value length earlier
    
    [ Upstream commit 5fa2cffba0b82336a2244d941322eb1627ff787b ]
    
    Coverity complains about assigning a pointer based on
    value length before checking that value length goes
    beyond the end of the SMB.  Although this is even more
    unlikely as value length is a single byte, and the
    pointer is not dereferenced until laterm, it is clearer
    to check the lengths first.
    
    Addresses-Coverity: 1467704 ("Speculative execution data leak")
    Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7725d8158ca9377057e01fd44b2d429dbd2a812e
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Jul 28 14:59:43 2022 +0200

    ALSA: timer: Use deferred fasync helper
    
    [ Upstream commit 95cc637c1afd83fb7dd3d7c8a53710488f4caf9c ]
    
    For avoiding the potential deadlock via kill_fasync() call, use the
    new fasync helpers to defer the invocation from PCI API.  Note that
    it's merely a workaround.
    
    Reported-by: syzbot+1ee0910eca9c94f71f25@syzkaller.appspotmail.com
    Reported-by: syzbot+49b10793b867871ee26f@syzkaller.appspotmail.com
    Reported-by: syzbot+8285e973a41b5aa68902@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/20220728125945.29533-3-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit abad59867ac2a7af523335bea7ec7bd1a5b2f3e2
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Jul 28 14:59:42 2022 +0200

    ALSA: core: Add async signal helpers
    
    [ Upstream commit ef34a0ae7a2654bc9e58675e36898217fb2799d8 ]
    
    Currently the call of kill_fasync() from an interrupt handler might
    lead to potential spin deadlocks, as spotted by syzkaller.
    Unfortunately, it's not so trivial to fix this lock chain as it's
    involved with the tasklist_lock that is touched in allover places.
    
    As a temporary workaround, this patch provides the way to defer the
    async signal notification in a work.  The new helper functions,
    snd_fasync_helper() and snd_kill_faync() are replacements for
    fasync_helper() and kill_fasync(), respectively.  In addition,
    snd_fasync_free() needs to be called at the destructor of the relevant
    file object.
    
    Link: https://lore.kernel.org/r/20220728125945.29533-2-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit af87a469695dc2b2419b2fdff0bf41db5265b325
Author: Liang He <windhl@126.com>
Date:   Fri Jul 1 20:41:12 2022 +0800

    mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start
    
    [ Upstream commit 7a9f743ceead60ed454c46fbc3085ee9a79cbebb ]
    
    We should call of_node_put() for the reference 'uctl_node' returned by
    of_get_parent() which will increase the refcount. Otherwise, there will
    be a refcount leak bug.
    
    Signed-off-by: Liang He <windhl@126.com>
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 68898ddaaaf08f057de3bae45fd98a3eb2b1f6a8
Author: Schspa Shi <schspa@gmail.com>
Date:   Wed Jun 29 10:29:48 2022 +0800

    vfio: Clear the caps->buf to NULL after free
    
    [ Upstream commit 6641085e8d7b3f061911517f79a2a15a0a21b97b ]
    
    On buffer resize failure, vfio_info_cap_add() will free the buffer,
    report zero for the size, and return -ENOMEM.  As additional
    hardening, also clear the buffer pointer to prevent any chance of a
    double free.
    
    Signed-off-by: Schspa Shi <schspa@gmail.com>
    Reviewed-by: Cornelia Huck <cohuck@redhat.com>
    Link: https://lore.kernel.org/r/20220629022948.55608-1-schspa@gmail.com
    Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ec56f886f3bf0f15f7a3844d4c025e165b8e8de7
Author: Liang He <windhl@126.com>
Date:   Sat Jun 18 14:08:50 2022 +0800

    tty: serial: Fix refcount leak bug in ucc_uart.c
    
    [ Upstream commit d24d7bb2cd947676f9b71fb944d045e09b8b282f ]
    
    In soc_info(), of_find_node_by_type() will return a node pointer
    with refcount incremented. We should use of_node_put() when it is
    not used anymore.
    
    Acked-by: Timur Tabi <timur@kernel.org>
    Signed-off-by: Liang He <windhl@126.com>
    Link: https://lore.kernel.org/r/20220618060850.4058525-1-windhl@126.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 952b3dc02baaae6a69c71c0aca23e06741182d9a
Author: Kiselev, Oleg <okiselev@amazon.com>
Date:   Wed Jul 20 04:27:48 2022 +0000

    ext4: avoid resizing to a partial cluster size
    
    [ Upstream commit 69cb8e9d8cd97cdf5e293b26d70a9dee3e35e6bd ]
    
    This patch avoids an attempt to resize the filesystem to an
    unaligned cluster boundary.  An online resize to a size that is not
    integral to cluster size results in the last iteration attempting to
    grow the fs by a negative amount, which trips a BUG_ON and leaves the fs
    with a corrupted in-memory superblock.
    
    Signed-off-by: Oleg Kiselev <okiselev@amazon.com>
    Link: https://lore.kernel.org/r/0E92A0AB-4F16-4F1A-94B7-702CC6504FDE@amazon.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b02787042cb31c6f8c65805636fbbb8b653bbea0
Author: Ye Bin <yebin10@huawei.com>
Date:   Wed Jun 22 17:02:23 2022 +0800

    ext4: avoid remove directory when directory is corrupted
    
    [ Upstream commit b24e77ef1c6d4dbf42749ad4903c97539cc9755a ]
    
    Now if check directoy entry is corrupted, ext4_empty_dir may return true
    then directory will be removed when file system mounted with "errors=continue".
    In order not to make things worse just return false when directory is corrupted.
    
    Signed-off-by: Ye Bin <yebin10@huawei.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220622090223.682234-1-yebin10@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 09cf99bace7789d91caa8d10fbcfc8b2fb35857f
Author: Wentao_Liang <Wentao_Liang_g@163.com>
Date:   Thu Jul 28 19:39:19 2022 +0800

    drivers:md:fix a potential use-after-free bug
    
    [ Upstream commit 104212471b1c1817b311771d817fb692af983173 ]
    
    In line 2884, "raid5_release_stripe(sh);" drops the reference to sh and
    may cause sh to be released. However, sh is subsequently used in lines
    2886 "if (sh->batch_head && sh != sh->batch_head)". This may result in an
    use-after-free bug.
    
    It can be fixed by moving "raid5_release_stripe(sh);" to the bottom of
    the function.
    
    Signed-off-by: Wentao_Liang <Wentao_Liang_g@163.com>
    Signed-off-by: Song Liu <song@kernel.org>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6544ff559315498ad6c0a311359ca44987f9ca07
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Mon Jul 11 21:14:48 2022 +0200

    cxl: Fix a memory leak in an error handling path
    
    [ Upstream commit 3a15b45b5454da862376b5d69a4967f5c6fa1368 ]
    
    A bitmap_zalloc() must be balanced by a corresponding bitmap_free() in the
    error handling path of afu_allocate_irqs().
    
    Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/ce5869418f5838187946eb6b11a52715a93ece3d.1657566849.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 118d967ce00a3d128bf731b35e4e2cb0facf5f00
Author: Jozef Martiniak <jomajm@gmail.com>
Date:   Fri Jul 8 09:06:44 2022 +0200

    gadgetfs: ep_io - wait until IRQ finishes
    
    [ Upstream commit 04cb742d4d8f30dc2e83b46ac317eec09191c68e ]
    
    after usb_ep_queue() if wait_for_completion_interruptible() is
    interrupted we need to wait until IRQ gets finished.
    
    Otherwise complete() from epio_complete() can corrupt stack.
    
    Signed-off-by: Jozef Martiniak <jomajm@gmail.com>
    Link: https://lore.kernel.org/r/20220708070645.6130-1-jomajm@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 38cee0d2b65eed42a44052de1bfdc0177b6c3f05
Author: Robert Marko <robimarko@gmail.com>
Date:   Sun May 15 23:00:47 2022 +0200

    clk: qcom: ipq8074: dont disable gcc_sleep_clk_src
    
    [ Upstream commit 1bf7305e79aab095196131bdc87a97796e0e3fac ]
    
    Once the usb sleep clocks are disabled, clock framework is trying to
    disable the sleep clock source also.
    
    However, it seems that it cannot be disabled and trying to do so produces:
    [  245.436390] ------------[ cut here ]------------
    [  245.441233] gcc_sleep_clk_src status stuck at 'on'
    [  245.441254] WARNING: CPU: 2 PID: 223 at clk_branch_wait+0x130/0x140
    [  245.450435] Modules linked in: xhci_plat_hcd xhci_hcd dwc3 dwc3_qcom leds_gpio
    [  245.456601] CPU: 2 PID: 223 Comm: sh Not tainted 5.18.0-rc4 #215
    [  245.463889] Hardware name: Xiaomi AX9000 (DT)
    [  245.470050] pstate: 204000c5 (nzCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [  245.474307] pc : clk_branch_wait+0x130/0x140
    [  245.481073] lr : clk_branch_wait+0x130/0x140
    [  245.485588] sp : ffffffc009f2bad0
    [  245.489838] x29: ffffffc009f2bad0 x28: ffffff8003e6c800 x27: 0000000000000000
    [  245.493057] x26: 0000000000000000 x25: 0000000000000000 x24: ffffff800226ef20
    [  245.500175] x23: ffffffc0089ff550 x22: 0000000000000000 x21: ffffffc008476ad0
    [  245.507294] x20: 0000000000000000 x19: ffffffc00965ac70 x18: fffffffffffc51a7
    [  245.514413] x17: 68702e3030303837 x16: 3a6d726f6674616c x15: ffffffc089f2b777
    [  245.521531] x14: ffffffc0095c9d18 x13: 0000000000000129 x12: 0000000000000129
    [  245.528649] x11: 00000000ffffffea x10: ffffffc009621d18 x9 : 0000000000000001
    [  245.535767] x8 : 0000000000000001 x7 : 0000000000017fe8 x6 : 0000000000000001
    [  245.542885] x5 : ffffff803fdca6d8 x4 : 0000000000000000 x3 : 0000000000000027
    [  245.550002] x2 : 0000000000000027 x1 : 0000000000000023 x0 : 0000000000000026
    [  245.557122] Call trace:
    [  245.564229]  clk_branch_wait+0x130/0x140
    [  245.566490]  clk_branch2_disable+0x2c/0x40
    [  245.570656]  clk_core_disable+0x60/0xb0
    [  245.574561]  clk_core_disable+0x68/0xb0
    [  245.578293]  clk_disable+0x30/0x50
    [  245.582113]  dwc3_qcom_remove+0x60/0xc0 [dwc3_qcom]
    [  245.585588]  platform_remove+0x28/0x60
    [  245.590361]  device_remove+0x4c/0x80
    [  245.594179]  device_release_driver_internal+0x1dc/0x230
    [  245.597914]  device_driver_detach+0x18/0x30
    [  245.602861]  unbind_store+0xec/0x110
    [  245.607027]  drv_attr_store+0x24/0x40
    [  245.610847]  sysfs_kf_write+0x44/0x60
    [  245.614405]  kernfs_fop_write_iter+0x128/0x1c0
    [  245.618052]  new_sync_write+0xc0/0x130
    [  245.622391]  vfs_write+0x1d4/0x2a0
    [  245.626123]  ksys_write+0x58/0xe0
    [  245.629508]  __arm64_sys_write+0x1c/0x30
    [  245.632895]  invoke_syscall.constprop.0+0x5c/0x110
    [  245.636890]  do_el0_svc+0xa0/0x150
    [  245.641488]  el0_svc+0x18/0x60
    [  245.644872]  el0t_64_sync_handler+0xa4/0x130
    [  245.647914]  el0t_64_sync+0x174/0x178
    [  245.652340] ---[ end trace 0000000000000000 ]---
    
    So, add CLK_IS_CRITICAL flag to the clock so that the kernel won't try
    to disable the sleep clock.
    
    Signed-off-by: Robert Marko <robimarko@gmail.com>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220515210048.483898-10-robimarko@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c5c5bd5cdcc6dc9f75f53d1c89af463d39a2bb96
Author: Liang He <windhl@126.com>
Date:   Fri Jun 17 11:46:37 2022 +0800

    usb: host: ohci-ppc-of: Fix refcount leak bug
    
    [ Upstream commit 40a959d7042bb7711e404ad2318b30e9f92c6b9b ]
    
    In ohci_hcd_ppc_of_probe(), of_find_compatible_node() will return
    a node pointer with refcount incremented. We should use of_node_put()
    when it is not used anymore.
    
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Liang He <windhl@126.com>
    Link: https://lore.kernel.org/r/20220617034637.4003115-1-windhl@126.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3f08c6ab4dc53cca1c7ffd88d45d5f099788fedc
Author: Sai Prakash Ranjan <quic_saipraka@quicinc.com>
Date:   Wed May 18 22:14:12 2022 +0530

    irqchip/tegra: Fix overflow implicit truncation warnings
    
    [ Upstream commit 443685992bda9bb4f8b17fc02c9f6c60e62b1461 ]
    
    Fix -Woverflow warnings for tegra irqchip driver which is a result
    of moving arm64 custom MMIO accessor macros to asm-generic function
    implementations giving a bonus type-checking now and uncovering these
    overflow warnings.
    
    drivers/irqchip/irq-tegra.c: In function ‘tegra_ictlr_suspend’:
    drivers/irqchip/irq-tegra.c:151:18: warning: large integer implicitly truncated to unsigned type [-Woverflow]
       writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR);
                      ^
    
    Suggested-by: Marc Zyngier <maz@kernel.org>
    Signed-off-by: Sai Prakash Ranjan <quic_saipraka@quicinc.com>
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Cc: Marc Zyngier <maz@kernel.org>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7f5060a66d0cd8dc78e5140a371a7edab9d4f971
Author: Pavan Chebbi <pavan.chebbi@broadcom.com>
Date:   Thu Jun 9 13:41:47 2022 -0400

    PCI: Add ACS quirk for Broadcom BCM5750x NICs
    
    [ Upstream commit afd306a65cedb9589564bdb23a0c368abc4215fd ]
    
    The Broadcom BCM5750x NICs may be multi-function devices.  They do not
    advertise ACS capability. Peer-to-peer transactions are not possible
    between the individual functions, so it is safe to treat them as fully
    isolated.
    
    Add an ACS quirk for these devices so the functions can be in independent
    IOMMU groups and attached individually to userspace applications using
    VFIO.
    
    Link: https://lore.kernel.org/r/1654796507-28610-1-git-send-email-michael.chan@broadcom.com
    Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
    Signed-off-by: Michael Chan <michael.chan@broadcom.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6a758f0ba11699837af9e1a0f7cbac6ef765a23e
Author: Liang He <windhl@126.com>
Date:   Tue Jul 26 09:07:22 2022 +0800

    drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
    
    [ Upstream commit 91b3c8dbe898df158fd2a84675f3a284ff6666f7 ]
    
    In this function, there are two refcount leak bugs:
    (1) when breaking out of for_each_endpoint_of_node(), we need call
    the of_node_put() for the 'ep';
    (2) we should call of_node_put() for the reference returned by
    of_graph_get_remote_port() when it is not used anymore.
    
    Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
    Signed-off-by: Liang He <windhl@126.com>
    Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
    Acked-by: Neil Armstrong <narmstrong@baylibre.com>
    Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220726010722.1319416-1-windhl@126.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 33bf7decefbf68aba9c35ea64010beefd43074d9
Author: Qu Wenruo <wqu@suse.com>
Date:   Sat Aug 20 16:49:23 2022 +0800

    btrfs: raid56: don't trust any cached sector in __raid56_parity_recover()
    
    commit f6065f8edeb25f4a9dfe0b446030ad995a84a088 upstream.
    
    [BUG]
    There is a small workload which will always fail with recent kernel:
    (A simplified version from btrfs/125 test case)
    
      mkfs.btrfs -f -m raid5 -d raid5 -b 1G $dev1 $dev2 $dev3
      mount $dev1 $mnt
      xfs_io -f -c "pwrite -S 0xee 0 1M" $mnt/file1
      sync
      umount $mnt
      btrfs dev scan -u $dev3
      mount -o degraded $dev1 $mnt
      xfs_io -f -c "pwrite -S 0xff 0 128M" $mnt/file2
      umount $mnt
      btrfs dev scan
      mount $dev1 $mnt
      btrfs balance start --full-balance $mnt
      umount $mnt
    
    The failure is always failed to read some tree blocks:
    
      BTRFS info (device dm-4): relocating block group 217710592 flags data|raid5
      BTRFS error (device dm-4): parent transid verify failed on 38993920 wanted 9 found 7
      BTRFS error (device dm-4): parent transid verify failed on 38993920 wanted 9 found 7
      ...
    
    [CAUSE]
    With the recently added debug output, we can see all RAID56 operations
    related to full stripe 38928384:
    
      56.1183: raid56_read_partial: full_stripe=38928384 devid=2 type=DATA1 offset=0 opf=0x0 physical=9502720 len=65536
      56.1185: raid56_read_partial: full_stripe=38928384 devid=3 type=DATA2 offset=16384 opf=0x0 physical=9519104 len=16384
      56.1185: raid56_read_partial: full_stripe=38928384 devid=3 type=DATA2 offset=49152 opf=0x0 physical=9551872 len=16384
      56.1187: raid56_write_stripe: full_stripe=38928384 devid=3 type=DATA2 offset=0 opf=0x1 physical=9502720 len=16384
      56.1188: raid56_write_stripe: full_stripe=38928384 devid=3 type=DATA2 offset=32768 opf=0x1 physical=9535488 len=16384
      56.1188: raid56_write_stripe: full_stripe=38928384 devid=1 type=PQ1 offset=0 opf=0x1 physical=30474240 len=16384
      56.1189: raid56_write_stripe: full_stripe=38928384 devid=1 type=PQ1 offset=32768 opf=0x1 physical=30507008 len=16384
      56.1218: raid56_write_stripe: full_stripe=38928384 devid=3 type=DATA2 offset=49152 opf=0x1 physical=9551872 len=16384
      56.1219: raid56_write_stripe: full_stripe=38928384 devid=1 type=PQ1 offset=49152 opf=0x1 physical=30523392 len=16384
      56.2721: raid56_parity_recover: full stripe=38928384 eb=39010304 mirror=2
      56.2723: raid56_parity_recover: full stripe=38928384 eb=39010304 mirror=2
      56.2724: raid56_parity_recover: full stripe=38928384 eb=39010304 mirror=2
    
    Before we enter raid56_parity_recover(), we have triggered some metadata
    write for the full stripe 38928384, this leads to us to read all the
    sectors from disk.
    
    Furthermore, btrfs raid56 write will cache its calculated P/Q sectors to
    avoid unnecessary read.
    
    This means, for that full stripe, after any partial write, we will have
    stale data, along with P/Q calculated using that stale data.
    
    Thankfully due to patch "btrfs: only write the sectors in the vertical stripe
    which has data stripes" we haven't submitted all the corrupted P/Q to disk.
    
    When we really need to recover certain range, aka in
    raid56_parity_recover(), we will use the cached rbio, along with its
    cached sectors (the full stripe is all cached).
    
    This explains why we have no event raid56_scrub_read_recover()
    triggered.
    
    Since we have the cached P/Q which is calculated using the stale data,
    the recovered one will just be stale.
    
    In our particular test case, it will always return the same incorrect
    metadata, thus causing the same error message "parent transid verify
    failed on 39010304 wanted 9 found 7" again and again.
    
    [BTRFS DESTRUCTIVE RMW PROBLEM]
    
    Test case btrfs/125 (and above workload) always has its trouble with
    the destructive read-modify-write (RMW) cycle:
    
            0       32K     64K
    Data1:  | Good  | Good  |
    Data2:  | Bad   | Bad   |
    Parity: | Good  | Good  |
    
    In above case, if we trigger any write into Data1, we will use the bad
    data in Data2 to re-generate parity, killing the only chance to recovery
    Data2, thus Data2 is lost forever.
    
    This destructive RMW cycle is not specific to btrfs RAID56, but there
    are some btrfs specific behaviors making the case even worse:
    
    - Btrfs will cache sectors for unrelated vertical stripes.
    
      In above example, if we're only writing into 0~32K range, btrfs will
      still read data range (32K ~ 64K) of Data1, and (64K~128K) of Data2.
      This behavior is to cache sectors for later update.
    
      Incidentally commit d4e28d9b5f04 ("btrfs: raid56: make steal_rbio()
      subpage compatible") has a bug which makes RAID56 to never trust the
      cached sectors, thus slightly improve the situation for recovery.
    
      Unfortunately, follow up fix "btrfs: update stripe_sectors::uptodate in
      steal_rbio" will revert the behavior back to the old one.
    
    - Btrfs raid56 partial write will update all P/Q sectors and cache them
    
      This means, even if data at (64K ~ 96K) of Data2 is free space, and
      only (96K ~ 128K) of Data2 is really stale data.
      And we write into that (96K ~ 128K), we will update all the parity
      sectors for the full stripe.
    
      This unnecessary behavior will completely kill the chance of recovery.
    
      Thankfully, an unrelated optimization "btrfs: only write the sectors
      in the vertical stripe which has data stripes" will prevent
      submitting the write bio for untouched vertical sectors.
    
      That optimization will keep the on-disk P/Q untouched for a chance for
      later recovery.
    
    [FIX]
    Although we have no good way to completely fix the destructive RMW
    (unless we go full scrub for each partial write), we can still limit the
    damage.
    
    With patch "btrfs: only write the sectors in the vertical stripe which
    has data stripes" now we won't really submit the P/Q of unrelated
    vertical stripes, so the on-disk P/Q should still be fine.
    
    Now we really need to do is just drop all the cached sectors when doing
    recovery.
    
    By this, we have a chance to read the original P/Q from disk, and have a
    chance to recover the stale data, while still keep the cache to speed up
    regular write path.
    
    In fact, just dropping all the cache for recovery path is good enough to
    allow the test case btrfs/125 along with the small script to pass
    reliably.
    
    The lack of metadata write after the degraded mount, and forced metadata
    COW is saving us this time.
    
    So this patch will fix the behavior by not trust any cache in
    __raid56_parity_recover(), to solve the problem while still keep the
    cache useful.
    
    But please note that this test pass DOES NOT mean we have solved the
    destructive RMW problem, we just do better damage control a little
    better.
    
    Related patches:
    
    - btrfs: only write the sectors in the vertical stripe
    - d4e28d9b5f04 ("btrfs: raid56: make steal_rbio() subpage compatible")
    - btrfs: update stripe_sectors::uptodate in steal_rbio
    
    Acked-by: David Sterba <dsterba@suse.com>
    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 dc574b767092cc30665d018c7f7b558e3f740d47
Author: Qu Wenruo <wqu@suse.com>
Date:   Sat Aug 20 16:49:22 2022 +0800

    btrfs: only write the sectors in the vertical stripe which has data stripes
    
    commit bd8f7e627703ca5707833d623efcd43f104c7b3f upstream.
    
    If we have only 8K partial write at the beginning of a full RAID56
    stripe, we will write the following contents:
    
                        0  8K           32K             64K
    Disk 1  (data):     |XX|            |               |
    Disk 2  (data):     |               |               |
    Disk 3  (parity):   |XXXXXXXXXXXXXXX|XXXXXXXXXXXXXXX|
    
    |X| means the sector will be written back to disk.
    
    Note that, although we won't write any sectors from disk 2, but we will
    write the full 64KiB of parity to disk.
    
    This behavior is fine for now, but not for the future (especially for
    RAID56J, as we waste quite some space to journal the unused parity
    stripes).
    
    So here we will also utilize the btrfs_raid_bio::dbitmap, anytime we
    queue a higher level bio into an rbio, we will update rbio::dbitmap to
    indicate which vertical stripes we need to writeback.
    
    And at finish_rmw(), we also check dbitmap to see if we need to write
    any sector in the vertical stripe.
    
    So after the patch, above example will only lead to the following
    writeback pattern:
    
                        0  8K           32K             64K
    Disk 1  (data):     |XX|            |               |
    Disk 2  (data):     |               |               |
    Disk 3  (parity):   |XX|            |               |
    
    Acked-by: David Sterba <dsterba@suse.com>
    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 87734c7c9a669d394ed49b55e5616f3970f0d308
Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Date:   Fri Mar 16 16:37:09 2018 +0900

    kbuild: clear LDFLAGS in the top Makefile
    
    commit ce99d0bf312daf0178e640da9e3c93b773a67e7d upstream.
    
    Currently LDFLAGS is not cleared, so same flags are accumulated in
    LDFLAGS when the top Makefile is recursively invoked.
    
    I found unneeded rebuild for ARCH=arm64 when CONFIG_TRIM_UNUSED_KSYMS
    is enabled.  If include/generated/autoksyms.h is updated, the top
    Makefile is recursively invoked, then arch/arm64/Makefile adds one
    more '-maarch64linux'.  Due to the command line change, modules are
    rebuilt needlessly.
    
    Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
    Acked-by: Nicolas Pitre <nico@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5773a1e6e5ba9f62c4573c57878d154fda269bc2
Author: Lin Ma <linma@zju.edu.cn>
Date:   Wed Aug 17 11:49:21 2022 -0700

    igb: Add lock to avoid data race
    
    commit 6faee3d4ee8be0f0367d0c3d826afb3571b7a5e0 upstream.
    
    The commit c23d92b80e0b ("igb: Teardown SR-IOV before
    unregister_netdev()") places the unregister_netdev() call after the
    igb_disable_sriov() call to avoid functionality issue.
    
    However, it introduces several race conditions when detaching a device.
    For example, when .remove() is called, the below interleaving leads to
    use-after-free.
    
     (FREE from device detaching)      |   (USE from netdev core)
    igb_remove                         |  igb_ndo_get_vf_config
     igb_disable_sriov                 |  vf >= adapter->vfs_allocated_count?
      kfree(adapter->vf_data)          |
      adapter->vfs_allocated_count = 0 |
                                       |    memcpy(... adapter->vf_data[vf]
    
    Moreover, the igb_disable_sriov() also suffers from data race with the
    requests from VF driver.
    
     (FREE from device detaching)      |   (USE from requests)
    igb_remove                         |  igb_msix_other
     igb_disable_sriov                 |   igb_msg_task
      kfree(adapter->vf_data)          |    vf < adapter->vfs_allocated_count
      adapter->vfs_allocated_count = 0 |
    
    To this end, this commit first eliminates the data races from netdev
    core by using rtnl_lock (similar to commit 719479230893 ("dpaa2-eth: add
    MAC/PHY support through phylink")). And then adds a spinlock to
    eliminate races from driver requests. (similar to commit 1e53834ce541
    ("ixgbe: Add locking to prevent panic when setting sriov_numvfs to zero")
    
    Fixes: c23d92b80e0b ("igb: Teardown SR-IOV before unregister_netdev()")
    Signed-off-by: Lin Ma <linma@zju.edu.cn>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Link: https://lore.kernel.org/r/20220817184921.735244-1-anthony.l.nguyen@intel.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 46ec5abd567327783864ef09d6a6452a447d1b2f
Author: Csókás Bence <csokas.bence@prolan.hu>
Date:   Thu Aug 11 12:13:49 2022 +0200

    fec: Fix timer capture timing in `fec_ptp_enable_pps()`
    
    commit 61d5e2a251fb20c2c5e998c3f1d52ed6d5360319 upstream.
    
    Code reimplements functionality already in `fec_ptp_read()`,
    but misses check for FEC_QUIRK_BUG_CAPTURE. Replace with function call.
    
    Fixes: 28b5f058cf1d ("net: fec: ptp: fix convergence issue to support LinuxPTP stack")
    Signed-off-by: Csókás Bence <csokas.bence@prolan.hu>
    Link: https://lore.kernel.org/r/20220811101348.13755-1-csokas.bence@prolan.hu
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9675ac3c6052c1064438bc0eebd0e710a478abac
Author: Alan Brady <alan.brady@intel.com>
Date:   Tue Aug 2 10:19:17 2022 +0200

    i40e: Fix to stop tx_timeout recovery if GLOBR fails
    
    commit 57c942bc3bef0970f0b21f8e0998e76a900ea80d upstream.
    
    When a tx_timeout fires, the PF attempts to recover by incrementally
    resetting.  First we try a PFR, then CORER and finally a GLOBR.  If the
    GLOBR fails, then we keep hitting the tx_timeout and incrementing the
    recovery level and issuing dmesgs, which is both annoying to the user
    and accomplishes nothing.
    
    If the GLOBR fails, then we're pretty much totally hosed, and there's
    not much else we can do to recover, so this makes it such that we just
    kill the VSI and stop hitting the tx_timeout in such a case.
    
    Fixes: 41c445ff0f48 ("i40e: main driver core")
    Signed-off-by: Alan Brady <alan.brady@intel.com>
    Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
    Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6f75057c21eab12c6ccb7f06f859641a6edfab99
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Mon Aug 15 16:55:23 2022 +1000

    powerpc/pci: Fix get_phb_number() locking
    
    commit 8d48562a2729742f767b0fdd994d6b2a56a49c63 upstream.
    
    The recent change to get_phb_number() causes a DEBUG_ATOMIC_SLEEP
    warning on some systems:
    
      BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
      in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper
      preempt_count: 1, expected: 0
      RCU nest depth: 0, expected: 0
      1 lock held by swapper/1:
       #0: c157efb0 (hose_spinlock){+.+.}-{2:2}, at: pcibios_alloc_controller+0x64/0x220
      Preemption disabled at:
      [<00000000>] 0x0
      CPU: 0 PID: 1 Comm: swapper Not tainted 5.19.0-yocto-standard+ #1
      Call Trace:
      [d101dc90] [c073b264] dump_stack_lvl+0x50/0x8c (unreliable)
      [d101dcb0] [c0093b70] __might_resched+0x258/0x2a8
      [d101dcd0] [c0d3e634] __mutex_lock+0x6c/0x6ec
      [d101dd50] [c0a84174] of_alias_get_id+0x50/0xf4
      [d101dd80] [c002ec78] pcibios_alloc_controller+0x1b8/0x220
      [d101ddd0] [c140c9dc] pmac_pci_init+0x198/0x784
      [d101de50] [c140852c] discover_phbs+0x30/0x4c
      [d101de60] [c0007fd4] do_one_initcall+0x94/0x344
      [d101ded0] [c1403b40] kernel_init_freeable+0x1a8/0x22c
      [d101df10] [c00086e0] kernel_init+0x34/0x160
      [d101df30] [c001b334] ret_from_kernel_thread+0x5c/0x64
    
    This is because pcibios_alloc_controller() holds hose_spinlock but
    of_alias_get_id() takes of_mutex which can sleep.
    
    The hose_spinlock protects the phb_bitmap, and also the hose_list, but
    it doesn't need to be held while get_phb_number() calls the OF routines,
    because those are only looking up information in the device tree.
    
    So fix it by having get_phb_number() take the hose_spinlock itself, only
    where required, and then dropping the lock before returning.
    pcibios_alloc_controller() then needs to take the lock again before the
    list_add() but that's safe, the order of the list is not important.
    
    Fixes: 0fe1e96fef0a ("powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias")
    Reported-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220815065550.1303620-1-mpe@ellerman.id.au
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0252286c2b331d62654dd6c5196c85e44cb25861
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Tue Aug 9 17:23:53 2022 +0200

    netfilter: nf_tables: really skip inactive sets when allocating name
    
    commit 271c5ca826e0c3c53e0eb4032f8eaedea1ee391c upstream.
    
    While looping to build the bitmap of used anonymous set names, check the
    current set in the iteration, instead of the one that is being created.
    
    Fixes: 37a9cc525525 ("netfilter: nf_tables: add generation mask to sets")
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a2e1f07e3f8c37bd1de6e934dcf2d49021df7ff7
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Aug 8 16:09:45 2022 +0100

    nios2: add force_successful_syscall_return()
    
    commit fd0c153daad135d0ec1a53c5dbe6936a724d6ae1 upstream.
    
    If we use the ancient SysV syscall ABI, we'd better have tell the
    kernel how to claim that a negative return value is a success.
    Use ->orig_r2 for that - it's inaccessible via ptrace, so it's
    a fair game for changes and it's normally[*] non-negative on return
    from syscall.  Set to -1; syscall is not going to be restart-worthy
    by definition, so we won't interfere with that use either.
    
    [*] the only exception is rt_sigreturn(), where we skip the entire
    messing with r1/r2 anyway.
    
    Fixes: 82ed08dd1b0e ("nios2: Exception handling")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 06acb4197b5ae8212cc6b8c4436e9a8190f32f1d
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Aug 8 16:09:16 2022 +0100

    nios2: restarts apply only to the first sigframe we build...
    
    commit 411a76b7219555c55867466c82d70ce928d6c9e1 upstream.
    
    Fixes: b53e906d255d ("nios2: Signal handling support")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 23f654bda0a4bc8ed764b4b32983523b03132830
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Aug 8 16:08:48 2022 +0100

    nios2: fix syscall restart checks
    
    commit 2d631bd58fe0ea3e3350212e23c9aba1fb606514 upstream.
    
    sys_foo() returns -512 (aka -ERESTARTSYS) => do_signal() sees
    512 in r2 and 1 in r1.
    
    sys_foo() returns 512 => do_signal() sees 512 in r2 and 0 in r1.
    
    The former is restart-worthy; the latter obviously isn't.
    
    Fixes: b53e906d255d ("nios2: Signal handling support")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b40daf625c015d2abf7008af0b91c10459322166
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Aug 8 16:07:21 2022 +0100

    nios2: traced syscall does need to check the syscall number
    
    commit 25ba820ef36bdbaf9884adeac69b6e1821a7df76 upstream.
    
    all checks done before letting the tracer modify the register
    state are worthless...
    
    Fixes: 82ed08dd1b0e ("nios2: Exception handling")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b9918b326bf3dc1cf03bcea97ed6fe0b8cb02c8f
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Aug 8 16:06:46 2022 +0100

    nios2: don't leave NULLs in sys_call_table[]
    
    commit 45ec746c65097c25e77d24eae8fee0def5b6cc5d upstream.
    
    fill the gaps in there with sys_ni_syscall, as everyone does...
    
    Fixes: 82ed08dd1b0e ("nios2: Exception handling")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit eb8850d9bed474d64e2247d84522c0052f6f23bd
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Aug 8 16:06:04 2022 +0100

    nios2: page fault et.al. are *not* restartable syscalls...
    
    commit 8535c239ac674f7ead0f2652932d35c52c4123b2 upstream.
    
    make sure that ->orig_r2 is negative for everything except
    the syscalls.
    
    Fixes: 82ed08dd1b0e ("nios2: Exception handling")
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3db3f3bf05a88635beb7391fca235fb0e5213e6f
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Fri Aug 5 15:00:08 2022 +0800

    atm: idt77252: fix use-after-free bugs caused by tst_timer
    
    commit 3f4093e2bf4673f218c0bf17d8362337c400e77b upstream.
    
    There are use-after-free bugs caused by tst_timer. The root cause
    is that there are no functions to stop tst_timer in idt77252_exit().
    One of the possible race conditions is shown below:
    
        (thread 1)          |        (thread 2)
                            |  idt77252_init_one
                            |    init_card
                            |      fill_tst
                            |        mod_timer(&card->tst_timer, ...)
    idt77252_exit           |  (wait a time)
                            |  tst_timer
                            |
                            |    ...
      kfree(card) // FREE   |
                            |    card->soft_tst[e] // USE
    
    The idt77252_dev is deallocated in idt77252_exit() and used in
    timer handler.
    
    This patch adds del_timer_sync() in idt77252_exit() in order that
    the timer handler could be stopped before the idt77252_dev is
    deallocated.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Link: https://lore.kernel.org/r/20220805070008.18007-1-duoming@zju.edu.cn
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a97a92374a58eebebf4238935c8cc69a7f45f4c4
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu Aug 4 10:11:33 2022 +0300

    xen/xenbus: fix return type in xenbus_file_read()
    
    commit 32ad11127b95236dfc52375f3707853194a7f4b4 upstream.
    
    This code tries to store -EFAULT in an unsigned int.  The
    xenbus_file_read() function returns type ssize_t so the negative value
    is returned as a positive value to the user.
    
    This change forces another change to the min() macro.  Originally, the
    min() macro used "unsigned" type which checkpatch complains about.  Also
    unsigned type would break if "len" were not capped at MAX_RW_COUNT.  Use
    size_t for the min().  (No effect on runtime for the min_t() change).
    
    Fixes: 2fb3683e7b16 ("xen: Add xenbus device driver")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    Link: https://lore.kernel.org/r/YutxJUaUYRG/VLVc@kili
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e288d0c5a0dc7cd7fd7eb6fb351e11fc4416d512
Author: Roberto Sassu <roberto.sassu@huawei.com>
Date:   Tue Jul 19 19:05:55 2022 +0200

    tools build: Switch to new openssl API for test-libcrypto
    
    commit 5b245985a6de5ac18b5088c37068816d413fb8ed upstream.
    
    Switch to new EVP API for detecting libcrypto, as Fedora 36 returns an
    error when it encounters the deprecated function MD5_Init() and the others.
    
    The error would be interpreted as missing libcrypto, while in reality it is
    not.
    
    Fixes: 6e8ccb4f624a73c5 ("tools/bpf: properly account for libbfd variations")
    Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Andrii Nakryiko <andrii@kernel.org>
    Cc: bpf@vger.kernel.org
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: John Fastabend <john.fastabend@gmail.com>
    Cc: KP Singh <kpsingh@kernel.org>
    Cc: llvm@lists.linux.dev
    Cc: Martin KaFai Lau <martin.lau@linux.dev>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    Cc: Nick Terrell <terrelln@fb.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Quentin Monnet <quentin@isovalent.com>
    Cc: Song Liu <song@kernel.org>
    Cc: Stanislav Fomichev <sdf@google.com>
    Link: https://lore.kernel.org/r/20220719170555.2576993-4-roberto.sassu@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9035d5912cec89f68b8921fd5a801c169613decf
Author: Peilin Ye <peilin.ye@bytedance.com>
Date:   Mon Aug 8 11:05:25 2022 -0700

    vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout()
    
    commit a3e7b29e30854ed67be0d17687e744ad0c769c4b upstream.
    
    Imagine two non-blocking vsock_connect() requests on the same socket.
    The first request schedules @connect_work, and after it times out,
    vsock_connect_timeout() sets *sock* state back to TCP_CLOSE, but keeps
    *socket* state as SS_CONNECTING.
    
    Later, the second request returns -EALREADY, meaning the socket "already
    has a pending connection in progress", even though the first request has
    already timed out.
    
    As suggested by Stefano, fix it by setting *socket* state back to
    SS_UNCONNECTED, so that the second request will return -ETIMEDOUT.
    
    Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
    Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ec0a5b730cc053202df6b6e6dd6c860977990646
Author: Peilin Ye <peilin.ye@bytedance.com>
Date:   Mon Aug 8 11:04:47 2022 -0700

    vsock: Fix memory leak in vsock_connect()
    
    commit 7e97cfed9929eaabc41829c395eb0d1350fccb9d upstream.
    
    An O_NONBLOCK vsock_connect() request may try to reschedule
    @connect_work.  Imagine the following sequence of vsock_connect()
    requests:
    
      1. The 1st, non-blocking request schedules @connect_work, which will
         expire after 200 jiffies.  Socket state is now SS_CONNECTING;
    
      2. Later, the 2nd, blocking request gets interrupted by a signal after
         a few jiffies while waiting for the connection to be established.
         Socket state is back to SS_UNCONNECTED, but @connect_work is still
         pending, and will expire after 100 jiffies.
    
      3. Now, the 3rd, non-blocking request tries to schedule @connect_work
         again.  Since @connect_work is already scheduled,
         schedule_delayed_work() silently returns.  sock_hold() is called
         twice, but sock_put() will only be called once in
         vsock_connect_timeout(), causing a memory leak reported by syzbot:
    
      BUG: memory leak
      unreferenced object 0xffff88810ea56a40 (size 1232):
        comm "syz-executor756", pid 3604, jiffies 4294947681 (age 12.350s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          28 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00  (..@............
        backtrace:
          [<ffffffff837c830e>] sk_prot_alloc+0x3e/0x1b0 net/core/sock.c:1930
          [<ffffffff837cbe22>] sk_alloc+0x32/0x2e0 net/core/sock.c:1989
          [<ffffffff842ccf68>] __vsock_create.constprop.0+0x38/0x320 net/vmw_vsock/af_vsock.c:734
          [<ffffffff842ce8f1>] vsock_create+0xc1/0x2d0 net/vmw_vsock/af_vsock.c:2203
          [<ffffffff837c0cbb>] __sock_create+0x1ab/0x2b0 net/socket.c:1468
          [<ffffffff837c3acf>] sock_create net/socket.c:1519 [inline]
          [<ffffffff837c3acf>] __sys_socket+0x6f/0x140 net/socket.c:1561
          [<ffffffff837c3bba>] __do_sys_socket net/socket.c:1570 [inline]
          [<ffffffff837c3bba>] __se_sys_socket net/socket.c:1568 [inline]
          [<ffffffff837c3bba>] __x64_sys_socket+0x1a/0x20 net/socket.c:1568
          [<ffffffff84512815>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
          [<ffffffff84512815>] do_syscall_64+0x35/0x80 arch/x86/entry/common.c:80
          [<ffffffff84600068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
      <...>
    
    Use mod_delayed_work() instead: if @connect_work is already scheduled,
    reschedule it, and undo sock_hold() to keep the reference count
    balanced.
    
    Reported-and-tested-by: syzbot+b03f55bf128f9a38f064@syzkaller.appspotmail.com
    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Co-developed-by: Stefano Garzarella <sgarzare@redhat.com>
    Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
    Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
    Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e3b1b19ad14a72d1726d3b7bcd0a96bf206692c
Author: Matthias May <matthias.may@westermo.com>
Date:   Fri Aug 5 21:19:03 2022 +0200

    geneve: do not use RT_TOS for IPv6 flowlabel
    
    commit ca2bb69514a8bc7f83914122f0d596371352416c upstream.
    
    According to Guillaume Nault RT_TOS should never be used for IPv6.
    
    Quote:
    RT_TOS() is an old macro used to interprete IPv4 TOS as described in
    the obsolete RFC 1349. It's conceptually wrong to use it even in IPv4
    code, although, given the current state of the code, most of the
    existing calls have no consequence.
    
    But using RT_TOS() in IPv6 code is always a bug: IPv6 never had a "TOS"
    field to be interpreted the RFC 1349 way. There's no historical
    compatibility to worry about.
    
    Fixes: 3a56f86f1be6 ("geneve: handle ipv6 priority like ipv4 tos")
    Acked-by: Guillaume Nault <gnault@redhat.com>
    Signed-off-by: Matthias May <matthias.may@westermo.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f11e96ca64316b7b7ab9b53df04b40526a89b10a
Author: Sakari Ailus <sakari.ailus@linux.intel.com>
Date:   Mon Jul 11 14:25:59 2022 +0300

    ACPI: property: Return type of acpi_add_nondev_subnodes() should be bool
    
    commit 85140ef275f577f64e8a2c5789447222dfc14fc4 upstream.
    
    The value acpi_add_nondev_subnodes() returns is bool so change the return
    type of the function to match that.
    
    Fixes: 445b0eb058f5 ("ACPI / property: Add support for data-only subnodes")
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 180418a471c9a6391c114482662633d5c0edab3b
Author: Nikita Travkin <nikita@trvn.ru>
Date:   Sun Jun 12 19:59:54 2022 +0500

    pinctrl: qcom: msm8916: Allow CAMSS GP clocks to be muxed
    
    commit 44339391c666e46cba522d19c65a6ad1071c68b7 upstream.
    
    GPIO 31, 32 can be muxed to GCC_CAMSS_GP(1,2)_CLK respectively but the
    function was never assigned to the pingroup (even though the function
    exists already).
    
    Add this mode to the related pins.
    
    Fixes: 5373a2c5abb6 ("pinctrl: qcom: Add msm8916 pinctrl driver")
    Signed-off-by: Nikita Travkin <nikita@trvn.ru>
    Link: https://lore.kernel.org/r/20220612145955.385787-4-nikita@trvn.ru
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c35f89a9021fa947ecede0584ae509368a52ec5a
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Tue Jun 7 15:16:01 2022 +0400

    pinctrl: nomadik: Fix refcount leak in nmk_pinctrl_dt_subnode_to_map
    
    commit 4b32e054335ea0ce50967f63a7bfd4db058b14b9 upstream.
    
    of_parse_phandle() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Add missing of_node_put() to avoid refcount leak."
    
    Fixes: c2f6d059abfc ("pinctrl: nomadik: refactor DT parser to take two paths")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220607111602.57355-1-linmq006@gmail.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3899e57ac1dbbd6153f86fdc09fc923c9bc4601d
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Wed Jul 27 12:27:54 2022 -0400

    SUNRPC: Reinitialise the backchannel request buffers before reuse
    
    commit 6622e3a73112fc336c1c2c582428fb5ef18e456a upstream.
    
    When we're reusing the backchannel requests instead of freeing them,
    then we should reinitialise any values of the send/receive xdr_bufs so
    that they reflect the available space.
    
    Fixes: 0d2a970d0ae5 ("SUNRPC: Fix a backchannel race")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7e5787469419519d8c06034240d818f385c09ea0
Author: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
Date:   Wed Jul 27 18:01:07 2022 +0800

    NFSv4.1: RECLAIM_COMPLETE must handle EACCES
    
    commit e35a5e782f67ed76a65ad0f23a484444a95f000f upstream.
    
    A client should be able to handle getting an EACCES error while doing
    a mount operation to reclaim state due to NFS4CLNT_RECLAIM_REBOOT
    being set. If the server returns RPC_AUTH_BADCRED because authentication
    failed when we execute "exportfs -au", then RECLAIM_COMPLETE will go a
    wrong way. After mount succeeds, all OPEN call will fail due to an
    NFS4ERR_GRACE error being returned. This patch is to fix it by resending
    a RPC request.
    
    Signed-off-by: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
    Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
    Fixes: aa5190d0ed7d ("NFSv4: Kill nfs4_async_handle_error() abuses by NFSv4.1")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7c9699654ab786b0f21dd889c6eee936ca543007
Author: Trond Myklebust <trond.myklebust@hammerspace.com>
Date:   Wed Jul 13 17:46:52 2022 -0400

    NFSv4: Fix races in the legacy idmapper upcall
    
    commit 51fd2eb52c0ca8275a906eed81878ef50ae94eb0 upstream.
    
    nfs_idmap_instantiate() will cause the process that is waiting in
    request_key_with_auxdata() to wake up and exit. If there is a second
    process waiting for the idmap->idmap_mutex, then it may wake up and
    start a new call to request_key_with_auxdata(). If the call to
    idmap_pipe_downcall() from the first process has not yet finished
    calling nfs_idmap_complete_pipe_upcall_locked(), then we may end up
    triggering the WARN_ON_ONCE() in nfs_idmap_prepare_pipe_upcall().
    
    The fix is to ensure that we clear idmap->idmap_upcall_data before
    calling nfs_idmap_instantiate().
    
    Fixes: e9ab41b620e4 ("NFSv4: Clean up the legacy idmapper upcall")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d53194707d2a1851be027cd74266b96ceff799d3
Author: Xin Xiong <xiongx18@fudan.edu.cn>
Date:   Thu Apr 28 11:39:08 2022 +0800

    apparmor: fix reference count leak in aa_pivotroot()
    
    commit 11c3627ec6b56c1525013f336f41b79a983b4d46 upstream.
    
    The aa_pivotroot() function has a reference counting bug in a specific
    path. When aa_replace_current_label() returns on success, the function
    forgets to decrement the reference count of “target”, which is
    increased earlier by build_pivotroot(), causing a reference leak.
    
    Fix it by decreasing the refcount of “target” in that path.
    
    Fixes: 2ea3ffb7782a ("apparmor: add mount mediation")
    Co-developed-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
    Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
    Co-developed-by: Xin Tan <tanxin.ctf@gmail.com>
    Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
    Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
    Signed-off-by: John Johansen <john.johansen@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c912dba2cc7d781a25c535d400e285523c5a29ad
Author: Tom Rix <trix@redhat.com>
Date:   Sun Feb 13 13:32:28 2022 -0800

    apparmor: fix aa_label_asxprint return check
    
    commit 3e2a3a0830a2090e766d0d887d52c67de2a6f323 upstream.
    
    Clang static analysis reports this issue
    label.c:1802:3: warning: 2nd function call argument
      is an uninitialized value
      pr_info("%s", str);
      ^~~~~~~~~~~~~~~~~~
    
    str is set from a successful call to aa_label_asxprint(&str, ...)
    On failure a negative value is returned, not a -1.  So change
    the check.
    
    Fixes: f1bd904175e8 ("apparmor: add the base fns() for domain labels")
    Signed-off-by: Tom Rix <trix@redhat.com>
    Signed-off-by: John Johansen <john.johansen@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1fff357ea6bb13038e1a197d4e561eece176d574
Author: John Johansen <john.johansen@canonical.com>
Date:   Tue Jan 25 00:37:42 2022 -0800

    apparmor: Fix failed mount permission check error message
    
    commit ec240b5905bbb09a03dccffee03062cf39e38dc2 upstream.
    
    When the mount check fails due to a permission check failure instead
    of explicitly at one of the subcomponent checks, AppArmor is reporting
    a failure in the flags match. However this is not true and AppArmor
    can not attribute the error at this point to any particular component,
    and should only indicate the mount failed due to missing permissions.
    
    Fixes: 2ea3ffb7782a ("apparmor: add mount mediation")
    Signed-off-by: John Johansen <john.johansen@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0828d1db5bbc9b8de172f5028562b323fbc4db23
Author: John Johansen <john.johansen@canonical.com>
Date:   Thu Apr 29 01:48:28 2021 -0700

    apparmor: fix quiet_denied for file rules
    
    commit 68ff8540cc9e4ab557065b3f635c1ff4c96e1f1c upstream.
    
    Global quieting of denied AppArmor generated file events is not
    handled correctly. Unfortunately the is checking if quieting of all
    audit events is set instead of just denied events.
    
    Fixes: 67012e8209df ("AppArmor: basic auditing infrastructure.")
    Signed-off-by: John Johansen <john.johansen@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d3919826802cc22b7ab22db858c5ea3bebe97541
Author: Marc Kleine-Budde <mkl@pengutronix.de>
Date:   Mon Aug 1 22:47:16 2022 +0200

    can: ems_usb: fix clang's -Wunaligned-access warning
    
    commit a4cb6e62ea4d36e53fb3c0f18ea4503d7b76674f upstream.
    
    clang emits a -Wunaligned-access warning on struct __packed
    ems_cpc_msg.
    
    The reason is that the anonymous union msg (not declared as packed) is
    being packed right after some non naturally aligned variables (3*8
    bits + 2*32) inside a packed struct:
    
    | struct __packed ems_cpc_msg {
    |       u8 type;        /* type of message */
    |       u8 length;      /* length of data within union 'msg' */
    |       u8 msgid;       /* confirmation handle */
    |       __le32 ts_sec;  /* timestamp in seconds */
    |       __le32 ts_nsec; /* timestamp in nano seconds */
    |       /* ^ not naturally aligned */
    |
    |       union {
    |       /* ^ not declared as packed */
    |               u8 generic[64];
    |               struct cpc_can_msg can_msg;
    |               struct cpc_can_params can_params;
    |               struct cpc_confirm confirmation;
    |               struct cpc_overrun overrun;
    |               struct cpc_can_error error;
    |               struct cpc_can_err_counter err_counter;
    |               u8 can_state;
    |       } msg;
    | };
    
    Starting from LLVM 14, having an unpacked struct nested in a packed
    struct triggers a warning. c.f. [1].
    
    Fix the warning by marking the anonymous union as packed.
    
    [1] https://github.com/llvm/llvm-project/issues/55520
    
    Fixes: 702171adeed3 ("ems_usb: Added support for EMS CPC-USB/ARM7 CAN/USB interface")
    Link: https://lore.kernel.org/all/20220802094021.959858-1-mkl@pengutronix.de
    Cc: Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>
    Cc: Sebastian Haas <haas@ems-wuensche.com>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6a58c948b98c72ecf5798e4d078d49d60d8ea48e
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Aug 1 14:57:51 2022 +0100

    btrfs: fix lost error handling when looking up extended ref on log replay
    
    commit 7a6b75b79902e47f46328b57733f2604774fa2d9 upstream.
    
    During log replay, when processing inode references, if we get an error
    when looking up for an extended reference at __add_inode_ref(), we ignore
    it and proceed, returning success (0) if no other error happens after the
    lookup. This is obviously wrong because in case an extended reference
    exists and it encodes some name not in the log, we need to unlink it,
    otherwise the filesystem state will not match the state it had after the
    last fsync.
    
    So just make __add_inode_ref() return an error it gets from the extended
    reference lookup.
    
    Fixes: f186373fef005c ("btrfs: extended inode refs")
    CC: stable@vger.kernel.org # 4.9+
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 70f7fca81118c5a31faa8a59adeb10a248f66ab9
Author: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Date:   Fri Aug 12 02:29:53 2022 +0900

    ata: libata-eh: Add missing command name
    
    commit d3122bf9aa4c974f5e2c0112f799757b3a2779da upstream.
    
    Add the missing command name for ATA_CMD_NCQ_NON_DATA to
    ata_get_cmd_name().
    
    Fixes: 661ce1f0c4a6 ("libata/libsas: Define ATA_CMD_NCQ_NON_DATA")
    Cc: stable@vger.kernel.org
    Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 84295ae9384c30d6873e0ecabd9f3e8b15dc4442
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Wed Aug 10 09:00:42 2022 -0400

    rds: add missing barrier to release_refill
    
    commit 9f414eb409daf4f778f011cf8266d36896bb930b upstream.
    
    The functions clear_bit and set_bit do not imply a memory barrier, thus it
    may be possible that the waitqueue_active function (which does not take
    any locks) is moved before clear_bit and it could miss a wakeup event.
    
    Fix this bug by adding a memory barrier after clear_bit.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1825806cc6d07a245e1b25bdf01ab4043d7d753e
Author: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Date:   Wed Aug 17 14:49:24 2022 +0200

    ALSA: info: Fix llseek return value when using callback
    
    commit 9be080edcca330be4af06b19916c35227891e8bc upstream.
    
    When using callback there was a flow of
    
            ret = -EINVAL
            if (callback) {
                    offset = callback();
                    goto out;
            }
            ...
            offset = some other value in case of no callback;
            ret = offset;
    out:
            return ret;
    
    which causes the snd_info_entry_llseek() to return -EINVAL when there is
    callback handler. Fix this by setting "ret" directly to callback return
    value before jumping to "out".
    
    Fixes: 73029e0ff18d ("ALSA: info - Implement common llseek for binary mode")
    Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220817124924.3974577-1-amadeuszx.slawinski@linux.intel.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8b14b7ed0e5ebcb51e04d7f0caf5504b7462f75f
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Tue Jun 28 16:43:35 2022 +0200

    powerpc/ptdump: Fix display of RW pages on FSL_BOOK3E
    
    commit dd8de84b57b02ba9c1fe530a6d916c0853f136bd upstream.
    
    On FSL_BOOK3E, _PAGE_RW is defined with two bits, one for user and one
    for supervisor. As soon as one of the two bits is set, the page has
    to be display as RW. But the way it is implemented today requires both
    bits to be set in order to display it as RW.
    
    Instead of display RW when _PAGE_RW bits are set and R otherwise,
    reverse the logic and display R when _PAGE_RW bits are all 0 and
    RW otherwise.
    
    This change has no impact on other platforms as _PAGE_RW is a single
    bit on all of them.
    
    Fixes: 8eb07b187000 ("powerpc/mm: Dump linux pagetables")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/0c33b96317811edf691e81698aaee8fa45ec3449.1656427391.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 99b25b8778b3c5f185877f1ea9f576bc75079967
Author: Jamal Hadi Salim <jhs@mojatatu.com>
Date:   Sun Aug 14 11:27:58 2022 +0000

    net_sched: cls_route: disallow handle of 0
    
    commit 02799571714dc5dd6948824b9d080b44a295f695 upstream.
    
    Follows up on:
    https://lore.kernel.org/all/20220809170518.164662-1-cascardo@canonical.com/
    
    handle of 0 implies from/to of universe realm which is not very
    sensible.
    
    Lets see what this patch will do:
    $sudo tc qdisc add dev $DEV root handle 1:0 prio
    
    //lets manufacture a way to insert handle of 0
    $sudo tc filter add dev $DEV parent 1:0 protocol ip prio 100 \
    route to 0 from 0 classid 1:10 action ok
    
    //gets rejected...
    Error: handle of 0 is not valid.
    We have an error talking to the kernel, -1
    
    //lets create a legit entry..
    sudo tc filter add dev $DEV parent 1:0 protocol ip prio 100 route from 10 \
    classid 1:10 action ok
    
    //what did the kernel insert?
    $sudo tc filter ls dev $DEV parent 1:0
    filter protocol ip pref 100 route chain 0
    filter protocol ip pref 100 route chain 0 fh 0x000a8000 flowid 1:10 from 10
            action order 1: gact action pass
             random type none pass val 0
             index 1 ref 1 bind 1
    
    //Lets try to replace that legit entry with a handle of 0
    $ sudo tc filter replace dev $DEV parent 1:0 protocol ip prio 100 \
    handle 0x000a8000 route to 0 from 0 classid 1:10 action drop
    
    Error: Replacing with handle of 0 is invalid.
    We have an error talking to the kernel, -1
    
    And last, lets run Cascardo's POC:
    $ ./poc
    0
    0
    -22
    -22
    -22
    
    Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
    Acked-by: Stephen Hemminger <stephen@networkplumber.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 918ce0827e6faf9e5ba1434c2ef2af5eed50c865
Author: Tyler Hicks <tyhicks@linux.microsoft.com>
Date:   Sun Jul 10 09:14:02 2022 -0500

    net/9p: Initialize the iounit field during fid creation
    
    commit aa7aeee169480e98cf41d83c01290a37e569be6d upstream.
    
    Ensure that the fid's iounit field is set to zero when a new fid is
    created. Certain 9P operations, such as OPEN and CREATE, allow the
    server to reply with an iounit size which the client code assigns to the
    p9_fid struct shortly after the fid is created by p9_fid_create(). On
    the other hand, an XATTRWALK operation doesn't allow for the server to
    specify an iounit value. The iounit field of the newly allocated p9_fid
    struct remained uninitialized in that case. Depending on allocation
    patterns, the iounit value could have been something reasonable that was
    carried over from previously freed fids or, in the worst case, could
    have been arbitrary values from non-fid related usages of the memory
    location.
    
    The bug was detected in the Windows Subsystem for Linux 2 (WSL2) kernel
    after the uninitialized iounit field resulted in the typical sequence of
    two getxattr(2) syscalls, one to get the size of an xattr and another
    after allocating a sufficiently sized buffer to fit the xattr value, to
    hit an unexpected ERANGE error in the second call to getxattr(2). An
    uninitialized iounit field would sometimes force rsize to be smaller
    than the xattr value size in p9_client_read_once() and the 9P server in
    WSL refused to chunk up the READ on the attr_fid and, instead, returned
    ERANGE to the client. The virtfs server in QEMU seems happy to chunk up
    the READ and this problem goes undetected there.
    
    Link: https://lkml.kernel.org/r/20220710141402.803295-1-tyhicks@linux.microsoft.com
    Fixes: ebf46264a004 ("fs/9p: Add support user. xattr")
    Cc: stable@vger.kernel.org
    Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
    Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
    Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
    [tyhicks: Adjusted context due to:
     - Lack of fid refcounting introduced in v5.11 commit 6636b6dcc3db ("9p:
       add refcount to p9_fid struct")
     - Difference in how buffer sizes are specified v5.16 commit
       6e195b0f7c8e ("9p: fix a bunch of checkpatch warnings")
     - Reimplementation of the fidlist as an IDR in v4.19 commit
       f28cdf0430fc ("9p: Replace the fidlist with an IDR")]
    Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5f776b8b32fd7de7117459d5e7be4acb4510a6e5
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Mon Aug 1 13:52:07 2022 -0700

    Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm regression
    
    commit 332f1795ca202489c665a75e62e18ff6284de077 upstream.
    
    The patch d0be8347c623: "Bluetooth: L2CAP: Fix use-after-free caused
    by l2cap_chan_put" from Jul 21, 2022, leads to the following Smatch
    static checker warning:
    
            net/bluetooth/l2cap_core.c:1977 l2cap_global_chan_by_psm()
            error: we previously assumed 'c' could be null (see line 1996)
    
    Fixes: d0be8347c623 ("Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put")
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 127f323c4655ea6c633f235496c7e6abba372583
Author: Jose Alonso <joalonsof@gmail.com>
Date:   Mon Aug 8 08:35:04 2022 -0300

    Revert "net: usb: ax88179_178a needs FLAG_SEND_ZLP"
    
    commit 6fd2c17fb6e02a8c0ab51df1cfec82ce96b8e83d upstream.
    
    This reverts commit 36a15e1cb134c0395261ba1940762703f778438c.
    
    The usage of FLAG_SEND_ZLP causes problems to other firmware/hardware
    versions that have no issues.
    
    The FLAG_SEND_ZLP is not safe to use in this context.
    See:
    https://patchwork.ozlabs.org/project/netdev/patch/1270599787.8900.8.camel@Linuxdev4-laptop/#118378
    The original problem needs another way to solve.
    
    Fixes: 36a15e1cb134 ("net: usb: ax88179_178a needs FLAG_SEND_ZLP")
    Cc: stable@vger.kernel.org
    Reported-by: Ronald Wahl <ronald.wahl@raritan.com>
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216327
    Link: https://bugs.archlinux.org/task/75491
    Signed-off-by: Jose Alonso <joalonsof@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f5e61d9b4a699dd16f32d5f39eb1cf98d84c92ed
Author: Tony Battersby <tonyb@cybernetics.com>
Date:   Mon Jul 11 10:51:32 2022 -0400

    scsi: sg: Allow waiting for commands to complete on removed device
    
    commit 3455607fd7be10b449f5135c00dc306b85dc0d21 upstream.
    
    When a SCSI device is removed while in active use, currently sg will
    immediately return -ENODEV on any attempt to wait for active commands that
    were sent before the removal.  This is problematic for commands that use
    SG_FLAG_DIRECT_IO since the data buffer may still be in use by the kernel
    when userspace frees or reuses it after getting ENODEV, leading to
    corrupted userspace memory (in the case of READ-type commands) or corrupted
    data being sent to the device (in the case of WRITE-type commands).  This
    has been seen in practice when logging out of a iscsi_tcp session, where
    the iSCSI driver may still be processing commands after the device has been
    marked for removal.
    
    Change the policy to allow userspace to wait for active sg commands even
    when the device is being removed.  Return -ENODEV only when there are no
    more responses to read.
    
    Link: https://lore.kernel.org/r/5ebea46f-fe83-2d0b-233d-d0dcb362dd0a@cybernetics.com
    Cc: <stable@vger.kernel.org>
    Acked-by: Douglas Gilbert <dgilbert@interlog.com>
    Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2aa3bcb00558928fc0987b1346f9742ee91d3605
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue Jun 14 10:17:33 2022 -0700

    tcp: fix over estimation in sk_forced_mem_schedule()
    
    commit c4ee118561a0f74442439b7b5b486db1ac1ddfeb upstream.
    
    sk_forced_mem_schedule() has a bug similar to ones fixed
    in commit 7c80b038d23e ("net: fix sk_wmem_schedule() and
    sk_rmem_schedule() errors")
    
    While this bug has little chance to trigger in old kernels,
    we need to fix it before the following patch.
    
    Fixes: d83769a580f1 ("tcp: fix possible deadlock in tcp_send_fin()")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
    Reviewed-by: Shakeel Butt <shakeelb@google.com>
    Reviewed-by: Wei Wang <weiwan@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bcf0a450fbaabe7e14d71f885525805b4f86e855
Author: Vitaly Kuznetsov <vkuznets@redhat.com>
Date:   Wed Aug 10 23:26:55 2022 +0300

    KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast()
    
    commit 00b5f37189d24ac3ed46cb7f11742094778c46ce upstream
    
    When kvm_irq_delivery_to_apic_fast() is called with APIC_DEST_SELF
    shorthand, 'src' must not be NULL. Crash the VM with KVM_BUG_ON()
    instead of crashing the host.
    
    Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
    Message-Id: <20220325132140.25650-3-vkuznets@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Stefan Ghinea <stefan.ghinea@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a4bd692a950ada6d9757dbb78a6aea129ff8a943
Author: Vitaly Kuznetsov <vkuznets@redhat.com>
Date:   Wed Aug 10 23:26:54 2022 +0300

    KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq
    
    commit 7ec37d1cbe17d8189d9562178d8b29167fe1c31a upstream
    
    When KVM_CAP_HYPERV_SYNIC{,2} is activated, KVM already checks for
    irqchip_in_kernel() so normally SynIC irqs should never be set. It is,
    however,  possible for a misbehaving VMM to write to SYNIC/STIMER MSRs
    causing erroneous behavior.
    
    The immediate issue being fixed is that kvm_irq_delivery_to_apic()
    (kvm_irq_delivery_to_apic_fast()) crashes when called with
    'irq.shorthand = APIC_DEST_SELF' and 'src == NULL'.
    
    Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
    Message-Id: <20220325132140.25650-2-vkuznets@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Stefan Ghinea <stefan.ghinea@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2566c4cff2e75c3f85c6c7e932f8f30a9aec5a67
Author: Sean Christopherson <seanjc@google.com>
Date:   Wed Aug 10 23:26:53 2022 +0300

    KVM: Add infrastructure and macro to mark VM as bugged
    
    commit 0b8f11737cffc1a406d1134b58687abc29d76b52 upstream
    
    Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
    Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
    Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <3a0998645c328bf0895f1290e61821b70f048549.1625186503.git.isaku.yamahata@intel.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    [SG: Adjusted context for kernel version 4.14]
    Signed-off-by: Stefan Ghinea <stefan.ghinea@windriver.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c6fa71ae398b8d1e44263d8873ba88082a549a6c
Author: Qu Wenruo <wqu@suse.com>
Date:   Tue Jun 7 19:48:24 2022 +0800

    btrfs: reject log replay if there is unsupported RO compat flag
    
    commit dc4d31684974d140250f3ee612c3f0cab13b3146 upstream.
    
    [BUG]
    If we have a btrfs image with dirty log, along with an unsupported RO
    compatible flag:
    
    log_root                30474240
    ...
    compat_flags            0x0
    compat_ro_flags         0x40000003
                            ( FREE_SPACE_TREE |
                              FREE_SPACE_TREE_VALID |
                              unknown flag: 0x40000000 )
    
    Then even if we can only mount it RO, we will still cause metadata
    update for log replay:
    
      BTRFS info (device dm-1): flagging fs with big metadata feature
      BTRFS info (device dm-1): using free space tree
      BTRFS info (device dm-1): has skinny extents
      BTRFS info (device dm-1): start tree-log replay
    
    This is definitely against RO compact flag requirement.
    
    [CAUSE]
    RO compact flag only forces us to do RO mount, but we will still do log
    replay for plain RO mount.
    
    Thus this will result us to do log replay and update metadata.
    
    This can be very problematic for new RO compat flag, for example older
    kernel can not understand v2 cache, and if we allow metadata update on
    RO mount and invalidate/corrupt v2 cache.
    
    [FIX]
    Just reject the mount unless rescue=nologreplay is provided:
    
      BTRFS error (device dm-1): cannot replay dirty log with unsupport optional features (0x40000000), try rescue=nologreplay instead
    
    We don't want to set rescue=nologreply directly, as this would make the
    end user to read the old data, and cause confusion.
    
    Since the such case is really rare, we're mostly fine to just reject the
    mount with an error message, which also includes the proper workaround.
    
    CC: stable@vger.kernel.org #4.9+
    Signed-off-by: Qu Wenruo <wqu@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d0cce31f328fa10e7256f314e6e044e13cdf6814
Author: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Date:   Tue Aug 9 14:05:18 2022 -0300

    net_sched: cls_route: remove from list when handle is 0
    
    commit 9ad36309e2719a884f946678e0296be10f0bb4c1 upstream.
    
    When a route filter is replaced and the old filter has a 0 handle, the old
    one won't be removed from the hashtable, while it will still be freed.
    
    The test was there since before commit 1109c00547fc ("net: sched: RCU
    cls_route"), when a new filter was not allocated when there was an old one.
    The old filter was reused and the reinserting would only be necessary if an
    old filter was replaced. That was still wrong for the same case where the
    old handle was 0.
    
    Remove the old filter from the list independently from its handle value.
    
    This fixes CVE-2022-2588, also reported as ZDI-CAN-17440.
    
    Reported-by: Zhenpeng Lin <zplin@u.northwestern.edu>
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Reviewed-by: Kamal Mostafa <kamal@canonical.com>
    Cc: <stable@vger.kernel.org>
    Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
    Link: https://lore.kernel.org/r/20220809170518.164662-1-cascardo@canonical.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 90b006da40dd42285b24dd3c940d2c32aca9a70b
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Sun Jul 24 14:31:35 2022 -0400

    dm raid: fix address sanitizer warning in raid_status
    
    commit 1fbeea217d8f297fe0e0956a1516d14ba97d0396 upstream.
    
    There is this warning when using a kernel with the address sanitizer
    and running this testsuite:
    https://gitlab.com/cki-project/kernel-tests/-/tree/main/storage/swraid/scsi_raid
    
    ==================================================================
    BUG: KASAN: slab-out-of-bounds in raid_status+0x1747/0x2820 [dm_raid]
    Read of size 4 at addr ffff888079d2c7e8 by task lvcreate/13319
    CPU: 0 PID: 13319 Comm: lvcreate Not tainted 5.18.0-0.rc3.<snip> #1
    Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
    Call Trace:
     <TASK>
     dump_stack_lvl+0x6a/0x9c
     print_address_description.constprop.0+0x1f/0x1e0
     print_report.cold+0x55/0x244
     kasan_report+0xc9/0x100
     raid_status+0x1747/0x2820 [dm_raid]
     dm_ima_measure_on_table_load+0x4b8/0xca0 [dm_mod]
     table_load+0x35c/0x630 [dm_mod]
     ctl_ioctl+0x411/0x630 [dm_mod]
     dm_ctl_ioctl+0xa/0x10 [dm_mod]
     __x64_sys_ioctl+0x12a/0x1a0
     do_syscall_64+0x5b/0x80
    
    The warning is caused by reading conf->max_nr_stripes in raid_status. The
    code in raid_status reads mddev->private, casts it to struct r5conf and
    reads the entry max_nr_stripes.
    
    However, if we have different raid type than 4/5/6, mddev->private
    doesn't point to struct r5conf; it may point to struct r0conf, struct
    r1conf, struct r10conf or struct mpconf. If we cast a pointer to one
    of these structs to struct r5conf, we will be reading invalid memory
    and KASAN warns about it.
    
    Fix this bug by reading struct r5conf only if raid type is 4, 5 or 6.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c2f075e729636a44e98d9722e3852c2fa6fa49b6
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Sun Jul 24 14:33:52 2022 -0400

    dm raid: fix address sanitizer warning in raid_resume
    
    commit 7dad24db59d2d2803576f2e3645728866a056dab upstream.
    
    There is a KASAN warning in raid_resume when running the lvm test
    lvconvert-raid.sh. The reason for the warning is that mddev->raid_disks
    is greater than rs->raid_disks, so the loop touches one entry beyond
    the allocated length.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5a0a894ac6966290410eb700c5f488f11f771ccd
Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Date:   Tue Jul 5 11:26:35 2022 +0300

    intel_th: pci: Add Meteor Lake-P support
    
    commit 802a9a0b1d91274ef10d9fe429b4cc1e8c200aef upstream.
    
    Add support for the Trace Hub in Meteor Lake-P.
    
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Cc: stable <stable@kernel.org>
    Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Link: https://lore.kernel.org/r/20220705082637.59979-5-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c77aad16a1d5257a1786e8867495117551539ba9
Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Date:   Tue Jul 5 11:26:36 2022 +0300

    intel_th: pci: Add Raptor Lake-S PCH support
    
    commit 23e2de5826e2fc4dd43e08bab3a2ea1a5338b063 upstream.
    
    Add support for the Trace Hub in Raptor Lake-S PCH.
    
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Cc: stable <stable@kernel.org>
    Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Link: https://lore.kernel.org/r/20220705082637.59979-6-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5531f3d0bd5d46ba8f74259e48cae0175ebe90ed
Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Date:   Tue Jul 5 11:26:37 2022 +0300

    intel_th: pci: Add Raptor Lake-S CPU support
    
    commit ff46a601afc5a66a81c3945b83d0a2caeb88e8bc upstream.
    
    Add support for the Trace Hub in Raptor Lake-S CPU.
    
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Cc: stable <stable@kernel.org>
    Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Link: https://lore.kernel.org/r/20220705082637.59979-7-alexander.shishkin@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 720508f1da0e9e00d799314bb035371e99d9c364
Author: Baokun Li <libaokun1@huawei.com>
Date:   Thu Jun 16 10:13:58 2022 +0800

    ext4: correct the misjudgment in ext4_iget_extra_inode
    
    commit fd7e672ea98b95b9d4c9dae316639f03c16a749d upstream.
    
    Use the EXT4_INODE_HAS_XATTR_SPACE macro to more accurately
    determine whether the inode have xattr space.
    
    Cc: stable@kernel.org
    Signed-off-by: Baokun Li <libaokun1@huawei.com>
    Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220616021358.2504451-5-libaokun1@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 48b5a08e9fa285b1e8fb7ca154629904c37dcd95
Author: Baokun Li <libaokun1@huawei.com>
Date:   Thu Jun 16 10:13:57 2022 +0800

    ext4: correct max_inline_xattr_value_size computing
    
    commit c9fd167d57133c5b748d16913c4eabc55e531c73 upstream.
    
    If the ext4 inode does not have xattr space, 0 is returned in the
    get_max_inline_xattr_value_size function. Otherwise, the function returns
    a negative value when the inode does not contain EXT4_STATE_XATTR.
    
    Cc: stable@kernel.org
    Signed-off-by: Baokun Li <libaokun1@huawei.com>
    Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220616021358.2504451-4-libaokun1@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02f1637ba4181e272430a03e976f55f06f0bda40
Author: Eric Whitney <enwlinux@gmail.com>
Date:   Wed Jun 15 12:05:30 2022 -0400

    ext4: fix extent status tree race in writeback error recovery path
    
    commit 7f0d8e1d607c1a4fa9a27362a108921d82230874 upstream.
    
    A race can occur in the unlikely event ext4 is unable to allocate a
    physical cluster for a delayed allocation in a bigalloc file system
    during writeback.  Failure to allocate a cluster forces error recovery
    that includes a call to mpage_release_unused_pages().  That function
    removes any corresponding delayed allocated blocks from the extent
    status tree.  If a new delayed write is in progress on the same cluster
    simultaneously, resulting in the addition of an new extent containing
    one or more blocks in that cluster to the extent status tree, delayed
    block accounting can be thrown off if that delayed write then encounters
    a similar cluster allocation failure during future writeback.
    
    Write lock the i_data_sem in mpage_release_unused_pages() to fix this
    problem.  Ext4's block/cluster accounting code for bigalloc relies on
    i_data_sem for mutual exclusion, as is found in the delayed write path,
    and the locking in mpage_release_unused_pages() is missing.
    
    Cc: stable@kernel.org
    Reported-by: Ye Bin <yebin10@huawei.com>
    Signed-off-by: Eric Whitney <enwlinux@gmail.com>
    Link: https://lore.kernel.org/r/20220615160530.1928801-1-enwlinux@gmail.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 653187c5dfa078b2725824ea89b929525cd1a5a6
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Wed Jun 29 00:00:25 2022 -0400

    ext4: update s_overhead_clusters in the superblock during an on-line resize
    
    commit de394a86658ffe4e89e5328fd4993abfe41b7435 upstream.
    
    When doing an online resize, the on-disk superblock on-disk wasn't
    updated.  This means that when the file system is unmounted and
    remounted, and the on-disk overhead value is non-zero, this would
    result in the results of statfs(2) to be incorrect.
    
    This was partially fixed by Commits 10b01ee92df5 ("ext4: fix overhead
    calculation to account for the reserved gdt blocks"), 85d825dbf489
    ("ext4: force overhead calculation if the s_overhead_cluster makes no
    sense"), and eb7054212eac ("ext4: update the cached overhead value in
    the superblock").
    
    However, since it was too expensive to forcibly recalculate the
    overhead for bigalloc file systems at every mount, this didn't fix the
    problem for bigalloc file systems.  This commit should address the
    problem when resizing file systems with the bigalloc feature enabled.
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Link: https://lore.kernel.org/r/20220629040026.112371-1-tytso@mit.edu
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fb8b3aa9dae22b2184d31fd63ed44d3215fcb41f
Author: Baokun Li <libaokun1@huawei.com>
Date:   Thu Jun 16 10:13:56 2022 +0800

    ext4: fix use-after-free in ext4_xattr_set_entry
    
    commit 67d7d8ad99beccd9fe92d585b87f1760dc9018e3 upstream.
    
    Hulk Robot reported a issue:
    ==================================================================
    BUG: KASAN: use-after-free in ext4_xattr_set_entry+0x18ab/0x3500
    Write of size 4105 at addr ffff8881675ef5f4 by task syz-executor.0/7092
    
    CPU: 1 PID: 7092 Comm: syz-executor.0 Not tainted 4.19.90-dirty #17
    Call Trace:
    [...]
     memcpy+0x34/0x50 mm/kasan/kasan.c:303
     ext4_xattr_set_entry+0x18ab/0x3500 fs/ext4/xattr.c:1747
     ext4_xattr_ibody_inline_set+0x86/0x2a0 fs/ext4/xattr.c:2205
     ext4_xattr_set_handle+0x940/0x1300 fs/ext4/xattr.c:2386
     ext4_xattr_set+0x1da/0x300 fs/ext4/xattr.c:2498
     __vfs_setxattr+0x112/0x170 fs/xattr.c:149
     __vfs_setxattr_noperm+0x11b/0x2a0 fs/xattr.c:180
     __vfs_setxattr_locked+0x17b/0x250 fs/xattr.c:238
     vfs_setxattr+0xed/0x270 fs/xattr.c:255
     setxattr+0x235/0x330 fs/xattr.c:520
     path_setxattr+0x176/0x190 fs/xattr.c:539
     __do_sys_lsetxattr fs/xattr.c:561 [inline]
     __se_sys_lsetxattr fs/xattr.c:557 [inline]
     __x64_sys_lsetxattr+0xc2/0x160 fs/xattr.c:557
     do_syscall_64+0xdf/0x530 arch/x86/entry/common.c:298
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    RIP: 0033:0x459fe9
    RSP: 002b:00007fa5e54b4c08 EFLAGS: 00000246 ORIG_RAX: 00000000000000bd
    RAX: ffffffffffffffda RBX: 000000000051bf60 RCX: 0000000000459fe9
    RDX: 00000000200003c0 RSI: 0000000020000180 RDI: 0000000020000140
    RBP: 000000000051bf60 R08: 0000000000000001 R09: 0000000000000000
    R10: 0000000000001009 R11: 0000000000000246 R12: 0000000000000000
    R13: 00007ffc73c93fc0 R14: 000000000051bf60 R15: 00007fa5e54b4d80
    [...]
    ==================================================================
    
    Above issue may happen as follows:
    -------------------------------------
    ext4_xattr_set
      ext4_xattr_set_handle
        ext4_xattr_ibody_find
          >> s->end < s->base
          >> no EXT4_STATE_XATTR
          >> xattr_check_inode is not executed
        ext4_xattr_ibody_set
          ext4_xattr_set_entry
           >> size_t min_offs = s->end - s->base
           >> UAF in memcpy
    
    we can easily reproduce this problem with the following commands:
        mkfs.ext4 -F /dev/sda
        mount -o debug_want_extra_isize=128 /dev/sda /mnt
        touch /mnt/file
        setfattr -n user.cat -v `seq -s z 4096|tr -d '[:digit:]'` /mnt/file
    
    In ext4_xattr_ibody_find, we have the following assignment logic:
      header = IHDR(inode, raw_inode)
             = raw_inode + EXT4_GOOD_OLD_INODE_SIZE + i_extra_isize
      is->s.base = IFIRST(header)
                 = header + sizeof(struct ext4_xattr_ibody_header)
      is->s.end = raw_inode + s_inode_size
    
    In ext4_xattr_set_entry
      min_offs = s->end - s->base
               = s_inode_size - EXT4_GOOD_OLD_INODE_SIZE - i_extra_isize -
                 sizeof(struct ext4_xattr_ibody_header)
      last = s->first
      free = min_offs - ((void *)last - s->base) - sizeof(__u32)
           = s_inode_size - EXT4_GOOD_OLD_INODE_SIZE - i_extra_isize -
             sizeof(struct ext4_xattr_ibody_header) - sizeof(__u32)
    
    In the calculation formula, all values except s_inode_size and
    i_extra_size are fixed values. When i_extra_size is the maximum value
    s_inode_size - EXT4_GOOD_OLD_INODE_SIZE, min_offs is -4 and free is -8.
    The value overflows. As a result, the preceding issue is triggered when
    memcpy is executed.
    
    Therefore, when finding xattr or setting xattr, check whether
    there is space for storing xattr in the inode to resolve this issue.
    
    Cc: stable@kernel.org
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Baokun Li <libaokun1@huawei.com>
    Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220616021358.2504451-3-libaokun1@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 57e3a559dadc9fecce9baa55b78181d1ad261aad
Author: Lukas Czerner <lczerner@redhat.com>
Date:   Mon Jul 4 16:27:21 2022 +0200

    ext4: make sure ext4_append() always allocates new block
    
    commit b8a04fe77ef1360fbf73c80fddbdfeaa9407ed1b upstream.
    
    ext4_append() must always allocate a new block, otherwise we run the
    risk of overwriting existing directory block corrupting the directory
    tree in the process resulting in all manner of problems later on.
    
    Add a sanity check to see if the logical block is already allocated and
    error out if it is.
    
    Cc: stable@kernel.org
    Signed-off-by: Lukas Czerner <lczerner@redhat.com>
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Link: https://lore.kernel.org/r/20220704142721.157985-2-lczerner@redhat.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f217b1ccb178475192e6a516fab7230f51ddae94
Author: Baokun Li <libaokun1@huawei.com>
Date:   Thu Jun 16 10:13:55 2022 +0800

    ext4: add EXT4_INODE_HAS_XATTR_SPACE macro in xattr.h
    
    commit 179b14152dcb6a24c3415200603aebca70ff13af upstream.
    
    When adding an xattr to an inode, we must ensure that the inode_size is
    not less than EXT4_GOOD_OLD_INODE_SIZE + extra_isize + pad. Otherwise,
    the end position may be greater than the start position, resulting in UAF.
    
    Signed-off-by: Baokun Li <libaokun1@huawei.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
    Link: https://lore.kernel.org/r/20220616021358.2504451-2-libaokun1@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dc6033a7761254e5a5ba7df36b64db787a53313c
Author: David Collins <quic_collinsd@quicinc.com>
Date:   Mon Jun 27 16:55:12 2022 -0700

    spmi: trace: fix stack-out-of-bound access in SPMI tracing functions
    
    commit 2af28b241eea816e6f7668d1954f15894b45d7e3 upstream.
    
    trace_spmi_write_begin() and trace_spmi_read_end() both call
    memcpy() with a length of "len + 1".  This leads to one extra
    byte being read beyond the end of the specified buffer.  Fix
    this out-of-bound memory access by using a length of "len"
    instead.
    
    Here is a KASAN log showing the issue:
    
    BUG: KASAN: stack-out-of-bounds in trace_event_raw_event_spmi_read_end+0x1d0/0x234
    Read of size 2 at addr ffffffc0265b7540 by task thermal@2.0-ser/1314
    ...
    Call trace:
     dump_backtrace+0x0/0x3e8
     show_stack+0x2c/0x3c
     dump_stack_lvl+0xdc/0x11c
     print_address_description+0x74/0x384
     kasan_report+0x188/0x268
     kasan_check_range+0x270/0x2b0
     memcpy+0x90/0xe8
     trace_event_raw_event_spmi_read_end+0x1d0/0x234
     spmi_read_cmd+0x294/0x3ac
     spmi_ext_register_readl+0x84/0x9c
     regmap_spmi_ext_read+0x144/0x1b0 [regmap_spmi]
     _regmap_raw_read+0x40c/0x754
     regmap_raw_read+0x3a0/0x514
     regmap_bulk_read+0x418/0x494
     adc5_gen3_poll_wait_hs+0xe8/0x1e0 [qcom_spmi_adc5_gen3]
     ...
     __arm64_sys_read+0x4c/0x60
     invoke_syscall+0x80/0x218
     el0_svc_common+0xec/0x1c8
     ...
    
    addr ffffffc0265b7540 is located in stack of task thermal@2.0-ser/1314 at offset 32 in frame:
     adc5_gen3_poll_wait_hs+0x0/0x1e0 [qcom_spmi_adc5_gen3]
    
    this frame has 1 object:
     [32, 33) 'status'
    
    Memory state around the buggy address:
     ffffffc0265b7400: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
     ffffffc0265b7480: 04 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
    >ffffffc0265b7500: 00 00 00 00 f1 f1 f1 f1 01 f3 f3 f3 00 00 00 00
                                               ^
     ffffffc0265b7580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     ffffffc0265b7600: f1 f1 f1 f1 01 f2 07 f2 f2 f2 01 f3 00 00 00 00
    ==================================================================
    
    Fixes: a9fce374815d ("spmi: add command tracepoints for SPMI")
    Cc: stable@vger.kernel.org
    Reviewed-by: Stephen Boyd <sboyd@kernel.org>
    Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: David Collins <quic_collinsd@quicinc.com>
    Link: https://lore.kernel.org/r/20220627235512.2272783-1-quic_collinsd@quicinc.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6597441b864088d2a83eb7741dbe759a142f2673
Author: Alexander Lobakin <alexandr.lobakin@intel.com>
Date:   Fri Jul 15 17:15:36 2022 +0200

    x86/olpc: fix 'logical not is only applied to the left hand side'
    
    commit 3a2ba42cbd0b669ce3837ba400905f93dd06c79f upstream.
    
    The bitops compile-time optimization series revealed one more
    problem in olpc-xo1-sci.c:send_ebook_state(), resulted in GCC
    warnings:
    
    arch/x86/platform/olpc/olpc-xo1-sci.c: In function 'send_ebook_state':
    arch/x86/platform/olpc/olpc-xo1-sci.c:83:63: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
       83 |         if (!!test_bit(SW_TABLET_MODE, ebook_switch_idev->sw) == state)
          |                                                               ^~
    arch/x86/platform/olpc/olpc-xo1-sci.c:83:13: note: add parentheses around left hand side expression to silence this warning
    
    Despite this code working as intended, this redundant double
    negation of boolean value, together with comparing to `char`
    with no explicit conversion to bool, makes compilers think
    the author made some unintentional logical mistakes here.
    Make it the other way around and negate the char instead
    to silence the warnings.
    
    Fixes: d2aa37411b8e ("x86/olpc/xo1/sci: Produce wakeup events for buttons and switches")
    Cc: stable@vger.kernel.org # 3.5+
    Reported-by: Guenter Roeck <linux@roeck-us.net>
    Reported-by: kernel test robot <lkp@intel.com>
    Reviewed-and-tested-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 038a358bac9fc01ec168ab4a1d87720d39653ba5
Author: Steffen Maier <maier@linux.ibm.com>
Date:   Fri Jul 29 18:25:29 2022 +0200

    scsi: zfcp: Fix missing auto port scan and thus missing target ports
    
    commit 4da8c5f76825269f28d6a89fa752934a4bcb6dfa upstream.
    
    Case (1):
      The only waiter on wka_port->completion_wq is zfcp_fc_wka_port_get()
      trying to open a WKA port. As such it should only be woken up by WKA port
      *open* responses, not by WKA port close responses.
    
    Case (2):
      A close WKA port response coming in just after having sent a new open WKA
      port request and before blocking for the open response with wait_event()
      in zfcp_fc_wka_port_get() erroneously renders the wait_event a NOP
      because the close handler overwrites wka_port->status. Hence the
      wait_event condition is erroneously true and it does not enter blocking
      state.
    
    With non-negligible probability, the following time space sequence happens
    depending on timing without this fix:
    
    user process        ERP thread zfcp work queue tasklet system work queue
    ============        ========== =============== ======= =================
    $ echo 1 > online
    zfcp_ccw_set_online
    zfcp_ccw_activate
    zfcp_erp_adapter_reopen
    msleep scan backoff zfcp_erp_strategy
    |                   ...
    |                   zfcp_erp_action_cleanup
    |                   ...
    |                   queue delayed scan_work
    |                   queue ns_up_work
    |                              ns_up_work:
    |                              zfcp_fc_wka_port_get
    |                               open wka request
    |                                              open response
    |                              GSPN FC-GS
    |                              RSPN FC-GS [NPIV-only]
    |                              zfcp_fc_wka_port_put
    |                               (--wka->refcount==0)
    |                               sched delayed wka->work
    |
    ~~~Case (1)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    zfcp_erp_wait
    flush scan_work
    |                                                      wka->work:
    |                                                      wka->status=CLOSING
    |                                                      close wka request
    |                              scan_work:
    |                              zfcp_fc_wka_port_get
    |                               (wka->status==CLOSING)
    |                               wka->status=OPENING
    |                               open wka request
    |                               wait_event
    |                               |              close response
    |                               |              wka->status=OFFLINE
    |                               |              wake_up /*WRONG*/
    ~~~Case (2)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |                                                      wka->work:
    |                                                      wka->status=CLOSING
    |                                                      close wka request
    zfcp_erp_wait
    flush scan_work
    |                              scan_work:
    |                              zfcp_fc_wka_port_get
    |                               (wka->status==CLOSING)
    |                               wka->status=OPENING
    |                               open wka request
    |                                              close response
    |                                              wka->status=OFFLINE
    |                                              wake_up /*WRONG&NOP*/
    |                               wait_event /*NOP*/
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |                               (wka->status!=ONLINE)
    |                               return -EIO
    |                              return early
                                                   open response
                                                   wka->status=ONLINE
                                                   wake_up /*NOP*/
    
    So we erroneously end up with no automatic port scan. This is a big problem
    when it happens during boot. The timing is influenced by v3.19 commit
    18f87a67e6d6 ("zfcp: auto port scan resiliency").
    
    Fix it by fully mutually excluding zfcp_fc_wka_port_get() and
    zfcp_fc_wka_port_offline(). For that to work, we make the latter block
    until we got the response for a close WKA port. In order not to penalize
    the system workqueue, we move wka_port->work to our own adapter workqueue.
    Note that before v2.6.30 commit 828bc1212a68 ("[SCSI] zfcp: Set WKA-port to
    offline on adapter deactivation"), zfcp did block in
    zfcp_fc_wka_port_offline() as well, but with a different condition.
    
    While at it, make non-functional cleanups to improve code reading in
    zfcp_fc_wka_port_get(). If we cannot send the WKA port open request, don't
    rely on the subsequent wait_event condition to immediately let this case
    pass without blocking. Also don't want to rely on the additional condition
    handling the refcount to be skipped just to finally return with -EIO.
    
    Link: https://lore.kernel.org/r/20220729162529.1620730-1-maier@linux.ibm.com
    Fixes: 5ab944f97e09 ("[SCSI] zfcp: attach and release SAN nameserver port on demand")
    Cc: <stable@vger.kernel.org> #v2.6.28+
    Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
    Signed-off-by: Steffen Maier <maier@linux.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 574912261528589012b61f82d368256247c3a5a8
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Thu Aug 4 20:41:25 2022 +0800

    video: fbdev: s3fb: Check the size of screen before memset_io()
    
    [ Upstream commit 6ba592fa014f21f35a8ee8da4ca7b95a018f13e8 ]
    
    In the function s3fb_set_par(), the value of 'screen_size' is
    calculated by the user input. If the user provides the improper value,
    the value of 'screen_size' may larger than 'info->screen_size', which
    may cause the following bug:
    
    [   54.083733] BUG: unable to handle page fault for address: ffffc90003000000
    [   54.083742] #PF: supervisor write access in kernel mode
    [   54.083744] #PF: error_code(0x0002) - not-present page
    [   54.083760] RIP: 0010:memset_orig+0x33/0xb0
    [   54.083782] Call Trace:
    [   54.083788]  s3fb_set_par+0x1ec6/0x4040
    [   54.083806]  fb_set_var+0x604/0xeb0
    [   54.083836]  do_fb_ioctl+0x234/0x670
    
    Fix the this by checking the value of 'screen_size' before memset_io().
    
    Fixes: a268422de8bf ("fbdev driver for S3 Trio/Virge")
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4a20c5510aa2c031a096a58deb356e91609781c9
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Thu Aug 4 20:41:24 2022 +0800

    video: fbdev: arkfb: Check the size of screen before memset_io()
    
    [ Upstream commit 96b550971c65d54d64728d8ba973487878a06454 ]
    
    In the function arkfb_set_par(), the value of 'screen_size' is
    calculated by the user input. If the user provides the improper value,
    the value of 'screen_size' may larger than 'info->screen_size', which
    may cause the following bug:
    
    [  659.399066] BUG: unable to handle page fault for address: ffffc90003000000
    [  659.399077] #PF: supervisor write access in kernel mode
    [  659.399079] #PF: error_code(0x0002) - not-present page
    [  659.399094] RIP: 0010:memset_orig+0x33/0xb0
    [  659.399116] Call Trace:
    [  659.399122]  arkfb_set_par+0x143f/0x24c0
    [  659.399130]  fb_set_var+0x604/0xeb0
    [  659.399161]  do_fb_ioctl+0x234/0x670
    [  659.399189]  fb_ioctl+0xdd/0x130
    
    Fix the this by checking the value of 'screen_size' before memset_io().
    
    Fixes: 681e14730c73 ("arkfb: new framebuffer driver for ARK Logic cards")
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 73280a184aa2e1a625ce54ce761042955cc79cd0
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Thu Aug 4 20:41:23 2022 +0800

    video: fbdev: vt8623fb: Check the size of screen before memset_io()
    
    [ Upstream commit ec0754c60217248fa77cc9005d66b2b55200ac06 ]
    
    In the function vt8623fb_set_par(), the value of 'screen_size' is
    calculated by the user input. If the user provides the improper value,
    the value of 'screen_size' may larger than 'info->screen_size', which
    may cause the following bug:
    
    [  583.339036] BUG: unable to handle page fault for address: ffffc90005000000
    [  583.339049] #PF: supervisor write access in kernel mode
    [  583.339052] #PF: error_code(0x0002) - not-present page
    [  583.339074] RIP: 0010:memset_orig+0x33/0xb0
    [  583.339110] Call Trace:
    [  583.339118]  vt8623fb_set_par+0x11cd/0x21e0
    [  583.339146]  fb_set_var+0x604/0xeb0
    [  583.339181]  do_fb_ioctl+0x234/0x670
    [  583.339209]  fb_ioctl+0xdd/0x130
    
    Fix the this by checking the value of 'screen_size' before memset_io().
    
    Fixes: 558b7bd86c32 ("vt8623fb: new framebuffer driver for VIA VT8623")
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 65dad30796ee1bed0c349efb790403cf870a5e41
Author: Florian Fainelli <f.fainelli@gmail.com>
Date:   Mon Jul 25 10:37:54 2022 -0700

    tools/thermal: Fix possible path truncations
    
    [ Upstream commit 6c58cf40e3a1d2f47c09d3489857e9476316788a ]
    
    A build with -D_FORTIFY_SOURCE=2 enabled will produce the following warnings:
    
    sysfs.c:63:30: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 255 [-Wformat-truncation=]
      snprintf(filepath, 256, "%s/%s", path, filename);
                                  ^~
    Bump up the buffer to PATH_MAX which is the limit and account for all of
    the possible NUL and separators that could lead to exceeding the
    allocated buffer sizes.
    
    Fixes: 94f69966faf8 ("tools/thermal: Introduce tmon, a tool for thermal subsystem")
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 76b3f0a0b56e53a960a14624a0f48b3d94b5e7e7
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Wed Aug 3 17:23:12 2022 +0800

    video: fbdev: arkfb: Fix a divide-by-zero bug in ark_set_pixclock()
    
    [ Upstream commit 2f1c4523f7a3aaabe7e53d3ebd378292947e95c8 ]
    
    Since the user can control the arguments of the ioctl() from the user
    space, under special arguments that may result in a divide-by-zero bug
    in:
      drivers/video/fbdev/arkfb.c:784: ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul);
    with hdiv=1, pixclock=1 and hmul=2 you end up with (1*1)/2 = (int) 0.
    and then in:
      drivers/video/fbdev/arkfb.c:504: rv = dac_set_freq(par->dac, 0, 1000000000 / pixclock);
    we'll get a division-by-zero.
    
    The following log can reveal it:
    
    divide error: 0000 [#1] PREEMPT SMP KASAN PTI
    RIP: 0010:ark_set_pixclock drivers/video/fbdev/arkfb.c:504 [inline]
    RIP: 0010:arkfb_set_par+0x10fc/0x24c0 drivers/video/fbdev/arkfb.c:784
    Call Trace:
     fb_set_var+0x604/0xeb0 drivers/video/fbdev/core/fbmem.c:1034
     do_fb_ioctl+0x234/0x670 drivers/video/fbdev/core/fbmem.c:1110
     fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1189
    
    Fix this by checking the argument of ark_set_pixclock() first.
    
    Fixes: 681e14730c73 ("arkfb: new framebuffer driver for ARK Logic cards")
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 26baff5a7d748211eea15ef7a5779747eb2cbed4
Author: Siddh Raman Pant <code@siddh.me>
Date:   Sun Jul 31 21:39:13 2022 +0530

    x86/numa: Use cpumask_available instead of hardcoded NULL check
    
    [ Upstream commit 625395c4a0f4775e0fe00f616888d2e6c1ba49db ]
    
    GCC-12 started triggering a new warning:
    
      arch/x86/mm/numa.c: In function ‘cpumask_of_node’:
      arch/x86/mm/numa.c:916:39: warning: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Waddress]
        916 |         if (node_to_cpumask_map[node] == NULL) {
            |                                       ^~
    
    node_to_cpumask_map is of type cpumask_var_t[].
    
    When CONFIG_CPUMASK_OFFSTACK is set, cpumask_var_t is typedef'd to a
    pointer for dynamic allocation, else to an array of one element. The
    "wicked game" can be checked on line 700 of include/linux/cpumask.h.
    
    The original code in debug_cpumask_set_cpu() and cpumask_of_node() were
    probably written by the original authors with CONFIG_CPUMASK_OFFSTACK=y
    (i.e. dynamic allocation) in mind, checking if the cpumask was available
    via a direct NULL check.
    
    When CONFIG_CPUMASK_OFFSTACK is not set, GCC gives the above warning
    while compiling the kernel.
    
    Fix that by using cpumask_available(), which does the NULL check when
    CONFIG_CPUMASK_OFFSTACK is set, otherwise returns true. Use it wherever
    such checks are made.
    
    Conditional definitions of cpumask_available() can be found along with
    the definition of cpumask_var_t. Check the cpumask.h reference mentioned
    above.
    
    Fixes: c032ef60d1aa ("cpumask: convert node_to_cpumask_map[] to cpumask_var_t")
    Fixes: de2d9445f162 ("x86: Unify node_to_cpumask_map handling between 32 and 64bit")
    Signed-off-by: Siddh Raman Pant <code@siddh.me>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/r/20220731160913.632092-1-code@siddh.me
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fddac33133461e5d1beeddde6d754ab43697e43f
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Tue Aug 2 15:13:22 2022 -0300

    genelf: Use HAVE_LIBCRYPTO_SUPPORT, not the never defined HAVE_LIBCRYPTO
    
    [ Upstream commit 91cea6be90e436c55cde8770a15e4dac9d3032d0 ]
    
    When genelf was introduced it tested for HAVE_LIBCRYPTO not
    HAVE_LIBCRYPTO_SUPPORT, which is the define the feature test for openssl
    defines, fix it.
    
    This also adds disables the deprecation warning, someone has to fix this
    to build with openssl 3.0 before the warning becomes a hard error.
    
    Fixes: 9b07e27f88b9cd78 ("perf inject: Add jitdump mmap injection support")
    Reported-by: 谭梓煊 <tanzixuan.me@gmail.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Andrii Nakryiko <andrii@kernel.org>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: John Fastabend <john.fastabend@gmail.com>
    Cc: KP Singh <kpsingh@kernel.org>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Cc: Nick Terrell <terrelln@fb.com>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Stephane Eranian <eranian@google.com>
    Link: http://lore.kernel.org/lkml/YulpPqXSOG0Q4J1o@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1ed2ab5d9e8f1e1207ee641ccf52a6547637bcfe
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Tue Aug 2 20:38:32 2022 +1000

    powerpc/pci: Fix PHB numbering when using opal-phbid
    
    [ Upstream commit f4b39e88b42d13366b831270306326b5c20971ca ]
    
    The recent change to the PHB numbering logic has a logic error in the
    handling of "ibm,opal-phbid".
    
    When an "ibm,opal-phbid" property is present, &prop is written to and
    ret is set to zero.
    
    The following call to of_alias_get_id() is skipped because ret == 0.
    
    But then the if (ret >= 0) is true, and the body of that if statement
    sets prop = ret which throws away the value that was just read from
    "ibm,opal-phbid".
    
    Fix the logic by only doing the ret >= 0 check in the of_alias_get_id()
    case.
    
    Fixes: 0fe1e96fef0a ("powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias")
    Reviewed-by: Pali Rohár <pali@kernel.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220802105723.1055178-1-mpe@ellerman.id.au
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4262b6eb057d86c7829168c541654fe0d48fdac8
Author: Chen Zhongjin <chenzhongjin@huawei.com>
Date:   Mon Aug 1 11:37:19 2022 +0800

    kprobes: Forbid probing on trampoline and BPF code areas
    
    [ Upstream commit 28f6c37a2910f565b4f5960df52b2eccae28c891 ]
    
    kernel_text_address() treats ftrace_trampoline, kprobe_insn_slot
    and bpf_text_address as valid kprobe addresses - which is not ideal.
    
    These text areas are removable and changeable without any notification
    to kprobes, and probing on them can trigger unexpected behavior:
    
      https://lkml.org/lkml/2022/7/26/1148
    
    Considering that jump_label and static_call text are already
    forbiden to probe, kernel_text_address() should be replaced with
    core_kernel_text() and is_module_text_address() to check other text
    areas which are unsafe to kprobe.
    
    [ mingo: Rewrote the changelog. ]
    
    Fixes: 5b485629ba0d ("kprobes, extable: Identify kprobes trampolines as kernel text area")
    Fixes: 74451e66d516 ("bpf: make jited programs visible in traces")
    Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Link: https://lore.kernel.org/r/20220801033719.228248-1-chenzhongjin@huawei.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6263ec8032c411b8ef6b7f00198cb18c855ee6cb
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Sun Jun 5 10:51:29 2022 +0400

    powerpc/cell/axon_msi: Fix refcount leak in setup_msi_msg_address
    
    [ Upstream commit df5d4b616ee76abc97e5bd348e22659c2b095b1c ]
    
    of_get_next_parent() returns a node pointer with refcount incremented,
    we should use of_node_put() on it when not need anymore.
    Add missing of_node_put() in the error path to avoid refcount leak.
    
    Fixes: ce21b3c9648a ("[CELL] add support for MSI on Axon-based Cell systems")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220605065129.63906-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5ed9709d262bf026b2ff64979fbfe0f496287588
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Sun Jun 5 09:32:23 2022 +0400

    powerpc/xive: Fix refcount leak in xive_get_max_prio
    
    [ Upstream commit 255b650cbec6849443ce2e0cdd187fd5e61c218c ]
    
    of_find_node_by_path() returns a node pointer with
    refcount incremented, we should use of_node_put() on it when done.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: eac1e731b59e ("powerpc/xive: guest exploitation of the XIVE interrupt controller")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220605053225.56125-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 43584490ee6c8a104797444af6bf89d0dafe95c0
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Fri Jun 3 16:15:42 2022 +0400

    powerpc/spufs: Fix refcount leak in spufs_init_isolated_loader
    
    [ Upstream commit 6ac059dacffa8ab2f7798f20e4bd3333890c541c ]
    
    of_find_node_by_path() returns remote device nodepointer with
    refcount incremented, we should use of_node_put() on it when done.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: 0afacde3df4c ("[POWERPC] spufs: allow isolated mode apps by starting the SPE loader")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220603121543.22884-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a79e4395619c926ea7e828b2023c0fbe2776385b
Author: Pali Rohár <pali@kernel.org>
Date:   Wed Jul 6 12:21:48 2022 +0200

    powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias
    
    [ Upstream commit 0fe1e96fef0a5c53b4c0d1500d356f3906000f81 ]
    
    Other Linux architectures use DT property 'linux,pci-domain' for
    specifying fixed PCI domain of PCI controller specified in Device-Tree.
    
    And lot of Freescale powerpc boards have defined numbered pci alias in
    Device-Tree for every PCIe controller which number specify preferred PCI
    domain.
    
    So prefer usage of DT property 'linux,pci-domain' (via function
    of_get_pci_domain_nr()) and DT pci alias (via function
    of_alias_get_id()) on powerpc architecture for assigning PCI domain to
    PCI controller.
    
    Fixes: 63a72284b159 ("powerpc/pci: Assign fixed PHB number based on device-tree properties")
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220706102148.5060-2-pali@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 396e4c2f6c9bf6262dca9d6f571c789fab63a623
Author: Rustam Subkhankulov <subkhankulov@ispras.ru>
Date:   Mon Jul 18 15:43:43 2022 +0300

    video: fbdev: sis: fix typos in SiS_GetModeID()
    
    [ Upstream commit 3eb8fccc244bfb41a7961969e4db280d44911226 ]
    
    The second operand of a '&&' operator has no impact on expression
    result for cases 400 and 512 in SiS_GetModeID().
    
    Judging by the logic and the names of the variables, in both cases a
    typo was made.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Signed-off-by: Rustam Subkhankulov <subkhankulov@ispras.ru>
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2688df86c02da6bdc9866b62d974e169a2678883
Author: Liang He <windhl@126.com>
Date:   Tue Jul 19 16:25:46 2022 +0800

    video: fbdev: amba-clcd: Fix refcount leak bugs
    
    [ Upstream commit 26c2b7d9fac42eb8317f3ceefa4c1a9a9170ca69 ]
    
    In clcdfb_of_init_display(), we should call of_node_put() for the
    references returned by of_graph_get_next_endpoint() and
    of_graph_get_remote_port_parent() which have increased the refcount.
    
    Besides, we should call of_node_put() both in fail path or when
    the references are not used anymore.
    
    Fixes: d10715be03bd ("video: ARM CLCD: Add DT support")
    Signed-off-by: Liang He <windhl@126.com>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit db7bc17d33ac1f08d6a9f512eee1a6e13031c968
Author: Alexander Gordeev <agordeev@linux.ibm.com>
Date:   Tue Jul 19 07:16:33 2022 +0200

    s390/zcore: fix race when reading from hardware system area
    
    [ Upstream commit 9ffed254d938c9e99eb7761c7f739294c84e0367 ]
    
    Memory buffer used for reading out data from hardware system
    area is not protected against concurrent access.
    
    Reported-by: Matthew Wilcox <willy@infradead.org>
    Fixes: 411ed3225733 ("[S390] zfcpdump support.")
    Acked-by: Heiko Carstens <hca@linux.ibm.com>
    Tested-by: Alexander Egorenkov <egorenar@linux.ibm.com>
    Link: https://lore.kernel.org/r/e68137f0f9a0d2558f37becc20af18e2939934f6.1658206891.git.agordeev@linux.ibm.com
    Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b73104bb79a65ccf3abb8df4e5901b01dbcc829b
Author: Liang He <windhl@126.com>
Date:   Tue Jul 19 20:49:55 2022 +0800

    iommu/arm-smmu: qcom_iommu: Add of_node_put() when breaking out of loop
    
    [ Upstream commit a91eb6803c1c715738682fece095145cbd68fe0b ]
    
    In qcom_iommu_has_secure_context(), we should call of_node_put()
    for the reference 'child' when breaking out of for_each_child_of_node()
    which will automatically increase and decrease the refcount.
    
    Fixes: d051f28c8807 ("iommu/qcom: Initialize secure page table")
    Signed-off-by: Liang He <windhl@126.com>
    Link: https://lore.kernel.org/r/20220719124955.1242171-1-windhl@126.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a1c08338eb0e114829825d467150374250159338
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Mon May 30 21:24:28 2022 +0200

    mfd: t7l66xb: Drop platform disable callback
    
    [ Upstream commit 128ac294e1b437cb8a7f2ff8ede1cde9082bddbe ]
    
    None of the in-tree instantiations of struct t7l66xb_platform_data
    provides a disable callback. So better don't dereference this function
    pointer unconditionally. As there is no user, drop it completely instead
    of calling it conditional.
    
    This is a preparation for making platform remove callbacks return void.
    
    Fixes: 1f192015ca5b ("mfd: driver for the T7L66XB TMIO SoC")
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Link: https://lore.kernel.org/r/20220530192430.2108217-3-u.kleine-koenig@pengutronix.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7a627997a7a7c61b0b4ca2f90298beddc0fb940e
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Fri Jun 24 08:30:04 2022 +0300

    kfifo: fix kfifo_to_user() return type
    
    [ Upstream commit 045ed31e23aea840648c290dbde04797064960db ]
    
    The kfifo_to_user() macro is supposed to return zero for success or
    negative error codes.  Unfortunately, there is a signedness bug so it
    returns unsigned int.  This only affects callers which try to save the
    result in ssize_t and as far as I can see the only place which does that
    is line6_hwdep_read().
    
    TL;DR: s/_uint/_int/.
    
    Link: https://lkml.kernel.org/r/YrVL3OJVLlNhIMFs@kili
    Fixes: 144ecf310eb5 ("kfifo: fix kfifo_alloc() to return a signed int value")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Cc: Stefani Seibold <stefani@seibold.net>
    Cc: Randy Dunlap <randy.dunlap@oracle.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 169dbe180b1e36ce8d1dc37c3284aecd8283ff96
Author: Sam Protsenko <semen.protsenko@linaro.org>
Date:   Thu Jul 14 19:55:46 2022 +0300

    iommu/exynos: Handle failed IOMMU device registration properly
    
    [ Upstream commit fce398d2d02c0a9a2bedf7c7201b123e153e8963 ]
    
    If iommu_device_register() fails in exynos_sysmmu_probe(), the previous
    calls have to be cleaned up. In this case, the iommu_device_sysfs_add()
    should be cleaned up, by calling its remove counterpart call.
    
    Fixes: d2c302b6e8b1 ("iommu/exynos: Make use of iommu_device_register interface")
    Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
    Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Link: https://lore.kernel.org/r/20220714165550.8884-3-semen.protsenko@linaro.org
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b2d84b6db83ea52bc727bd28df29a108f1fe0c47
Author: Daniel Starke <daniel.starke@siemens.com>
Date:   Thu Jul 7 13:32:21 2022 +0200

    tty: n_gsm: fix DM command
    
    [ Upstream commit 18a948c7d90995d127785e308fa7b701df4c499f ]
    
    n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
    See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
    The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
    the newer 27.010 here. Chapter 5.3.3 defines the DM response. There exists
    no DM command. However, the current implementation incorrectly sends DM as
    command in case of unexpected UIH frames in gsm_queue().
    Correct this behavior by always sending DM as response.
    
    Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
    Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
    Link: https://lore.kernel.org/r/20220707113223.3685-2-daniel.starke@siemens.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8b2af39c72b187718eda0c557135177594cccd4d
Author: Daniel Starke <daniel.starke@siemens.com>
Date:   Thu Jul 7 13:32:20 2022 +0200

    tty: n_gsm: fix wrong T1 retry count handling
    
    [ Upstream commit f30e10caa80aa1f35508bc17fc302dbbde9a833c ]
    
    n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
    See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
    The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
    the newer 27.010 here. Chapter 5.7.3 states that the valid range for the
    maximum number of retransmissions (N2) is from 0 to 255 (both including).
    gsm_dlci_t1() handles this number incorrectly by performing N2 - 1
    retransmission attempts. Setting N2 to zero results in more than 255
    retransmission attempts.
    Fix gsm_dlci_t1() to comply with 3GPP 27.010.
    
    Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
    Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
    Link: https://lore.kernel.org/r/20220707113223.3685-1-daniel.starke@siemens.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3aaa98e7b528274e524c6304ac93f2a90fe3a07f
Author: Eric Farman <farman@linux.ibm.com>
Date:   Thu Jul 7 15:57:29 2022 +0200

    vfio/ccw: Do not change FSM state in subchannel event
    
    [ Upstream commit cffcc109fd682075dee79bade3d60a07152a8fd1 ]
    
    The routine vfio_ccw_sch_event() is tasked with handling subchannel events,
    specifically machine checks, on behalf of vfio-ccw. It correctly calls
    cio_update_schib(), and if that fails (meaning the subchannel is gone)
    it makes an FSM event call to mark the subchannel Not Operational.
    
    If that worked, however, then it decides that if the FSM state was already
    Not Operational (implying the subchannel just came back), then it should
    simply change the FSM to partially- or fully-open.
    
    Remove this trickery, since a subchannel returning will require more
    probing than simply "oh all is well again" to ensure it works correctly.
    
    Fixes: bbe37e4cb8970 ("vfio: ccw: introduce a finite state machine")
    Signed-off-by: Eric Farman <farman@linux.ibm.com>
    Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
    Link: https://lore.kernel.org/r/20220707135737.720765-4-farman@linux.ibm.com
    Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 23f6160461c87daa46819ae7a08d19793de6631b
Author: Sireesh Kodali <sireeshkodali1@gmail.com>
Date:   Thu May 26 19:47:39 2022 +0530

    remoteproc: qcom: wcnss: Fix handling of IRQs
    
    [ Upstream commit bed0adac1ded4cb486ba19a3a7e730fbd9a1c9c6 ]
    
    The wcnss_get_irq function is expected to return a value > 0 in the
    event that an IRQ is succssfully obtained, but it instead returns 0.
    This causes the stop and ready IRQs to never actually be used despite
    being defined in the device-tree. This patch fixes that.
    
    Fixes: aed361adca9f ("remoteproc: qcom: Introduce WCNSS peripheral image loader")
    Signed-off-by: Sireesh Kodali <sireeshkodali1@gmail.com>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220526141740.15834-2-sireeshkodali1@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e1e3b6517ddbb0e9934785d3bd94e61fde05c6ec
Author: Daniel Starke <daniel.starke@siemens.com>
Date:   Fri Jul 1 08:16:52 2022 +0200

    tty: n_gsm: fix race condition in gsmld_write()
    
    [ Upstream commit 32dd59f96924f45e33bc79854f7a00679c0fa28e ]
    
    The function may be used by the user directly and also by the n_gsm
    internal functions. They can lead into a race condition which results in
    interleaved frames if both are writing at the same time. The receiving side
    is not able to decode those interleaved frames correctly.
    
    Add a lock around the low side tty write to avoid race conditions and frame
    interleaving between user originated writes and n_gsm writes.
    
    Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
    Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
    Link: https://lore.kernel.org/r/20220701061652.39604-9-daniel.starke@siemens.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7d986ee1986ac826ccb4f0646e04d99b6f55f9b5
Author: Daniel Starke <daniel.starke@siemens.com>
Date:   Fri Jul 1 08:16:50 2022 +0200

    tty: n_gsm: fix packet re-transmission without open control channel
    
    [ Upstream commit 4fae831b3a71fc5a44cc5c7d0b8c1267ee7659f5 ]
    
    In the current implementation control packets are re-transmitted even if
    the control channel closed down during T2. This is wrong.
    Check whether the control channel is open before re-transmitting any
    packets. Note that control channel open/close is handled by T1 and not T2
    and remains unaffected by this.
    
    Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
    Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
    Link: https://lore.kernel.org/r/20220701061652.39604-7-daniel.starke@siemens.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit de693d02ee44920aaa2e33f9d7b482acd437fb75
Author: Daniel Starke <daniel.starke@siemens.com>
Date:   Fri Jul 1 08:16:48 2022 +0200

    tty: n_gsm: fix non flow control frames during mux flow off
    
    [ Upstream commit bec0224816d19abe4fe503586d16d51890540615 ]
    
    n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
    See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
    The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
    the newer 27.010 here. Chapter 5.4.6.3.6 states that FCoff stops the
    transmission on all channels except the control channel. This is already
    implemented in gsm_data_kick(). However, chapter 5.4.8.1 explains that this
    shall result in the same behavior as software flow control on the ldisc in
    advanced option mode. That means only flow control frames shall be sent
    during flow off. The current implementation does not consider this case.
    
    Change gsm_data_kick() to send only flow control frames if constipated to
    abide the standard. gsm_read_ea_val() and gsm_is_flow_ctrl_msg() are
    introduced as helper functions for this.
    It is planned to use gsm_read_ea_val() in later code cleanups for other
    functions, too.
    
    Fixes: c01af4fec2c8 ("n_gsm : Flow control handling in Mux driver")
    Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
    Link: https://lore.kernel.org/r/20220701061652.39604-5-daniel.starke@siemens.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8036057f8cd3a9f0cef009ddd5d6ca60cee3b66b
Author: Chen Zhongjin <chenzhongjin@huawei.com>
Date:   Tue May 31 09:28:54 2022 +0800

    profiling: fix shift too large makes kernel panic
    
    [ Upstream commit 0fe6ee8f123a4dfb529a5aff07536bb481f34043 ]
    
    2d186afd04d6 ("profiling: fix shift-out-of-bounds bugs") limits shift
    value by [0, BITS_PER_LONG -1], which means [0, 63].
    
    However, syzbot found that the max shift value should be the bit number of
    (_etext - _stext).  If shift is outside of this, the "buffer_bytes" will
    be zero and will cause kzalloc(0).  Then the kernel panics due to
    dereferencing the returned pointer 16.
    
    This can be easily reproduced by passing a large number like 60 to enable
    profiling and then run readprofile.
    
    LOGS:
     BUG: kernel NULL pointer dereference, address: 0000000000000010
     #PF: supervisor write access in kernel mode
     #PF: error_code(0x0002) - not-present page
     PGD 6148067 P4D 6148067 PUD 6142067 PMD 0
     PREEMPT SMP
     CPU: 4 PID: 184 Comm: readprofile Not tainted 5.18.0+ #162
     Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014
     RIP: 0010:read_profile+0x104/0x220
     RSP: 0018:ffffc900006fbe80 EFLAGS: 00000202
     RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
     RDX: ffff888006150000 RSI: 0000000000000001 RDI: ffffffff82aba4a0
     RBP: 000000000188bb60 R08: 0000000000000010 R09: ffff888006151000
     R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff82aba4a0
     R13: 0000000000000000 R14: ffffc900006fbf08 R15: 0000000000020c30
     FS:  000000000188a8c0(0000) GS:ffff88803ed00000(0000) knlGS:0000000000000000
     CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
     CR2: 0000000000000010 CR3: 0000000006144000 CR4: 00000000000006e0
     Call Trace:
      <TASK>
      proc_reg_read+0x56/0x70
      vfs_read+0x9a/0x1b0
      ksys_read+0xa1/0xe0
      ? fpregs_assert_state_consistent+0x1e/0x40
      do_syscall_64+0x3a/0x80
      entry_SYSCALL_64_after_hwframe+0x46/0xb0
     RIP: 0033:0x4d4b4e
     RSP: 002b:00007ffebb668d58 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
     RAX: ffffffffffffffda RBX: 000000000188a8a0 RCX: 00000000004d4b4e
     RDX: 0000000000000400 RSI: 000000000188bb60 RDI: 0000000000000003
     RBP: 0000000000000003 R08: 000000000000006e R09: 0000000000000000
     R10: 0000000000000041 R11: 0000000000000246 R12: 000000000188bb60
     R13: 0000000000000400 R14: 0000000000000000 R15: 000000000188bb60
      </TASK>
     Modules linked in:
     CR2: 0000000000000010
    Killed
     ---[ end trace 0000000000000000 ]---
    
    Check prof_len in profile_init() to prevent it be zero.
    
    Link: https://lkml.kernel.org/r/20220531012854.229439-1-chenzhongjin@huawei.com
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 06ace427953f5036b64aed658f0055f65d76fd27
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Fri Jun 3 16:42:41 2022 +0400

    ASoC: mediatek: mt8173-rt5650: Fix refcount leak in mt8173_rt5650_dev_probe
    
    [ Upstream commit efe2178d1a32492f99e7f1f2568eea5c88a85729 ]
    
    of_parse_phandle() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Fix refcount leak in some error paths.
    
    Fixes: 0f83f9296d5c ("ASoC: mediatek: Add machine driver for ALC5650 codec")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220603124243.31358-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7178a0be5260401fe4de2e48b60b1e2b47618b5e
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Tue May 31 17:47:12 2022 +0800

    ASoC: codecs: da7210: add check for i2c_add_driver
    
    [ Upstream commit 82fa8f581a954ddeec1602bed9f8b4a09d100e6e ]
    
    As i2c_add_driver could return error if fails, it should be
    better to check the return value.
    However, if the CONFIG_I2C and CONFIG_SPI_MASTER are both true,
    the return value of i2c_add_driver will be covered by
    spi_register_driver.
    Therefore, it is necessary to add check and return error if fails.
    
    Fixes: aa0e25caafb7 ("ASoC: da7210: Add support for spi regmap")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Link: https://lore.kernel.org/r/20220531094712.2376759-1-jiasheng@iscas.ac.cn
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit aa668f8e93199cda8fa1612eb49ff70f5ecd8c92
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Thu Jun 2 07:41:42 2022 +0400

    ASoC: mediatek: mt8173: Fix refcount leak in mt8173_rt5650_rt5676_dev_probe
    
    [ Upstream commit ae4f11c1ed2d67192fdf3d89db719ee439827c11 ]
    
    of_parse_phandle() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Fix missing of_node_put() in error paths.
    
    Fixes: 94319ba10eca ("ASoC: mediatek: Use platform_of_node for machine drivers")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220602034144.60159-1-linmq006@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0f61c6dc4b714be9d79cf0782ca02ba01c1b7ac3
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Fri Jul 15 20:51:52 2022 +0800

    jbd2: fix assertion 'jh->b_frozen_data == NULL' failure when journal aborted
    
    [ Upstream commit 4a734f0869f970b8a9b65062ea40b09a5da9dba8 ]
    
    Following process will fail assertion 'jh->b_frozen_data == NULL' in
    jbd2_journal_dirty_metadata():
    
                       jbd2_journal_commit_transaction
    unlink(dir/a)
     jh->b_transaction = trans1
     jh->b_jlist = BJ_Metadata
                        journal->j_running_transaction = NULL
                        trans1->t_state = T_COMMIT
    unlink(dir/b)
     handle->h_trans = trans2
     do_get_write_access
      jh->b_modified = 0
      jh->b_frozen_data = frozen_buffer
      jh->b_next_transaction = trans2
     jbd2_journal_dirty_metadata
      is_handle_aborted
       is_journal_aborted // return false
    
               --> jbd2 abort <--
    
                         while (commit_transaction->t_buffers)
                          if (is_journal_aborted)
                           jbd2_journal_refile_buffer
                            __jbd2_journal_refile_buffer
                             WRITE_ONCE(jh->b_transaction,
                                                    jh->b_next_transaction)
                             WRITE_ONCE(jh->b_next_transaction, NULL)
                             __jbd2_journal_file_buffer(jh, BJ_Reserved)
            J_ASSERT_JH(jh, jh->b_frozen_data == NULL) // assertion failure !
    
    The reproducer (See detail in [Link]) reports:
     ------------[ cut here ]------------
     kernel BUG at fs/jbd2/transaction.c:1629!
     invalid opcode: 0000 [#1] PREEMPT SMP
     CPU: 2 PID: 584 Comm: unlink Tainted: G        W
     5.19.0-rc6-00115-g4a57a8400075-dirty #697
     RIP: 0010:jbd2_journal_dirty_metadata+0x3c5/0x470
     RSP: 0018:ffffc90000be7ce0 EFLAGS: 00010202
     Call Trace:
      <TASK>
      __ext4_handle_dirty_metadata+0xa0/0x290
      ext4_handle_dirty_dirblock+0x10c/0x1d0
      ext4_delete_entry+0x104/0x200
      __ext4_unlink+0x22b/0x360
      ext4_unlink+0x275/0x390
      vfs_unlink+0x20b/0x4c0
      do_unlinkat+0x42f/0x4c0
      __x64_sys_unlink+0x37/0x50
      do_syscall_64+0x35/0x80
    
    After journal aborting, __jbd2_journal_refile_buffer() is executed with
    holding @jh->b_state_lock, we can fix it by moving 'is_handle_aborted()'
    into the area protected by @jh->b_state_lock.
    
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216251
    Fixes: 470decc613ab20 ("[PATCH] jbd2: initial copy of files from jbd")
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Link: https://lore.kernel.org/r/20220715125152.4022726-1-chengzhihao1@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d4de56cc614a7760eb09f5c47ee1bc6878c2354f
Author: Li Lingfeng <lilingfeng3@huawei.com>
Date:   Fri Jun 17 14:25:15 2022 +0800

    ext4: recover csum seed of tmp_inode after migrating to extents
    
    [ Upstream commit 07ea7a617d6b278fb7acedb5cbe1a81ce2de7d0c ]
    
    When migrating to extents, the checksum seed of temporary inode
    need to be replaced by inode's, otherwise the inode checksums
    will be incorrect when swapping the inodes data.
    
    However, the temporary inode can not match it's checksum to
    itself since it has lost it's own checksum seed.
    
    mkfs.ext4 -F /dev/sdc
    mount /dev/sdc /mnt/sdc
    xfs_io -fc "pwrite 4k 4k" -c "fsync" /mnt/sdc/testfile
    chattr -e /mnt/sdc/testfile
    chattr +e /mnt/sdc/testfile
    umount /dev/sdc
    fsck -fn /dev/sdc
    
    ========
    ...
    Pass 1: Checking inodes, blocks, and sizes
    Inode 13 passes checks, but checksum does not match inode.  Fix? no
    ...
    ========
    
    The fix is simple, save the checksum seed of temporary inode, and
    recover it after migrating to extents.
    
    Fixes: e81c9302a6c3 ("ext4: set csum seed in tmp inode while migrating to extents")
    Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20220617062515.2113438-1-lilingfeng3@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3c838ca6fbdb173102780d7bdf18f2f7d9e30979
Author: Zhu Yanjun <yanjun.zhu@linux.dev>
Date:   Sun Jul 31 02:36:21 2022 -0400

    RDMA/rxe: Fix error unwind in rxe_create_qp()
    
    [ Upstream commit fd5382c5805c4bcb50fd25b7246247d3f7114733 ]
    
    In the function rxe_create_qp(), rxe_qp_from_init() is called to
    initialize qp, internally things like the spin locks are not setup until
    rxe_qp_init_req().
    
    If an error occures before this point then the unwind will call
    rxe_cleanup() and eventually to rxe_qp_do_cleanup()/rxe_cleanup_task()
    which will oops when trying to access the uninitialized spinlock.
    
    Move the spinlock initializations earlier before any failures.
    
    Fixes: 8700e3e7c485 ("Soft RoCE driver")
    Link: https://lore.kernel.org/r/20220731063621.298405-1-yanjun.zhu@linux.dev
    Reported-by: syzbot+833061116fa28df97f3b@syzkaller.appspotmail.com
    Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 06a6d6c51e791b89f1024a8b5fb696b16f4c5187
Author: Miaohe Lin <linmiaohe@huawei.com>
Date:   Sat Jun 18 16:20:27 2022 +0800

    mm/mmap.c: fix missing call to vm_unacct_memory in mmap_region
    
    [ Upstream commit 7f82f922319ede486540e8746769865b9508d2c2 ]
    
    Since the beginning, charged is set to 0 to avoid calling vm_unacct_memory
    twice because vm_unacct_memory will be called by above unmap_region.  But
    since commit 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from
    the unmap_vmas() interfaces"), unmap_region doesn't call vm_unacct_memory
    anymore.  So charged shouldn't be set to 0 now otherwise the calling to
    paired vm_unacct_memory will be missed and leads to imbalanced account.
    
    Link: https://lkml.kernel.org/r/20220618082027.43391-1-linmiaohe@huawei.com
    Fixes: 4f74d2c8e827 ("vm: remove 'nr_accounted' calculations from the unmap_vmas() interfaces")
    Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 58410698a7444c20b5449b1b413090e0c3079a31
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Jul 20 21:23:38 2022 +0300

    platform/olpc: Fix uninitialized data in debugfs write
    
    [ Upstream commit 40ec787e1adf302c11668d4cc69838f4d584187d ]
    
    The call to:
    
            size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size);
    
    will succeed if at least one byte is written to the "cmdbuf" buffer.
    The "*ppos" value controls which byte is written.  Another problem is
    that this code does not check for errors so it's possible for the entire
    buffer to be uninitialized.
    
    Inintialize the struct to zero to prevent reading uninitialized stack
    data.
    
    Debugfs is normally only writable by root so the impact of this bug is
    very minimal.
    
    Fixes: 6cca83d498bd ("Platform: OLPC: move debugfs support from x86 EC driver")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Link: https://lore.kernel.org/r/YthIKn+TfZSZMEcM@kili
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1f9fa50f165cec20a69314d867abd59bd11f2b09
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Jul 25 10:44:57 2022 +0200

    USB: serial: fix tty-port initialized comments
    
    [ Upstream commit 688ee1d1785c1359f9040f615dd8e6054962bce2 ]
    
    Fix up the tty-port initialized comments which got truncated and
    obfuscated when replacing the old ASYNCB_INITIALIZED flag.
    
    Fixes: d41861ca19c9 ("tty: Replace ASYNC_INITIALIZED bit and update atomically")
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 16ca365e334f799d96e8c772d3a57325ec17d946
Author: Liang He <windhl@126.com>
Date:   Tue Jul 19 17:52:16 2022 +0800

    mmc: cavium-thunderx: Add of_node_put() when breaking out of loop
    
    [ Upstream commit 7ee480795e41db314f2c445c65ed854a5d6e8e32 ]
    
    In thunder_mmc_probe(), we should call of_node_put() when breaking
    out of for_each_child_of_node() which has increased and decreased
    the refcount during each iteration.
    
    Fixes: 166bac38c3c5 ("mmc: cavium: Add MMC PCI driver for ThunderX SOCs")
    Signed-off-by: Liang He <windhl@126.com>
    Acked-by: Robert Richter <rric@kernel.org>
    Link: https://lore.kernel.org/r/20220719095216.1241601-2-windhl@126.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 03b56349a5da24eddb74b9a3b4b4572d16fd3d16
Author: Liang He <windhl@126.com>
Date:   Tue Jul 19 17:52:15 2022 +0800

    mmc: cavium-octeon: Add of_node_put() when breaking out of loop
    
    [ Upstream commit 19bbb49acf8d7a03cb83e05624363741a4c3ec6f ]
    
    In octeon_mmc_probe(), we should call of_node_put() when breaking
    out of for_each_child_of_node() which has increased and decreased
    the refcount during each iteration.
    
    Fixes: 01d95843335c ("mmc: cavium: Add MMC support for Octeon SOCs.")
    Signed-off-by: Liang He <windhl@126.com>
    Acked-by: Robert Richter <rric@kernel.org>
    Link: https://lore.kernel.org/r/20220719095216.1241601-1-windhl@126.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a7af678e76613ca79a0071e92ebef13173d926e2
Author: Liang He <windhl@126.com>
Date:   Mon Jul 11 20:52:38 2022 +0800

    gpio: gpiolib-of: Fix refcount bugs in of_mm_gpiochip_add_data()
    
    [ Upstream commit 5d07a692f9562f9c06e62cce369e9dd108173a0f ]
    
    We should use of_node_get() when a new reference of device_node
    is created. It is noted that the old reference stored in
    'mm_gc->gc.of_node' should also be decreased.
    
    This patch is based on the fact that there is a call site in function
    'qe_add_gpiochips()' of src file 'drivers\soc\fsl\qe\gpio.c'. In this
    function, of_mm_gpiochip_add_data() is contained in an iteration of
    for_each_compatible_node() which will automatically increase and
    decrease the refcount. So we need additional of_node_get() for the
    reference escape in of_mm_gpiochip_add_data().
    
    Fixes: a19e3da5bc5f ("of/gpio: Kill of_gpio_chip and add members directly to gpio_chip")
    Signed-off-by: Liang He <windhl@126.com>
    Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fc4de8009fd6c2ca51986c6757efa964040e7d02
Author: Jianglei Nie <niejianglei2021@163.com>
Date:   Mon Jul 11 15:07:18 2022 +0800

    RDMA/hfi1: fix potential memory leak in setup_base_ctxt()
    
    [ Upstream commit aa2a1df3a2c85f855af7d54466ac10bd48645d63 ]
    
    setup_base_ctxt() allocates a memory chunk for uctxt->groups with
    hfi1_alloc_ctxt_rcv_groups(). When init_user_ctxt() fails, uctxt->groups
    is not released, which will lead to a memory leak.
    
    We should release the uctxt->groups with hfi1_free_ctxt_rcv_groups()
    when init_user_ctxt() fails.
    
    Fixes: e87473bc1b6c ("IB/hfi1: Only set fd pointer when base context is completely initialized")
    Link: https://lore.kernel.org/r/20220711070718.2318320-1-niejianglei2021@163.com
    Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
    Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
    Signed-off-by: Leon Romanovsky <leon@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 041a4247b8fb26d1af92d8d338c53b49e0ed8023
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Fri Jul 8 18:36:01 2022 -0700

    usb: gadget: udc: amd5536 depends on HAS_DMA
    
    [ Upstream commit 8097cf2fb3b2205257f1c76f4808e3398d66b6d9 ]
    
    USB_AMD5536UDC should depend on HAS_DMA since it selects USB_SNP_CORE,
    which depends on HAS_DMA and since 'select' does not follow any
    dependency chains.
    
    Fixes this kconfig warning:
    
    WARNING: unmet direct dependencies detected for USB_SNP_CORE
      Depends on [n]: USB_SUPPORT [=y] && USB_GADGET [=y] && (USB_AMD5536UDC [=y] || USB_SNP_UDC_PLAT [=n]) && HAS_DMA [=n]
      Selected by [y]:
      - USB_AMD5536UDC [=y] && USB_SUPPORT [=y] && USB_GADGET [=y] && USB_PCI [=y]
    
    Fixes: 97b3ffa233b9 ("usb: gadget: udc: amd5536: split core and PCI layer")
    Cc: Raviteja Garimella <raviteja.garimella@broadcom.com>
    Cc: Felipe Balbi <balbi@kernel.org>
    Cc: linux-usb@vger.kernel.org
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Link: https://lore.kernel.org/r/20220709013601.7536-1-rdunlap@infradead.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 617b3cf2b7f03ad9993d73259ddb5f4c401ad84f
Author: Mahesh Rajashekhara <Mahesh.Rajashekhara@microchip.com>
Date:   Fri Jul 8 13:47:36 2022 -0500

    scsi: smartpqi: Fix DMA direction for RAID requests
    
    [ Upstream commit 69695aeaa6621bc49cdd7a8e5a8d1042461e496e ]
    
    Correct a SOP READ and WRITE DMA flags for some requests.
    
    This update corrects DMA direction issues with SCSI commands removed from
    the controller's internal lookup table.
    
    Currently, SCSI READ BLOCK LIMITS (0x5) was removed from the controller
    lookup table and exposed a DMA direction flag issue.
    
    SCSI READ BLOCK LIMITS was recently removed from our controller lookup
    table so the controller uses the respective IU flag field to set the DMA
    data direction. Since the DMA direction is incorrect the FW never completes
    the request causing a hang.
    
    Some SCSI commands which use SCSI READ BLOCK LIMITS
    
          * sg_map
          * mt -f /dev/stX status
    
    After updating controller firmware, users may notice their tape units
    failing. This patch resolves the issue.
    
    Also, the AIO path DMA direction is correct.
    
    The DMA direction flag is a day-one bug with no reported BZ.
    
    Fixes: 6c223761eb54 ("smartpqi: initial commit of Microsemi smartpqi driver")
    Link: https://lore.kernel.org/r/165730605618.177165.9054223644512926624.stgit@brunhilda
    Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
    Reviewed-by: Scott Teel <scott.teel@microchip.com>
    Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
    Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
    Signed-off-by: Mahesh Rajashekhara <Mahesh.Rajashekhara@microchip.com>
    Signed-off-by: Don Brace <don.brace@microchip.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 91d0d361fc1d0d890b21c5d56882950dca198cf4
Author: Eugen Hristev <eugen.hristev@microchip.com>
Date:   Thu Jun 30 12:09:26 2022 +0300

    mmc: sdhci-of-at91: fix set_uhs_signaling rewriting of MC1R
    
    [ Upstream commit 5987e6ded29d52e42fc7b06aa575c60a25eee38e ]
    
    In set_uhs_signaling, the DDR bit is being set by fully writing the MC1R
    register.
    This can lead to accidental erase of certain bits in this register.
    Avoid this by doing a read-modify-write operation.
    
    Fixes: d0918764c17b ("mmc: sdhci-of-at91: fix MMC_DDR_52 timing selection")
    Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
    Tested-by: Karl Olsen <karl@micro-technic.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Link: https://lore.kernel.org/r/20220630090926.15061-1-eugen.hristev@microchip.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit efd675246aec045507b9425c67b548cc2d782d8f
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat Jun 25 14:55:56 2022 +0200

    memstick/ms_block: Fix a memory leak
    
    [ Upstream commit 54eb7a55be6779c4d0c25eaf5056498a28595049 ]
    
    'erased_blocks_bitmap' is never freed. As it is allocated at the same time
    as 'used_blocks_bitmap', it is likely that it should be freed also at the
    same time.
    
    Add the corresponding bitmap_free() in msb_data_clear().
    
    Fixes: 0ab30494bc4f ("memstick: add support for legacy memorysticks")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/b3b78926569445962ea5c3b6e9102418a9effb88.1656155715.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fc7512d2b294a5f49de1d8f59aabc2ef4d61cdef
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sat Jun 25 14:55:25 2022 +0200

    memstick/ms_block: Fix some incorrect memory allocation
    
    [ Upstream commit 2e531bc3e0d86362fcd8a577b3278d9ef3cc2ba0 ]
    
    Some functions of the bitmap API take advantage of the fact that a bitmap
    is an array of long.
    
    So, to make sure this assertion is correct, allocate bitmaps with
    bitmap_zalloc() instead of kzalloc()+hand-computed number of bytes.
    
    While at it, also use bitmap_free() instead of kfree() to keep the
    semantic.
    
    Fixes: 0ab30494bc4f ("memstick: add support for legacy memorysticks")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/dbf633c48c24ae6d95f852557e8d8b3bbdef65fe.1656155715.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a63d5d01e83b984b1b9c7ae8fc9c8c93697a3820
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon May 23 18:42:54 2022 +0400

    mmc: sdhci-of-esdhc: Fix refcount leak in esdhc_signal_voltage_switch
    
    [ Upstream commit b5899a3e2f783a27b268e38d37f9b24c71bddf45 ]
    
    of_find_matching_node() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Add missing of_node_put() to avoid refcount leak.
    of_node_put() checks null pointer.
    
    Fixes: ea35645a3c66 ("mmc: sdhci-of-esdhc: add support for signal voltage switch")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220523144255.10310-1-linmq006@gmail.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 155479cd67246f3062c4645a012e3f7630789fe4
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Wed Jun 15 07:33:44 2022 +0200

    misc: rtsx: Fix an error handling path in rtsx_pci_probe()
    
    [ Upstream commit 44fd1917314e9d4f53dd95dd65df1c152f503d3a ]
    
    If an error occurs after a successful idr_alloc() call, the corresponding
    resource must be released with idr_remove() as already done in the .remove
    function.
    
    Update the error handling path to add the missing idr_remove() call.
    
    Fixes: ada8a8a13b13 ("mfd: Add realtek pcie card reader driver")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/e8dc41716cbf52fb37a12e70d8972848e69df6d6.1655271216.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 591ab8dbf6c21927f23f83ddb90691f48b86d136
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Fri Jun 3 18:12:30 2022 +0400

    usb: ohci-nxp: Fix refcount leak in ohci_hcd_nxp_probe
    
    [ Upstream commit 302970b4cad3ebfda2c05ce06c322ccdc447d17e ]
    
    of_parse_phandle() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: 73108aa90cbf ("USB: ohci-nxp: Use isp1301 driver")
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220603141231.979-1-linmq006@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b9c4a480cb0ada07154debf681454cbb55e30b59
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Thu Jun 2 15:08:49 2022 +0400

    usb: host: Fix refcount leak in ehci_hcd_ppc_of_probe
    
    [ Upstream commit b5c5b13cb45e2c88181308186b0001992cb41954 ]
    
    of_find_compatible_node() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when done.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: 796bcae7361c ("USB: powerpc: Workaround for the PPC440EPX USBH_23 errata [take 3]")
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220602110849.58549-1-linmq006@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 59ef9bfd29ae85db438a3ec91ad5b8d9209cb3cb
Author: Marco Pagani <marpagan@redhat.com>
Date:   Thu Jun 9 16:05:19 2022 +0200

    fpga: altera-pr-ip: fix unsigned comparison with less than zero
    
    [ Upstream commit 2df84a757d87fd62869fc401119d429735377ec5 ]
    
    Fix the "comparison with less than zero" warning reported by
    cppcheck for the unsigned (size_t) parameter count of the
    alt_pr_fpga_write() function.
    
    Fixes: d201cc17a8a3 ("fpga pr ip: Core driver support for Altera Partial Reconfiguration IP")
    Reviewed-by: Tom Rix <trix@redhat.com>
    Acked-by: Xu Yilun <yilun.xu@intel.com>
    Signed-off-by: Marco Pagani <marpagan@redhat.com>
    Link: https://lore.kernel.org/r/20220609140520.42662-1-marpagan@redhat.com
    Signed-off-by: Xu Yilun <yilun.xu@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 34e4e5b005416abdc1b4305d4f2d789d6c747588
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Tue Jun 7 17:24:55 2022 +0200

    mtd: st_spi_fsm: Add a clk_disable_unprepare() in .probe()'s error path
    
    [ Upstream commit 28607b426c3d050714f250d0faeb99d2e9106e90 ]
    
    For all but one error path clk_disable_unprepare() is already there. Add
    it to the one location where it's missing.
    
    Fixes: 481815a6193b ("mtd: st_spi_fsm: Handle clk_prepare_enable/clk_disable_unprepare.")
    Fixes: 69d5af8d016c ("mtd: st_spi_fsm: Obtain and use EMI clock")
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/linux-mtd/20220607152458.232847-2-u.kleine-koenig@pengutronix.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9b4fb916e642d0587ef8e79c3f58e724c1e848c1
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Tue May 24 12:48:41 2022 +0800

    mtd: sm_ftl: Fix deadlock caused by cancel_work_sync in sm_release
    
    [ Upstream commit a61528d997619a518ee8c51cf0ef0513021afaff ]
    
    There is a deadlock between sm_release and sm_cache_flush_work
    which is a work item. The cancel_work_sync in sm_release will
    not return until sm_cache_flush_work is finished. If we hold
    mutex_lock and use cancel_work_sync to wait the work item to
    finish, the work item also requires mutex_lock. As a result,
    the sm_release will be blocked forever. The race condition is
    shown below:
    
        (Thread 1)             |   (Thread 2)
    sm_release                 |
      mutex_lock(&ftl->mutex)  | sm_cache_flush_work
                               |   mutex_lock(&ftl->mutex)
      cancel_work_sync         |   ...
    
    This patch moves del_timer_sync and cancel_work_sync out of
    mutex_lock in order to mitigate deadlock.
    
    Fixes: 7d17c02a01a1 ("mtd: Add new SmartMedia/xD FTL")
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/linux-mtd/20220524044841.10517-1-duoming@zju.edu.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 995fb2874bb5696357846a91e59181c600e6aac8
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon May 23 18:32:55 2022 +0400

    mtd: maps: Fix refcount leak in ap_flash_init
    
    [ Upstream commit 77087a04c8fd554134bddcb8a9ff87b21f357926 ]
    
    of_find_matching_node() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: b0afd44bc192 ("mtd: physmap_of: add a hook for Versatile write protection")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/linux-mtd/20220523143255.4376-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3c8de6a838b7e0eb392754ac89dd66e698684342
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Mon May 23 18:02:05 2022 +0400

    mtd: maps: Fix refcount leak in of_flash_probe_versatile
    
    [ Upstream commit 33ec82a6d2b119938f26e5c8040ed5d92378eb54 ]
    
    of_find_matching_node_and_match() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: b0afd44bc192 ("mtd: physmap_of: add a hook for Versatile write protection")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/linux-mtd/20220523140205.48625-1-linmq006@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 22e778c0736299d9b39217b5de711d1f084343bc
Author: Hangyu Hua <hbh25y@gmail.com>
Date:   Fri Jul 29 19:00:27 2022 +0800

    dccp: put dccp_qpolicy_full() and dccp_qpolicy_push() in the same lock
    
    [ Upstream commit a41b17ff9dacd22f5f118ee53d82da0f3e52d5e3 ]
    
    In the case of sk->dccps_qpolicy == DCCPQ_POLICY_PRIO, dccp_qpolicy_full
    will drop a skb when qpolicy is full. And the lock in dccp_sendmsg is
    released before sock_alloc_send_skb and then relocked after
    sock_alloc_send_skb. The following conditions may lead dccp_qpolicy_push
    to add skb to an already full sk_write_queue:
    
    thread1--->lock
    thread1--->dccp_qpolicy_full: queue is full. drop a skb
    thread1--->unlock
    thread2--->lock
    thread2--->dccp_qpolicy_full: queue is not full. no need to drop.
    thread2--->unlock
    thread1--->lock
    thread1--->dccp_qpolicy_push: add a skb. queue is full.
    thread1--->unlock
    thread2--->lock
    thread2--->dccp_qpolicy_push: add a skb!
    thread2--->unlock
    
    Fix this by moving dccp_qpolicy_full.
    
    Fixes: b1308dc015eb ("[DCCP]: Set TX Queue Length Bounds via Sysctl")
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Link: https://lore.kernel.org/r/20220729110027.40569-1-hbh25y@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fbc166dce6e2abeaff238e38e6673daf0b7d6d31
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Jul 29 09:12:32 2022 +0000

    net: rose: fix netdev reference changes
    
    [ Upstream commit 931027820e4dafabc78aff82af59f8c1c4bd3128 ]
    
    Bernard reported that trying to unload rose module would lead
    to infamous messages:
    
    unregistered_netdevice: waiting for rose0 to become free. Usage count = xx
    
    This patch solves the issue, by making sure each socket referring to
    a netdevice holds a reference count on it, and properly releases it
    in rose_release().
    
    rose_dev_first() is also fixed to take a device reference
    before leaving the rcu_read_locked section.
    
    Following patch will add ref_tracker annotations to ease
    future bug hunting.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reported-by: Bernard Pidoux <f6bvp@free.fr>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Tested-by: Bernard Pidoux <f6bvp@free.fr>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 61b2ec97487399c58ae2e34f250f4884e671799b
Author: Hangyu Hua <hbh25y@gmail.com>
Date:   Mon Jun 20 17:23:50 2022 +0800

    wifi: libertas: Fix possible refcount leak in if_usb_probe()
    
    [ Upstream commit 6fd57e1d120bf13d4dc6c200a7cf914e6347a316 ]
    
    usb_get_dev will be called before lbs_get_firmware_async which means that
    usb_put_dev need to be called when lbs_get_firmware_async fails.
    
    Fixes: ce84bb69f50e ("libertas USB: convert to asynchronous firmware loading")
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20220620092350.39960-1-hbh25y@gmail.com
    Link: https://lore.kernel.org/r/20220622113402.16969-1-colin.i.king@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b13c84e877d7a3095bacb14665db304b2c00e95f
Author: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Date:   Mon Jul 25 20:49:11 2022 +0300

    wifi: wil6210: debugfs: fix uninitialized variable use in `wil_write_file_wmi()`
    
    [ Upstream commit d578e0af3a003736f6c440188b156483d451b329 ]
    
    Commit 7a4836560a61 changes simple_write_to_buffer() with memdup_user()
    but it forgets to change the value to be returned that came from
    simple_write_to_buffer() call. It results in the following warning:
    
      warning: variable 'rc' is uninitialized when used here [-Wuninitialized]
               return rc;
                      ^~
    
    Remove rc variable and just return the passed in length if the
    memdup_user() succeeds.
    
    Cc: Dan Carpenter <dan.carpenter@oracle.com>
    Reported-by: kernel test robot <lkp@intel.com>
    Fixes: 7a4836560a6198d245d5732e26f94898b12eb760 ("wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()")
    Fixes: ff974e4083341383d3dd4079e52ed30f57f376f0 ("wil6210: debugfs interface to send raw WMI command")
    Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
    Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/20220724202452.61846-1-ammar.faizi@intel.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ebd634be86c393501307a9aa0ae54654d1906cb5
Author: Liang He <windhl@126.com>
Date:   Fri Jul 22 09:24:01 2022 +0800

    i2c: mux-gpmux: Add of_node_put() when breaking out of loop
    
    [ Upstream commit 6435319c34704994e19b0767f6a4e6f37439867b ]
    
    In i2c_mux_probe(), we should call of_node_put() when breaking out
    of for_each_child_of_node() which will automatically increase and
    decrease the refcount.
    
    Fixes: ac8498f0ce53 ("i2c: i2c-mux-gpmux: new driver")
    Signed-off-by: Liang He <windhl@126.com>
    Acked-by: Peter Rosin <peda@axentia.se>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit dc3dcee0d55203b4444ce429b4b766b99db96f63
Author: Lars-Peter Clausen <lars@metafoo.de>
Date:   Sun Jul 17 16:52:44 2022 +0200

    i2c: cadence: Support PEC for SMBus block read
    
    [ Upstream commit 9fdf6d97f03035ad5298e2d1635036c74c2090ed ]
    
    SMBus packet error checking (PEC) is implemented by appending one
    additional byte of checksum data at the end of the message. This provides
    additional protection and allows to detect data corruption on the I2C bus.
    
    SMBus block reads support variable length reads. The first byte in the read
    message is the number of available data bytes.
    
    The combination of PEC and block read is currently not supported by the
    Cadence I2C driver.
     * When PEC is enabled the maximum transfer length for block reads
       increases from 33 to 34 bytes.
     * The I2C core smbus emulation layer relies on the driver updating the
       `i2c_msg` `len` field with the number of received bytes. The updated
       length is used when checking the PEC.
    
    Add support to the Cadence I2C driver for handling SMBus block reads with
    PEC. To determine the maximum transfer length uses the initial `len` value
    of the `i2c_msg`. When PEC is enabled this will be 2, when it is disabled
    it will be 1.
    
    Once a read transfer is done also increment the `len` field by the amount
    of received data bytes.
    
    This change has been tested with a UCM90320 PMBus power monitor, which
    requires block reads to access certain data fields, but also has PEC
    enabled by default.
    
    Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller")
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    Tested-by: Shubhrajyoti Datta <Shubhrajyoti.datta@amd.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 45c6a3fc0fcb1057fc3cda9190368fb1cbecfe6f
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Fri Jun 3 09:24:36 2022 +0800

    Bluetooth: hci_intel: Add check for platform_driver_register
    
    [ Upstream commit ab2d2a982ff721f4b029282d9a40602ea46a745e ]
    
    As platform_driver_register() could fail, it should be better
    to deal with the return value in order to maintain the code
    consisitency.
    
    Fixes: 1ab1f239bf17 ("Bluetooth: hci_intel: Add support for platform driver")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 502ce72430fecba825b70017f96a5d271c1b8229
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Fri Jul 22 01:00:32 2022 +0900

    can: pch_can: pch_can_error(): initialize errc before using it
    
    [ Upstream commit 9950f11211331180269867aef848c7cf56861742 ]
    
    After commit 3a5c7e4611dd, the variable errc is accessed before being
    initialized, c.f. below W=2 warning:
    
    | In function 'pch_can_error',
    |     inlined from 'pch_can_poll' at drivers/net/can/pch_can.c:739:4:
    | drivers/net/can/pch_can.c:501:29: warning: 'errc' may be used uninitialized [-Wmaybe-uninitialized]
    |   501 |                 cf->data[6] = errc & PCH_TEC;
    |       |                             ^
    | drivers/net/can/pch_can.c: In function 'pch_can_poll':
    | drivers/net/can/pch_can.c:484:13: note: 'errc' was declared here
    |   484 |         u32 errc, lec;
    |       |             ^~~~
    
    Moving errc initialization up solves this issue.
    
    Fixes: 3a5c7e4611dd ("can: pch_can: do not report txerr and rxerr during bus-off")
    Reported-by: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Reviewed-by: Nathan Chancellor <nathan@kernel.org>
    Link: https://lore.kernel.org/all/20220721160032.9348-1-mailhol.vincent@wanadoo.fr
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f60fa2510a6405bf7bcaf05e2069610e1cb0fdcb
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Tue Jul 19 23:35:48 2022 +0900

    can: error: specify the values of data[5..7] of CAN error frames
    
    [ Upstream commit e70a3263a7eed768d5f947b8f2aff8d2a79c9d97 ]
    
    Currently, data[5..7] of struct can_frame, when used as a CAN error
    frame, are defined as being "controller specific". Device specific
    behaviours are problematic because it prevents someone from writing
    code which is portable between devices.
    
    As a matter of fact, data[5] is never used, data[6] is always used to
    report TX error counter and data[7] is always used to report RX error
    counter. can-utils also relies on this.
    
    This patch updates the comment in the uapi header to specify that
    data[5] is reserved (and thus should not be used) and that data[6..7]
    are used for error counters.
    
    Fixes: 0d66548a10cb ("[CAN]: Add PF_CAN core module")
    Link: https://lore.kernel.org/all/20220719143550.3681-11-mailhol.vincent@wanadoo.fr
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2af0a52d67bad5b0dd585fb26e1b93b0d39c007f
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Tue Jul 19 23:35:47 2022 +0900

    can: usb_8dev: do not report txerr and rxerr during bus-off
    
    [ Upstream commit aebe8a2433cd090ccdc222861f44bddb75eb01de ]
    
    During bus off, the error count is greater than 255 and can not fit in
    a u8.
    
    Fixes: 0024d8ad1639 ("can: usb_8dev: Add support for USB2CAN interface from 8 devices")
    Link: https://lore.kernel.org/all/20220719143550.3681-10-mailhol.vincent@wanadoo.fr
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 50a4a511925fce923108c6e2c04bf6f7a11ec4c5
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Tue Jul 19 23:35:44 2022 +0900

    can: sun4i_can: do not report txerr and rxerr during bus-off
    
    [ Upstream commit 0ac15a8f661b941519379831d09bfb12271b23ee ]
    
    During bus off, the error count is greater than 255 and can not fit in
    a u8.
    
    Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module")
    Link: https://lore.kernel.org/all/20220719143550.3681-7-mailhol.vincent@wanadoo.fr
    CC: Chen-Yu Tsai <wens@csie.org>
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 303733fdab728d34708014b3096dc69ebae6e531
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Tue Jul 19 23:35:43 2022 +0900

    can: hi311x: do not report txerr and rxerr during bus-off
    
    [ Upstream commit a22bd630cfff496b270211745536e50e98eb3a45 ]
    
    During bus off, the error count is greater than 255 and can not fit in
    a u8.
    
    Fixes: 57e83fb9b746 ("can: hi311x: Add Holt HI-311x CAN driver")
    Link: https://lore.kernel.org/all/20220719143550.3681-6-mailhol.vincent@wanadoo.fr
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ea7635a02379b3a6716de83cdf23bdf9a9342461
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Tue Jul 19 23:35:41 2022 +0900

    can: sja1000: do not report txerr and rxerr during bus-off
    
    [ Upstream commit 164d7cb2d5a30f1b3a5ab4fab1a27731fb1494a8 ]
    
    During bus off, the error count is greater than 255 and can not fit in
    a u8.
    
    Fixes: 215db1856e83 ("can: sja1000: Consolidate and unify state change handling")
    Link: https://lore.kernel.org/all/20220719143550.3681-4-mailhol.vincent@wanadoo.fr
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7fcc6fbc65f26ac5f80d6c820a9ba54f8c39e6dd
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Tue Jul 19 23:35:40 2022 +0900

    can: rcar_can: do not report txerr and rxerr during bus-off
    
    [ Upstream commit a37b7245e831a641df360ca41db6a71c023d3746 ]
    
    During bus off, the error count is greater than 255 and can not fit in
    a u8.
    
    Fixes: fd1159318e55 ("can: add Renesas R-Car CAN driver")
    Link: https://lore.kernel.org/all/20220719143550.3681-3-mailhol.vincent@wanadoo.fr
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bfe855aa9a9092613da973738305fb8926705ce2
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Tue Jul 19 23:35:39 2022 +0900

    can: pch_can: do not report txerr and rxerr during bus-off
    
    [ Upstream commit 3a5c7e4611ddcf0ef37a3a17296b964d986161a6 ]
    
    During bus off, the error count is greater than 255 and can not fit in
    a u8.
    
    Fixes: 0c78ab76a05c ("pch_can: Add setting TEC/REC statistics processing")
    Link: https://lore.kernel.org/all/20220719143550.3681-2-mailhol.vincent@wanadoo.fr
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 51a93dbf6943a6cfba8c7cf9fcf0df9d7f84c914
Author: Rustam Subkhankulov <subkhankulov@ispras.ru>
Date:   Thu Jul 14 16:48:31 2022 +0300

    wifi: p54: add missing parentheses in p54_flush()
    
    [ Upstream commit bcfd9d7f6840b06d5988c7141127795cf405805e ]
    
    The assignment of the value to the variable total in the loop
    condition must be enclosed in additional parentheses, since otherwise,
    in accordance with the precedence of the operators, the conjunction
    will be performed first, and only then the assignment.
    
    Due to this error, a warning later in the function after the loop may
    not occur in the situation when it should.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Signed-off-by: Rustam Subkhankulov <subkhankulov@ispras.ru>
    Fixes: 0d4171e2153b ("p54: implement flush callback")
    Acked-by: Christian Lamparter <chunkeey@gmail.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20220714134831.106004-1-subkhankulov@ispras.ru
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a66dd737854d9684481738a1ebeb5725408ec404
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sun Jun 12 23:12:20 2022 +0200

    wifi: p54: Fix an error handling path in p54spi_probe()
    
    [ Upstream commit 83781f0162d080fec7dcb911afd1bc2f5ad04471 ]
    
    If an error occurs after a successful call to p54spi_request_firmware(), it
    must be undone by a corresponding release_firmware() as already done in
    the error handling path of p54spi_request_firmware() and in the .remove()
    function.
    
    Add the missing call in the error handling path and remove it from
    p54spi_request_firmware() now that it is the responsibility of the caller
    to release the firmware
    
    Fixes: cd8d3d321285 ("p54spi: p54spi driver")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Acked-by: Christian Lamparter <chunkeey@gmail.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/297d2547ff2ee627731662abceeab9dbdaf23231.1655068321.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c1216e699a1ce83ea005510844bd7508d34c6cef
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Fri Jul 15 13:35:18 2022 +0300

    wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()
    
    [ Upstream commit 7a4836560a6198d245d5732e26f94898b12eb760 ]
    
    The simple_write_to_buffer() function will succeed if even a single
    byte is initialized.  However, we need to initialize the whole buffer
    to prevent information leaks.  Just use memdup_user().
    
    Fixes: ff974e408334 ("wil6210: debugfs interface to send raw WMI command")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/Ysg14NdKAZF/hcNG@kili
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 48cca38787e3e08e3c442d861ee7addbf63c5a2e
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Wed Jun 29 15:06:58 2022 +0200

    fs: check FMODE_LSEEK to control internal pipe splicing
    
    [ Upstream commit 97ef77c52b789ec1411d360ed99dca1efe4b2c81 ]
    
    The original direct splicing mechanism from Jens required the input to
    be a regular file because it was avoiding the special socket case. It
    also recognized blkdevs as being close enough to a regular file. But it
    forgot about chardevs, which behave the same way and work fine here.
    
    This is an okayish heuristic, but it doesn't totally work. For example,
    a few chardevs should be spliceable here. And a few regular files
    shouldn't. This patch fixes this by instead checking whether FMODE_LSEEK
    is set, which represents decently enough what we need rewinding for when
    splicing to internal pipes.
    
    Fixes: b92ce5589374 ("[PATCH] splice: add direct fd <-> fd splicing support")
    Cc: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6c4e435b8d91e64d75ecd3118ffe70945a38cfcd
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Wed Jul 13 22:46:17 2022 +0200

    selftests: timers: clocksource-switch: fix passing errors from child
    
    [ Upstream commit 4d8f52ac5fa9eede7b7aa2f2d67c841d9eeb655f ]
    
    The return value from system() is a waitpid-style integer. Do not return
    it directly because with the implicit masking in exit() it will always
    return 0. Access it with appropriate macros to really pass on errors.
    
    Fixes: 7290ce1423c3 ("selftests/timers: Add clocksource-switch test from timetest suite")
    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Acked-by: John Stultz <jstultz@google.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c66b57015ec1e03afe841b8283408f9b98eb4f04
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date:   Wed Jul 13 22:46:13 2022 +0200

    selftests: timers: valid-adjtimex: build fix for newer toolchains
    
    [ Upstream commit 9a162977d20436be5678a8e21a8e58eb4616d86a ]
    
    Toolchains with an include file 'sys/timex.h' based on 3.18 will have a
    'clock_adjtime' definition added, so it can't be static in the code:
    
    valid-adjtimex.c:43:12: error: static declaration of ‘clock_adjtime’ follows non-static declaration
    
    Fixes: e03a58c320e1 ("kselftests: timers: Add adjtimex SETOFFSET validity tests")
    Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
    Acked-by: John Stultz <jstultz@google.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e7a3c80235aaf808f8870a076ed8bb048c1c06d3
Author: Yonglong Li <liyonglong@chinatelecom.cn>
Date:   Mon Jul 11 17:47:18 2022 +0800

    tcp: make retransmitted SKB fit into the send window
    
    [ Upstream commit 536a6c8e05f95e3d1118c40ae8b3022ee2d05d52 ]
    
    current code of __tcp_retransmit_skb only check TCP_SKB_CB(skb)->seq
    in send window, and TCP_SKB_CB(skb)->seq_end maybe out of send window.
    If receiver has shrunk his window, and skb is out of new window,  it
    should retransmit a smaller portion of the payload.
    
    test packetdrill script:
        0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
       +0 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
       +0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
    
       +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
       +0 > S 0:0(0)  win 65535 <mss 1460,sackOK,TS val 100 ecr 0,nop,wscale 8>
     +.05 < S. 0:0(0) ack 1 win 6000 <mss 1000,nop,nop,sackOK>
       +0 > . 1:1(0) ack 1
    
       +0 write(3, ..., 10000) = 10000
    
       +0 > . 1:2001(2000) ack 1 win 65535
       +0 > . 2001:4001(2000) ack 1 win 65535
       +0 > . 4001:6001(2000) ack 1 win 65535
    
     +.05 < . 1:1(0) ack 4001 win 1001
    
    and tcpdump show:
    192.168.226.67.55 > 192.0.2.1.8080: Flags [.], seq 1:2001, ack 1, win 65535, length 2000
    192.168.226.67.55 > 192.0.2.1.8080: Flags [.], seq 2001:4001, ack 1, win 65535, length 2000
    192.168.226.67.55 > 192.0.2.1.8080: Flags [P.], seq 4001:5001, ack 1, win 65535, length 1000
    192.168.226.67.55 > 192.0.2.1.8080: Flags [.], seq 5001:6001, ack 1, win 65535, length 1000
    192.0.2.1.8080 > 192.168.226.67.55: Flags [.], ack 4001, win 1001, length 0
    192.168.226.67.55 > 192.0.2.1.8080: Flags [.], seq 5001:6001, ack 1, win 65535, length 1000
    192.168.226.67.55 > 192.0.2.1.8080: Flags [P.], seq 4001:5001, ack 1, win 65535, length 1000
    
    when cient retract window to 1001, send window is [4001,5002],
    but TLP send 5001-6001 packet which is out of send window.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Yonglong Li <liyonglong@chinatelecom.cn>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Link: https://lore.kernel.org/r/1657532838-20200-1-git-send-email-liyonglong@chinatelecom.cn
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0fb73634b3b56a49c8ad5b9e4917b189254a921d
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Date:   Thu Jun 23 14:55:46 2022 +0100

    media: platform: mtk-mdp: Fix mdp_ipi_comm structure alignment
    
    [ Upstream commit ab14c99c035da7156a3b66fa171171295bc4b89a ]
    
    The mdp_ipi_comm structure defines a command that is either
    PROCESS (start processing) or DEINIT (destroy instance); we
    are using this one to send PROCESS or DEINIT commands from Linux
    to an MDP instance through a VPU write but, while the first wants
    us to stay 4-bytes aligned, the VPU instead requires an 8-bytes
    data alignment.
    
    Keeping in mind that these commands are executed immediately
    after sending them (hence not chained with others before the
    VPU/MDP "actually" start executing), it is fine to simply add
    a padding of 4 bytes to this structure: this keeps the same
    performance as before, as we're still stack-allocating it,
    while avoiding hackery inside of mtk-vpu to ensure alignment
    bringing a definitely bigger performance impact.
    
    Fixes: c8eb2d7e8202 ("[media] media: Add Mediatek MDP Driver")
    Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
    Reviewed-by: Houlong Wei <houlong.wei@mediatek.com>
    Reviewed-by: Irui Wang <irui.wang@mediatek.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 87d8b15bf9a148b62aebc2b188e0ca8190718fd3
Author: Hangyu Hua <hbh25y@gmail.com>
Date:   Wed May 18 14:58:56 2022 +0800

    drm: bridge: sii8620: fix possible off-by-one
    
    [ Upstream commit 21779cc21c732c5eff8ea1624be6590450baa30f ]
    
    The next call to sii8620_burst_get_tx_buf will result in off-by-one
    When ctx->burst.tx_count + size == ARRAY_SIZE(ctx->burst.tx_buf). The same
    thing happens in sii8620_burst_get_rx_buf.
    
    This patch also change tx_count and tx_buf to rx_count and rx_buf in
    sii8620_burst_get_rx_buf. It is unreasonable to check tx_buf's size and
    use rx_buf.
    
    Fixes: e19e9c692f81 ("drm/bridge/sii8620: add support for burst eMSC transmissions")
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
    Signed-off-by: Robert Foss <robert.foss@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220518065856.18936-1-hbh25y@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 966a032cd1f7818a9e25e0047dfb9fd90e67fdbe
Author: Bo-Chen Chen <rex-bc.chen@mediatek.com>
Date:   Fri Jul 1 11:58:33 2022 +0800

    drm/mediatek: dpi: Remove output format of YUV
    
    [ Upstream commit c9ed0713b3c35fc45677707ba47f432cad95da56 ]
    
    DPI is not support output format as YUV, but there is the setting of
    configuring output YUV. Therefore, remove them in this patch.
    
    Fixes: 9e629c17aa8d ("drm/mediatek: Add DPI sub driver")
    Signed-off-by: Bo-Chen Chen <rex-bc.chen@mediatek.com>
    Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20220701035845.16458-5-rex-bc.chen@mediatek.com/
    Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d5c603034cf398f81318c5d325afda097fc48afe
Author: Brian Norris <briannorris@chromium.org>
Date:   Fri Jun 17 17:26:52 2022 -0700

    drm/rockchip: vop: Don't crash for invalid duplicate_state()
    
    [ Upstream commit 1449110b0dade8b638d2c17ab7c5b0ff696bfccb ]
    
    It's possible for users to try to duplicate the CRTC state even when the
    state doesn't exist. drm_atomic_helper_crtc_duplicate_state() (and other
    users of __drm_atomic_helper_crtc_duplicate_state()) already guard this
    with a WARN_ON() instead of crashing, so let's do that here too.
    
    Fixes: 4e257d9eee23 ("drm/rockchip: get rid of rockchip_drm_crtc_mode_config")
    Signed-off-by: Brian Norris <briannorris@chromium.org>
    Reviewed-by: Sean Paul <seanpaul@chromium.org>
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Signed-off-by: Heiko Stuebner <heiko@sntech.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220617172623.1.I62db228170b1559ada60b8d3e1637e1688424926@changeid
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2a3bf0fb348db4e7e9ededd328b26b7feb340e33
Author: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date:   Mon Jun 13 16:47:39 2022 +0200

    drm/vc4: dsi: Correct DSI divider calculations
    
    [ Upstream commit 3b45eee87da171caa28f61240ddb5c21170cda53 ]
    
    The divider calculations tried to find the divider just faster than the
    clock requested. However if it required a divider of 7 then the for loop
    aborted without handling the "error" case, and could end up with a clock
    lower than requested.
    
    The integer divider from parent PLL to DSI clock is also capable of
    going up to /255, not just /7 that the driver was trying.  This allows
    for slower link frequencies on the DSI bus where the resolution permits.
    
    Correct the loop so that we always have a clock greater than requested,
    and covering the whole range of dividers.
    
    Fixes: 86c1b9eff3f2 ("drm/vc4: Adjust modes in DSI to work around the integer PLL divider.")
    Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
    Link: https://lore.kernel.org/r/20220613144800.326124-13-maxime@cerno.tech
    Signed-off-by: Maxime Ripard <maxime@cerno.tech>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 386e943169eacf16dd90b783a9ce57e77b056df4
Author: Niels Dossche <dossche.niels@gmail.com>
Date:   Tue Jun 14 18:50:02 2022 +0100

    media: hdpvr: fix error value returns in hdpvr_read
    
    [ Upstream commit 359c27c6ddbde404f44a9c0d3ec88ccd1e2042f2 ]
    
    Error return values are supposed to be negative in hdpvr_read. Most
    error returns are currently handled via an unsigned integer "ret". When
    setting a negative error value to "ret", the value actually becomes a
    large positive value, because "ret" is unsigned. Later on, the "ret"
    value is returned. But as ssize_t is a 64-bit signed number, the error
    return value stays a large positive integer instead of a negative
    integer. This can cause an error value to be interpreted as the read
    size, which can cause a buffer overread for applications relying on the
    returned size.
    
    Fixes: 9aba42efe85b ("V4L/DVB (11096): V4L2 Driver for the Hauppauge HD PVR usb capture device")
    Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 736abe07b5b61d8c07a29f81383916a233abbc92
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Thu Jun 2 18:34:01 2022 +0800

    drm: bridge: adv7511: Add check for mipi_dsi_driver_register
    
    [ Upstream commit 831463667b5f4f1e5bce9c3b94e9e794d2bc8923 ]
    
    As mipi_dsi_driver_register could return error if fails,
    it should be better to check the return value and return error
    if fails.
    Moreover, if i2c_add_driver fails,  mipi_dsi_driver_register
    should be reverted.
    
    Fixes: 1e4d58cd7f88 ("drm/bridge: adv7533: Create a MIPI DSI device")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220602103401.2980938-1-jiasheng@iscas.ac.cn
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f59e7534e2b11d7c018a412c293897e8417addd4
Author: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Date:   Wed Jun 8 20:16:14 2022 +0300

    wifi: iwlegacy: 4965: fix potential off-by-one overflow in il4965_rs_fill_link_cmd()
    
    [ Upstream commit a8eb8e6f7159c7c20c0ddac428bde3d110890aa7 ]
    
    As a result of the execution of the inner while loop, the value
    of 'idx' can be equal to LINK_QUAL_MAX_RETRY_NUM. However, this
    is not checked after the loop and 'idx' is used to write the
    LINK_QUAL_MAX_RETRY_NUM size array 'lq_cmd->rs_table[idx]' below
    in the outer loop.
    
    The fix is to check the new value of 'idx' inside the nested loop,
    and break both loops if index equals the size. Checking it at the
    start is now pointless, so let's remove it.
    
    Detected using the static analysis tool - Svace.
    
    Fixes: be663ab67077 ("iwlwifi: split the drivers for agn and legacy devices 3945/4965")
    Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/20220608171614.28891-1-aleksei.kodanev@bell-sw.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 62bc1ea5c7401d77eaf73d0c6a15f3d2e742856e
Author: Pavel Skripkin <paskripkin@gmail.com>
Date:   Mon Jun 13 21:43:59 2022 +0300

    ath9k: fix use-after-free in ath9k_hif_usb_rx_cb
    
    [ Upstream commit 0ac4827f78c7ffe8eef074bc010e7e34bc22f533 ]
    
    Syzbot reported use-after-free Read in ath9k_hif_usb_rx_cb() [0]. The
    problem was in incorrect htc_handle->drv_priv initialization.
    
    Probable call trace which can trigger use-after-free:
    
    ath9k_htc_probe_device()
      /* htc_handle->drv_priv = priv; */
      ath9k_htc_wait_for_target()      <--- Failed
      ieee80211_free_hw()              <--- priv pointer is freed
    
    <IRQ>
    ...
    ath9k_hif_usb_rx_cb()
      ath9k_hif_usb_rx_stream()
       RX_STAT_INC()                <--- htc_handle->drv_priv access
    
    In order to not add fancy protection for drv_priv we can move
    htc_handle->drv_priv initialization at the end of the
    ath9k_htc_probe_device() and add helper macro to make
    all *_STAT_* macros NULL safe, since syzbot has reported related NULL
    deref in that macros [1]
    
    Link: https://syzkaller.appspot.com/bug?id=6ead44e37afb6866ac0c7dd121b4ce07cb665f60 [0]
    Link: https://syzkaller.appspot.com/bug?id=b8101ffcec107c0567a0cd8acbbacec91e9ee8de [1]
    Fixes: fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
    Reported-and-tested-by: syzbot+03110230a11411024147@syzkaller.appspotmail.com
    Reported-and-tested-by: syzbot+c6dde1f690b60e0b9fbe@syzkaller.appspotmail.com
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
    Link: https://lore.kernel.org/r/d57bbedc857950659bfacac0ab48790c1eda00c8.1655145743.git.paskripkin@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e6412ba3b6508bdf9c074d310bf4144afa6aec1a
Author: Xu Wang <vulab@iscas.ac.cn>
Date:   Fri Dec 27 09:34:32 2019 +0000

    i2c: Fix a potential use after free
    
    [ Upstream commit e4c72c06c367758a14f227c847f9d623f1994ecf ]
    
    Free the adap structure only after we are done using it.
    This patch just moves the put_device() down a bit to avoid the
    use after free.
    
    Fixes: 611e12ea0f12 ("i2c: core: manage i2c bus device refcount in i2c_[get|put]_adapter")
    Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
    [wsa: added comment to the code, added Fixes tag]
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c323dfdf91cff6c3185883b184d01d28889e1b4c
Author: Xinlei Lee <xinlei.lee@mediatek.com>
Date:   Fri May 20 10:00:07 2022 +0800

    drm/mediatek: Add pull-down MIPI operation in mtk_dsi_poweroff function
    
    [ Upstream commit fa5d0a0205c34734c5b8daa77e39ac2817f63a10 ]
    
    In the dsi_enable function, mtk_dsi_rxtx_control is to
    pull up the MIPI signal operation. Before dsi_disable,
    MIPI should also be pulled down by writing a register
    instead of disabling dsi.
    
    If disable dsi without pulling the mipi signal low, the value of
    the register will still maintain the setting of the mipi signal being
    pulled high.
    After resume, even if the mipi signal is not pulled high, it will still
    be in the high state.
    
    Fixes: 2e54c14e310f ("drm/mediatek: Add DSI sub driver")
    
    Link: https://patchwork.kernel.org/project/linux-mediatek/patch/1653012007-11854-5-git-send-email-xinlei.lee@mediatek.com/
    Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
    Signed-off-by: Xinlei Lee <xinlei.lee@mediatek.com>
    Reviewed-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
    Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ea73869df6ef386fc0feeb28ff66742ca835b18f
Author: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Date:   Mon Jun 6 16:50:54 2022 +0300

    drm/radeon: fix potential buffer overflow in ni_set_mc_special_registers()
    
    [ Upstream commit 136f614931a2bb73616b292cf542da3a18daefd5 ]
    
    The last case label can write two buffers 'mc_reg_address[j]' and
    'mc_data[j]' with 'j' offset equal to SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE
    since there are no checks for this value in both case labels after the
    last 'j++'.
    
    Instead of changing '>' to '>=' there, add the bounds check at the start
    of the second 'case' (the first one already has it).
    
    Also, remove redundant last checks for 'j' index bigger than array size.
    The expression is always false. Moreover, before or after the patch
    'table->last' can be equal to SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE and it
    seems it can be a valid value.
    
    Detected using the static analysis tool - Svace.
    Fixes: 69e0b57a91ad ("drm/radeon/kms: add dpm support for cayman (v5)")
    Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 980c3d9d904aa0e5e77dc40f47adb90b851eb8cf
Author: Mike Snitzer <snitzer@kernel.org>
Date:   Fri Jul 22 15:31:23 2022 -0400

    dm: return early from dm_pr_call() if DM device is suspended
    
    [ Upstream commit e120a5f1e78fab6223544e425015f393d90d6f0d ]
    
    Otherwise PR ops may be issued while the broader DM device is being
    reconfigured, etc.
    
    Fixes: 9c72bad1f31a ("dm: call PR reserve/unreserve on each underlying device")
    Signed-off-by: Mike Snitzer <snitzer@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f26a946a35838343b61d19711033bee2e1377dbb
Author: Markus Mayer <mmayer@broadcom.com>
Date:   Sun Jul 17 20:10:39 2022 -0700

    thermal/tools/tmon: Include pthread and time headers in tmon.h
    
    [ Upstream commit 0cf51bfe999524377fbb71becb583b4ca6d07cfc ]
    
    Include sys/time.h and pthread.h in tmon.h, so that types
    "pthread_mutex_t" and "struct timeval tv" are known when tmon.h
    references them.
    
    Without these headers, compiling tmon against musl-libc will fail with
    these errors:
    
    In file included from sysfs.c:31:0:
    tmon.h:47:8: error: unknown type name 'pthread_mutex_t'
     extern pthread_mutex_t input_lock;
            ^~~~~~~~~~~~~~~
    make[3]: *** [<builtin>: sysfs.o] Error 1
    make[3]: *** Waiting for unfinished jobs....
    In file included from tui.c:31:0:
    tmon.h:54:17: error: field 'tv' has incomplete type
      struct timeval tv;
                     ^~
    make[3]: *** [<builtin>: tui.o] Error 1
    make[2]: *** [Makefile:83: tmon] Error 2
    
    Signed-off-by: Markus Mayer <mmayer@broadcom.com>
    Acked-by: Florian Fainelli <f.fainelli@gmail.com>
    Reviewed-by: Sumeet Pawnikar <sumeet.r.pawnikar@intel.com>
    Acked-by: Alejandro González <alejandro.gonzalez.correo@gmail.com>
    Tested-by: Alejandro González <alejandro.gonzalez.correo@gmail.com>
    Fixes: 94f69966faf8 ("tools/thermal: Introduce tmon, a tool for thermal  subsystem")
    Link: https://lore.kernel.org/r/20220718031040.44714-1-f.fainelli@gmail.com
    Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a23098cc32860272dc6c3200ff20c34c65b7b694
Author: Liang He <windhl@126.com>
Date:   Fri Jul 15 19:10:27 2022 +0800

    regulator: of: Fix refcount leak bug in of_get_regulation_constraints()
    
    [ Upstream commit 66efb665cd5ad69b27dca8571bf89fc6b9c628a4 ]
    
    We should call the of_node_put() for the reference returned by
    of_get_child_by_name() which has increased the refcount.
    
    Fixes: 40e20d68bb3f ("regulator: of: Add support for parsing regulator_state for suspend state")
    Signed-off-by: Liang He <windhl@126.com>
    Link: https://lore.kernel.org/r/20220715111027.391032-1-windhl@126.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 372d735a619646fb277181253bc0e84237ac9a94
Author: Sireesh Kodali <sireeshkodali1@gmail.com>
Date:   Thu May 26 19:47:40 2022 +0530

    arm64: dts: qcom: msm8916: Fix typo in pronto remoteproc node
    
    [ Upstream commit 5458d6f2827cd30218570f266b8d238417461f2f ]
    
    The smem-state properties for the pronto node were incorrectly labelled,
    reading `qcom,state*` rather than `qcom,smem-state*`. Fix that, allowing
    the stop state to be used.
    
    Fixes: 88106096cbf8 ("ARM: dts: msm8916: Add and enable wcnss node")
    Signed-off-by: Sireesh Kodali <sireeshkodali1@gmail.com>
    Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Reviewed-by: Stephan Gerhold <stephan@gerhold.net>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220526141740.15834-3-sireeshkodali1@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9b1f220de7fced70df493583b068de8ce65e5371
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Wed Jun 8 13:27:02 2022 +0200

    ARM: dts: qcom: pm8841: add required thermal-sensor-cells
    
    [ Upstream commit e2759fa0676c9a32bbddb9aff955b54bb35066ad ]
    
    The PM8841 temperature sensor has to define thermal-sensor-cells.
    
    Fixes: dab8134ca072 ("ARM: dts: qcom: Add PM8841 functions device nodes")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220608112702.80873-2-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f52c9be1779d70037ae300762d19b08fe3656237
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Sun Jun 5 12:28:07 2022 +0400

    cpufreq: zynq: Fix refcount leak in zynq_get_revision
    
    [ Upstream commit d1ff2559cef0f6f8d97fba6337b28adb10689e16 ]
    
    of_find_compatible_node() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when done.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: 00f7dc636366 ("ARM: zynq: Add support for SOC_BUS")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20220605082807.21526-1-linmq006@gmail.com
    Signed-off-by: Michal Simek <michal.simek@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit baf669dc7d9a983d6a693bb6de2481698147dac9
Author: Michael Walle <michael@walle.cc>
Date:   Mon Apr 4 11:56:03 2022 +0200

    soc: fsl: guts: machine variable might be unset
    
    [ Upstream commit ab3f045774f704c4e7b6a878102f4e9d4ae7bc74 ]
    
    If both the model and the compatible properties are missing, then
    machine will not be set. Initialize it with NULL.
    
    Fixes: 34c1c21e94ac ("soc: fsl: fix section mismatch build warnings")
    Signed-off-by: Michael Walle <michael@walle.cc>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Shawn Guo <shawnguo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c5c35e82bee74a9cec5de18a3ce74633414cb1a6
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date:   Sun May 29 12:49:25 2022 +0200

    ARM: dts: ast2500-evb: fix board compatible
    
    [ Upstream commit 30b276fca5c0644f3cb17bceb1bd6a626c670184 ]
    
    The AST2500 EVB board should have dedicated compatible.
    
    Fixes: 02440622656d ("arm/dst: Add Aspeed ast2500 device tree")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Link: https://lore.kernel.org/r/20220529104928.79636-4-krzysztof.kozlowski@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 14498162de9077f24a0e4d605cd1d5795b707073
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Jun 20 16:07:23 2022 +0200

    x86/pmem: Fix platform-device leak in error path
    
    [ Upstream commit 229e73d46994f15314f58b2d39bf952111d89193 ]
    
    Make sure to free the platform device in the unlikely event that
    registration fails.
    
    Fixes: 7a67832c7e44 ("libnvdimm, e820: make CONFIG_X86_PMEM_LEGACY a tristate option")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/20220620140723.9810-1-johan@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 62d719d31ec667276d7375b64542b080cf187797
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Thu May 26 12:13:25 2022 +0400

    ARM: bcm: Fix refcount leak in bcm_kona_smc_init
    
    [ Upstream commit cb23389a2458c2e4bfd6c86a513cbbe1c4d35e76 ]
    
    of_find_matching_node() returns a node pointer with refcount
    incremented, we should use of_node_put() on it when not need anymore.
    Add missing of_node_put() to avoid refcount leak.
    
    Fixes: b8eb35fd594a ("ARM: bcm281xx: Add L2 cache enable code")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 853d0d96e44d07e757de7012ddc4bb957ee4cd16
Author: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Date:   Tue Jul 26 23:51:48 2022 +0100

    ARM: findbit: fix overflowing offset
    
    [ Upstream commit ec85bd369fd2bfaed6f45dd678706429d4f75b48 ]
    
    When offset is larger than the size of the bit array, we should not
    attempt to access the array as we can perform an access beyond the
    end of the array. Fix this by changing the pre-condition.
    
    Using "cmp r2, r1; bhs ..." covers us for the size == 0 case, since
    this will always take the branch when r1 is zero, irrespective of
    the value of r2. This means we can fix this bug without adding any
    additional code!
    
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2dabe6a872a5744865372eb30ea51e8ccd21305a
Author: Xiu Jianfeng <xiujianfeng@huawei.com>
Date:   Tue Jun 14 10:14:49 2022 +0800

    selinux: Add boundary check in put_entry()
    
    [ Upstream commit 15ec76fb29be31df2bccb30fc09875274cba2776 ]
    
    Just like next_entry(), boundary check is necessary to prevent memory
    out-of-bound access.
    
    Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8c90947e5f1801e6c7120021c6ea0f3ad6a4eb91
Author: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date:   Fri Jul 15 14:49:58 2022 +0900

    PM: hibernate: defer device probing when resuming from hibernation
    
    [ Upstream commit 8386c414e27caba8501119948e9551e52b527f59 ]
    
    syzbot is reporting hung task at misc_open() [1], for there is a race
    window of AB-BA deadlock which involves probe_count variable. Currently
    wait_for_device_probe() from snapshot_open() from misc_open() can sleep
    forever with misc_mtx held if probe_count cannot become 0.
    
    When a device is probed by hub_event() work function, probe_count is
    incremented before the probe function starts, and probe_count is
    decremented after the probe function completed.
    
    There are three cases that can prevent probe_count from dropping to 0.
    
      (a) A device being probed stopped responding (i.e. broken/malicious
          hardware).
    
      (b) A process emulating a USB device using /dev/raw-gadget interface
          stopped responding for some reason.
    
      (c) New device probe requests keeps coming in before existing device
          probe requests complete.
    
    The phenomenon syzbot is reporting is (b). A process which is holding
    system_transition_mutex and misc_mtx is waiting for probe_count to become
    0 inside wait_for_device_probe(), but the probe function which is called
     from hub_event() work function is waiting for the processes which are
    blocked at mutex_lock(&misc_mtx) to respond via /dev/raw-gadget interface.
    
    This patch mitigates (b) by deferring wait_for_device_probe() from
    snapshot_open() to snapshot_write() and snapshot_ioctl(). Please note that
    the possibility of (b) remains as long as any thread which is emulating a
    USB device via /dev/raw-gadget interface can be blocked by uninterruptible
    blocking operations (e.g. mutex_lock()).
    
    Please also note that (a) and (c) are not addressed. Regarding (c), we
    should change the code to wait for only one device which contains the
    image for resuming from hibernation. I don't know how to address (a), for
    use of timeout for wait_for_device_probe() might result in loss of user
    data in the image. Maybe we should require the userland to wait for the
    image device before opening /dev/snapshot interface.
    
    Link: https://syzkaller.appspot.com/bug?extid=358c9ab4c93da7b7238c [1]
    Reported-by: syzbot <syzbot+358c9ab4c93da7b7238c@syzkaller.appspotmail.com>
    Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Tested-by: syzbot <syzbot+358c9ab4c93da7b7238c@syzkaller.appspotmail.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 15583c70e795a430db120160c70dd3aec8577f2f
Author: huhai <huhai@kylinos.cn>
Date:   Thu Jun 23 21:21:27 2022 +0800

    ACPI: LPSS: Fix missing check in register_device_clock()
    
    [ Upstream commit b4f1f61ed5928b1128e60e38d0dffa16966f06dc ]
    
    register_device_clock() misses a check for platform_device_register_simple().
    Add a check to fix it.
    
    Signed-off-by: huhai <huhai@kylinos.cn>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bfbcbb63f25056325e82b1150ec76de15679106e
Author: Manyi Li <limanyi@uniontech.com>
Date:   Wed Jun 22 15:42:48 2022 +0800

    ACPI: PM: save NVS memory for Lenovo G40-45
    
    [ Upstream commit 4b7ef7b05afcde44142225c184bf43a0cd9e2178 ]
    
    [821d6f0359b0614792ab8e2fb93b503e25a65079] is to make machines
    produced from 2012 to now not saving NVS region to accelerate S3.
    
    But, Lenovo G40-45, a platform released in 2015, still needs NVS memory
    saving during S3. A quirk is introduced for this platform.
    
    Signed-off-by: Manyi Li <limanyi@uniontech.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bdbdf69d5b78c5712c60c0004fa6aed12da36e26
Author: Liang He <windhl@126.com>
Date:   Fri Jun 17 22:58:03 2022 +0800

    ARM: OMAP2+: display: Fix refcount leak bug
    
    [ Upstream commit 50b87a32a79bca6e275918a711fb8cc55e16d739 ]
    
    In omapdss_init_fbdev(), of_find_node_by_name() will return a node
    pointer with refcount incremented. We should use of_node_put() when
    it is not used anymore.
    
    Signed-off-by: Liang He <windhl@126.com>
    Message-Id: <20220617145803.4050918-1-windhl@126.com>
    Signed-off-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit becee48cc3cbf0eb1ce053b543554c70b5701044
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Mon Jun 13 14:33:57 2022 +0200

    ARM: dts: imx6ul: fix qspi node compatible
    
    [ Upstream commit 0c6cf86e1ab433b2d421880fdd9c6e954f404948 ]
    
    imx6ul is not compatible to imx6sx, both have different erratas.
    Fixes the dt_binding_check warning:
    spi@21e0000: compatible: 'oneOf' conditional failed, one must be fixed:
    ['fsl,imx6ul-qspi', 'fsl,imx6sx-qspi'] is too long
    Additional items are not allowed ('fsl,imx6sx-qspi' was unexpected)
    'fsl,imx6ul-qspi' is not one of ['fsl,ls1043a-qspi']
    'fsl,imx6ul-qspi' is not one of ['fsl,imx8mq-qspi']
    'fsl,ls1021a-qspi' was expected
    'fsl,imx7d-qspi' was expected
    
    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Signed-off-by: Shawn Guo <shawnguo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 31753ba14f8a8d9debc20c623db174858a99902b
Author: Alexander Stein <alexander.stein@ew.tq-group.com>
Date:   Mon Jun 13 14:33:51 2022 +0200

    ARM: dts: imx6ul: add missing properties for sram
    
    [ Upstream commit 5655699cf5cff9f4c4ee703792156bdd05d1addf ]
    
    All 3 properties are required by sram.yaml. Fixes the dtbs_check
    warning:
    sram@900000: '#address-cells' is a required property
    sram@900000: '#size-cells' is a required property
    sram@900000: 'ranges' is a required property
    
    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    Signed-off-by: Shawn Guo <shawnguo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0bcdc31094a12b4baf59e241feabc9787cf635fa
Author: Jan Kara <jack@suse.cz>
Date:   Tue Jul 26 13:13:50 2022 +0200

    ext2: Add more validity checks for inode counts
    
    [ Upstream commit fa78f336937240d1bc598db817d638086060e7e9 ]
    
    Add checks verifying number of inodes stored in the superblock matches
    the number computed from number of inodes per group. Also verify we have
    at least one block worth of inodes per group. This prevents crashes on
    corrupted filesystems.
    
    Reported-by: syzbot+d273f7d7f58afd93be48@syzkaller.appspotmail.com
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9d5fec6ba2e4117d196a8259ab54615ffe562460
Author: haibinzhang (张海斌) <haibinzhang@tencent.com>
Date:   Sat Jul 2 05:43:19 2022 +0000

    arm64: fix oops in concurrently setting insn_emulation sysctls
    
    [ Upstream commit af483947d472eccb79e42059276c4deed76f99a6 ]
    
    emulation_proc_handler() changes table->data for proc_dointvec_minmax
    and can generate the following Oops if called concurrently with itself:
    
     | Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
     | Internal error: Oops: 96000006 [#1] SMP
     | Call trace:
     | update_insn_emulation_mode+0xc0/0x148
     | emulation_proc_handler+0x64/0xb8
     | proc_sys_call_handler+0x9c/0xf8
     | proc_sys_write+0x18/0x20
     | __vfs_write+0x20/0x48
     | vfs_write+0xe4/0x1d0
     | ksys_write+0x70/0xf8
     | __arm64_sys_write+0x20/0x28
     | el0_svc_common.constprop.0+0x7c/0x1c0
     | el0_svc_handler+0x2c/0xa0
     | el0_svc+0x8/0x200
    
    To fix this issue, keep the table->data as &insn->current_mode and
    use container_of() to retrieve the insn pointer. Another mutex is
    used to protect against the current_mode update but not for retrieving
    insn_emulation as table->data is no longer changing.
    
    Co-developed-by: hewenliang <hewenliang4@huawei.com>
    Signed-off-by: hewenliang <hewenliang4@huawei.com>
    Signed-off-by: Haibin Zhang <haibinzhang@tencent.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Link: https://lore.kernel.org/r/20220128090324.2727688-1-hewenliang4@huawei.com
    Link: https://lore.kernel.org/r/9A004C03-250B-46C5-BF39-782D7551B00E@tencent.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 864b9eb65835503a03c9ae8a0be82f317f164bca
Author: Francis Laniel <flaniel@linux.microsoft.com>
Date:   Wed Jun 8 17:24:46 2022 +0100

    arm64: Do not forget syscall when starting a new thread.
    
    [ Upstream commit de6921856f99c11d3986c6702d851e1328d4f7f6 ]
    
    Enable tracing of the execve*() system calls with the
    syscalls:sys_exit_execve tracepoint by removing the call to
    forget_syscall() when starting a new thread and preserving the value of
    regs->syscallno across exec.
    
    Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
    Link: https://lore.kernel.org/r/20220608162447.666494-2-flaniel@linux.microsoft.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 49d57fb1fd44b9d3422f096d3b1b6415685d7364
Author: Florian Westphal <fw@strlen.de>
Date:   Tue Aug 9 18:34:02 2022 +0200

    netfilter: nf_tables: fix null deref due to zeroed list head
    
    commit 580077855a40741cf511766129702d97ff02f4d9 upstream.
    
    In nf_tables_updtable, if nf_tables_table_enable returns an error,
    nft_trans_destroy is called to free the transaction object.
    
    nft_trans_destroy() calls list_del(), but the transaction was never
    placed on a list -- the list head is all zeroes, this results in
    a null dereference:
    
    BUG: KASAN: null-ptr-deref in nft_trans_destroy+0x26/0x59
    Call Trace:
     nft_trans_destroy+0x26/0x59
     nf_tables_newtable+0x4bc/0x9bc
     [..]
    
    Its sane to assume that nft_trans_destroy() can be called
    on the transaction object returned by nft_trans_alloc(), so
    make sure the list head is initialised.
    
    Fixes: 55dd6f93076b ("netfilter: nf_tables: use new transaction infrastructure to handle table")
    Reported-by: mingi cho <mgcho.minic@gmail.com>
    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 c8a002d04f082d60bf84f6c0fa3f9b3996ce37a3
Author: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Date:   Tue Jul 26 15:49:18 2022 +0800

    USB: HCD: Fix URB giveback issue in tasklet function
    
    commit 26c6c2f8a907c9e3a2f24990552a4d77235791e6 upstream.
    
    Usb core introduce the mechanism of giveback of URB in tasklet context to
    reduce hardware interrupt handling time. On some test situation(such as
    FIO with 4KB block size), when tasklet callback function called to
    giveback URB, interrupt handler add URB node to the bh->head list also.
    If check bh->head list again after finish all URB giveback of local_list,
    then it may introduce a "dynamic balance" between giveback URB and add URB
    to bh->head list. This tasklet callback function may not exit for a long
    time, which will cause other tasklet function calls to be delayed. Some
    real-time applications(such as KB and Mouse) will see noticeable lag.
    
    In order to prevent the tasklet function from occupying the cpu for a long
    time at a time, new URBS will not be added to the local_list even though
    the bh->head list is not empty. But also need to ensure the left URB
    giveback to be processed in time, so add a member high_prio for structure
    giveback_urb_bh to prioritize tasklet and schelule this tasklet again if
    bh->head list is not empty.
    
    At the same time, we are able to prioritize tasklet through structure
    member high_prio. So, replace the local high_prio_bh variable with this
    structure member in usb_hcd_giveback_urb.
    
    Fixes: 94dfd7edfd5c ("USB: HCD: support giveback of URB in tasklet context")
    Cc: stable <stable@kernel.org>
    Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
    Link: https://lore.kernel.org/r/20220726074918.5114-1-WeitaoWang-oc@zhaoxin.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 98aaa511957667ba26d6dabe28dfa210a8f53a63
Author: Huacai Chen <chenhuacai@kernel.org>
Date:   Thu Jul 14 16:41:34 2022 +0800

    MIPS: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK
    
    commit e1a534f5d074db45ae5cbac41d8912b98e96a006 upstream.
    
    When CONFIG_CPUMASK_OFFSTACK and CONFIG_DEBUG_PER_CPU_MAPS is selected,
    cpu_max_bits_warn() generates a runtime warning similar as below while
    we show /proc/cpuinfo. Fix this by using nr_cpu_ids (the runtime limit)
    instead of NR_CPUS to iterate CPUs.
    
    [    3.052463] ------------[ cut here ]------------
    [    3.059679] WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:108 show_cpuinfo+0x5e8/0x5f0
    [    3.070072] Modules linked in: efivarfs autofs4
    [    3.076257] CPU: 0 PID: 1 Comm: systemd Not tainted 5.19-rc5+ #1052
    [    3.084034] Hardware name: Loongson Loongson-3A4000-7A1000-1w-V0.1-CRB/Loongson-LS3A4000-7A1000-1w-EVB-V1.21, BIOS Loongson-UDK2018-V2.0.04082-beta7 04/27
    [    3.099465] Stack : 9000000100157b08 9000000000f18530 9000000000cf846c 9000000100154000
    [    3.109127]         9000000100157a50 0000000000000000 9000000100157a58 9000000000ef7430
    [    3.118774]         90000001001578e8 0000000000000040 0000000000000020 ffffffffffffffff
    [    3.128412]         0000000000aaaaaa 1ab25f00eec96a37 900000010021de80 900000000101c890
    [    3.138056]         0000000000000000 0000000000000000 0000000000000000 0000000000aaaaaa
    [    3.147711]         ffff8000339dc220 0000000000000001 0000000006ab4000 0000000000000000
    [    3.157364]         900000000101c998 0000000000000004 9000000000ef7430 0000000000000000
    [    3.167012]         0000000000000009 000000000000006c 0000000000000000 0000000000000000
    [    3.176641]         9000000000d3de08 9000000001639390 90000000002086d8 00007ffff0080286
    [    3.186260]         00000000000000b0 0000000000000004 0000000000000000 0000000000071c1c
    [    3.195868]         ...
    [    3.199917] Call Trace:
    [    3.203941] [<98000000002086d8>] show_stack+0x38/0x14c
    [    3.210666] [<9800000000cf846c>] dump_stack_lvl+0x60/0x88
    [    3.217625] [<980000000023d268>] __warn+0xd0/0x100
    [    3.223958] [<9800000000cf3c90>] warn_slowpath_fmt+0x7c/0xcc
    [    3.231150] [<9800000000210220>] show_cpuinfo+0x5e8/0x5f0
    [    3.238080] [<98000000004f578c>] seq_read_iter+0x354/0x4b4
    [    3.245098] [<98000000004c2e90>] new_sync_read+0x17c/0x1c4
    [    3.252114] [<98000000004c5174>] vfs_read+0x138/0x1d0
    [    3.258694] [<98000000004c55f8>] ksys_read+0x70/0x100
    [    3.265265] [<9800000000cfde9c>] do_syscall+0x7c/0x94
    [    3.271820] [<9800000000202fe4>] handle_syscall+0xc4/0x160
    [    3.281824] ---[ end trace 8b484262b4b8c24c ]---
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4133c530bfba7cdc41d6b538acab543162cbbb71
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Thu Jul 28 00:32:17 2022 +1000

    powerpc/powernv: Avoid crashing if rng is NULL
    
    commit 90b5d4fe0b3ba7f589c6723c6bfb559d9e83956a upstream.
    
    On a bare-metal Power8 system that doesn't have an "ibm,power-rng", a
    malicious QEMU and guest that ignore the absence of the
    KVM_CAP_PPC_HWRNG flag, and calls H_RANDOM anyway, will dereference a
    NULL pointer.
    
    In practice all Power8 machines have an "ibm,power-rng", but let's not
    rely on that, add a NULL check and early return in
    powernv_get_random_real_mode().
    
    Fixes: e928e9cb3601 ("KVM: PPC: Book3S HV: Add fast real-mode H_RANDOM implementation.")
    Cc: stable@vger.kernel.org # v4.1+
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220727143219.2684192-1-mpe@ellerman.id.au
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 314836112f569ca11f758590475b7cd68cf89ca5
Author: Pali Rohár <pali@kernel.org>
Date:   Wed Jul 6 12:10:43 2022 +0200

    powerpc/fsl-pci: Fix Class Code of PCIe Root Port
    
    commit 0c551abfa004ce154d487d91777bf221c808a64f upstream.
    
    By default old pre-3.0 Freescale PCIe controllers reports invalid PCI Class
    Code 0x0b20 for PCIe Root Port. It can be seen by lspci -b output on P2020
    board which has this pre-3.0 controller:
    
      $ lspci -bvnn
      00:00.0 Power PC [0b20]: Freescale Semiconductor Inc P2020E [1957:0070] (rev 21)
              !!! Invalid class 0b20 for header type 01
              Capabilities: [4c] Express Root Port (Slot-), MSI 00
    
    Fix this issue by programming correct PCI Class Code 0x0604 for PCIe Root
    Port to the Freescale specific PCIe register 0x474.
    
    With this change lspci -b output is:
    
      $ lspci -bvnn
      00:00.0 PCI bridge [0604]: Freescale Semiconductor Inc P2020E [1957:0070] (rev 21) (prog-if 00 [Normal decode])
              Capabilities: [4c] Express Root Port (Slot-), MSI 00
    
    Without any "Invalid class" error. So class code was properly reflected
    into standard (read-only) PCI register 0x08.
    
    Same fix is already implemented in U-Boot pcie_fsl.c driver in commit:
    http://source.denx.de/u-boot/u-boot/-/commit/d18d06ac35229345a0af80977a408cfbe1d1015b
    
    Fix activated by U-Boot stay active also after booting Linux kernel.
    But boards which use older U-Boot version without that fix are affected and
    still require this fix.
    
    So implement this class code fix also in kernel fsl_pci.c driver.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220706101043.4867-1-pali@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c1429f8263e6fabbdd8780d4ad6afb590c569f32
Author: Pali Rohár <pali@kernel.org>
Date:   Mon Feb 14 12:41:08 2022 +0100

    PCI: Add defines for normal and subtractive PCI bridges
    
    commit 904b10fb189cc15376e9bfce1ef0282e68b0b004 upstream.
    
    Add these PCI class codes to pci_ids.h:
    
      PCI_CLASS_BRIDGE_PCI_NORMAL
      PCI_CLASS_BRIDGE_PCI_SUBTRACTIVE
    
    Use these defines in all kernel code for describing PCI class codes for
    normal and subtractive PCI bridges.
    
    [bhelgaas: similar change in pci-mvebu.c]
    Link: https://lore.kernel.org/r/20220214114109.26809-1-pali@kernel.org
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: Guenter Roeck <linux@roeck-us.net>a
    Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
    [ gregkh - take only the pci_ids.h portion for stable backports ]
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7a58ec078807e46fc36aa9d7f697c5eeecbd7cc9
Author: Alexander Lobakin <alexandr.lobakin@intel.com>
Date:   Fri Jun 24 14:13:05 2022 +0200

    ia64, processor: fix -Wincompatible-pointer-types in ia64_get_irr()
    
    commit e5a16a5c4602c119262f350274021f90465f479d upstream.
    
    test_bit(), as any other bitmap op, takes `unsigned long *` as a
    second argument (pointer to the actual bitmap), as any bitmap
    itself is an array of unsigned longs. However, the ia64_get_irr()
    code passes a ref to `u64` as a second argument.
    This works with the ia64 bitops implementation due to that they
    have `void *` as the second argument and then cast it later on.
    This works with the bitmap API itself due to that `unsigned long`
    has the same size on ia64 as `u64` (`unsigned long long`), but
    from the compiler PoV those two are different.
    Define @irr as `unsigned long` to fix that. That implies no
    functional changes. Has been hidden for 16 years!
    
    Fixes: a58786917ce2 ("[IA64] avoid broken SAL_CACHE_FLUSH implementations")
    Cc: stable@vger.kernel.org # 2.6.16+
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Yury Norov <yury.norov@gmail.com>
    Signed-off-by: Yury Norov <yury.norov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bcbdc26a44aba488d2f7122f2d66801bccb74733
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Tue Jul 26 04:33:12 2022 -0400

    md-raid10: fix KASAN warning
    
    commit d17f744e883b2f8d13cca252d71cfe8ace346f7d upstream.
    
    There's a KASAN warning in raid10_remove_disk when running the lvm
    test lvconvert-raid-reshape.sh. We fix this warning by verifying that the
    value "number" is valid.
    
    BUG: KASAN: slab-out-of-bounds in raid10_remove_disk+0x61/0x2a0 [raid10]
    Read of size 8 at addr ffff889108f3d300 by task mdX_raid10/124682
    
    CPU: 3 PID: 124682 Comm: mdX_raid10 Not tainted 5.19.0-rc6 #1
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014
    Call Trace:
     <TASK>
     dump_stack_lvl+0x34/0x44
     print_report.cold+0x45/0x57a
     ? __lock_text_start+0x18/0x18
     ? raid10_remove_disk+0x61/0x2a0 [raid10]
     kasan_report+0xa8/0xe0
     ? raid10_remove_disk+0x61/0x2a0 [raid10]
     raid10_remove_disk+0x61/0x2a0 [raid10]
    Buffer I/O error on dev dm-76, logical block 15344, async page read
     ? __mutex_unlock_slowpath.constprop.0+0x1e0/0x1e0
     remove_and_add_spares+0x367/0x8a0 [md_mod]
     ? super_written+0x1c0/0x1c0 [md_mod]
     ? mutex_trylock+0xac/0x120
     ? _raw_spin_lock+0x72/0xc0
     ? _raw_spin_lock_bh+0xc0/0xc0
     md_check_recovery+0x848/0x960 [md_mod]
     raid10d+0xcf/0x3360 [raid10]
     ? sched_clock_cpu+0x185/0x1a0
     ? rb_erase+0x4d4/0x620
     ? var_wake_function+0xe0/0xe0
     ? psi_group_change+0x411/0x500
     ? preempt_count_sub+0xf/0xc0
     ? _raw_spin_lock_irqsave+0x78/0xc0
     ? __lock_text_start+0x18/0x18
     ? raid10_sync_request+0x36c0/0x36c0 [raid10]
     ? preempt_count_sub+0xf/0xc0
     ? _raw_spin_unlock_irqrestore+0x19/0x40
     ? del_timer_sync+0xa9/0x100
     ? try_to_del_timer_sync+0xc0/0xc0
     ? _raw_spin_lock_irqsave+0x78/0xc0
     ? __lock_text_start+0x18/0x18
     ? _raw_spin_unlock_irq+0x11/0x24
     ? __list_del_entry_valid+0x68/0xa0
     ? finish_wait+0xa3/0x100
     md_thread+0x161/0x260 [md_mod]
     ? unregister_md_personality+0xa0/0xa0 [md_mod]
     ? _raw_spin_lock_irqsave+0x78/0xc0
     ? prepare_to_wait_event+0x2c0/0x2c0
     ? unregister_md_personality+0xa0/0xa0 [md_mod]
     kthread+0x148/0x180
     ? kthread_complete_and_exit+0x20/0x20
     ret_from_fork+0x1f/0x30
     </TASK>
    
    Allocated by task 124495:
     kasan_save_stack+0x1e/0x40
     __kasan_kmalloc+0x80/0xa0
     setup_conf+0x140/0x5c0 [raid10]
     raid10_run+0x4cd/0x740 [raid10]
     md_run+0x6f9/0x1300 [md_mod]
     raid_ctr+0x2531/0x4ac0 [dm_raid]
     dm_table_add_target+0x2b0/0x620 [dm_mod]
     table_load+0x1c8/0x400 [dm_mod]
     ctl_ioctl+0x29e/0x560 [dm_mod]
     dm_compat_ctl_ioctl+0x7/0x20 [dm_mod]
     __do_compat_sys_ioctl+0xfa/0x160
     do_syscall_64+0x90/0xc0
     entry_SYSCALL_64_after_hwframe+0x46/0xb0
    
    Last potentially related work creation:
     kasan_save_stack+0x1e/0x40
     __kasan_record_aux_stack+0x9e/0xc0
     kvfree_call_rcu+0x84/0x480
     timerfd_release+0x82/0x140
    L __fput+0xfa/0x400
     task_work_run+0x80/0xc0
     exit_to_user_mode_prepare+0x155/0x160
     syscall_exit_to_user_mode+0x12/0x40
     do_syscall_64+0x42/0xc0
     entry_SYSCALL_64_after_hwframe+0x46/0xb0
    
    Second to last potentially related work creation:
     kasan_save_stack+0x1e/0x40
     __kasan_record_aux_stack+0x9e/0xc0
     kvfree_call_rcu+0x84/0x480
     timerfd_release+0x82/0x140
     __fput+0xfa/0x400
     task_work_run+0x80/0xc0
     exit_to_user_mode_prepare+0x155/0x160
     syscall_exit_to_user_mode+0x12/0x40
     do_syscall_64+0x42/0xc0
     entry_SYSCALL_64_after_hwframe+0x46/0xb0
    
    The buggy address belongs to the object at ffff889108f3d200
     which belongs to the cache kmalloc-256 of size 256
    The buggy address is located 0 bytes to the right of
     256-byte region [ffff889108f3d200, ffff889108f3d300)
    
    The buggy address belongs to the physical page:
    page:000000007ef2a34c refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1108f3c
    head:000000007ef2a34c order:2 compound_mapcount:0 compound_pincount:0
    flags: 0x4000000000010200(slab|head|zone=2)
    raw: 4000000000010200 0000000000000000 dead000000000001 ffff889100042b40
    raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff889108f3d200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     ffff889108f3d280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    >ffff889108f3d300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                       ^
     ffff889108f3d380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
     ffff889108f3d400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Song Liu <song@kernel.org>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f41d1503642e7632b2d65fe5d2cea95371e4069f
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Thu Jul 21 16:06:18 2022 +0200

    fuse: limit nsec
    
    commit 47912eaa061a6a81e4aa790591a1874c650733c0 upstream.
    
    Limit nanoseconds to 0..999999999.
    
    Fixes: d8a5ba45457e ("[PATCH] FUSE - core")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ca63d5abf404d2934e2ac03545350de7bb8c8e96
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Sun Jul 17 08:42:41 2022 +0800

    iio: light: isl29028: Fix the warning in isl29028_remove()
    
    commit 06674fc7c003b9d0aa1d37fef7ab2c24802cc6ad upstream.
    
    The driver use the non-managed form of the register function in
    isl29028_remove(). To keep the release order as mirroring the ordering
    in probe, the driver should use non-managed form in probe, too.
    
    The following log reveals it:
    
    [   32.374955] isl29028 0-0010: remove
    [   32.376861] general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1] PREEMPT SMP KASAN PTI
    [   32.377676] KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
    [   32.379432] RIP: 0010:kernfs_find_and_get_ns+0x28/0xe0
    [   32.385461] Call Trace:
    [   32.385807]  sysfs_unmerge_group+0x59/0x110
    [   32.386110]  dpm_sysfs_remove+0x58/0xc0
    [   32.386391]  device_del+0x296/0xe50
    [   32.386959]  cdev_device_del+0x1d/0xd0
    [   32.387231]  devm_iio_device_unreg+0x27/0xb0
    [   32.387542]  devres_release_group+0x319/0x3d0
    [   32.388162]  i2c_device_remove+0x93/0x1f0
    
    Fixes: 2db5054ac28d ("staging: iio: isl29028: add runtime power management support")
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Link: https://lore.kernel.org/r/20220717004241.2281028-1-zheyuma97@gmail.com
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cfe6d4e509e3bdbab9a98732ce433e9382ca5ad3
Author: Leo Li <sunpeng.li@amd.com>
Date:   Tue Jul 12 12:30:29 2022 -0400

    drm/amdgpu: Check BO's requested pinning domains against its preferred_domains
    
    commit f5ba14043621f4afdf3ad5f92ee2d8dbebbe4340 upstream.
    
    When pinning a buffer, we should check to see if there are any
    additional restrictions imposed by bo->preferred_domains. This will
    prevent the BO from being moved to an invalid domain when pinning.
    
    For example, this can happen if the user requests to create a BO in GTT
    domain for display scanout. amdgpu_dm will allow pinning to either VRAM
    or GTT domains, since DCN can scanout from either or. However, in
    amdgpu_bo_pin_restricted(), pinning to VRAM is preferred if there is
    adequate carveout. This can lead to pinning to VRAM despite the user
    requesting GTT placement for the BO.
    
    v2: Allow the kernel to override the domain, which can happen when
        exporting a BO to a V4L camera (for example).
    
    Signed-off-by: Leo Li <sunpeng.li@amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Reviewed-by: Christian König <christian.koenig@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 7f2433e9aa9b70b082a9a45f3c2dd07c6b675ef2
Author: Timur Tabi <ttabi@nvidia.com>
Date:   Wed May 11 11:37:16 2022 -0500

    drm/nouveau: fix another off-by-one in nvbios_addr
    
    commit c441d28945fb113220d48d6c86ebc0b090a2b677 upstream.
    
    This check determines whether a given address is part of
    image 0 or image 1.  Image 1 starts at offset image0_size,
    so that address should be included.
    
    Fixes: 4d4e9907ff572 ("drm/nouveau/bios: guard against out-of-bounds accesses to image")
    Cc: <stable@vger.kernel.org> # v4.8+
    Signed-off-by: Timur Tabi <ttabi@nvidia.com>
    Reviewed-by: Karol Herbst <kherbst@redhat.com>
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220511163716.3520591-1-ttabi@nvidia.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d6f6d01c89a852f23c887c7f0b9df275c57897fe
Author: Helge Deller <deller@gmx.de>
Date:   Mon Jul 18 17:06:47 2022 +0200

    parisc: Fix device names in /proc/iomem
    
    commit cab56b51ec0e69128909cef4650e1907248d821b upstream.
    
    Fix the output of /proc/iomem to show the real hardware device name
    including the pa_pathname, e.g. "Merlin 160 Core Centronics [8:16:0]".
    Up to now only the pa_pathname ("[8:16.0]") was shown.
    
    Signed-off-by: Helge Deller <deller@gmx.de>
    Cc: <stable@vger.kernel.org> # v4.9+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e2a521a7dcc463c5017b4426ca0804e151faeff7
Author: Lukas Wunner <lukas@wunner.de>
Date:   Thu Jun 23 14:50:59 2022 +0200

    usbnet: Fix linkwatch use-after-free on disconnect
    
    commit a69e617e533edddf3fa3123149900f36e0a6dc74 upstream.
    
    usbnet uses the work usbnet_deferred_kevent() to perform tasks which may
    sleep.  On disconnect, completion of the work was originally awaited in
    ->ndo_stop().  But in 2003, that was moved to ->disconnect() by historic
    commit "[PATCH] USB: usbnet, prevent exotic rtnl deadlock":
    
      https://git.kernel.org/tglx/history/c/0f138bbfd83c
    
    The change was made because back then, the kernel's workqueue
    implementation did not allow waiting for a single work.  One had to wait
    for completion of *all* work by calling flush_scheduled_work(), and that
    could deadlock when waiting for usbnet_deferred_kevent() with rtnl_mutex
    held in ->ndo_stop().
    
    The commit solved one problem but created another:  It causes a
    use-after-free in USB Ethernet drivers aqc111.c, asix_devices.c,
    ax88179_178a.c, ch9200.c and smsc75xx.c:
    
    * If the drivers receive a link change interrupt immediately before
      disconnect, they raise EVENT_LINK_RESET in their (non-sleepable)
      ->status() callback and schedule usbnet_deferred_kevent().
    * usbnet_deferred_kevent() invokes the driver's ->link_reset() callback,
      which calls netif_carrier_{on,off}().
    * That in turn schedules the work linkwatch_event().
    
    Because usbnet_deferred_kevent() is awaited after unregister_netdev(),
    netif_carrier_{on,off}() may operate on an unregistered netdev and
    linkwatch_event() may run after free_netdev(), causing a use-after-free.
    
    In 2010, usbnet was changed to only wait for a single instance of
    usbnet_deferred_kevent() instead of *all* work by commit 23f333a2bfaf
    ("drivers/net: don't use flush_scheduled_work()").
    
    Unfortunately the commit neglected to move the wait back to
    ->ndo_stop().  Rectify that omission at long last.
    
    Reported-by: Jann Horn <jannh@google.com>
    Link: https://lore.kernel.org/netdev/CAG48ez0MHBbENX5gCdHAUXZ7h7s20LnepBF-pa5M=7Bi-jZrEA@mail.gmail.com/
    Reported-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Link: https://lore.kernel.org/netdev/20220315113841.GA22337@pengutronix.de/
    Signed-off-by: Lukas Wunner <lukas@wunner.de>
    Cc: stable@vger.kernel.org
    Acked-by: Oliver Neukum <oneukum@suse.com>
    Link: https://lore.kernel.org/r/d1c87ebe9fc502bffcd1576e238d685ad08321e4.1655987888.git.lukas@wunner.de
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e247a9e4c355a2941c1aa3798548c0fa3f96c0e0
Author: Yang Xu <xuyang2018.jy@fujitsu.com>
Date:   Thu Jul 14 14:11:26 2022 +0800

    fs: Add missing umask strip in vfs_tmpfile
    
    commit ac6800e279a22b28f4fc21439843025a0d5bf03e upstream.
    
    All creation paths except for O_TMPFILE handle umask in the vfs directly
    if the filesystem doesn't support or enable POSIX ACLs. If the filesystem
    does then umask handling is deferred until posix_acl_create().
    Because, O_TMPFILE misses umask handling in the vfs it will not honor
    umask settings. Fix this by adding the missing umask handling.
    
    Link: https://lore.kernel.org/r/1657779088-2242-2-git-send-email-xuyang2018.jy@fujitsu.com
    Fixes: 60545d0d4610 ("[O_TMPFILE] it's still short a few helpers, but infrastructure should be OK now...")
    Cc: <stable@vger.kernel.org> # 4.19+
    Reported-by: Christian Brauner (Microsoft) <brauner@kernel.org>
    Reviewed-by: Darrick J. Wong <djwong@kernel.org>
    Reviewed-and-Tested-by: Jeff Layton <jlayton@kernel.org>
    Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org>
    Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
    Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2a12f7734536055366aaf09d1b6ed9ae806beb61
Author: David Howells <dhowells@redhat.com>
Date:   Mon Aug 8 09:52:35 2022 +0100

    vfs: Check the truncate maximum size in inode_newsize_ok()
    
    commit e2ebff9c57fe4eb104ce4768f6ebcccf76bef849 upstream.
    
    If something manages to set the maximum file size to MAX_OFFSET+1, this
    can cause the xfs and ext4 filesystems at least to become corrupt.
    
    Ordinarily, the kernel protects against userspace trying this by
    checking the value early in the truncate() and ftruncate() system calls
    calls - but there are at least two places that this check is bypassed:
    
     (1) Cachefiles will round up the EOF of the backing file to DIO block
         size so as to allow DIO on the final block - but this might push
         the offset negative. It then calls notify_change(), but this
         inadvertently bypasses the checking. This can be triggered if
         someone puts an 8EiB-1 file on a server for someone else to try and
         access by, say, nfs.
    
     (2) ksmbd doesn't check the value it is given in set_end_of_file_info()
         and then calls vfs_truncate() directly - which also bypasses the
         check.
    
    In both cases, it is potentially possible for a network filesystem to
    cause a disk filesystem to be corrupted: cachefiles in the client's
    cache filesystem; ksmbd in the server's filesystem.
    
    nfsd is okay as it checks the value, but we can then remove this check
    too.
    
    Fix this by adding a check to inode_newsize_ok(), as called from
    setattr_prepare(), thereby catching the issue as filesystems set up to
    perform the truncate with minimal opportunity for bypassing the new
    check.
    
    Fixes: 1f08c925e7a3 ("cachefiles: Implement backing file wrangling")
    Fixes: f44158485826 ("cifsd: add file operations")
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reported-by: Jeff Layton <jlayton@kernel.org>
    Tested-by: Jeff Layton <jlayton@kernel.org>
    Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
    Cc: stable@kernel.org
    Acked-by: Alexander Viro <viro@zeniv.linux.org.uk>
    cc: Steve French <sfrench@samba.org>
    cc: Hyunchul Lee <hyc.lee@gmail.com>
    cc: Chuck Lever <chuck.lever@oracle.com>
    cc: Dave Wysochanski <dwysocha@redhat.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f0d877f8460384d0ce3c69bad2ffe29974e63ab5
Author: Allen Ballway <ballway@chromium.org>
Date:   Wed Aug 10 15:27:22 2022 +0000

    ALSA: hda/cirrus - support for iMac 12,1 model
    
    commit 74bba640d69914cf832b87f6bbb700e5ba430672 upstream.
    
    The 12,1 model requires the same configuration as the 12,2 model
    to enable headphones but has a different codec SSID. Adds
    12,1 SSID for matching quirk.
    
    [ re-sorted in SSID order by tiwai ]
    
    Signed-off-by: Allen Ballway <ballway@chromium.org>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220810152701.1.I902c2e591bbf8de9acb649d1322fa1f291849266@changeid
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e4a9889401b48f321d02af11bc7efa755fb0526
Author: Meng Tang <tangmeng@uniontech.com>
Date:   Mon Aug 8 15:34:06 2022 +0800

    ALSA: hda/conexant: Add quirk for LENOVO 20149 Notebook model
    
    commit f83bb2592482fe94c6eea07a8121763c80f36ce5 upstream.
    
    There is another LENOVO 20149 (Type1Sku0) Notebook model with
    CX20590, the device PCI SSID is 17aa:3977, which headphones are
    not responding, that requires the quirk CXT_PINCFG_LENOVO_NOTEBOOK.
    Add the corresponding entry to the quirk table.
    
    Signed-off-by: Meng Tang <tangmeng@uniontech.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220808073406.19460-1-tangmeng@uniontech.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 74cb3e6e45ba9882e908cbe9606a50c8ff077ac0
Author: Sean Christopherson <seanjc@google.com>
Date:   Mon Jul 11 23:27:49 2022 +0000

    KVM: x86: Set error code to segment selector on LLDT/LTR non-canonical #GP
    
    commit 2626206963ace9e8bf92b6eea5ff78dd674c555c upstream.
    
    When injecting a #GP on LLDT/LTR due to a non-canonical LDT/TSS base, set
    the error code to the selector.  Intel SDM's says nothing about the #GP,
    but AMD's APM explicitly states that both LLDT and LTR set the error code
    to the selector, not zero.
    
    Note, a non-canonical memory operand on LLDT/LTR does generate a #GP(0),
    but the KVM code in question is specific to the base from the descriptor.
    
    Fixes: e37a75a13cda ("KVM: x86: Emulator ignores LDTR/TR extended base on LLDT/LTR")
    Cc: stable@vger.kernel.org
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
    Link: https://lore.kernel.org/r/20220711232750.1092012-3-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d651c3a28bf6e82a3f8b1d4aa877a2ca57e1f0cf
Author: Sean Christopherson <seanjc@google.com>
Date:   Mon Jul 11 23:27:48 2022 +0000

    KVM: x86: Mark TSS busy during LTR emulation _after_ all fault checks
    
    commit ec6e4d863258d4bfb36d48d5e3ef68140234d688 upstream.
    
    Wait to mark the TSS as busy during LTR emulation until after all fault
    checks for the LTR have passed.  Specifically, don't mark the TSS busy if
    the new TSS base is non-canonical.
    
    Opportunistically drop the one-off !seg_desc.PRESENT check for TR as the
    only reason for the early check was to avoid marking a !PRESENT TSS as
    busy, i.e. the common !PRESENT is now done before setting the busy bit.
    
    Fixes: e37a75a13cda ("KVM: x86: Emulator ignores LDTR/TR extended base on LLDT/LTR")
    Reported-by: syzbot+760a73552f47a8cd0fd9@syzkaller.appspotmail.com
    Cc: stable@vger.kernel.org
    Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
    Cc: Hou Wenlong <houwenlong.hwl@antgroup.com>
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
    Link: https://lore.kernel.org/r/20220711232750.1092012-2-seanjc@google.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6fcbab82ccbcde915644085f73d3487938bda42d
Author: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Date:   Mon May 2 00:07:26 2022 +0200

    KVM: SVM: Don't BUG if userspace injects an interrupt with GIF=0
    
    commit f17c31c48e5cde9895a491d91c424eeeada3e134 upstream.
    
    Don't BUG/WARN on interrupt injection due to GIF being cleared,
    since it's trivial for userspace to force the situation via
    KVM_SET_VCPU_EVENTS (even if having at least a WARN there would be correct
    for KVM internally generated injections).
    
      kernel BUG at arch/x86/kvm/svm/svm.c:3386!
      invalid opcode: 0000 [#1] SMP
      CPU: 15 PID: 926 Comm: smm_test Not tainted 5.17.0-rc3+ #264
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
      RIP: 0010:svm_inject_irq+0xab/0xb0 [kvm_amd]
      Code: <0f> 0b 0f 1f 00 0f 1f 44 00 00 80 3d ac b3 01 00 00 55 48 89 f5 53
      RSP: 0018:ffffc90000b37d88 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: ffff88810a234ac0 RCX: 0000000000000006
      RDX: 0000000000000000 RSI: ffffc90000b37df7 RDI: ffff88810a234ac0
      RBP: ffffc90000b37df7 R08: ffff88810a1fa410 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
      R13: ffff888109571000 R14: ffff88810a234ac0 R15: 0000000000000000
      FS:  0000000001821380(0000) GS:ffff88846fdc0000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f74fc550008 CR3: 000000010a6fe000 CR4: 0000000000350ea0
      Call Trace:
       <TASK>
       inject_pending_event+0x2f7/0x4c0 [kvm]
       kvm_arch_vcpu_ioctl_run+0x791/0x17a0 [kvm]
       kvm_vcpu_ioctl+0x26d/0x650 [kvm]
       __x64_sys_ioctl+0x82/0xb0
       do_syscall_64+0x3b/0xc0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
       </TASK>
    
    Fixes: 219b65dcf6c0 ("KVM: SVM: Improve nested interrupt injection")
    Cc: stable@vger.kernel.org
    Co-developed-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
    Message-Id: <35426af6e123cbe91ec7ce5132ce72521f02b1b5.1651440202.git.maciej.szmigiero@oracle.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6331290180c53e859d55e2b0a45623235e45d741
Author: Ping Cheng <pinglinux@gmail.com>
Date:   Fri May 13 14:52:37 2022 -0700

    HID: wacom: Don't register pad_input for touch switch
    
    commit d6b675687a4ab4dba684716d97c8c6f81bf10905 upstream.
    
    Touch switch state is received through WACOM_PAD_FIELD. However, it
    is reported by touch_input. Don't register pad_input if no other pad
    events require the interface.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
    Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 484f8486a8bfeeb156c2346f2ce29fddb3bef7f0
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Tue Aug 9 14:32:13 2022 -0400

    add barriers to buffer_uptodate and set_buffer_uptodate
    
    commit d4252071b97d2027d246f6a82cbee4d52f618b47 upstream.
    
    Let's have a look at this piece of code in __bread_slow:
    
            get_bh(bh);
            bh->b_end_io = end_buffer_read_sync;
            submit_bh(REQ_OP_READ, 0, bh);
            wait_on_buffer(bh);
            if (buffer_uptodate(bh))
                    return bh;
    
    Neither wait_on_buffer nor buffer_uptodate contain any memory barrier.
    Consequently, if someone calls sb_bread and then reads the buffer data,
    the read of buffer data may be executed before wait_on_buffer(bh) on
    architectures with weak memory ordering and it may return invalid data.
    
    Fix this bug by adding a memory barrier to set_buffer_uptodate and an
    acquire barrier to buffer_uptodate (in a similar way as
    folio_test_uptodate and folio_mark_uptodate).
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4fc41f7ebb7efca282f1740ea934d16f33c1d109
Author: Zheyu Ma <zheyuma97@gmail.com>
Date:   Fri Jul 15 09:05:15 2022 +0800

    ALSA: bcd2000: Fix a UAF bug on the error path of probing
    
    commit ffb2759df7efbc00187bfd9d1072434a13a54139 upstream.
    
    When the driver fails in snd_card_register() at probe time, it will free
    the 'bcd2k->midi_out_urb' before killing it, which may cause a UAF bug.
    
    The following log can reveal it:
    
    [   50.727020] BUG: KASAN: use-after-free in bcd2000_input_complete+0x1f1/0x2e0 [snd_bcd2000]
    [   50.727623] Read of size 8 at addr ffff88810fab0e88 by task swapper/4/0
    [   50.729530] Call Trace:
    [   50.732899]  bcd2000_input_complete+0x1f1/0x2e0 [snd_bcd2000]
    
    Fix this by adding usb_kill_urb() before usb_free_urb().
    
    Fixes: b47a22290d58 ("ALSA: MIDI driver for Behringer BCD2000 USB device")
    Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220715010515.2087925-1-zheyuma97@gmail.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9d9fc744c98a7c1ff57ba8028c6473d574485844
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Wed Aug 10 15:24:41 2022 -0700

    x86: link vdso and boot with -z noexecstack --no-warn-rwx-segments
    
    commit ffcf9c5700e49c0aee42dcba9a12ba21338e8136 upstream.
    
    Users of GNU ld (BFD) from binutils 2.39+ will observe multiple
    instances of a new warning when linking kernels in the form:
    
      ld: warning: arch/x86/boot/pmjump.o: missing .note.GNU-stack section implies executable stack
      ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
      ld: warning: arch/x86/boot/compressed/vmlinux has a LOAD segment with RWX permissions
    
    Generally, we would like to avoid the stack being executable.  Because
    there could be a need for the stack to be executable, assembler sources
    have to opt-in to this security feature via explicit creation of the
    .note.GNU-stack feature (which compilers create by default) or command
    line flag --noexecstack.  Or we can simply tell the linker the
    production of such sections is irrelevant and to link the stack as
    --noexecstack.
    
    LLVM's LLD linker defaults to -z noexecstack, so this flag isn't
    strictly necessary when linking with LLD, only BFD, but it doesn't hurt
    to be explicit here for all linkers IMO.  --no-warn-rwx-segments is
    currently BFD specific and only available in the current latest release,
    so it's wrapped in an ld-option check.
    
    While the kernel makes extensive usage of ELF sections, it doesn't use
    permissions from ELF segments.
    
    Link: https://lore.kernel.org/linux-block/3af4127a-f453-4cf7-f133-a181cce06f73@kernel.dk/
    Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba951afb99912da01a6e8434126b8fac7aa75107
    Link: https://github.com/llvm/llvm-project/issues/57009
    Reported-and-tested-by: Jens Axboe <axboe@kernel.dk>
    Suggested-by: Fangrui Song <maskray@google.com>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7f613d231fc749fe1fda3f14c971867e4eb02f45
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Wed Aug 10 15:24:40 2022 -0700

    Makefile: link with -z noexecstack --no-warn-rwx-segments
    
    commit 0d362be5b14200b77ecc2127936a5ff82fbffe41 upstream.
    
    Users of GNU ld (BFD) from binutils 2.39+ will observe multiple
    instances of a new warning when linking kernels in the form:
    
      ld: warning: vmlinux: missing .note.GNU-stack section implies executable stack
      ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
      ld: warning: vmlinux has a LOAD segment with RWX permissions
    
    Generally, we would like to avoid the stack being executable.  Because
    there could be a need for the stack to be executable, assembler sources
    have to opt-in to this security feature via explicit creation of the
    .note.GNU-stack feature (which compilers create by default) or command
    line flag --noexecstack.  Or we can simply tell the linker the
    production of such sections is irrelevant and to link the stack as
    --noexecstack.
    
    LLVM's LLD linker defaults to -z noexecstack, so this flag isn't
    strictly necessary when linking with LLD, only BFD, but it doesn't hurt
    to be explicit here for all linkers IMO.  --no-warn-rwx-segments is
    currently BFD specific and only available in the current latest release,
    so it's wrapped in an ld-option check.
    
    While the kernel makes extensive usage of ELF sections, it doesn't use
    permissions from ELF segments.
    
    Link: https://lore.kernel.org/linux-block/3af4127a-f453-4cf7-f133-a181cce06f73@kernel.dk/
    Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ba951afb99912da01a6e8434126b8fac7aa75107
    Link: https://github.com/llvm/llvm-project/issues/57009
    Reported-and-tested-by: Jens Axboe <axboe@kernel.dk>
    Suggested-by: Fangrui Song <maskray@google.com>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 00acc945f51ec20ce8612f11f955d23496f9c2b0
Author: Ning Qiang <sohu0106@126.com>
Date:   Wed Jul 13 23:37:34 2022 +0800

    macintosh/adb: fix oob read in do_adb_query() function
    
    commit fd97e4ad6d3b0c9fce3bca8ea8e6969d9ce7423b upstream.
    
    In do_adb_query() function of drivers/macintosh/adb.c, req->data is copied
    form userland. The parameter "req->data[2]" is missing check, the array
    size of adb_handler[] is 16, so adb_handler[req->data[2]].original_address and
    adb_handler[req->data[2]].handler_id will lead to oob read.
    
    Cc: stable <stable@kernel.org>
    Signed-off-by: Ning Qiang <sohu0106@126.com>
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20220713153734.2248-1-sohu0106@126.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b0e034f11f0ffb878af72b604d4819594ddbfbc1
Author: Werner Sembach <wse@tuxedocomputers.com>
Date:   Thu Jul 7 20:09:53 2022 +0200

    ACPI: video: Shortening quirk list by identifying Clevo by board_name only
    
    commit f0341e67b3782603737f7788e71bd3530012a4f4 upstream.
    
    Taking a recent change in the i8042 quirklist to this one: Clevo
    board_names are somewhat unique, and if not: The generic Board_-/Sys_Vendor
    string "Notebook" doesn't help much anyway. So identifying the devices just
    by the board_name helps keeping the list significantly shorter and might
    even hit more devices requiring the fix.
    
    Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
    Fixes: c844d22fe0c0 ("ACPI: video: Force backlight native for Clevo NL5xRU and NL5xNU")
    Cc: All applicable <stable@vger.kernel.org>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b04a537b941db2e21b20f090d90b6f0016a160df
Author: Werner Sembach <wse@tuxedocomputers.com>
Date:   Thu Jul 7 20:09:52 2022 +0200

    ACPI: video: Force backlight native for some TongFang devices
    
    commit c752089f7cf5b5800c6ace4cdd1a8351ee78a598 upstream.
    
    The TongFang PF5PU1G, PF4NU1F, PF5NU1G, and PF5LUXG/TUXEDO BA15 Gen10,
    Pulse 14/15 Gen1, and Pulse 15 Gen2 have the same problem as the Clevo
    NL5xRU and NL5xNU/TUXEDO Aura 15 Gen1 and Gen2:
    They have a working native and video interface. However the default
    detection mechanism first registers the video interface before
    unregistering it again and switching to the native interface during boot.
    This results in a dangling SBIOS request for backlight change for some
    reason, causing the backlight to switch to ~2% once per boot on the first
    power cord connect or disconnect event. Setting the native interface
    explicitly circumvents this buggy behaviour by avoiding the unregistering
    process.
    
    Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
    Cc: All applicable <stable@vger.kernel.org>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 569294b23ce57a935d103155b620ad6c839181b1
Author: Wei Mingzhi <whistler@member.fsf.org>
Date:   Sat Jun 19 00:08:40 2021 +0800

    mt7601u: add USB device ID for some versions of XiaoDu WiFi Dongle.
    
    commit 829eea7c94e0bac804e65975639a2f2e5f147033 upstream.
    
    USB device ID of some versions of XiaoDu WiFi Dongle is 2955:1003
    instead of 2955:1001. Both are the same mt7601u hardware.
    
    Signed-off-by: Wei Mingzhi <whistler@member.fsf.org>
    Acked-by: Jakub Kicinski <kubakici@wp.pl>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/20210618160840.305024-1-whistler@member.fsf.org
    Cc: Yan Xinyu <sdlyyxy@bupt.edu.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 90b3c3c6f396f278315940c5ec5369073ccd99c0
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Sun Jul 31 12:05:51 2022 +0200

    ARM: crypto: comment out gcc warning that breaks clang builds
    
    The gcc build warning prevents all clang-built kernels from working
    properly, so comment it out to fix the build.
    
    This is a -stable kernel only patch for now, it will be resolved
    differently in mainline releases in the future.
    
    Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
    Cc: "Justin M. Forbes" <jforbes@fedoraproject.org>
    Cc: Ard Biesheuvel <ardb@kernel.org>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Cc: Nicolas Pitre <nico@linaro.org>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 83636c64b796a7e44fa72f371777f803c1ef9e74
Author: Florian Westphal <fw@strlen.de>
Date:   Tue Jul 26 12:42:06 2022 +0200

    netfilter: nf_queue: do not allow packet truncation below transport header offset
    
    [ Upstream commit 99a63d36cb3ed5ca3aa6fcb64cffbeaf3b0fb164 ]
    
    Domingo Dirutigliano and Nicola Guerrera report kernel panic when
    sending nf_queue verdict with 1-byte nfta_payload attribute.
    
    The IP/IPv6 stack pulls the IP(v6) header from the packet after the
    input hook.
    
    If user truncates the packet below the header size, this skb_pull() will
    result in a malformed skb (skb->len < 0).
    
    Fixes: 7af4cc3fa158 ("[NETFILTER]: Add "nfnetlink_queue" netfilter queue handler over nfnetlink")
    Reported-by: Domingo Dirutigliano <pwnzer0tt1@proton.me>
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 23a925c92f1fc81c219109ba486e1008815c3135
Author: Liang He <windhl@126.com>
Date:   Wed Jul 20 21:10:03 2022 +0800

    net: sungem_phy: Add of_node_put() for reference returned by of_get_parent()
    
    [ Upstream commit ebbbe23fdf6070e31509638df3321688358cc211 ]
    
    In bcm5421_init(), we should call of_node_put() for the reference
    returned by of_get_parent() which has increased the refcount.
    
    Fixes: 3c326fe9cb7a ("[PATCH] ppc64: Add new PHY to sungem")
    Signed-off-by: Liang He <windhl@126.com>
    Link: https://lore.kernel.org/r/20220720131003.1287426-1-windhl@126.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit dee475fa36cb3a91ebed5e378a08f0da30b5105f
Author: Kuniyuki Iwashima <kuniyu@amazon.com>
Date:   Wed Jul 27 18:22:20 2022 -0700

    net: ping6: Fix memleak in ipv6_renew_options().
    
    commit e27326009a3d247b831eda38878c777f6f4eb3d1 upstream.
    
    When we close ping6 sockets, some resources are left unfreed because
    pingv6_prot is missing sk->sk_prot->destroy().  As reported by
    syzbot [0], just three syscalls leak 96 bytes and easily cause OOM.
    
        struct ipv6_sr_hdr *hdr;
        char data[24] = {0};
        int fd;
    
        hdr = (struct ipv6_sr_hdr *)data;
        hdr->hdrlen = 2;
        hdr->type = IPV6_SRCRT_TYPE_4;
    
        fd = socket(AF_INET6, SOCK_DGRAM, NEXTHDR_ICMP);
        setsockopt(fd, IPPROTO_IPV6, IPV6_RTHDR, data, 24);
        close(fd);
    
    To fix memory leaks, let's add a destroy function.
    
    Note the socket() syscall checks if the GID is within the range of
    net.ipv4.ping_group_range.  The default value is [1, 0] so that no
    GID meets the condition (1 <= GID <= 0).  Thus, the local DoS does
    not succeed until we change the default value.  However, at least
    Ubuntu/Fedora/RHEL loosen it.
    
        $ cat /usr/lib/sysctl.d/50-default.conf
        ...
        -net.ipv4.ping_group_range = 0 2147483647
    
    Also, there could be another path reported with these options, and
    some of them require CAP_NET_RAW.
    
      setsockopt
          IPV6_ADDRFORM (inet6_sk(sk)->pktoptions)
          IPV6_RECVPATHMTU (inet6_sk(sk)->rxpmtu)
          IPV6_HOPOPTS (inet6_sk(sk)->opt)
          IPV6_RTHDRDSTOPTS (inet6_sk(sk)->opt)
          IPV6_RTHDR (inet6_sk(sk)->opt)
          IPV6_DSTOPTS (inet6_sk(sk)->opt)
          IPV6_2292PKTOPTIONS (inet6_sk(sk)->opt)
    
      getsockopt
          IPV6_FLOWLABEL_MGR (inet6_sk(sk)->ipv6_fl_list)
    
    For the record, I left a different splat with syzbot's one.
    
      unreferenced object 0xffff888006270c60 (size 96):
        comm "repro2", pid 231, jiffies 4294696626 (age 13.118s)
        hex dump (first 32 bytes):
          01 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00  ....D...........
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000f6bc7ea9>] sock_kmalloc (net/core/sock.c:2564 net/core/sock.c:2554)
          [<000000006d699550>] do_ipv6_setsockopt.constprop.0 (net/ipv6/ipv6_sockglue.c:715)
          [<00000000c3c3b1f5>] ipv6_setsockopt (net/ipv6/ipv6_sockglue.c:1024)
          [<000000007096a025>] __sys_setsockopt (net/socket.c:2254)
          [<000000003a8ff47b>] __x64_sys_setsockopt (net/socket.c:2265 net/socket.c:2262 net/socket.c:2262)
          [<000000007c409dcb>] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
          [<00000000e939c4a9>] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120)
    
    [0]: https://syzkaller.appspot.com/bug?extid=a8430774139ec3ab7176
    
    Fixes: 6d0bfe226116 ("net: ipv6: Add IPv6 support to the ping socket.")
    Reported-by: syzbot+a8430774139ec3ab7176@syzkaller.appspotmail.com
    Reported-by: Ayushman Dutta <ayudutta@amazon.com>
    Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Link: https://lore.kernel.org/r/20220728012220.46918-1-kuniyu@amazon.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d810212cd20803a1c90d54934a2eed5ea27d0d88
Author: Liang He <windhl@126.com>
Date:   Tue Jul 19 15:15:29 2022 +0800

    scsi: ufs: host: Hold reference returned by of_parse_phandle()
    
    commit a3435afba87dc6cd83f5595e7607f3c40f93ef01 upstream.
    
    In ufshcd_populate_vreg(), we should hold the reference returned by
    of_parse_phandle() and then use it to call of_node_put() for refcount
    balance.
    
    Link: https://lore.kernel.org/r/20220719071529.1081166-1-windhl@126.com
    Fixes: aa4976130934 ("ufs: Add regulator enable support")
    Reviewed-by: Bart Van Assche <bvanassche@acm.org>
    Signed-off-by: Liang He <windhl@126.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fd174ecef9350fea85c8c3e28e5c17a5b7960894
Author: Harald Freudenberger <freude@linux.ibm.com>
Date:   Wed Jul 13 15:17:21 2022 +0200

    s390/archrandom: prevent CPACF trng invocations in interrupt context
    
    commit 918e75f77af7d2e049bb70469ec0a2c12782d96a upstream.
    
    This patch slightly reworks the s390 arch_get_random_seed_{int,long}
    implementation: Make sure the CPACF trng instruction is never
    called in any interrupt context. This is done by adding an
    additional condition in_task().
    
    Justification:
    
    There are some constrains to satisfy for the invocation of the
    arch_get_random_seed_{int,long}() functions:
    - They should provide good random data during kernel initialization.
    - They should not be called in interrupt context as the TRNG
      instruction is relatively heavy weight and may for example
      make some network loads cause to timeout and buck.
    
    However, it was not clear what kind of interrupt context is exactly
    encountered during kernel init or network traffic eventually calling
    arch_get_random_seed_long().
    
    After some days of investigations it is clear that the s390
    start_kernel function is not running in any interrupt context and
    so the trng is called:
    
    Jul 11 18:33:39 t35lp54 kernel:  [<00000001064e90ca>] arch_get_random_seed_long.part.0+0x32/0x70
    Jul 11 18:33:39 t35lp54 kernel:  [<000000010715f246>] random_init+0xf6/0x238
    Jul 11 18:33:39 t35lp54 kernel:  [<000000010712545c>] start_kernel+0x4a4/0x628
    Jul 11 18:33:39 t35lp54 kernel:  [<000000010590402a>] startup_continue+0x2a/0x40
    
    The condition in_task() is true and the CPACF trng provides random data
    during kernel startup.
    
    The network traffic however, is more difficult. A typical call stack
    looks like this:
    
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b5600fc>] extract_entropy.constprop.0+0x23c/0x240
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b560136>] crng_reseed+0x36/0xd8
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b5604b8>] crng_make_state+0x78/0x340
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b5607e0>] _get_random_bytes+0x60/0xf8
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b56108a>] get_random_u32+0xda/0x248
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008aefe7a8>] kfence_guarded_alloc+0x48/0x4b8
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008aeff35e>] __kfence_alloc+0x18e/0x1b8
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008aef7f10>] __kmalloc_node_track_caller+0x368/0x4d8
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b611eac>] kmalloc_reserve+0x44/0xa0
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b611f98>] __alloc_skb+0x90/0x178
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b6120dc>] __napi_alloc_skb+0x5c/0x118
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b8f06b4>] qeth_extract_skb+0x13c/0x680
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b8f6526>] qeth_poll+0x256/0x3f8
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b63d76e>] __napi_poll.constprop.0+0x46/0x2f8
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b63dbec>] net_rx_action+0x1cc/0x408
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b937302>] __do_softirq+0x132/0x6b0
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008abf46ce>] __irq_exit_rcu+0x13e/0x170
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008abf531a>] irq_exit_rcu+0x22/0x50
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b922506>] do_io_irq+0xe6/0x198
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b935826>] io_int_handler+0xd6/0x110
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b9358a6>] psw_idle_exit+0x0/0xa
    Jul 06 17:37:07 t35lp54 kernel: ([<000000008ab9c59a>] arch_cpu_idle+0x52/0xe0)
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b933cfe>] default_idle_call+0x6e/0xd0
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008ac59f4e>] do_idle+0xf6/0x1b0
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008ac5a28e>] cpu_startup_entry+0x36/0x40
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008abb0d90>] smp_start_secondary+0x148/0x158
    Jul 06 17:37:07 t35lp54 kernel:  [<000000008b935b9e>] restart_int_handler+0x6e/0x90
    
    which confirms that the call is in softirq context. So in_task() covers exactly
    the cases where we want to have CPACF trng called: not in nmi, not in hard irq,
    not in soft irq but in normal task context and during kernel init.
    
    Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
    Acked-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
    Link: https://lore.kernel.org/r/20220713131721.257907-1-freude@linux.ibm.com
    Fixes: e4f74400308c ("s390/archrandom: simplify back to earlier design and initialize earlier")
    [agordeev@linux.ibm.com changed desc, added Fixes and Link, removed -stable]
    Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 12f301c29e80c8c9110858c467b08a86b311ea43
Author: ChenXiaoSong <chenxiaosong2@huawei.com>
Date:   Thu Jul 7 18:53:29 2022 +0800

    ntfs: fix use-after-free in ntfs_ucsncmp()
    
    commit 38c9c22a85aeed28d0831f230136e9cf6fa2ed44 upstream.
    
    Syzkaller reported use-after-free bug as follows:
    
    ==================================================================
    BUG: KASAN: use-after-free in ntfs_ucsncmp+0x123/0x130
    Read of size 2 at addr ffff8880751acee8 by task a.out/879
    
    CPU: 7 PID: 879 Comm: a.out Not tainted 5.19.0-rc4-next-20220630-00001-gcc5218c8bd2c-dirty #7
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
    Call Trace:
     <TASK>
     dump_stack_lvl+0x1c0/0x2b0
     print_address_description.constprop.0.cold+0xd4/0x484
     print_report.cold+0x55/0x232
     kasan_report+0xbf/0xf0
     ntfs_ucsncmp+0x123/0x130
     ntfs_are_names_equal.cold+0x2b/0x41
     ntfs_attr_find+0x43b/0xb90
     ntfs_attr_lookup+0x16d/0x1e0
     ntfs_read_locked_attr_inode+0x4aa/0x2360
     ntfs_attr_iget+0x1af/0x220
     ntfs_read_locked_inode+0x246c/0x5120
     ntfs_iget+0x132/0x180
     load_system_files+0x1cc6/0x3480
     ntfs_fill_super+0xa66/0x1cf0
     mount_bdev+0x38d/0x460
     legacy_get_tree+0x10d/0x220
     vfs_get_tree+0x93/0x300
     do_new_mount+0x2da/0x6d0
     path_mount+0x496/0x19d0
     __x64_sys_mount+0x284/0x300
     do_syscall_64+0x3b/0xc0
     entry_SYSCALL_64_after_hwframe+0x46/0xb0
    RIP: 0033:0x7f3f2118d9ea
    Code: 48 8b 0d a9 f4 0b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 76 f4 0b 00 f7 d8 64 89 01 48
    RSP: 002b:00007ffc269deac8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
    RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3f2118d9ea
    RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007ffc269dec00
    RBP: 00007ffc269dec80 R08: 00007ffc269deb00 R09: 00007ffc269dec44
    R10: 0000000000000000 R11: 0000000000000202 R12: 000055f81ab1d220
    R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
     </TASK>
    
    The buggy address belongs to the physical page:
    page:0000000085430378 refcount:1 mapcount:1 mapping:0000000000000000 index:0x555c6a81d pfn:0x751ac
    memcg:ffff888101f7e180
    anon flags: 0xfffffc00a0014(uptodate|lru|mappedtodisk|swapbacked|node=0|zone=1|lastcpupid=0x1fffff)
    raw: 000fffffc00a0014 ffffea0001bf2988 ffffea0001de2448 ffff88801712e201
    raw: 0000000555c6a81d 0000000000000000 0000000100000000 ffff888101f7e180
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff8880751acd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     ffff8880751ace00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    >ffff8880751ace80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                                                              ^
     ffff8880751acf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     ffff8880751acf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    ==================================================================
    
    The reason is that struct ATTR_RECORD->name_offset is 6485, end address of
    name string is out of bounds.
    
    Fix this by adding sanity check on end address of attribute name string.
    
    [akpm@linux-foundation.org: coding-style cleanups]
    [chenxiaosong2@huawei.com: cleanup suggested by Hawkins Jiawei]
      Link: https://lkml.kernel.org/r/20220709064511.3304299-1-chenxiaosong2@huawei.com
    Link: https://lkml.kernel.org/r/20220707105329.4020708-1-chenxiaosong2@huawei.com
    Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
    Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
    Cc: Anton Altaparmakov <anton@tuxera.com>
    Cc: ChenXiaoSong <chenxiaosong2@huawei.com>
    Cc: Yongqiang Liu <liuyongqiang13@huawei.com>
    Cc: Zhang Yi <yi.zhang@huawei.com>
    Cc: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5bb395334392891dffae5a0e8f37dbe1d70496c9
Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date:   Thu Jul 21 09:10:50 2022 -0700

    Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put
    
    commit d0be8347c623e0ac4202a1d4e0373882821f56b0 upstream.
    
    This fixes the following trace which is caused by hci_rx_work starting up
    *after* the final channel reference has been put() during sock_close() but
    *before* the references to the channel have been destroyed, so instead
    the code now rely on kref_get_unless_zero/l2cap_chan_hold_unless_zero to
    prevent referencing a channel that is about to be destroyed.
    
      refcount_t: increment on 0; use-after-free.
      BUG: KASAN: use-after-free in refcount_dec_and_test+0x20/0xd0
      Read of size 4 at addr ffffffc114f5bf18 by task kworker/u17:14/705
    
      CPU: 4 PID: 705 Comm: kworker/u17:14 Tainted: G S      W
      4.14.234-00003-g1fb6d0bd49a4-dirty #28
      Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150
      Google Inc. MSM sm8150 Flame DVT (DT)
      Workqueue: hci0 hci_rx_work
      Call trace:
       dump_backtrace+0x0/0x378
       show_stack+0x20/0x2c
       dump_stack+0x124/0x148
       print_address_description+0x80/0x2e8
       __kasan_report+0x168/0x188
       kasan_report+0x10/0x18
       __asan_load4+0x84/0x8c
       refcount_dec_and_test+0x20/0xd0
       l2cap_chan_put+0x48/0x12c
       l2cap_recv_frame+0x4770/0x6550
       l2cap_recv_acldata+0x44c/0x7a4
       hci_acldata_packet+0x100/0x188
       hci_rx_work+0x178/0x23c
       process_one_work+0x35c/0x95c
       worker_thread+0x4cc/0x960
       kthread+0x1a8/0x1c4
       ret_from_fork+0x10/0x18
    
    Cc: stable@kernel.org
    Reported-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Tested-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>