Merge tag 'locking-urgent-2020-11-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking fixes from Thomas Gleixner:
"Two fixes for the locking subsystem:

- Prevent an unconditional interrupt enable in a futex helper
function which can be called from contexts which expect interrupts
to stay disabled across the call

- Don't modify lockdep chain keys in the validation process as that
causes chain inconsistency"

* tag 'locking-urgent-2020-11-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
lockdep: Avoid to modify chain keys in validate_chain()
futex: Don't enable IRQs unconditionally in put_pi_state()

+12 -12
+3 -2
kernel/futex.c
··· 788 788 */ 789 789 if (pi_state->owner) { 790 790 struct task_struct *owner; 791 + unsigned long flags; 791 792 792 - raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock); 793 + raw_spin_lock_irqsave(&pi_state->pi_mutex.wait_lock, flags); 793 794 owner = pi_state->owner; 794 795 if (owner) { 795 796 raw_spin_lock(&owner->pi_lock); ··· 798 797 raw_spin_unlock(&owner->pi_lock); 799 798 } 800 799 rt_mutex_proxy_unlock(&pi_state->pi_mutex, owner); 801 - raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); 800 + raw_spin_unlock_irqrestore(&pi_state->pi_mutex.wait_lock, flags); 802 801 } 803 802 804 803 if (current->pi_state_cache) {
+9 -10
kernel/locking/lockdep.c
··· 2765 2765 * (Note that this has to be done separately, because the graph cannot 2766 2766 * detect such classes of deadlocks.) 2767 2767 * 2768 - * Returns: 0 on deadlock detected, 1 on OK, 2 on recursive read 2768 + * Returns: 0 on deadlock detected, 1 on OK, 2 if another lock with the same 2769 + * lock class is held but nest_lock is also held, i.e. we rely on the 2770 + * nest_lock to avoid the deadlock. 2769 2771 */ 2770 2772 static int 2771 2773 check_deadlock(struct task_struct *curr, struct held_lock *next) ··· 2790 2788 * lock class (i.e. read_lock(lock)+read_lock(lock)): 2791 2789 */ 2792 2790 if ((next->read == 2) && prev->read) 2793 - return 2; 2791 + continue; 2794 2792 2795 2793 /* 2796 2794 * We're holding the nest_lock, which serializes this lock's ··· 3595 3593 if (!ret) 3596 3594 return 0; 3597 3595 /* 3598 - * Mark recursive read, as we jump over it when 3599 - * building dependencies (just like we jump over 3600 - * trylock entries): 3601 - */ 3602 - if (ret == 2) 3603 - hlock->read = 2; 3604 - /* 3605 3596 * Add dependency only if this lock is not the head 3606 - * of the chain, and if it's not a secondary read-lock: 3597 + * of the chain, and if the new lock introduces no more 3598 + * lock dependency (because we already hold a lock with the 3599 + * same lock class) nor deadlock (because the nest_lock 3600 + * serializes nesting locks), see the comments for 3601 + * check_deadlock(). 3607 3602 */ 3608 3603 if (!chain_head && ret != 2) { 3609 3604 if (!check_prevs_add(curr, hlock))