summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2023-09-20 13:46:27 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-10 22:53:28 +0300
commit78106529b3908ca9a1e307044a80b0a72465a816 (patch)
tree3c21138f555b3170352f1ecc53783d1ce1ab7c20 /include/linux
parenta8dd21118b0fa33efd09b713cef79d02e72719e2 (diff)
downloadlinux-78106529b3908ca9a1e307044a80b0a72465a816.tar.xz
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@I-love.SAKURA.ne.jp> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20230920104627._DTHgPyA@linutronix.de Closes: https://lore.kernel.org/20230621130641.-5iueY1I@linutronix.de Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/seqlock.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 008fa88ad58e..0928a60b8f82 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -511,8 +511,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);
}
/**