From: Daniel Jordan <daniel.m.jordan@oracle.com>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: eadavis@sina.com, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+bc05445bc14148d51915@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] padata: fix lockdep warning in padata serialization
Date: Wed, 21 Sep 2022 14:51:38 -0400 [thread overview]
Message-ID: <20220921185138.c6chlv77ugfrsukj@oracle.com> (raw)
In-Reply-To: <20220921073616.GZ2950045@gauss3.secunet.de>
On Wed, Sep 21, 2022 at 09:36:16AM +0200, Steffen Klassert wrote:
> On Tue, Sep 20, 2022 at 10:10:57AM -0400, Daniel Jordan wrote:
> > Yeah, padata_do_serial can be called with BHs off, like in the tipc
> > stack, but there are also cases where BHs can be on, like lockdep said
> > here:
>
> padata_do_serial was designed to run with BHs off, it is a bug if it
> runs with BHs on. But I don't see a case where this can happen. The
> only user of padata_do_serial is pcrypt in its serialization callbacks
> (pcrypt_aead_enc, pcrypt_aead_dec) and the async crypto callback
> pcrypt_aead_done. pcrypt_aead_enc and pcrypt_aead_dec are issued via
> the padata_serial_worker with the padata->serial call. BHs are
> off here. The crypto callback also runs with BHs off.
>
> What do I miss here?
Ugh.. this newer, buggy part of padata_do_parallel:
/* Maximum works limit exceeded, run in the current task. */
padata->parallel(padata);
This skips the usual path in padata_parallel_worker, which disables BHs.
They should be left off in the above case too.
What about this?
---8<---
Subject: [PATCH] padata: always leave BHs disabled when running ->parallel()
A deadlock can happen when an overloaded system runs ->parallel() in the
context of the current task:
padata_do_parallel
->parallel()
pcrypt_aead_enc/dec
padata_do_serial
spin_lock(&reorder->lock) // BHs still enabled
<interrupt>
...
__do_softirq
...
padata_do_serial
spin_lock(&reorder->lock)
It's a bug for BHs to be on in _do_serial as Steffen points out, so
ensure they're off in the "current task" case like they are in
padata_parallel_worker to avoid this situation.
Reported-by: syzbot+bc05445bc14148d51915@syzkaller.appspotmail.com
Fixes: 4611ce224688 ("padata: allocate work structures for parallel jobs from a pool")
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
---
kernel/padata.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/kernel/padata.c b/kernel/padata.c
index e5819bb8bd1d..97f51e0c1776 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -207,14 +207,16 @@ int padata_do_parallel(struct padata_shell *ps,
pw = padata_work_alloc();
spin_unlock(&padata_works_lock);
+ if (!pw) {
+ /* Maximum works limit exceeded, run in the current task. */
+ padata->parallel(padata);
+ }
+
rcu_read_unlock_bh();
if (pw) {
padata_work_init(pw, padata_parallel_worker, padata, 0);
queue_work(pinst->parallel_wq, &pw->pw_work);
- } else {
- /* Maximum works limit exceeded, run in the current task. */
- padata->parallel(padata);
}
return 0;
--
2.37.2
next prev parent reply other threads:[~2022-09-21 18:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-18 19:43 [syzbot] inconsistent lock state in padata_do_serial (2) syzbot
[not found] ` <20220919010555.130609-1-eadavis@sina.com>
2022-09-19 15:12 ` [PATCH] padata: fix lockdep warning in padata serialization Daniel Jordan
2022-09-19 15:27 ` Daniel Jordan
[not found] ` <20220920012508.403159-1-eadavis@sina.com>
2022-09-20 1:48 ` [PATCH v2] padata: fix lockdep warning Daniel Jordan
[not found] ` <20220920003908.391835-1-eadavis@sina.com>
2022-09-20 1:47 ` [PATCH] padata: fix lockdep warning in padata serialization Daniel Jordan
2022-09-20 5:54 ` Steffen Klassert
2022-09-20 14:10 ` Daniel Jordan
2022-09-21 7:36 ` Steffen Klassert
2022-09-21 18:51 ` Daniel Jordan [this message]
2022-09-22 10:55 ` Steffen Klassert
2022-09-23 2:07 ` Daniel Jordan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220921185138.c6chlv77ugfrsukj@oracle.com \
--to=daniel.m.jordan@oracle.com \
--cc=eadavis@sina.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=syzbot+bc05445bc14148d51915@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).