Patch "locking/seqlock: Do the lockdep annotation before locking in do_write_seqcount_begin_nested()" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    locking/seqlock: Do the lockdep annotation before locking in do_write_seqcount_begin_nested()

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     locking-seqlock-do-the-lockdep-annotation-before-loc.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 903286a67bee0861e2722bd1ab8bea07ca022b2f
Author: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Date:   Wed Sep 20 12:46:27 2023 +0200

    locking/seqlock: Do the lockdep annotation before locking in do_write_seqcount_begin_nested()
    
    [ Upstream commit 41b43b6c6e30a832c790b010a06772e793bca193 ]
    
    It was brought up by Tetsuo that the following sequence:
    
       write_seqlock_irqsave()
       printk_deferred_enter()
    
    could lead to a deadlock if the lockdep annotation within
    write_seqlock_irqsave() triggers.
    
    The problem is that the sequence counter is incremented before the lockdep
    annotation is performed. The lockdep splat would then attempt to invoke
    printk() but the reader side, of the same seqcount, could have a
    tty_port::lock acquired waiting for the sequence number to become even again.
    
    The other lockdep annotations come before the actual locking because "we
    want to see the locking error before it happens". There is no reason why
    seqcount should be different here.
    
    Do the lockdep annotation first then perform the locking operation (the
    sequence increment).
    
    Fixes: 1ca7d67cf5d5a ("seqcount: Add lockdep functionality to seqcount/seqlock structures")
    Reported-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230920104627._DTHgPyA@xxxxxxxxxxxxx
    
    Closes: https://lore.kernel.org/20230621130641.-5iueY1I@xxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 3926e90279477..d778af83c8f36 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -512,8 +512,8 @@ do {									\
 
 static inline void do_write_seqcount_begin_nested(seqcount_t *s, int subclass)
 {
-	do_raw_write_seqcount_begin(s);
 	seqcount_acquire(&s->dep_map, subclass, 0, _RET_IP_);
+	do_raw_write_seqcount_begin(s);
 }
 
 /**



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux