From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-crypto@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Herbert Xu <herbert@gondor.apana.org.au>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] crypto: x86/aes-gcm: Disable FPU around skcipher_walk_done().
Date: Tue, 6 Aug 2024 09:46:14 +0200 [thread overview]
Message-ID: <20240806074614.2c9Y52Lt@linutronix.de> (raw)
In-Reply-To: <20240805173826.GA1564@sol.localdomain>
On 2024-08-05 10:38:26 [-0700], Eric Biggers wrote:
> No, it was intentional. See the comment above the first kernel_fpu_begin() in
> gcm_crypt():
>
> /*
> * Since the AES-GCM assembly code requires that at least three assembly
> * functions be called to process any message (this is needed to support
> * incremental updates cleanly), to reduce overhead we try to do all
> * three calls in the same kernel FPU section if possible. We close the
> * section and start a new one if there are multiple data segments or if
> * rescheduling is needed while processing the associated data.
> */
> kernel_fpu_begin();
Okay.
> > > Note that kfree() lacks a might_sleep(), and its kerneldoc does not say that it
> > > can sleep. Have you checked for other instances of this same problem? It seems
> > > it would be quite common kernel-wide.
> >
> > kfree() can't have a might_sleep() because it does not qualify for this
> > since you can use it in softirq context for instance with an acquired
> > spinlockt_t on !RT which would trigger it.
> > On PREEMPT_RT interrupts are threaded, softirq is preemptible,
> > spintlock_t is a sleeping lock so all these things where a kfree()
> > would have been invoked in preempt-disable context on !PREEMPT_RT is
> > actually preemptible on PREEMPT_RT.
> > This is of course not true in cases where preemption is explicitly
> > disabled like in this case.
>
> WARN_ON(!preemptible()) then?
>
> If I add that to kfree(), it triggers from lots of other places. Are those
> problems on PREEMPT_RT too?
Nope, shouldn't. On PREEMPT_RT you can only invoke kfree() or kmalloc()
from preemptible context. This is not a problem since interrupts are
threaded, softirqs are preemptbile,…
> What I am trying to get at is what debugging options do I need to detect issues
> like this. Is there really no option other than actually running a PREEMPT_RT
> kernel?
There is PROVE_RAW_LOCK_NESTING but this only catches something like
raw_spinlock_t -> spinlock_t or using a spinlock_t in an interrupt
handler that won't be threaded. It won't find anything where you disable
interrupts or preemption on purpose.
> I had tested this code with lots of debug options pre-merge and nothing came up.
>
> If there was something in CONFIG_SLUB_DEBUG, for example, I would have seen
> that, and you would never have had to deal with this issue at all as it would
> never have been introduced.
Don't worry. I didn't think for a second that there was lack of testing
on your side.
> - Eric
Sebastian
next prev parent reply other threads:[~2024-08-06 7:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 10:23 [PATCH] crypto: x86/aes-gcm: Disable FPU around skcipher_walk_done() Sebastian Andrzej Siewior
2024-08-02 16:28 ` Eric Biggers
2024-08-02 16:49 ` Eric Biggers
2024-08-05 9:02 ` Herbert Xu
2024-08-05 9:56 ` Sebastian Andrzej Siewior
2024-08-03 0:34 ` Herbert Xu
2024-08-05 8:21 ` Sebastian Andrzej Siewior
2024-08-05 8:41 ` Sebastian Andrzej Siewior
2024-08-05 17:38 ` Eric Biggers
2024-08-06 7:46 ` Sebastian Andrzej Siewior [this message]
2024-08-03 0:37 ` Herbert Xu
2024-08-05 9:34 ` Sebastian Andrzej Siewior
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=20240806074614.2c9Y52Lt@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=tglx@linutronix.de \
/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