commit b71e57af961fc0cc69998a13dea631ba2229333e
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Nov 18 18:25:04 2020 +0100

    Linux 4.4.244
    
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20201117122106.144800239@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4000c1b820087964a8c68cf7d5de71036f962107
Author: Boris Protopopov <pboris@amazon.com>
Date:   Thu Sep 24 00:36:38 2020 +0000

    Convert trailing spaces and periods in path components
    
    commit 57c176074057531b249cf522d90c22313fa74b0b upstream.
    
    When converting trailing spaces and periods in paths, do so
    for every component of the path, not just the last component.
    If the conversion is not done for every path component, then
    subsequent operations in directories with trailing spaces or
    periods (e.g. create(), mkdir()) will fail with ENOENT. This
    is because on the server, the directory will have a special
    symbol in its name, and the client needs to provide the same.
    
    Signed-off-by: Boris Protopopov <pboris@amazon.com>
    Acked-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 428f824e9df4888836e9a3f2d132cbf10783e61a
Author: Eric Biggers <ebiggers@google.com>
Date:   Tue Sep 22 09:24:56 2020 -0700

    ext4: fix leaking sysfs kobject after failed mount
    
    commit cb8d53d2c97369029cc638c9274ac7be0a316c75 upstream.
    
    ext4_unregister_sysfs() only deletes the kobject.  The reference to it
    needs to be put separately, like ext4_put_super() does.
    
    This addresses the syzbot report
    "memory leak in kobject_set_name_vargs (3)"
    (https://syzkaller.appspot.com/bug?extid=9f864abad79fae7c17e1).
    
    Reported-by: syzbot+9f864abad79fae7c17e1@syzkaller.appspotmail.com
    Fixes: 72ba74508b28 ("ext4: release sysfs kobject when failing to enable quotas on mount")
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Link: https://lore.kernel.org/r/20200922162456.93657-1-ebiggers@kernel.org
    Reviewed-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [sudip: adjust context]
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0b2a9f794fea949a17502b050f44f694c8a9b2fe
Author: Matteo Croce <mcroce@microsoft.com>
Date:   Fri Nov 13 22:52:07 2020 -0800

    reboot: fix overflow parsing reboot cpu number
    
    commit df5b0ab3e08a156701b537809914b339b0daa526 upstream.
    
    Limit the CPU number to num_possible_cpus(), because setting it to a
    value lower than INT_MAX but higher than NR_CPUS produces the following
    error on reboot and shutdown:
    
        BUG: unable to handle page fault for address: ffffffff90ab1bb0
        #PF: supervisor read access in kernel mode
        #PF: error_code(0x0000) - not-present page
        PGD 1c09067 P4D 1c09067 PUD 1c0a063 PMD 0
        Oops: 0000 [#1] SMP
        CPU: 1 PID: 1 Comm: systemd-shutdow Not tainted 5.9.0-rc8-kvm #110
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
        RIP: 0010:migrate_to_reboot_cpu+0xe/0x60
        Code: ea ea 00 48 89 fa 48 c7 c7 30 57 f1 81 e9 fa ef ff ff 66 2e 0f 1f 84 00 00 00 00 00 53 8b 1d d5 ea ea 00 e8 14 33 fe ff 89 da <48> 0f a3 15 ea fc bd 00 48 89 d0 73 29 89 c2 c1 e8 06 65 48 8b 3c
        RSP: 0018:ffffc90000013e08 EFLAGS: 00010246
        RAX: ffff88801f0a0000 RBX: 0000000077359400 RCX: 0000000000000000
        RDX: 0000000077359400 RSI: 0000000000000002 RDI: ffffffff81c199e0
        RBP: ffffffff81c1e3c0 R08: ffff88801f41f000 R09: ffffffff81c1e348
        R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
        R13: 00007f32bedf8830 R14: 00000000fee1dead R15: 0000000000000000
        FS:  00007f32bedf8980(0000) GS:ffff88801f480000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: ffffffff90ab1bb0 CR3: 000000001d057000 CR4: 00000000000006a0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
          __do_sys_reboot.cold+0x34/0x5b
          do_syscall_64+0x2d/0x40
    
    Fixes: 1b3a5d02ee07 ("reboot: move arch/x86 reboot= handling to generic kernel")
    Signed-off-by: Matteo Croce <mcroce@microsoft.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Fabian Frederick <fabf@skynet.be>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Guenter Roeck <linux@roeck-us.net>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Mike Rapoport <rppt@kernel.org>
    Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Robin Holt <robinmholt@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lkml.kernel.org/r/20201103214025.116799-3-mcroce@linux.microsoft.com
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [sudip: use reboot_mode instead of mode]
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a48b733bf4a7de778308aafd76ae616fd3b1c6ff
Author: Matteo Croce <mcroce@microsoft.com>
Date:   Fri Nov 13 22:52:02 2020 -0800

    Revert "kernel/reboot.c: convert simple_strtoul to kstrtoint"
    
    commit 8b92c4ff4423aa9900cf838d3294fcade4dbda35 upstream.
    
    Patch series "fix parsing of reboot= cmdline", v3.
    
    The parsing of the reboot= cmdline has two major errors:
    
     - a missing bound check can crash the system on reboot
    
     - parsing of the cpu number only works if specified last
    
    Fix both.
    
    This patch (of 2):
    
    This reverts commit 616feab753972b97.
    
    kstrtoint() and simple_strtoul() have a subtle difference which makes
    them non interchangeable: if a non digit character is found amid the
    parsing, the former will return an error, while the latter will just
    stop parsing, e.g.  simple_strtoul("123xyx") = 123.
    
    The kernel cmdline reboot= argument allows to specify the CPU used for
    rebooting, with the syntax `s####` among the other flags, e.g.
    "reboot=warm,s31,force", so if this flag is not the last given, it's
    silently ignored as well as the subsequent ones.
    
    Fixes: 616feab75397 ("kernel/reboot.c: convert simple_strtoul to kstrtoint")
    Signed-off-by: Matteo Croce <mcroce@microsoft.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Guenter Roeck <linux@roeck-us.net>
    Cc: Petr Mladek <pmladek@suse.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Mike Rapoport <rppt@kernel.org>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
    Cc: Robin Holt <robinmholt@gmail.com>
    Cc: Fabian Frederick <fabf@skynet.be>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: <stable@vger.kernel.org>
    Link: https://lkml.kernel.org/r/20201103214025.116799-2-mcroce@linux.microsoft.com
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [sudip: use reboot_mode instead of mode]
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 17b235e6cc9d701a2eece74a64f89062072b81b1
Author: Jiri Olsa <jolsa@redhat.com>
Date:   Wed Sep 16 13:53:11 2020 +0200

    perf/core: Fix race in the perf_mmap_close() function
    
    commit f91072ed1b7283b13ca57fcfbece5a3b92726143 upstream.
    
    There's a possible race in perf_mmap_close() when checking ring buffer's
    mmap_count refcount value. The problem is that the mmap_count check is
    not atomic because we call atomic_dec() and atomic_read() separately.
    
      perf_mmap_close:
      ...
       atomic_dec(&rb->mmap_count);
       ...
       if (atomic_read(&rb->mmap_count))
          goto out_put;
    
       <ring buffer detach>
       free_uid
    
    out_put:
      ring_buffer_put(rb); /* could be last */
    
    The race can happen when we have two (or more) events sharing same ring
    buffer and they go through atomic_dec() and then they both see 0 as refcount
    value later in atomic_read(). Then both will go on and execute code which
    is meant to be run just once.
    
    The code that detaches ring buffer is probably fine to be executed more
    than once, but the problem is in calling free_uid(), which will later on
    demonstrate in related crashes and refcount warnings, like:
    
      refcount_t: addition on 0; use-after-free.
      ...
      RIP: 0010:refcount_warn_saturate+0x6d/0xf
      ...
      Call Trace:
      prepare_creds+0x190/0x1e0
      copy_creds+0x35/0x172
      copy_process+0x471/0x1a80
      _do_fork+0x83/0x3a0
      __do_sys_wait4+0x83/0x90
      __do_sys_clone+0x85/0xa0
      do_syscall_64+0x5b/0x1e0
      entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Using atomic decrease and check instead of separated calls.
    
    Tested-by: Michael Petlan <mpetlan@redhat.com>
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Acked-by: Namhyung Kim <namhyung@kernel.org>
    Acked-by: Wade Mealing <wmealing@redhat.com>
    Fixes: 9bb5d40cd93c ("perf: Fix mmap() accounting hole");
    Link: https://lore.kernel.org/r/20200916115311.GE2301783@krava
    [sudip: backport to v4.9.y by using ring_buffer]
    Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ea31e9d9320404ddf74ad1d23c77cacd98d9e78c
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:38 2020 +0100

    xen/events: block rogue events for some time
    
    commit 5f7f77400ab5b357b5fdb7122c3442239672186c upstream.
    
    In order to avoid high dom0 load due to rogue guests sending events at
    high frequency, block those events in case there was no action needed
    in dom0 to handle the events.
    
    This is done by adding a per-event counter, which set to zero in case
    an EOI without the XEN_EOI_FLAG_SPURIOUS is received from a backend
    driver, and incremented when this flag has been set. In case the
    counter is 2 or higher delay the EOI by 1 << (cnt - 2) jiffies, but
    not more than 1 second.
    
    In order not to waste memory shorten the per-event refcnt to two bytes
    (it should normally never exceed a value of 2). Add an overflow check
    to evtchn_get() to make sure the 2 bytes really won't overflow.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 732d4f2eb4160cae14978b15d5b01f0d59915a32
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:37 2020 +0100

    xen/events: defer eoi in case of excessive number of events
    
    commit e99502f76271d6bc4e374fe368c50c67a1fd3070 upstream.
    
    In case rogue guests are sending events at high frequency it might
    happen that xen_evtchn_do_upcall() won't stop processing events in
    dom0. As this is done in irq handling a crash might be the result.
    
    In order to avoid that, delay further inter-domain events after some
    time in xen_evtchn_do_upcall() by forcing eoi processing into a
    worker on the same cpu, thus inhibiting new events coming in.
    
    The time after which eoi processing is to be delayed is configurable
    via a new module parameter "event_loop_timeout" which specifies the
    maximum event loop time in jiffies (default: 2, the value was chosen
    after some tests showing that a value of 2 was the lowest with an
    only slight drop of dom0 network throughput while multiple guests
    performed an event storm).
    
    How long eoi processing will be delayed can be specified via another
    parameter "event_eoi_delay" (again in jiffies, default 10, again the
    value was chosen after testing with different delay values).
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 26a6cbe30a2b12ef0840710aae2877a12abd761e
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:36 2020 +0100

    xen/events: use a common cpu hotplug hook for event channels
    
    commit 7beb290caa2adb0a399e735a1e175db9aae0523a upstream.
    
    Today only fifo event channels have a cpu hotplug callback. In order
    to prepare for more percpu (de)init work move that callback into
    events_base.c and add percpu_init() and percpu_deinit() hooks to
    struct evtchn_ops.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 957a6b5f628b9d5a481d95603f15cfdbb508f1d2
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:35 2020 +0100

    xen/events: switch user event channels to lateeoi model
    
    commit c44b849cee8c3ac587da3b0980e01f77500d158c upstream.
    
    Instead of disabling the irq when an event is received and enabling
    it again when handled by the user process use the lateeoi model.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Tested-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fc1f51b7ab4981de662a70d0c6f1691b0ff85752
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:34 2020 +0100

    xen/pciback: use lateeoi irq binding
    
    commit c2711441bc961b37bba0615dd7135857d189035f upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving pcifront use the lateeoi irq
    binding for pciback and unmask the event channel only just before
    leaving the event handling function.
    
    Restructure the handling to support that scheme. Basically an event can
    come in for two reasons: either a normal request for a pciback action,
    which is handled in a worker, or in case the guest has finished an AER
    request which was requested by pciback.
    
    When an AER request is issued to the guest and a normal pciback action
    is currently active issue an EOI early in order to be able to receive
    another event when the AER request has been finished by the guest.
    
    Let the worker processing the normal requests run until no further
    request is pending, instead of starting a new worker ion that case.
    Issue the EOI only just before leaving the worker.
    
    This scheme allows to drop calling the generic function
    xen_pcibk_test_and_schedule_op() after processing of any request as
    the handling of both request types is now separated more cleanly.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit deac277523883f745d3d539932850e5c361be098
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:33 2020 +0100

    xen/scsiback: use lateeoi irq binding
    
    commit 86991b6e7ea6c613b7692f65106076943449b6b7 upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving scsifront use the lateeoi
    irq binding for scsiback and unmask the event channel only just before
    leaving the event handling function.
    
    In case of a ring protocol error don't issue an EOI in order to avoid
    the possibility to use that for producing an event storm. This at once
    will result in no further call of scsiback_irq_fn(), so the ring_error
    struct member can be dropped and scsiback_do_cmd_fn() can signal the
    protocol error via a negative return value.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fffc1ca5ed0e265793252388b3bf1765f8f9640e
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:32 2020 +0100

    xen/netback: use lateeoi irq binding
    
    commit 23025393dbeb3b8b3b60ebfa724cdae384992e27 upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving netfront use the lateeoi
    irq binding for netback and unmask the event channel only just before
    going to sleep waiting for new events.
    
    Make sure not to issue an EOI when none is pending by introducing an
    eoi_pending element to struct xenvif_queue.
    
    When no request has been consumed set the spurious flag when sending
    the EOI for an interrupt.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a0eff570f98e5e0411482104efa11330a394ec7f
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:31 2020 +0100

    xen/blkback: use lateeoi irq binding
    
    commit 01263a1fabe30b4d542f34c7e2364a22587ddaf2 upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving blkfront use the lateeoi
    irq binding for blkback and unmask the event channel only after
    processing all pending requests.
    
    As the thread processing requests is used to do purging work in regular
    intervals an EOI may be sent only after having received an event. If
    there was no pending I/O request flag the EOI as spurious.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1d762cb6676b5f9c57c6ac56856e540529a8d928
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:30 2020 +0100

    xen/events: add a new "late EOI" evtchn framework
    
    commit 54c9de89895e0a36047fcc4ae754ea5b8655fb9d upstream.
    
    In order to avoid tight event channel related IRQ loops add a new
    framework of "late EOI" handling: the IRQ the event channel is bound
    to will be masked until the event has been handled and the related
    driver is capable to handle another event. The driver is responsible
    for unmasking the event channel via the new function xen_irq_lateeoi().
    
    This is similar to binding an event channel to a threaded IRQ, but
    without having to structure the driver accordingly.
    
    In order to support a future special handling in case a rogue guest
    is sending lots of unsolicited events, add a flag to xen_irq_lateeoi()
    which can be set by the caller to indicate the event was a spurious
    one.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2e76c99ffbf9b054001d5753feb86910c91138ea
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:29 2020 +0100

    xen/events: fix race in evtchn_fifo_unmask()
    
    commit f01337197419b7e8a492e83089552b77d3b5fb90 upstream.
    
    Unmasking a fifo event channel can result in unmasking it twice, once
    directly in the kernel and once via a hypercall in case the event was
    pending.
    
    Fix that by doing the local unmask only if the event is not pending.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 33f38ccfe479fdb53bf0409e9b74e993e30d4d1f
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:28 2020 +0100

    xen/events: add a proper barrier to 2-level uevent unmasking
    
    commit 4d3fe31bd993ef504350989786858aefdb877daa upstream.
    
    A follow-up patch will require certain write to happen before an event
    channel is unmasked.
    
    While the memory barrier is not strictly necessary for all the callers,
    the main one will need it. In order to avoid an extra memory barrier
    when using fifo event channels, mandate evtchn_unmask() to provide
    write ordering.
    
    The 2-level event handling unmask operation is missing an appropriate
    barrier, so add it. Fifo event channels are fine in this regard due to
    using sync_cmpxchg().
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Suggested-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c0e77192829a1a02983d672ac144e6196098cad7
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Nov 3 17:22:27 2020 +0100

    xen/events: avoid removing an event channel while handling it
    
    commit 073d0552ead5bfc7a3a9c01de590e924f11b5dd2 upstream.
    
    Today it can happen that an event channel is being removed from the
    system while the event handling loop is active. This can lead to a
    race resulting in crashes or WARN() splats when trying to access the
    irq_info structure related to the event channel.
    
    Fix this problem by using a rwlock taken as reader in the event
    handling loop and as writer when deallocating the irq_info structure.
    
    As the observed problem was a NULL dereference in evtchn_from_irq()
    make this function more robust against races by testing the irq_info
    pointer to be not NULL before dereferencing it.
    
    And finally make all accesses to evtchn_to_irq[row][col] atomic ones
    in order to avoid seeing partial updates of an array element in irq
    handling. Note that irq handling can be entered only for event channels
    which have been valid before, so any not populated row isn't a problem
    in this regard, as rows are only ever added and never removed.
    
    This is XSA-331.
    
    Cc: stable@vger.kernel.org
    Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reported-by: Jinoh Kang <luke1337@theori.io>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dd55e75a4d39bc00eb437feb94af3881214155a9
Author: Anand K Mistry <amistry@google.com>
Date:   Thu Nov 5 16:33:04 2020 +1100

    x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP
    
    commit 1978b3a53a74e3230cd46932b149c6e62e832e9a upstream.
    
    On AMD CPUs which have the feature X86_FEATURE_AMD_STIBP_ALWAYS_ON,
    STIBP is set to on and
    
      spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED
    
    At the same time, IBPB can be set to conditional.
    
    However, this leads to the case where it's impossible to turn on IBPB
    for a process because in the PR_SPEC_DISABLE case in ib_prctl_set() the
    
      spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED
    
    condition leads to a return before the task flag is set. Similarly,
    ib_prctl_get() will return PR_SPEC_DISABLE even though IBPB is set to
    conditional.
    
    More generally, the following cases are possible:
    
    1. STIBP = conditional && IBPB = on for spectre_v2_user=seccomp,ibpb
    2. STIBP = on && IBPB = conditional for AMD CPUs with
       X86_FEATURE_AMD_STIBP_ALWAYS_ON
    
    The first case functions correctly today, but only because
    spectre_v2_user_ibpb isn't updated to reflect the IBPB mode.
    
    At a high level, this change does one thing. If either STIBP or IBPB
    is set to conditional, allow the prctl to change the task flag.
    Also, reflect that capability when querying the state. This isn't
    perfect since it doesn't take into account if only STIBP or IBPB is
    unconditionally on. But it allows the conditional feature to work as
    expected, without affecting the unconditional one.
    
     [ bp: Massage commit message and comment; space out statements for
       better readability. ]
    
    Fixes: 21998a351512 ("x86/speculation: Avoid force-disabling IBPB based on STIBP and enhanced IBRS.")
    Signed-off-by: Anand K Mistry <amistry@google.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
    Link: https://lkml.kernel.org/r/20201105163246.v2.1.Ifd7243cd3e2c2206a893ad0a5b9a4f19549e22c6@changeid
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 09f5820cfdda63af6f3cc0168d833d809e054bcd
Author: George Spelvin <lkml@sdf.org>
Date:   Sun Aug 9 06:57:44 2020 +0000

    random32: make prandom_u32() output unpredictable
    
    commit c51f8f88d705e06bd696d7510aff22b33eb8e638 upstream.
    
    Non-cryptographic PRNGs may have great statistical properties, but
    are usually trivially predictable to someone who knows the algorithm,
    given a small sample of their output.  An LFSR like prandom_u32() is
    particularly simple, even if the sample is widely scattered bits.
    
    It turns out the network stack uses prandom_u32() for some things like
    random port numbers which it would prefer are *not* trivially predictable.
    Predictability led to a practical DNS spoofing attack.  Oops.
    
    This patch replaces the LFSR with a homebrew cryptographic PRNG based
    on the SipHash round function, which is in turn seeded with 128 bits
    of strong random key.  (The authors of SipHash have *not* been consulted
    about this abuse of their algorithm.)  Speed is prioritized over security;
    attacks are rare, while performance is always wanted.
    
    Replacing all callers of prandom_u32() is the quick fix.
    Whether to reinstate a weaker PRNG for uses which can tolerate it
    is an open question.
    
    Commit f227e3ec3b5c ("random32: update the net random state on interrupt
    and activity") was an earlier attempt at a solution.  This patch replaces
    it.
    
    Reported-by: Amit Klein <aksecurity@gmail.com>
    Cc: Willy Tarreau <w@1wt.eu>
    Cc: Eric Dumazet <edumazet@google.com>
    Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: tytso@mit.edu
    Cc: Florian Westphal <fw@strlen.de>
    Cc: Marc Plumb <lkml.mplumb@gmail.com>
    Fixes: f227e3ec3b5c ("random32: update the net random state on interrupt and activity")
    Signed-off-by: George Spelvin <lkml@sdf.org>
    Link: https://lore.kernel.org/netdev/20200808152628.GA27941@SDF.ORG/
    [ willy: partial reversal of f227e3ec3b5c; moved SIPROUND definitions
      to prandom.h for later use; merged George's prandom_seed() proposal;
      inlined siprand_u32(); replaced the net_rand_state[] array with 4
      members to fix a build issue; cosmetic cleanups to make checkpatch
      happy; fixed RANDOM32_SELFTEST build ]
    [wt: backported to 4.4 -- no latent_entropy, drop prandom_reseed_late]
    Signed-off-by: Willy Tarreau <w@1wt.eu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 36d7b99b7a7de6b3c4dd6c206fb52135f51ac609
Author: Mao Wenan <wenan.mao@linux.alibaba.com>
Date:   Tue Nov 10 08:16:31 2020 +0800

    net: Update window_clamp if SOCK_RCVBUF is set
    
    [ Upstream commit 909172a149749242990a6e64cb55d55460d4e417 ]
    
    When net.ipv4.tcp_syncookies=1 and syn flood is happened,
    cookie_v4_check or cookie_v6_check tries to redo what
    tcp_v4_send_synack or tcp_v6_send_synack did,
    rsk_window_clamp will be changed if SOCK_RCVBUF is set,
    which will make rcv_wscale is different, the client
    still operates with initial window scale and can overshot
    granted window, the client use the initial scale but local
    server use new scale to advertise window value, and session
    work abnormally.
    
    Fixes: e88c64f0a425 ("tcp: allow effective reduction of TCP's rcv-buffer via setsockopt")
    Signed-off-by: Mao Wenan <wenan.mao@linux.alibaba.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Link: https://lore.kernel.org/r/1604967391-123737-1-git-send-email-wenan.mao@linux.alibaba.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8c6a13c269021e56287a7f250eb62e55790bce14
Author: Martin Schiller <ms@dev.tdt.de>
Date:   Mon Nov 9 07:54:49 2020 +0100

    net/x25: Fix null-ptr-deref in x25_connect
    
    [ Upstream commit 361182308766a265b6c521879b34302617a8c209 ]
    
    This fixes a regression for blocking connects introduced by commit
    4becb7ee5b3d ("net/x25: Fix x25_neigh refcnt leak when x25 disconnect").
    
    The x25->neighbour is already set to "NULL" by x25_disconnect() now,
    while a blocking connect is waiting in
    x25_wait_for_connection_establishment(). Therefore x25->neighbour must
    not be accessed here again and x25->state is also already set to
    X25_STATE_0 by x25_disconnect().
    
    Fixes: 4becb7ee5b3d ("net/x25: Fix x25_neigh refcnt leak when x25 disconnect")
    Signed-off-by: Martin Schiller <ms@dev.tdt.de>
    Reviewed-by: Xie He <xie.he.0141@gmail.com>
    Link: https://lore.kernel.org/r/20201109065449.9014-1-ms@dev.tdt.de
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 480c6b7c69fd7eefb9586b34e69720b674feb5e9
Author: Ursula Braun <ubraun@linux.ibm.com>
Date:   Mon Nov 9 08:57:05 2020 +0100

    net/af_iucv: fix null pointer dereference on shutdown
    
    [ Upstream commit 4031eeafa71eaf22ae40a15606a134ae86345daf ]
    
    syzbot reported the following KASAN finding:
    
    BUG: KASAN: nullptr-dereference in iucv_send_ctrl+0x390/0x3f0 net/iucv/af_iucv.c:385
    Read of size 2 at addr 000000000000021e by task syz-executor907/519
    
    CPU: 0 PID: 519 Comm: syz-executor907 Not tainted 5.9.0-syzkaller-07043-gbcf9877ad213 #0
    Hardware name: IBM 3906 M04 701 (KVM/Linux)
    Call Trace:
     [<00000000c576af60>] unwind_start arch/s390/include/asm/unwind.h:65 [inline]
     [<00000000c576af60>] show_stack+0x180/0x228 arch/s390/kernel/dumpstack.c:135
     [<00000000c9dcd1f8>] __dump_stack lib/dump_stack.c:77 [inline]
     [<00000000c9dcd1f8>] dump_stack+0x268/0x2f0 lib/dump_stack.c:118
     [<00000000c5fed016>] print_address_description.constprop.0+0x5e/0x218 mm/kasan/report.c:383
     [<00000000c5fec82a>] __kasan_report mm/kasan/report.c:517 [inline]
     [<00000000c5fec82a>] kasan_report+0x11a/0x168 mm/kasan/report.c:534
     [<00000000c98b5b60>] iucv_send_ctrl+0x390/0x3f0 net/iucv/af_iucv.c:385
     [<00000000c98b6262>] iucv_sock_shutdown+0x44a/0x4c0 net/iucv/af_iucv.c:1457
     [<00000000c89d3a54>] __sys_shutdown+0x12c/0x1c8 net/socket.c:2204
     [<00000000c89d3b70>] __do_sys_shutdown net/socket.c:2212 [inline]
     [<00000000c89d3b70>] __s390x_sys_shutdown+0x38/0x48 net/socket.c:2210
     [<00000000c9e36eac>] system_call+0xe0/0x28c arch/s390/kernel/entry.S:415
    
    There is nothing to shutdown if a connection has never been established.
    Besides that iucv->hs_dev is not yet initialized if a socket is in
    IUCV_OPEN state and iucv->path is not yet initialized if socket is in
    IUCV_BOUND state.
    So, just skip the shutdown calls for a socket in these states.
    
    Fixes: eac3731bd04c ("[S390]: Add AF_IUCV socket support")
    Fixes: 82492a355fac ("af_iucv: add shutdown for HS transport")
    Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
    [jwi: correct one Fixes tag]
    Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c22894e51deccca2ec232b5f2407366eed3ce369
Author: Oliver Herms <oliver.peter.herms@gmail.com>
Date:   Tue Nov 3 11:41:33 2020 +0100

    IPv6: Set SIT tunnel hard_header_len to zero
    
    [ Upstream commit 8ef9ba4d666614497a057d09b0a6eafc1e34eadf ]
    
    Due to the legacy usage of hard_header_len for SIT tunnels while
    already using infrastructure from net/ipv4/ip_tunnel.c the
    calculation of the path MTU in tnl_update_pmtu is incorrect.
    This leads to unnecessary creation of MTU exceptions for any
    flow going over a SIT tunnel.
    
    As SIT tunnels do not have a header themsevles other than their
    transport (L3, L2) headers we're leaving hard_header_len set to zero
    as tnl_update_pmtu is already taking care of the transport headers
    sizes.
    
    This will also help avoiding unnecessary IPv6 GC runs and spinlock
    contention seen when using SIT tunnels and for more than
    net.ipv6.route.gc_thresh flows.
    
    Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
    Signed-off-by: Oliver Herms <oliver.peter.herms@gmail.com>
    Acked-by: Willem de Bruijn <willemb@google.com>
    Link: https://lore.kernel.org/r/20201103104133.GA1573211@tws
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 18bfc9ef8b938e752ce547b28e7cb7b1944b2743
Author: Stefano Stabellini <stefano.stabellini@xilinx.com>
Date:   Mon Oct 26 17:02:14 2020 -0700

    swiotlb: fix "x86: Don't panic if can not alloc buffer for swiotlb"
    
    commit e9696d259d0fb5d239e8c28ca41089838ea76d13 upstream.
    
    kernel/dma/swiotlb.c:swiotlb_init gets called first and tries to
    allocate a buffer for the swiotlb. It does so by calling
    
      memblock_alloc_low(PAGE_ALIGN(bytes), PAGE_SIZE);
    
    If the allocation must fail, no_iotlb_memory is set.
    
    Later during initialization swiotlb-xen comes in
    (drivers/xen/swiotlb-xen.c:xen_swiotlb_init) and given that io_tlb_start
    is != 0, it thinks the memory is ready to use when actually it is not.
    
    When the swiotlb is actually needed, swiotlb_tbl_map_single gets called
    and since no_iotlb_memory is set the kernel panics.
    
    Instead, if swiotlb-xen.c:xen_swiotlb_init knew the swiotlb hadn't been
    initialized, it would do the initialization itself, which might still
    succeed.
    
    Fix the panic by setting io_tlb_start to 0 on swiotlb initialization
    failure, and also by setting no_iotlb_memory to false on swiotlb
    initialization success.
    
    Fixes: ac2cbab21f31 ("x86: Don't panic if can not alloc buffer for swiotlb")
    
    Reported-by: Elliott Mitchell <ehem+xen@m5p.com>
    Tested-by: Elliott Mitchell <ehem+xen@m5p.com>
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Cc: stable@vger.kernel.org
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cd02ef5ba7a775a0ea12a9a505dc2d6463317fef
Author: Coiby Xu <coiby.xu@gmail.com>
Date:   Fri Nov 6 07:19:09 2020 +0800

    pinctrl: amd: fix incorrect way to disable debounce filter
    
    commit 06abe8291bc31839950f7d0362d9979edc88a666 upstream.
    
    The correct way to disable debounce filter is to clear bit 5 and 6
    of the register.
    
    Cc: stable@vger.kerne.org
    Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Cc: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/linux-gpio/df2c008b-e7b5-4fdd-42ea-4d1c62b52139@redhat.com/
    Link: https://lore.kernel.org/r/20201105231912.69527-2-coiby.xu@gmail.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9ba5d0977edd3f2acc1f7ead6bf6346d44cf39f5
Author: Coiby Xu <coiby.xu@gmail.com>
Date:   Fri Nov 6 07:19:10 2020 +0800

    pinctrl: amd: use higher precision for 512 RtcClk
    
    commit c64a6a0d4a928c63e5bc3b485552a8903a506c36 upstream.
    
    RTC is 32.768kHz thus 512 RtcClk equals 15625 usec. The documentation
    likely has dropped precision and that's why the driver mistakenly took
    the slightly deviated value.
    
    Cc: stable@vger.kernel.org
    Reported-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Suggested-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/linux-gpio/2f4706a1-502f-75f0-9596-cc25b4933b6c@redhat.com/
    Link: https://lore.kernel.org/r/20201105231912.69527-3-coiby.xu@gmail.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 15b58f6375125bda0b7da5b33693afc4a0287de9
Author: Thomas Zimmermann <tzimmermann@suse.de>
Date:   Thu Nov 5 20:02:56 2020 +0100

    drm/gma500: Fix out-of-bounds access to struct drm_device.vblank[]
    
    commit 06ad8d339524bf94b89859047822c31df6ace239 upstream.
    
    The gma500 driver expects 3 pipelines in several it's IRQ functions.
    Accessing struct drm_device.vblank[], this fails with devices that only
    have 2 pipelines. An example KASAN report is shown below.
    
      [   62.267688] ==================================================================
      [   62.268856] BUG: KASAN: slab-out-of-bounds in psb_irq_postinstall+0x250/0x3c0 [gma500_gfx]
      [   62.269450] Read of size 1 at addr ffff8880012bc6d0 by task systemd-udevd/285
      [   62.269949]
      [   62.270192] CPU: 0 PID: 285 Comm: systemd-udevd Tainted: G            E     5.10.0-rc1-1-default+ #572
      [   62.270807] Hardware name:  /DN2800MT, BIOS MTCDT10N.86A.0164.2012.1213.1024 12/13/2012
      [   62.271366] Call Trace:
      [   62.271705]  dump_stack+0xae/0xe5
      [   62.272180]  print_address_description.constprop.0+0x17/0xf0
      [   62.272987]  ? psb_irq_postinstall+0x250/0x3c0 [gma500_gfx]
      [   62.273474]  __kasan_report.cold+0x20/0x38
      [   62.273989]  ? psb_irq_postinstall+0x250/0x3c0 [gma500_gfx]
      [   62.274460]  kasan_report+0x3a/0x50
      [   62.274891]  psb_irq_postinstall+0x250/0x3c0 [gma500_gfx]
      [   62.275380]  drm_irq_install+0x131/0x1f0
      <...>
      [   62.300751] Allocated by task 285:
      [   62.301223]  kasan_save_stack+0x1b/0x40
      [   62.301731]  __kasan_kmalloc.constprop.0+0xbf/0xd0
      [   62.302293]  drmm_kmalloc+0x55/0x100
      [   62.302773]  drm_vblank_init+0x77/0x210
    
    Resolve the issue by only handling vblank entries up to the number of
    CRTCs.
    
    I'm adding a Fixes tag for reference, although the bug has been present
    since the driver's initial commit.
    
    Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
    Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Fixes: 5c49fd3aa0ab ("gma500: Add the core DRM files and headers")
    Cc: Alan Cox <alan@linux.intel.com>
    Cc: Dave Airlie <airlied@redhat.com>
    Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
    Cc: dri-devel@lists.freedesktop.org
    Cc: stable@vger.kernel.org#v3.3+
    Link: https://patchwork.freedesktop.org/patch/msgid/20201105190256.3893-1-tzimmermann@suse.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 55c181227c190142656535364654c96ba50c50cc
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Wed Oct 28 16:39:49 2020 -0400

    don't dump the threads that had been already exiting when zapped.
    
    commit 77f6ab8b7768cf5e6bdd0e72499270a0671506ee upstream.
    
    Coredump logics needs to report not only the registers of the dumping
    thread, but (since 2.5.43) those of other threads getting killed.
    
    Doing that might require extra state saved on the stack in asm glue at
    kernel entry; signal delivery logics does that (we need to be able to
    save sigcontext there, at the very least) and so does seccomp.
    
    That covers all callers of do_coredump().  Secondary threads get hit with
    SIGKILL and caught as soon as they reach exit_mm(), which normally happens
    in signal delivery, so those are also fine most of the time.  Unfortunately,
    it is possible to end up with secondary zapped when it has already entered
    exit(2) (or, worse yet, is oopsing).  In those cases we reach exit_mm()
    when mm->core_state is already set, but the stack contents is not what
    we would have in signal delivery.
    
    At least on two architectures (alpha and m68k) it leads to infoleaks - we
    end up with a chunk of kernel stack written into coredump, with the contents
    consisting of normal C stack frames of the call chain leading to exit_mm()
    instead of the expected copy of userland registers.  In case of alpha we
    leak 312 bytes of stack.  Other architectures (including the regset-using
    ones) might have similar problems - the normal user of regsets is ptrace
    and the state of tracee at the time of such calls is special in the same
    way signal delivery is.
    
    Note that had the zapper gotten to the exiting thread slightly later,
    it wouldn't have been included into coredump anyway - we skip the threads
    that have already cleared their ->mm.  So let's pretend that zapper always
    loses the race.  IOW, have exit_mm() only insert into the dumper list if
    we'd gotten there from handling a fatal signal[*]
    
    As the result, the callers of do_exit() that have *not* gone through get_signal()
    are not seen by coredump logics as secondary threads.  Which excludes voluntary
    exit()/oopsen/traps/etc.  The dumper thread itself is unaffected by that,
    so seccomp is fine.
    
    [*] originally I intended to add a new flag in tsk->flags, but ebiederman pointed
    out that PF_SIGNALED is already doing just what we need.
    
    Cc: stable@vger.kernel.org
    Fixes: d89f3847def4 ("[PATCH] thread-aware coredumps, 2.5.43-C3")
    History-tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
    Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 79de2e8400e93b5074b5932f33fd1f056c9b0ca7
Author: Wengang Wang <wen.gang.wang@oracle.com>
Date:   Fri Nov 13 22:52:23 2020 -0800

    ocfs2: initialize ip_next_orphan
    
    commit f5785283dd64867a711ca1fb1f5bb172f252ecdf upstream.
    
    Though problem if found on a lower 4.1.12 kernel, I think upstream has
    same issue.
    
    In one node in the cluster, there is the following callback trace:
    
       # cat /proc/21473/stack
       __ocfs2_cluster_lock.isra.36+0x336/0x9e0 [ocfs2]
       ocfs2_inode_lock_full_nested+0x121/0x520 [ocfs2]
       ocfs2_evict_inode+0x152/0x820 [ocfs2]
       evict+0xae/0x1a0
       iput+0x1c6/0x230
       ocfs2_orphan_filldir+0x5d/0x100 [ocfs2]
       ocfs2_dir_foreach_blk+0x490/0x4f0 [ocfs2]
       ocfs2_dir_foreach+0x29/0x30 [ocfs2]
       ocfs2_recover_orphans+0x1b6/0x9a0 [ocfs2]
       ocfs2_complete_recovery+0x1de/0x5c0 [ocfs2]
       process_one_work+0x169/0x4a0
       worker_thread+0x5b/0x560
       kthread+0xcb/0xf0
       ret_from_fork+0x61/0x90
    
    The above stack is not reasonable, the final iput shouldn't happen in
    ocfs2_orphan_filldir() function.  Looking at the code,
    
      2067         /* Skip inodes which are already added to recover list, since dio may
      2068          * happen concurrently with unlink/rename */
      2069         if (OCFS2_I(iter)->ip_next_orphan) {
      2070                 iput(iter);
      2071                 return 0;
      2072         }
      2073
    
    The logic thinks the inode is already in recover list on seeing
    ip_next_orphan is non-NULL, so it skip this inode after dropping a
    reference which incremented in ocfs2_iget().
    
    While, if the inode is already in recover list, it should have another
    reference and the iput() at line 2070 should not be the final iput
    (dropping the last reference).  So I don't think the inode is really in
    the recover list (no vmcore to confirm).
    
    Note that ocfs2_queue_orphans(), though not shown up in the call back
    trace, is holding cluster lock on the orphan directory when looking up
    for unlinked inodes.  The on disk inode eviction could involve a lot of
    IOs which may need long time to finish.  That means this node could hold
    the cluster lock for very long time, that can lead to the lock requests
    (from other nodes) to the orhpan directory hang for long time.
    
    Looking at more on ip_next_orphan, I found it's not initialized when
    allocating a new ocfs2_inode_info structure.
    
    This causes te reflink operations from some nodes hang for very long
    time waiting for the cluster lock on the orphan directory.
    
    Fix: initialize ip_next_orphan as NULL.
    
    Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
    Cc: Mark Fasheh <mark@fasheh.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Junxiao Bi <junxiao.bi@oracle.com>
    Cc: Changwei Ge <gechangwei@live.cn>
    Cc: Gang He <ghe@suse.com>
    Cc: Jun Piao <piaojun@huawei.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lkml.kernel.org/r/20201109171746.27884-1-wen.gang.wang@oracle.com
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c9d1594f0fbcd070bdd6aecc2d768d78ff10595f
Author: Alexander Usyskin <alexander.usyskin@intel.com>
Date:   Thu Oct 29 11:54:42 2020 +0200

    mei: protect mei_cl_mtu from null dereference
    
    commit bcbc0b2e275f0a797de11a10eff495b4571863fc upstream.
    
    A receive callback is queued while the client is still connected
    but can still be called after the client was disconnected. Upon
    disconnect cl->me_cl is set to NULL, hence we need to check
    that ME client is not-NULL in mei_cl_mtu to avoid
    null dereference.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
    Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
    Link: https://lore.kernel.org/r/20201029095444.957924-2-tomas.winkler@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e6c6322e1ce093a84d12daccb24d5fdd66160cdb
Author: Chris Brandt <chris.brandt@renesas.com>
Date:   Wed Nov 11 08:12:09 2020 -0500

    usb: cdc-acm: Add DISABLE_ECHO for Renesas USB Download mode
    
    commit 6d853c9e4104b4fc8d55dc9cd3b99712aa347174 upstream.
    
    Renesas R-Car and RZ/G SoCs have a firmware download mode over USB.
    However, on reset a banner string is transmitted out which is not expected
    to be echoed back and will corrupt the protocol.
    
    Cc: stable <stable@vger.kernel.org>
    Acked-by: Oliver Neukum <oneukum@suse.com>
    Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
    Link: https://lore.kernel.org/r/20201111131209.3977903-1-chris.brandt@renesas.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9fbacd44844c614784d8a96e2aed1c197202ceba
Author: Joseph Qi <joseph.qi@linux.alibaba.com>
Date:   Tue Nov 3 10:29:02 2020 +0800

    ext4: unlock xattr_sem properly in ext4_inline_data_truncate()
    
    commit 7067b2619017d51e71686ca9756b454de0e5826a upstream.
    
    It takes xattr_sem to check inline data again but without unlock it
    in case not have. So unlock it before return.
    
    Fixes: aef1c8513c1f ("ext4: let ext4_truncate handle inline data correctly")
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Cc: Tao Ma <boyu.mt@taobao.com>
    Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Link: https://lore.kernel.org/r/1604370542-124630-1-git-send-email-joseph.qi@linux.alibaba.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 28f2350893a068fbde10e6e3621672b5a0e70058
Author: Kaixu Xia <kaixuxia@tencent.com>
Date:   Thu Oct 29 23:46:36 2020 +0800

    ext4: correctly report "not supported" for {usr,grp}jquota when !CONFIG_QUOTA
    
    commit 174fe5ba2d1ea0d6c5ab2a7d4aa058d6d497ae4d upstream.
    
    The macro MOPT_Q is used to indicates the mount option is related to
    quota stuff and is defined to be MOPT_NOSUPPORT when CONFIG_QUOTA is
    disabled.  Normally the quota options are handled explicitly, so it
    didn't matter that the MOPT_STRING flag was missing, even though the
    usrjquota and grpjquota mount options take a string argument.  It's
    important that's present in the !CONFIG_QUOTA case, since without
    MOPT_STRING, the mount option matcher will match usrjquota= followed
    by an integer, and will otherwise skip the table entry, and so "mount
    option not supported" error message is never reported.
    
    [ Fixed up the commit description to better explain why the fix
      works. --TYT ]
    
    Fixes: 26092bf52478 ("ext4: use a table-driven handler for mount options")
    Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
    Link: https://lore.kernel.org/r/1603986396-28917-1-git-send-email-kaixuxia@tencent.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 57f9654bde66ce31b61aab3cae5a7e3ab33ac880
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Fri Oct 30 12:49:45 2020 +0100

    perf: Fix get_recursion_context()
    
    [ Upstream commit ce0f17fc93f63ee91428af10b7b2ddef38cd19e5 ]
    
    One should use in_serving_softirq() to detect SoftIRQ context.
    
    Fixes: 96f6d4444302 ("perf_counter: avoid recursion")
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20201030151955.120572175@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3c9d5cf886fae11c0ae3c033f873c18029fe324b
Author: Wang Hai <wanghai38@huawei.com>
Date:   Tue Nov 10 22:46:14 2020 +0800

    cosa: Add missing kfree in error path of cosa_write
    
    [ Upstream commit 52755b66ddcef2e897778fac5656df18817b59ab ]
    
    If memory allocation for 'kbuf' succeed, cosa_write() doesn't have a
    corresponding kfree() in exception handling. Thus add kfree() for this
    function implementation.
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Wang Hai <wanghai38@huawei.com>
    Acked-by: Jan "Yenya" Kasprzak <kas@fi.muni.cz>
    Link: https://lore.kernel.org/r/20201110144614.43194-1-wanghai38@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2e4d9fac404b2674532c363ce203dc30372c7f7a
Author: Evan Nimmo <evan.nimmo@alliedtelesis.co.nz>
Date:   Tue Nov 10 15:28:25 2020 +1300

    of/address: Fix of_node memory leak in of_dma_is_coherent
    
    [ Upstream commit a5bea04fcc0b3c0aec71ee1fd58fd4ff7ee36177 ]
    
    Commit dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on
    powerpc") added a check to of_dma_is_coherent which returns early
    if OF_DMA_DEFAULT_COHERENT is enabled. This results in the of_node_put()
    being skipped causing a memory leak. Moved the of_node_get() below this
    check so we now we only get the node if OF_DMA_DEFAULT_COHERENT is not
    enabled.
    
    Fixes: dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc")
    Signed-off-by: Evan Nimmo <evan.nimmo@alliedtelesis.co.nz>
    Link: https://lore.kernel.org/r/20201110022825.30895-1-evan.nimmo@alliedtelesis.co.nz
    Signed-off-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bf19a74c7e33921ce79b97d973b343b8f56a9362
Author: Christoph Hellwig <hch@lst.de>
Date:   Wed Nov 11 08:07:37 2020 -0800

    xfs: fix a missing unlock on error in xfs_fs_map_blocks
    
    [ Upstream commit 2bd3fa793aaa7e98b74e3653fdcc72fa753913b5 ]
    
    We also need to drop the iolock when invalidate_inode_pages2 fails, not
    only on all other error or successful cases.
    
    Fixes: 527851124d10 ("xfs: implement pNFS export operations")
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 37081c901206a39bd679c1fa0a38d85152e438f8
Author: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Date:   Thu Oct 15 02:50:02 2020 +0000

    iommu/amd: Increase interrupt remapping table limit to 512 entries
    
    [ Upstream commit 73db2fc595f358460ce32bcaa3be1f0cce4a2db1 ]
    
    Certain device drivers allocate IO queues on a per-cpu basis.
    On AMD EPYC platform, which can support up-to 256 cpu threads,
    this can exceed the current MAX_IRQ_PER_TABLE limit of 256,
    and result in the error message:
    
        AMD-Vi: Failed to allocate IRTE
    
    This has been observed with certain NVME devices.
    
    AMD IOMMU hardware can actually support upto 512 interrupt
    remapping table entries. Therefore, update the driver to
    match the hardware limit.
    
    Please note that this also increases the size of interrupt remapping
    table to 8KB per device when using the 128-bit IRTE format.
    
    Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
    Link: https://lore.kernel.org/r/20201015025002.87997-1-suravee.suthikulpanit@amd.com
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 82c5a4fd20443ef1b14f5e94fbbd322124e3dcd2
Author: Ye Bin <yebin10@huawei.com>
Date:   Fri Oct 9 15:02:15 2020 +0800

    cfg80211: regulatory: Fix inconsistent format argument
    
    [ Upstream commit db18d20d1cb0fde16d518fb5ccd38679f174bc04 ]
    
    Fix follow warning:
    [net/wireless/reg.c:3619]: (warning) %d in format string (no. 2)
    requires 'int' but the argument type is 'unsigned int'.
    
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Ye Bin <yebin10@huawei.com>
    Link: https://lore.kernel.org/r/20201009070215.63695-1-yebin10@huawei.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 03ca13c58060fe0aeb74c5872bc522dfa672cfcb
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Oct 9 13:25:41 2020 +0200

    mac80211: fix use of skb payload instead of header
    
    [ Upstream commit 14f46c1e5108696ec1e5a129e838ecedf108c7bf ]
    
    When ieee80211_skb_resize() is called from ieee80211_build_hdr()
    the skb has no 802.11 header yet, in fact it consist only of the
    payload as the ethernet frame is removed. As such, we're using
    the payload data for ieee80211_is_mgmt(), which is of course
    completely wrong. This didn't really hurt us because these are
    always data frames, so we could only have added more tailroom
    than we needed if we determined it was a management frame and
    sdata->crypto_tx_tailroom_needed_cnt was false.
    
    However, syzbot found that of course there need not be any payload,
    so we're using at best uninitialized memory for the check.
    
    Fix this to pass explicitly the kind of frame that we have instead
    of checking there, by replacing the "bool may_encrypt" argument
    with an argument that can carry the three possible states - it's
    not going to be encrypted, it's a management frame, or it's a data
    frame (and then we check sdata->crypto_tx_tailroom_needed_cnt).
    
    Reported-by: syzbot+32fd1a1bfe355e93f1e2@syzkaller.appspotmail.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Link: https://lore.kernel.org/r/20201009132538.e1fd7f802947.I799b288466ea2815f9d4c84349fae697dca2f189@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 05b8a031aa8f5e6dce70e4b93246c08cbc57e5db
Author: Evan Quan <evan.quan@amd.com>
Date:   Wed Oct 28 15:29:59 2020 +0800

    drm/amdgpu: perform srbm soft reset always on SDMA resume
    
    [ Upstream commit 253475c455eb5f8da34faa1af92709e7bb414624 ]
    
    This can address the random SDMA hang after pci config reset
    seen on Hawaii.
    
    Signed-off-by: Evan Quan <evan.quan@amd.com>
    Tested-by: Sandeep Raghuraman <sandy.8925@gmail.com>
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 09537f7f0cd17ec9d72291196a98bae29b7a29eb
Author: Bob Peterson <rpeterso@redhat.com>
Date:   Wed Oct 28 13:42:18 2020 -0500

    gfs2: check for live vs. read-only file system in gfs2_fitrim
    
    [ Upstream commit c5c68724696e7d2f8db58a5fce3673208d35c485 ]
    
    Before this patch, gfs2_fitrim was not properly checking for a "live" file
    system. If the file system had something to trim and the file system
    was read-only (or spectator) it would start the trim, but when it starts
    the transaction, gfs2_trans_begin returns -EROFS (read-only file system)
    and it errors out. However, if the file system was already trimmed so
    there's no work to do, it never called gfs2_trans_begin. That code is
    bypassed so it never returns the error. Instead, it returns a good
    return code with 0 work. All this makes for inconsistent behavior:
    The same fstrim command can return -EROFS in one case and 0 in another.
    This tripped up xfstests generic/537 which reports the error as:
    
        +fstrim with unrecovered metadata just ate your filesystem
    
    This patch adds a check for a "live" (iow, active journal, iow, RW)
    file system, and if not, returns the error properly.
    
    Signed-off-by: Bob Peterson <rpeterso@redhat.com>
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 89d2da2495f0fb61a1678e644095cd7857a5a00f
Author: Bob Peterson <rpeterso@redhat.com>
Date:   Tue Oct 27 10:10:01 2020 -0500

    gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free
    
    [ Upstream commit d0f17d3883f1e3f085d38572c2ea8edbd5150172 ]
    
    Function gfs2_clear_rgrpd calls kfree(rgd->rd_bits) before calling
    return_all_reservations, but return_all_reservations still dereferences
    rgd->rd_bits in __rs_deltree.  Fix that by moving the call to kfree below the
    call to return_all_reservations.
    
    Signed-off-by: Bob Peterson <rpeterso@redhat.com>
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 71e893cf15d2466696360d39a50d7a722bdae648
Author: Evgeny Novikov <novikov@ispras.ru>
Date:   Fri Oct 2 18:01:55 2020 +0300

    usb: gadget: goku_udc: fix potential crashes in probe
    
    [ Upstream commit 0d66e04875c5aae876cf3d4f4be7978fa2b00523 ]
    
    goku_probe() goes to error label "err" and invokes goku_remove()
    in case of failures of pci_enable_device(), pci_resource_start()
    and ioremap(). goku_remove() gets a device from
    pci_get_drvdata(pdev) and works with it without any checks, in
    particular it dereferences a corresponding pointer. But
    goku_probe() did not set this device yet. So, one can expect
    various crashes. The patch moves setting the device just after
    allocation of memory for it.
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Reported-by: Pavel Andrianov <andrianov@ispras.ru>
    Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b05de537d42362e42fcf01b30c05480a1604720b
Author: Masashi Honma <masashi.honma@gmail.com>
Date:   Sun Aug 9 08:32:58 2020 +0900

    ath9k_htc: Use appropriate rs_datalen type
    
    commit 5024f21c159f8c1668f581fff37140741c0b1ba9 upstream.
    
    kernel test robot says:
    drivers/net/wireless/ath/ath9k/htc_drv_txrx.c:987:20: sparse: warning: incorrect type in assignment (different base types)
    drivers/net/wireless/ath/ath9k/htc_drv_txrx.c:987:20: sparse:    expected restricted __be16 [usertype] rs_datalen
    drivers/net/wireless/ath/ath9k/htc_drv_txrx.c:987:20: sparse:    got unsigned short [usertype]
    drivers/net/wireless/ath/ath9k/htc_drv_txrx.c:988:13: sparse: warning: restricted __be16 degrades to integer
    drivers/net/wireless/ath/ath9k/htc_drv_txrx.c:1001:13: sparse: warning: restricted __be16 degrades to integer
    
    Indeed rs_datalen has host byte order, so modify it's own type.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Fixes: cd486e627e67 ("ath9k_htc: Discard undersized packets")
    Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/20200808233258.4596-1-masashi.honma@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e98bcb65299870dfa98d2067d423da80555188c4
Author: Mark Gray <mark.d.gray@redhat.com>
Date:   Wed Sep 16 05:19:35 2020 -0400

    geneve: add transport ports in route lookup for geneve
    
    commit 34beb21594519ce64a55a498c2fe7d567bc1ca20 upstream.
    
    This patch adds transport ports information for route lookup so that
    IPsec can select Geneve tunnel traffic to do encryption. This is
    needed for OVS/OVN IPsec with encrypted Geneve tunnels.
    
    This can be tested by configuring a host-host VPN using an IKE
    daemon and specifying port numbers. For example, for an
    Openswan-type configuration, the following parameters should be
    configured on both hosts and IPsec set up as-per normal:
    
    $ cat /etc/ipsec.conf
    
    conn in
    ...
    left=$IP1
    right=$IP2
    ...
    leftprotoport=udp/6081
    rightprotoport=udp
    ...
    conn out
    ...
    left=$IP1
    right=$IP2
    ...
    leftprotoport=udp
    rightprotoport=udp/6081
    ...
    
    The tunnel can then be setup using "ip" on both hosts (but
    changing the relevant IP addresses):
    
    $ ip link add tun type geneve id 1000 remote $IP2
    $ ip addr add 192.168.0.1/24 dev tun
    $ ip link set tun up
    
    This can then be tested by pinging from $IP1:
    
    $ ping 192.168.0.2
    
    Without this patch the traffic is unencrypted on the wire.
    
    Fixes: 2d07dc79fe04 ("geneve: add initial netdev driver for GENEVE tunnels")
    Signed-off-by: Qiuyu Xiao <qiuyu.xiao.qyx@gmail.com>
    Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
    Reviewed-by: Greg Rose <gvrose8192@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 4.4:
     - Use geneve->dst_port instead of geneve->cfg.info.key.tp_dst
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 78b5c1e88af9ac13794d1e6bd2806b02897978ef
Author: Martyna Szapar <martyna.szapar@intel.com>
Date:   Mon Apr 15 14:43:07 2019 -0700

    i40e: Fix of memory leak and integer truncation in i40e_virtchnl.c
    
    commit 24474f2709af6729b9b1da1c5e160ab62e25e3a4 upstream.
    
    Fixed possible memory leak in i40e_vc_add_cloud_filter function:
    cfilter is being allocated and in some error conditions
    the function returns without freeing the memory.
    
    Fix of integer truncation from u16 (type of queue_id value) to u8
    when calling i40e_vc_isvalid_queue_id function.
    
    Signed-off-by: Martyna Szapar <martyna.szapar@intel.com>
    Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
    [bwh: Backported to 4.4: i40e_vc_add_cloud_filter() does not exist
     but the integer truncation is still possible]
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0f60ed1afff42f84dcba5a7950ee8712da8363d5
Author: Grzegorz Siwik <grzegorz.siwik@intel.com>
Date:   Fri Mar 29 15:08:37 2019 -0700

    i40e: Wrong truncation from u16 to u8
    
    commit c004804dceee9ca384d97d9857ea2e2795c2651d upstream.
    
    In this patch fixed wrong truncation method from u16 to u8 during
    validation.
    
    It was changed by changing u8 to u32 parameter in method declaration
    and arguments were changed to u32.
    
    Signed-off-by: Grzegorz Siwik <grzegorz.siwik@intel.com>
    Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
    Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 03f69244302d7954f42f528ea2d45903ebbf59f3
Author: Will Deacon <will@kernel.org>
Date:   Wed Oct 2 13:42:06 2019 +0100

    pinctrl: devicetree: Avoid taking direct reference to device name string
    
    commit be4c60b563edee3712d392aaeb0943a768df7023 upstream.
    
    When populating the pinctrl mapping table entries for a device, the
    'dev_name' field for each entry is initialised to point directly at the
    string returned by 'dev_name()' for the device and subsequently used by
    'create_pinctrl()' when looking up the mappings for the device being
    probed.
    
    This is unreliable in the presence of calls to 'dev_set_name()', which may
    reallocate the device name string leaving the pinctrl mappings with a
    dangling reference. This then leads to a use-after-free every time the
    name is dereferenced by a device probe:
    
      | BUG: KASAN: invalid-access in strcmp+0x20/0x64
      | Read of size 1 at addr 13ffffc153494b00 by task modprobe/590
      | Pointer tag: [13], memory tag: [fe]
      |
      | Call trace:
      |  __kasan_report+0x16c/0x1dc
      |  kasan_report+0x10/0x18
      |  check_memory_region
      |  __hwasan_load1_noabort+0x4c/0x54
      |  strcmp+0x20/0x64
      |  create_pinctrl+0x18c/0x7f4
      |  pinctrl_get+0x90/0x114
      |  devm_pinctrl_get+0x44/0x98
      |  pinctrl_bind_pins+0x5c/0x450
      |  really_probe+0x1c8/0x9a4
      |  driver_probe_device+0x120/0x1d8
    
    Follow the example of sysfs, and duplicate the device name string before
    stashing it away in the pinctrl mapping entries.
    
    Cc: Linus Walleij <linus.walleij@linaro.org>
    Reported-by: Elena Petrova <lenaptr@google.com>
    Tested-by: Elena Petrova <lenaptr@google.com>
    Signed-off-by: Will Deacon <will@kernel.org>
    Link: https://lore.kernel.org/r/20191002124206.22928-1-will@kernel.org
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    [bwh: Backported to 4.4: adjust context]
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b8b68014bfe6683d546663d9e8bb1cf2e5361b53
Author: Filipe Manana <fdmanana@suse.com>
Date:   Wed Sep 11 17:42:28 2019 +0100

    Btrfs: fix missing error return if writeback for extent buffer never started
    
    [ Upstream commit 0607eb1d452d45c5ac4c745a9e9e0d95152ea9d0 ]
    
    If lock_extent_buffer_for_io() fails, it returns a negative value, but its
    caller btree_write_cache_pages() ignores such error. This means that a
    call to flush_write_bio(), from lock_extent_buffer_for_io(), might have
    failed. We should make btree_write_cache_pages() notice such error values
    and stop immediatelly, making sure filemap_fdatawrite_range() returns an
    error to the transaction commit path. A failure from flush_write_bio()
    should also result in the endio callback end_bio_extent_buffer_writepage()
    being invoked, which sets the BTRFS_FS_*_ERR bits appropriately, so that
    there's no risk a transaction or log commit doesn't catch a writeback
    failure.
    
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a17fd24a24bd1d39323ab8f6f4fe9d3db89856f5
Author: Stephane Grosjean <s.grosjean@peak-system.com>
Date:   Wed Oct 14 10:56:31 2020 +0200

    can: peak_usb: peak_usb_get_ts_time(): fix timestamp wrapping
    
    [ Upstream commit ecc7b4187dd388549544195fb13a11b4ea8e6a84 ]
    
    Fabian Inostroza <fabianinostrozap@gmail.com> has discovered a potential
    problem in the hardware timestamp reporting from the PCAN-USB USB CAN interface
    (only), related to the fact that a timestamp of an event may precede the
    timestamp used for synchronization when both records are part of the same USB
    packet. However, this case was used to detect the wrapping of the time counter.
    
    This patch details and fixes the two identified cases where this problem can
    occur.
    
    Reported-by: Fabian Inostroza <fabianinostrozap@gmail.com>
    Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
    Link: https://lore.kernel.org/r/20201014085631.15128-1-s.grosjean@peak-system.com
    Fixes: bb4785551f64 ("can: usb: PEAK-System Technik USB adapters driver core")
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 261202518ab62d38d57c5680a7f823e13365353b
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu Aug 13 17:06:04 2020 +0300

    can: peak_usb: add range checking in decode operations
    
    [ Upstream commit a6921dd524fe31d1f460c161d3526a407533b6db ]
    
    These values come from skb->data so Smatch considers them untrusted.  I
    believe Smatch is correct but I don't have a way to test this.
    
    The usb_if->dev[] array has 2 elements but the index is in the 0-15
    range without checks.  The cfd->len can be up to 255 but the maximum
    valid size is CANFD_MAX_DLEN (64) so that could lead to memory
    corruption.
    
    Fixes: 0a25e1f4f185 ("can: peak_usb: add support for PEAK new CANFD USB adapters")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Link: https://lore.kernel.org/r/20200813140604.GA456946@mwanda
    Acked-by: Stephane Grosjean <s.grosjean@peak-system.com>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1164646e69d9dc72c7f59ef5c1dc3c1de2c91540
Author: Oleksij Rempel <linux@rempel-privat.de>
Date:   Wed Dec 18 09:39:02 2019 +0100

    can: can_create_echo_skb(): fix echo skb generation: always use skb_clone()
    
    [ Upstream commit 286228d382ba6320f04fa2e7c6fc8d4d92e428f4 ]
    
    All user space generated SKBs are owned by a socket (unless injected into the
    key via AF_PACKET). If a socket is closed, all associated skbs will be cleaned
    up.
    
    This leads to a problem when a CAN driver calls can_put_echo_skb() on a
    unshared SKB. If the socket is closed prior to the TX complete handler,
    can_get_echo_skb() and the subsequent delivering of the echo SKB to all
    registered callbacks, a SKB with a refcount of 0 is delivered.
    
    To avoid the problem, in can_get_echo_skb() the original SKB is now always
    cloned, regardless of shared SKB or not. If the process exists it can now
    safely discard its SKBs, without disturbing the delivery of the echo SKB.
    
    The problem shows up in the j1939 stack, when it clones the incoming skb, which
    detects the already 0 refcount.
    
    We can easily reproduce this with following example:
    
    testj1939 -B -r can0: &
    cansend can0 1823ff40#0123
    
    WARNING: CPU: 0 PID: 293 at lib/refcount.c:25 refcount_warn_saturate+0x108/0x174
    refcount_t: addition on 0; use-after-free.
    Modules linked in: coda_vpu imx_vdoa videobuf2_vmalloc dw_hdmi_ahb_audio vcan
    CPU: 0 PID: 293 Comm: cansend Not tainted 5.5.0-rc6-00376-g9e20dcb7040d #1
    Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
    Backtrace:
    [<c010f570>] (dump_backtrace) from [<c010f90c>] (show_stack+0x20/0x24)
    [<c010f8ec>] (show_stack) from [<c0c3e1a4>] (dump_stack+0x8c/0xa0)
    [<c0c3e118>] (dump_stack) from [<c0127fec>] (__warn+0xe0/0x108)
    [<c0127f0c>] (__warn) from [<c01283c8>] (warn_slowpath_fmt+0xa8/0xcc)
    [<c0128324>] (warn_slowpath_fmt) from [<c0539c0c>] (refcount_warn_saturate+0x108/0x174)
    [<c0539b04>] (refcount_warn_saturate) from [<c0ad2cac>] (j1939_can_recv+0x20c/0x210)
    [<c0ad2aa0>] (j1939_can_recv) from [<c0ac9dc8>] (can_rcv_filter+0xb4/0x268)
    [<c0ac9d14>] (can_rcv_filter) from [<c0aca2cc>] (can_receive+0xb0/0xe4)
    [<c0aca21c>] (can_receive) from [<c0aca348>] (can_rcv+0x48/0x98)
    [<c0aca300>] (can_rcv) from [<c09b1fdc>] (__netif_receive_skb_one_core+0x64/0x88)
    [<c09b1f78>] (__netif_receive_skb_one_core) from [<c09b2070>] (__netif_receive_skb+0x38/0x94)
    [<c09b2038>] (__netif_receive_skb) from [<c09b2130>] (netif_receive_skb_internal+0x64/0xf8)
    [<c09b20cc>] (netif_receive_skb_internal) from [<c09b21f8>] (netif_receive_skb+0x34/0x19c)
    [<c09b21c4>] (netif_receive_skb) from [<c0791278>] (can_rx_offload_napi_poll+0x58/0xb4)
    
    Fixes: 0ae89beb283a ("can: add destructor for self generated skbs")
    Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Link: http://lore.kernel.org/r/20200124132656.22156-1-o.rempel@pengutronix.de
    Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0b7578675c2a87d8750d645819564c1d2f7d8044
Author: Oliver Hartkopp <socketcan@hartkopp.net>
Date:   Tue Oct 20 08:44:43 2020 +0200

    can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames
    
    [ Upstream commit ed3320cec279407a86bc4c72edc4a39eb49165ec ]
    
    The can_get_echo_skb() function returns the number of received bytes to
    be used for netdev statistics. In the case of RTR frames we get a valid
    (potential non-zero) data length value which has to be passed for further
    operations. But on the wire RTR frames have no payload length. Therefore
    the value to be used in the statistics has to be zero for RTR frames.
    
    Reported-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
    Link: https://lore.kernel.org/r/20201020064443.80164-1-socketcan@hartkopp.net
    Fixes: cf5046b309b3 ("can: dev: let can_get_echo_skb() return dlc of CAN frame")
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 248b71ce92d4f3a574b2537f9838f48e892618f4
Author: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Date:   Sat Oct 3 00:41:45 2020 +0900

    can: dev: can_get_echo_skb(): prevent call to kfree_skb() in hard IRQ context
    
    [ Upstream commit 2283f79b22684d2812e5c76fc2280aae00390365 ]
    
    If a driver calls can_get_echo_skb() during a hardware IRQ (which is often, but
    not always, the case), the 'WARN_ON(in_irq)' in
    net/core/skbuff.c#skb_release_head_state() might be triggered, under network
    congestion circumstances, together with the potential risk of a NULL pointer
    dereference.
    
    The root cause of this issue is the call to kfree_skb() instead of
    dev_kfree_skb_irq() in net/core/dev.c#enqueue_to_backlog().
    
    This patch prevents the skb to be freed within the call to netif_rx() by
    incrementing its reference count with skb_get(). The skb is finally freed by
    one of the in-irq-context safe functions: dev_consume_skb_any() or
    dev_kfree_skb_any(). The "any" version is used because some drivers might call
    can_get_echo_skb() in a normal context.
    
    The reason for this issue to occur is that initially, in the core network
    stack, loopback skb were not supposed to be received in hardware IRQ context.
    The CAN stack is an exeption.
    
    This bug was previously reported back in 2017 in [1] but the proposed patch
    never got accepted.
    
    While [1] directly modifies net/core/dev.c, we try to propose here a
    smoother modification local to CAN network stack (the assumption
    behind is that only CAN devices are affected by this issue).
    
    [1] http://lore.kernel.org/r/57a3ffb6-3309-3ad5-5a34-e93c3fe3614d@cetitec.com
    
    Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Link: https://lore.kernel.org/r/20201002154219.4887-2-mailhol.vincent@wanadoo.fr
    Fixes: 39549eef3587 ("can: CAN Network device driver and Netlink interface")
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f1a6e0d012c9b1ab7a23a9baef4628d7670a0562
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Nov 3 13:18:07 2020 +0300

    ALSA: hda: prevent undefined shift in snd_hdac_ext_bus_get_link()
    
    [ Upstream commit 158e1886b6262c1d1c96a18c85fac5219b8bf804 ]
    
    This is harmless, but the "addr" comes from the user and it could lead
    to a negative shift or to shift wrapping if it's too high.
    
    Fixes: 0b00a5615dc4 ("ALSA: hdac_ext: add hdac extended controller")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Link: https://lore.kernel.org/r/20201103101807.GC1127762@mwanda
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d990e768f7c255c4e2073d658bc245d99200bb09
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Mon Nov 2 00:31:03 2020 +0100

    perf tools: Add missing swap for ino_generation
    
    [ Upstream commit fe01adb72356a4e2f8735e4128af85921ca98fa1 ]
    
    We are missing swap for ino_generation field.
    
    Fixes: 5c5e854bc760 ("perf tools: Add attr->mmap2 support")
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Acked-by: Namhyung Kim <namhyung@kernel.org>
    Link: https://lore.kernel.org/r/20201101233103.3537427-2-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c81542e3308f38f9ef455737ef697f8b03716909
Author: zhuoliang zhang <zhuoliang.zhang@mediatek.com>
Date:   Fri Oct 23 09:05:35 2020 +0200

    net: xfrm: fix a race condition during allocing spi
    
    [ Upstream commit a779d91314ca7208b7feb3ad817b62904397c56d ]
    
    we found that the following race condition exists in
    xfrm_alloc_userspi flow:
    
    user thread                                    state_hash_work thread
    ----                                           ----
    xfrm_alloc_userspi()
     __find_acq_core()
       /*alloc new xfrm_state:x*/
       xfrm_state_alloc()
       /*schedule state_hash_work thread*/
       xfrm_hash_grow_check()                      xfrm_hash_resize()
     xfrm_alloc_spi                                  /*hold lock*/
          x->id.spi = htonl(spi)                     spin_lock_bh(&net->xfrm.xfrm_state_lock)
          /*waiting lock release*/                     xfrm_hash_transfer()
          spin_lock_bh(&net->xfrm.xfrm_state_lock)      /*add x into hlist:net->xfrm.state_byspi*/
                                                            hlist_add_head_rcu(&x->byspi)
                                                     spin_unlock_bh(&net->xfrm.xfrm_state_lock)
    
        /*add x into hlist:net->xfrm.state_byspi 2 times*/
        hlist_add_head_rcu(&x->byspi)
    
    1. a new state x is alloced in xfrm_state_alloc() and added into the bydst hlist
    in  __find_acq_core() on the LHS;
    2. on the RHS, state_hash_work thread travels the old bydst and tranfers every xfrm_state
    (include x) into the new bydst hlist and new byspi hlist;
    3. user thread on the LHS gets the lock and adds x into the new byspi hlist again.
    
    So the same xfrm_state (x) is added into the same list_hash
    (net->xfrm.state_byspi) 2 times that makes the list_hash become
    an inifite loop.
    
    To fix the race, x->id.spi = htonl(spi) in the xfrm_alloc_spi() is moved
    to the back of spin_lock_bh, sothat state_hash_work thread no longer add x
    which id.spi is zero into the hash_list.
    
    Fixes: f034b5d4efdf ("[XFRM]: Dynamic xfrm_state hash table sizing.")
    Signed-off-by: zhuoliang zhang <zhuoliang.zhang@mediatek.com>
    Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9ce097a4ed94cb21b75719e4ea38e0f0316bc63e
Author: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Date:   Tue Sep 22 17:27:29 2020 +0900

    btrfs: reschedule when cloning lots of extents
    
    [ Upstream commit 6b613cc97f0ace77f92f7bc112b8f6ad3f52baf8 ]
    
    We have several occurrences of a soft lockup from fstest's generic/175
    testcase, which look more or less like this one:
    
      watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [xfs_io:10030]
      Kernel panic - not syncing: softlockup: hung tasks
      CPU: 0 PID: 10030 Comm: xfs_io Tainted: G             L    5.9.0-rc5+ #768
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4-rebuilt.opensuse.org 04/01/2014
      Call Trace:
       <IRQ>
       dump_stack+0x77/0xa0
       panic+0xfa/0x2cb
       watchdog_timer_fn.cold+0x85/0xa5
       ? lockup_detector_update_enable+0x50/0x50
       __hrtimer_run_queues+0x99/0x4c0
       ? recalibrate_cpu_khz+0x10/0x10
       hrtimer_run_queues+0x9f/0xb0
       update_process_times+0x28/0x80
       tick_handle_periodic+0x1b/0x60
       __sysvec_apic_timer_interrupt+0x76/0x210
       asm_call_on_stack+0x12/0x20
       </IRQ>
       sysvec_apic_timer_interrupt+0x7f/0x90
       asm_sysvec_apic_timer_interrupt+0x12/0x20
      RIP: 0010:btrfs_tree_unlock+0x91/0x1a0 [btrfs]
      RSP: 0018:ffffc90007123a58 EFLAGS: 00000282
      RAX: ffff8881cea2fbe0 RBX: ffff8881cea2fbe0 RCX: 0000000000000000
      RDX: ffff8881d23fd200 RSI: ffffffff82045220 RDI: ffff8881cea2fba0
      RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000032
      R10: 0000160000000000 R11: 0000000000001000 R12: 0000000000001000
      R13: ffff8882357fd5b0 R14: ffff88816fa76e70 R15: ffff8881cea2fad0
       ? btrfs_tree_unlock+0x15b/0x1a0 [btrfs]
       btrfs_release_path+0x67/0x80 [btrfs]
       btrfs_insert_replace_extent+0x177/0x2c0 [btrfs]
       btrfs_replace_file_extents+0x472/0x7c0 [btrfs]
       btrfs_clone+0x9ba/0xbd0 [btrfs]
       btrfs_clone_files.isra.0+0xeb/0x140 [btrfs]
       ? file_update_time+0xcd/0x120
       btrfs_remap_file_range+0x322/0x3b0 [btrfs]
       do_clone_file_range+0xb7/0x1e0
       vfs_clone_file_range+0x30/0xa0
       ioctl_file_clone+0x8a/0xc0
       do_vfs_ioctl+0x5b2/0x6f0
       __x64_sys_ioctl+0x37/0xa0
       do_syscall_64+0x33/0x40
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x7f87977fc247
      RSP: 002b:00007ffd51a2f6d8 EFLAGS: 00000206 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f87977fc247
      RDX: 00007ffd51a2f710 RSI: 000000004020940d RDI: 0000000000000003
      RBP: 0000000000000004 R08: 00007ffd51a79080 R09: 0000000000000000
      R10: 00005621f11352f2 R11: 0000000000000206 R12: 0000000000000000
      R13: 0000000000000000 R14: 00005621f128b958 R15: 0000000080000000
      Kernel Offset: disabled
      ---[ end Kernel panic - not syncing: softlockup: hung tasks ]---
    
    All of these lockup reports have the call chain btrfs_clone_files() ->
    btrfs_clone() in common. btrfs_clone_files() calls btrfs_clone() with
    both source and destination extents locked and loops over the source
    extent to create the clones.
    
    Conditionally reschedule in the btrfs_clone() loop, to give some time back
    to other processes.
    
    CC: stable@vger.kernel.org # 4.4+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9cddbb8787ef3354bb08f19a0b08850bf67a6d16
Author: Zeng Tao <prime.zeng@hisilicon.com>
Date:   Tue Sep 1 17:30:13 2020 +0800

    time: Prevent undefined behaviour in timespec64_to_ns()
    
    [ Upstream commit cb47755725da7b90fecbb2aa82ac3b24a7adb89b ]
    
    UBSAN reports:
    
    Undefined behaviour in ./include/linux/time64.h:127:27
    signed integer overflow:
    17179869187 * 1000000000 cannot be represented in type 'long long int'
    Call Trace:
     timespec64_to_ns include/linux/time64.h:127 [inline]
     set_cpu_itimer+0x65c/0x880 kernel/time/itimer.c:180
     do_setitimer+0x8e/0x740 kernel/time/itimer.c:245
     __x64_sys_setitimer+0x14c/0x2c0 kernel/time/itimer.c:336
     do_syscall_64+0xa1/0x540 arch/x86/entry/common.c:295
    
    Commit bd40a175769d ("y2038: itimer: change implementation to timespec64")
    replaced the original conversion which handled time clamping correctly with
    timespec64_to_ns() which has no overflow protection.
    
    Fix it in timespec64_to_ns() as this is not necessarily limited to the
    usage in itimers.
    
    [ tglx: Added comment and adjusted the fixes tag ]
    
    Fixes: 361a3bf00582 ("time64: Add time64.h header and define struct timespec64")
    Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/1598952616-6416-1-git-send-email-prime.zeng@hisilicon.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 45b52deae851b1eeca961cb0f73f43d3c8816df3
Author: Shijie Luo <luoshijie1@huawei.com>
Date:   Sun Nov 1 17:07:40 2020 -0800

    mm: mempolicy: fix potential pte_unmap_unlock pte error
    
    [ Upstream commit 3f08842098e842c51e3b97d0dcdebf810b32558e ]
    
    When flags in queue_pages_pte_range don't have MPOL_MF_MOVE or
    MPOL_MF_MOVE_ALL bits, code breaks and passing origin pte - 1 to
    pte_unmap_unlock seems like not a good idea.
    
    queue_pages_pte_range can run in MPOL_MF_MOVE_ALL mode which doesn't
    migrate misplaced pages but returns with EIO when encountering such a
    page.  Since commit a7f40cfe3b7a ("mm: mempolicy: make mbind() return
    -EIO when MPOL_MF_STRICT is specified") and early break on the first pte
    in the range results in pte_unmap_unlock on an underflow pte.  This can
    lead to lockups later on when somebody tries to lock the pte resp.
    page_table_lock again..
    
    Fixes: a7f40cfe3b7a ("mm: mempolicy: make mbind() return -EIO when MPOL_MF_STRICT is specified")
    Signed-off-by: Shijie Luo <luoshijie1@huawei.com>
    Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Reviewed-by: Oscar Salvador <osalvador@suse.de>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Miaohe Lin <linmiaohe@huawei.com>
    Cc: Feilong Lin <linfeilong@huawei.com>
    Cc: Shijie Luo <luoshijie1@huawei.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lkml.kernel.org/r/20201019074853.50856-1-luoshijie1@huawei.com
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 78933fded91d4cc412266c870184f1c6dcce1f5d
Author: Alexander Aring <aahringo@redhat.com>
Date:   Mon Oct 26 10:52:29 2020 -0400

    gfs2: Wake up when sd_glock_disposal becomes zero
    
    [ Upstream commit da7d554f7c62d0c17c1ac3cc2586473c2d99f0bd ]
    
    Commit fc0e38dae645 ("GFS2: Fix glock deallocation race") fixed a
    sd_glock_disposal accounting bug by adding a missing atomic_dec
    statement, but it failed to wake up sd_glock_wait when that decrement
    causes sd_glock_disposal to reach zero.  As a consequence,
    gfs2_gl_hash_clear can now run into a 10-minute timeout instead of
    being woken up.  Add the missing wakeup.
    
    Fixes: fc0e38dae645 ("GFS2: Fix glock deallocation race")
    Cc: stable@vger.kernel.org # v2.6.39+
    Signed-off-by: Alexander Aring <aahringo@redhat.com>
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 47f1d1fe0cfaddb87cedbf3e2929f6edfe20ed16
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Mon Nov 2 15:31:27 2020 -0500

    ring-buffer: Fix recursion protection transitions between interrupt context
    
    [ Upstream commit b02414c8f045ab3b9afc816c3735bc98c5c3d262 ]
    
    The recursion protection of the ring buffer depends on preempt_count() to be
    correct. But it is possible that the ring buffer gets called after an
    interrupt comes in but before it updates the preempt_count(). This will
    trigger a false positive in the recursion code.
    
    Use the same trick from the ftrace function callback recursion code which
    uses a "transition" bit that gets set, to allow for a single recursion for
    to handle transitions between contexts.
    
    Cc: stable@vger.kernel.org
    Fixes: 567cd4da54ff4 ("ring-buffer: User context bit recursion checking")
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>