commit 811218eceeaa7618652e1b8d11caeff67ab42072
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Sat Jan 30 13:32:13 2021 +0100

    Linux 4.19.172
    
    Tested-by: Pavel Machek (CIP) <pavel@denx.de>
    Link: https://lore.kernel.org/r/20210129105910.685105711@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b4da738055acf42e00535c52b60d9bef808a7464
Author: Eric Biggers <ebiggers@google.com>
Date:   Mon Jan 25 12:05:09 2021 -0800

    fs: fix lazytime expiration handling in __writeback_single_inode()
    
    commit 1e249cb5b7fc09ff216aa5a12f6c302e434e88f9 upstream.
    
    When lazytime is enabled and an inode is being written due to its
    in-memory updated timestamps having expired, either due to a sync() or
    syncfs() system call or due to dirtytime_expire_interval having elapsed,
    the VFS needs to inform the filesystem so that the filesystem can copy
    the inode's timestamps out to the on-disk data structures.
    
    This is done by __writeback_single_inode() calling
    mark_inode_dirty_sync(), which then calls ->dirty_inode(I_DIRTY_SYNC).
    
    However, this occurs after __writeback_single_inode() has already
    cleared the dirty flags from ->i_state.  This causes two bugs:
    
    - mark_inode_dirty_sync() redirties the inode, causing it to remain
      dirty.  This wastefully causes the inode to be written twice.  But
      more importantly, it breaks cases where sync_filesystem() is expected
      to clean dirty inodes.  This includes the FS_IOC_REMOVE_ENCRYPTION_KEY
      ioctl (as reported at
      https://lore.kernel.org/r/20200306004555.GB225345@gmail.com), as well
      as possibly filesystem freezing (freeze_super()).
    
    - Since ->i_state doesn't contain I_DIRTY_TIME when ->dirty_inode() is
      called from __writeback_single_inode() for lazytime expiration,
      xfs_fs_dirty_inode() ignores the notification.  (XFS only cares about
      lazytime expirations, and it assumes that i_state will contain
      I_DIRTY_TIME during those.)  Therefore, lazy timestamps aren't
      persisted by sync(), syncfs(), or dirtytime_expire_interval on XFS.
    
    Fix this by moving the call to mark_inode_dirty_sync() to earlier in
    __writeback_single_inode(), before the dirty flags are cleared from
    i_state.  This makes filesystems be properly notified of the timestamp
    expiration, and it avoids incorrectly redirtying the inode.
    
    This fixes xfstest generic/580 (which tests
    FS_IOC_REMOVE_ENCRYPTION_KEY) when run on ext4 or f2fs with lazytime
    enabled.  It also fixes the new lazytime xfstest I've proposed, which
    reproduces the above-mentioned XFS bug
    (https://lore.kernel.org/r/20210105005818.92978-1-ebiggers@kernel.org).
    
    Alternatively, we could call ->dirty_inode(I_DIRTY_SYNC) directly.  But
    due to the introduction of I_SYNC_QUEUED, mark_inode_dirty_sync() is the
    right thing to do because mark_inode_dirty_sync() now knows not to move
    the inode to a writeback list if it is currently queued for sync.
    
    Fixes: 0ae45f63d4ef ("vfs: add support for a lazytime mount option")
    Cc: stable@vger.kernel.org
    Depends-on: 5afced3bf281 ("writeback: Avoid skipping inode writeback")
    Link: https://lore.kernel.org/r/20210112190253.64307-2-ebiggers@kernel.org
    Suggested-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9f9623fc9340af731c3f3a09e6e9af0756b38a46
Author: Jan Kara <jack@suse.cz>
Date:   Mon Jan 25 12:05:08 2021 -0800

    writeback: Drop I_DIRTY_TIME_EXPIRE
    
    commit 5fcd57505c002efc5823a7355e21f48dd02d5a51 upstream.
    
    The only use of I_DIRTY_TIME_EXPIRE is to detect in
    __writeback_single_inode() that inode got there because flush worker
    decided it's time to writeback the dirty inode time stamps (either
    because we are syncing or because of age). However we can detect this
    directly in __writeback_single_inode() and there's no need for the
    strange propagation with I_DIRTY_TIME_EXPIRE flag.
    
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 26b30d36cb5cff5e075114d05e5309043514770c
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Wed Jan 20 13:59:11 2021 -0500

    dm integrity: conditionally disable "recalculate" feature
    
    commit 5c02406428d5219c367c5f53457698c58bc5f917 upstream.
    
    Otherwise a malicious user could (ab)use the "recalculate" feature
    that makes dm-integrity calculate the checksums in the background
    while the device is already usable. When the system restarts before all
    checksums have been calculated, the calculation continues where it was
    interrupted even if the recalculate feature is not requested the next
    time the dm device is set up.
    
    Disable recalculating if we use internal_hash or journal_hash with a
    key (e.g. HMAC) and we don't have the "legacy_recalculate" flag.
    
    This may break activation of a volume, created by an older kernel,
    that is not yet fully recalculated -- if this happens, the user should
    add the "legacy_recalculate" flag to constructor parameters.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Reported-by: Daniel Glockner <dg@emlix.com>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 440ed9aef50fa3cdb0a06a95125e34c9f1ecb4f3
Author: Jean-Philippe Brucker <jean-philippe@linaro.org>
Date:   Tue Nov 10 17:43:05 2020 +0100

    tools: Factor HOSTCC, HOSTLD, HOSTAR definitions
    
    commit c8a950d0d3b926a02c7b2e713850d38217cec3d1 upstream.
    
    Several Makefiles in tools/ need to define the host toolchain variables.
    Move their definition to tools/scripts/Makefile.include
    
    Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Acked-by: Jiri Olsa <jolsa@redhat.com>
    Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://lore.kernel.org/bpf/20201110164310.2600671-2-jean-philippe@linaro.org
    Cc: Alistair Delva <adelva@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit acfa7ad7b7f6489e2bed20880ce090fdabdbb841
Author: Gaurav Kohli <gkohli@codeaurora.org>
Date:   Tue Oct 6 15:03:53 2020 +0530

    tracing: Fix race in trace_open and buffer resize call
    
    commit bbeb97464eefc65f506084fd9f18f21653e01137 upstream.
    
    Below race can come, if trace_open and resize of
    cpu buffer is running parallely on different cpus
    CPUX                                CPUY
                                        ring_buffer_resize
                                        atomic_read(&buffer->resize_disabled)
    tracing_open
    tracing_reset_online_cpus
    ring_buffer_reset_cpu
    rb_reset_cpu
                                        rb_update_pages
                                        remove/insert pages
    resetting pointer
    
    This race can cause data abort or some times infinte loop in
    rb_remove_pages and rb_insert_pages while checking pages
    for sanity.
    
    Take buffer lock to fix this.
    
    Link: https://lkml.kernel.org/r/1601976833-24377-1-git-send-email-gkohli@codeaurora.org
    
    Cc: stable@vger.kernel.org
    Fixes: 83f40318dab00 ("ring-buffer: Make removal of ring buffer pages atomic")
    Reported-by: Denis Efremov <efremov@linux.com>
    Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1feeef6cc4c830d42fced7e78c25a712efb388c7
Author: Jason Gerecke <killertofu@gmail.com>
Date:   Thu Jan 21 10:46:49 2021 -0800

    HID: wacom: Correct NULL dereference on AES pen proximity
    
    commit 179e8e47c02a1950f1c556f2b854bdb2259078fb upstream.
    
    The recent commit to fix a memory leak introduced an inadvertant NULL
    pointer dereference. The `wacom_wac->pen_fifo` variable was never
    intialized, resuling in a crash whenever functions tried to use it.
    Since the FIFO is only used by AES pens (to buffer events from pen
    proximity until the hardware reports the pen serial number) this would
    have been easily overlooked without testing an AES device.
    
    This patch converts `wacom_wac->pen_fifo` over to a pointer (since the
    call to `devres_alloc` allocates memory for us) and ensures that we assign
    it to point to the allocated and initalized `pen_fifo` before the function
    returns.
    
    Link: https://github.com/linuxwacom/input-wacom/issues/230
    Fixes: 37309f47e2f5 ("HID: wacom: Fix memory leakage caused by kfifo_alloc")
    CC: stable@vger.kernel.org # v4.19+
    Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
    Tested-by: Ping Cheng <ping.cheng@wacom.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e7bfa046de83596c2a50f72e8ced1ee327db654
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Mon Jan 18 19:01:21 2021 +0100

    futex: Handle faults correctly for PI futexes
    
    commit 34b1a1ce1458f50ef27c54e28eb9b1947012907a upstream
    
    fixup_pi_state_owner() tries to ensure that the state of the rtmutex,
    pi_state and the user space value related to the PI futex are consistent
    before returning to user space. In case that the user space value update
    faults and the fault cannot be resolved by faulting the page in via
    fault_in_user_writeable() the function returns with -EFAULT and leaves
    the rtmutex and pi_state owner state inconsistent.
    
    A subsequent futex_unlock_pi() operates on the inconsistent pi_state and
    releases the rtmutex despite not owning it which can corrupt the RB tree of
    the rtmutex and cause a subsequent kernel stack use after free.
    
    It was suggested to loop forever in fixup_pi_state_owner() if the fault
    cannot be resolved, but that results in runaway tasks which is especially
    undesired when the problem happens due to a programming error and not due
    to malice.
    
    As the user space value cannot be fixed up, the proper solution is to make
    the rtmutex and the pi_state consistent so both have the same owner. This
    leaves the user space value out of sync. Any subsequent operation on the
    futex will fail because the 10th rule of PI futexes (pi_state owner and
    user space value are consistent) has been violated.
    
    As a consequence this removes the inept attempts of 'fixing' the situation
    in case that the current task owns the rtmutex when returning with an
    unresolvable fault by unlocking the rtmutex which left pi_state::owner and
    rtmutex::owner out of sync in a different and only slightly less dangerous
    way.
    
    Fixes: 1b7558e457ed ("futexes: fix fault handling in futex_lock_pi")
    Reported-by: gzobqq@gmail.com
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a4649185a98eb7adbdbdfdbf61237d518861e877
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Tue Jan 19 16:26:38 2021 +0100

    futex: Simplify fixup_pi_state_owner()
    
    commit f2dac39d93987f7de1e20b3988c8685523247ae2 upstream
    
    Too many gotos already and an upcoming fix would make it even more
    unreadable.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9d5dbf57d66f410d35da822a115dfd57531950dc
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Jan 20 11:35:19 2021 +0100

    futex: Use pi_state_update_owner() in put_pi_state()
    
    commit 6ccc84f917d33312eb2846bd7b567639f585ad6d upstream
    
    No point in open coding it. This way it gains the extra sanity checks.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29013e4f4b73e2f5ef39a443b05c231ac29c690f
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Jan 20 11:32:07 2021 +0100

    rtmutex: Remove unused argument from rt_mutex_proxy_unlock()
    
    commit 2156ac1934166d6deb6cd0f6ffc4c1076ec63697 upstream
    
    Nothing uses the argument. Remove it as preparation to use
    pi_state_update_owner().
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0e1501f7b1eea94991e60cc51fadb3838bb2c7cb
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Tue Jan 19 15:21:35 2021 +0100

    futex: Provide and use pi_state_update_owner()
    
    commit c5cade200ab9a2a3be9e7f32a752c8d86b502ec7 upstream
    
    Updating pi_state::owner is done at several places with the same
    code. Provide a function for it and use that at the obvious places.
    
    This is also a preparation for a bug fix to avoid yet another copy of the
    same code or alternatively introducing a completely unpenetratable mess of
    gotos.
    
    Originally-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f03b21494da1ebf4ecfcb34ab647f35dc7fb7d92
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Tue Jan 19 16:06:10 2021 +0100

    futex: Replace pointless printk in fixup_owner()
    
    commit 04b79c55201f02ffd675e1231d731365e335c307 upstream
    
    If that unexpected case of inconsistent arguments ever happens then the
    futex state is left completely inconsistent and the printk is not really
    helpful. Replace it with a warning and make the state consistent.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 72f38fffa4758b878f819f8a47761b3f03443f36
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Jan 20 16:00:24 2021 +0100

    futex: Ensure the correct return value from futex_lock_pi()
    
    commit 12bb3f7f1b03d5913b3f9d4236a488aa7774dfe9 upstream
    
    In case that futex_lock_pi() was aborted by a signal or a timeout and the
    task returned without acquiring the rtmutex, but is the designated owner of
    the futex due to a concurrent futex_unlock_pi() fixup_owner() is invoked to
    establish consistent state. In that case it invokes fixup_pi_state_owner()
    which in turn tries to acquire the rtmutex again. If that succeeds then it
    does not propagate this success to fixup_owner() and futex_lock_pi()
    returns -EINTR or -ETIMEOUT despite having the futex locked.
    
    Return success from fixup_pi_state_owner() in all cases where the current
    task owns the rtmutex and therefore the futex and propagate it correctly
    through fixup_owner(). Fixup the other callsite which does not expect a
    positive return value.
    
    Fixes: c1e2f0eaf015 ("futex: Avoid violating the 10th rule of futex")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7874eee0130adf9bee28e8720bb5dd051089def3
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:46 2019 +0100

    futex: Prevent exit livelock
    
    commit 3ef240eaff36b8119ac9e2ea17cbf41179c930ba upstream
    
    Oleg provided the following test case:
    
    int main(void)
    {
            struct sched_param sp = {};
    
            sp.sched_priority = 2;
            assert(sched_setscheduler(0, SCHED_FIFO, &sp) == 0);
    
            int lock = vfork();
            if (!lock) {
                    sp.sched_priority = 1;
                    assert(sched_setscheduler(0, SCHED_FIFO, &sp) == 0);
                    _exit(0);
            }
    
            syscall(__NR_futex, &lock, FUTEX_LOCK_PI, 0,0,0);
            return 0;
    }
    
    This creates an unkillable RT process spinning in futex_lock_pi() on a UP
    machine or if the process is affine to a single CPU. The reason is:
    
     parent                                 child
    
      set FIFO prio 2
    
      vfork()                       ->      set FIFO prio 1
       implies wait_for_child()             sched_setscheduler(...)
                                            exit()
                                            do_exit()
                                            ....
                                            mm_release()
                                              tsk->futex_state = FUTEX_STATE_EXITING;
                                              exit_futex(); (NOOP in this case)
                                              complete() --> wakes parent
      sys_futex()
        loop infinite because
        tsk->futex_state == FUTEX_STATE_EXITING
    
    The same problem can happen just by regular preemption as well:
    
      task holds futex
      ...
      do_exit()
        tsk->futex_state = FUTEX_STATE_EXITING;
    
      --> preemption (unrelated wakeup of some other higher prio task, e.g. timer)
    
      switch_to(other_task)
    
      return to user
      sys_futex()
            loop infinite as above
    
    Just for the fun of it the futex exit cleanup could trigger the wakeup
    itself before the task sets its futex state to DEAD.
    
    To cure this, the handling of the exiting owner is changed so:
    
       - A refcount is held on the task
    
       - The task pointer is stored in a caller visible location
    
       - The caller drops all locks (hash bucket, mmap_sem) and blocks
         on task::futex_exit_mutex. When the mutex is acquired then
         the exiting task has completed the cleanup and the state
         is consistent and can be reevaluated.
    
    This is not a pretty solution, but there is no choice other than returning
    an error code to user space, which would break the state consistency
    guarantee and open another can of problems including regressions.
    
    For stable backports the preparatory commits ac31c7ff8624 .. ba31c1a48538
    are required as well, but for anything older than 5.3.y the backports are
    going to be provided when this hits mainline as the other dependencies for
    those kernels are definitely not stable material.
    
    Fixes: 778e9a9c3e71 ("pi-futex: fix exit races and locking problems")
    Reported-by: Oleg Nesterov <oleg@redhat.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Stable Team <stable@vger.kernel.org>
    Link: https://lkml.kernel.org/r/20191106224557.041676471@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7f237695d3f02730d2dd60c83e92abe1487c7e89
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:45 2019 +0100

    futex: Provide distinct return value when owner is exiting
    
    commit ac31c7ff8624409ba3c4901df9237a616c187a5d upstream
    
    attach_to_pi_owner() returns -EAGAIN for various cases:
    
     - Owner task is exiting
     - Futex value has changed
    
    The caller drops the held locks (hash bucket, mmap_sem) and retries the
    operation. In case of the owner task exiting this can result in a live
    lock.
    
    As a preparatory step for seperating those cases, provide a distinct return
    value (EBUSY) for the owner exiting case.
    
    No functional change.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.935606117@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f9b0c6c556dbf3694fee05f1334830ce2ec1f5bc
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:44 2019 +0100

    futex: Add mutex around futex exit
    
    commit 3f186d974826847a07bc7964d79ec4eded475ad9 upstream
    
    The mutex will be used in subsequent changes to replace the busy looping of
    a waiter when the futex owner is currently executing the exit cleanup to
    prevent a potential live lock.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.845798895@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ab89202056ca11596ebed057a7f54fe68576d940
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:43 2019 +0100

    futex: Provide state handling for exec() as well
    
    commit af8cbda2cfcaa5515d61ec500498d46e9a8247e2 upstream
    
    exec() attempts to handle potentially held futexes gracefully by running
    the futex exit handling code like exit() does.
    
    The current implementation has no protection against concurrent incoming
    waiters. The reason is that the futex state cannot be set to
    FUTEX_STATE_DEAD after the cleanup because the task struct is still active
    and just about to execute the new binary.
    
    While its arguably buggy when a task holds a futex over exec(), for
    consistency sake the state handling can at least cover the actual futex
    exit cleanup section. This provides state consistency protection accross
    the cleanup. As the futex state of the task becomes FUTEX_STATE_OK after the
    cleanup has been finished, this cannot prevent subsequent attempts to
    attach to the task in case that the cleanup was not successfull in mopping
    up all leftovers.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.753355618@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b45696340f5321cd7bd4f4865bae86c229d2bcc1
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:42 2019 +0100

    futex: Sanitize exit state handling
    
    commit 4a8e991b91aca9e20705d434677ac013974e0e30 upstream
    
    Instead of having a smp_mb() and an empty lock/unlock of task::pi_lock move
    the state setting into to the lock section.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.645603214@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 226eed1ef71dbc0e505e15954c41a97275b87058
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:41 2019 +0100

    futex: Mark the begin of futex exit explicitly
    
    commit 18f694385c4fd77a09851fd301236746ca83f3cb upstream
    
    Instead of relying on PF_EXITING use an explicit state for the futex exit
    and set it in the futex exit function. This moves the smp barrier and the
    lock/unlock serialization into the futex code.
    
    As with the DEAD state this is restricted to the exit path as exec
    continues to use the same task struct.
    
    This allows to simplify that logic in a next step.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.539409004@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8f9a98a0e00ad101e2301ebb78d8537133e39ceb
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:40 2019 +0100

    futex: Set task::futex_state to DEAD right after handling futex exit
    
    commit f24f22435dcc11389acc87e5586239c1819d217c upstream
    
    Setting task::futex_state in do_exit() is rather arbitrarily placed for no
    reason. Move it into the futex code.
    
    Note, this is only done for the exit cleanup as the exec cleanup cannot set
    the state to FUTEX_STATE_DEAD because the task struct is still in active
    use.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.439511191@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1dd589346a127db6aa14889ef4099366dcab3a96
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:39 2019 +0100

    futex: Split futex_mm_release() for exit/exec
    
    commit 150d71584b12809144b8145b817e83b81158ae5f upstream
    
    To allow separate handling of the futex exit state in the futex exit code
    for exit and exec, split futex_mm_release() into two functions and invoke
    them from the corresponding exit/exec_mm_release() callsites.
    
    Preparatory only, no functional change.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.332094221@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9425476fb17a29b9f1c564321ae4b80129534c57
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:38 2019 +0100

    exit/exec: Seperate mm_release()
    
    commit 4610ba7ad877fafc0a25a30c6c82015304120426 upstream
    
    mm_release() contains the futex exit handling. mm_release() is called from
    do_exit()->exit_mm() and from exec()->exec_mm().
    
    In the exit_mm() case PF_EXITING and the futex state is updated. In the
    exec_mm() case these states are not touched.
    
    As the futex exit code needs further protections against exit races, this
    needs to be split into two functions.
    
    Preparatory only, no functional change.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.240518241@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 095444fad7e35dcd63d0c6b86461d024314e2051
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:37 2019 +0100

    futex: Replace PF_EXITPIDONE with a state
    
    commit 3d4775df0a89240f671861c6ab6e8d59af8e9e41 upstream
    
    The futex exit handling relies on PF_ flags. That's suboptimal as it
    requires a smp_mb() and an ugly lock/unlock of the exiting tasks pi_lock in
    the middle of do_exit() to enforce the observability of PF_EXITING in the
    futex code.
    
    Add a futex_state member to task_struct and convert the PF_EXITPIDONE logic
    over to the new state. The PF_EXITING dependency will be cleaned up in a
    later step.
    
    This prepares for handling various futex exit issues later.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.149449274@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3fe0ed7bd7329e28aca7cdaf7353c6d4778b3d41
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Nov 6 22:55:36 2019 +0100

    futex: Move futex exit handling into futex code
    
    commit ba31c1a48538992316cc71ce94fa9cd3e7b427c0 upstream
    
    The futex exit handling is #ifdeffed into mm_release() which is not pretty
    to begin with. But upcoming changes to address futex exit races need to add
    more functionality to this exit code.
    
    Split it out into a function, move it into futex code and make the various
    futex exit functions static.
    
    Preparatory only and no functional change.
    
    Folded build fix from Borislav.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20191106224556.049705556@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 08b227d9f380aff229fe7eb3e43c0d90ac14ec38
Author: Wang Hai <wanghai38@huawei.com>
Date:   Thu Jan 28 19:32:50 2021 +0800

    Revert "mm/slub: fix a memory leak in sysfs_slab_add()"
    
    commit 757fed1d0898b893d7daa84183947c70f27632f3 upstream.
    
    This reverts commit dde3c6b72a16c2db826f54b2d49bdea26c3534a2.
    
    syzbot report a double-free bug. The following case can cause this bug.
    
     - mm/slab_common.c: create_cache(): if the __kmem_cache_create() fails,
       it does:
    
            out_free_cache:
                    kmem_cache_free(kmem_cache, s);
    
     - but __kmem_cache_create() - at least for slub() - will have done
    
            sysfs_slab_add(s)
                    -> sysfs_create_group() .. fails ..
                    -> kobject_del(&s->kobj); .. which frees s ...
    
    We can't remove the kmem_cache_free() in create_cache(), because other
    error cases of __kmem_cache_create() do not free this.
    
    So, revert the commit dde3c6b72a16 ("mm/slub: fix a memory leak in
    sysfs_slab_add()") to fix this.
    
    Reported-by: syzbot+d0bd96b4696c1ef67991@syzkaller.appspotmail.com
    Fixes: dde3c6b72a16 ("mm/slub: fix a memory leak in sysfs_slab_add()")
    Acked-by: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: Wang Hai <wanghai38@huawei.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4e5ee86dcb0003ae9ed0b477e47a1d0aaf2f8c67
Author: Baruch Siach <baruch@tkos.co.il>
Date:   Sun Jan 17 15:17:02 2021 +0200

    gpio: mvebu: fix pwm .get_state period calculation
    
    commit e73b0101ae5124bf7cd3fb5d250302ad2f16a416 upstream.
    
    The period is the sum of on and off values. That is, calculate period as
    
      ($on + $off) / clkrate
    
    instead of
    
      $off / clkrate - $on / clkrate
    
    that makes no sense.
    
    Reported-by: Russell King <linux@armlinux.org.uk>
    Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Fixes: 757642f9a584e ("gpio: mvebu: Add limited PWM support")
    Signed-off-by: Baruch Siach <baruch@tkos.co.il>
    Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
    [baruch: backport to kernels <= v5.10]
    Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Baruch Siach <baruch@tkos.co.il>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>