From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Herbert Xu" <herbert@gondor.apana.org.au>,
"Greg KH" <gregkh@linuxfoundation.org>
Cc: "Linux Crypto Mailing List" <linux-crypto@vger.kernel.org>,
"Guangwu Zhang" <guazhang@redhat.com>,
"Peter Huewe" <peterhuewe@gmx.de>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
<linux-integrity@vger.kernel.org>,
"James Bottomley" <James.Bottomley@HansenPartnership.com>
Subject: Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values
Date: Mon, 23 Sep 2024 17:31:47 +0300 [thread overview]
Message-ID: <D4DQJ34I5FSD.1K618VWEKI7IW@kernel.org> (raw)
In-Reply-To: <ZvE0NrOC00ojRe3t@gondor.apana.org.au>
On Mon Sep 23, 2024 at 12:26 PM EEST, Herbert Xu wrote:
> > +
> > > + err = rng->read(rng, buffer, size, wait);
> > > + if (WARN_ON_ONCE(err > 0 && err > size))
> >
> > Are you sure you want to use WARN_ON_ONCE here instead of
> > pr_warn_once()? I.e. is it worth of taking down the whole
> > kernel?
>
> Absolutely. If this triggers it's a serious kernel bug and we
> should gather as much information as possible. pr_warn_once is
> not the same thing as WARN_ON_ONCE in terms of what it prints.
Personally I allow the use of WARN only as the last resort.
If you need stack printout you can always use dump_stack().
>
> If people want to turn WARNs into BUGs, then they've only got
> themselves to blame when the kernel goes down. On the other
> hand perhaps they *do* want this to panic and we should hand
> it to them.
Actually when you turn on "panic_on_warn" the user expectation is and
should be that the sites where WARN is used have been hand picked with
consideration so that panic happens for a reason.
This has also been denoted repeatedly by Greg:
https://lore.kernel.org/linux-cve-announce/2024061828-CVE-2024-36975-6719@gregkh/
I should check this somewhere but actually these days a wrongly chosen
WARN() might lead to CVE entry. That fix was by me but I never created
the CVE.
Greg, did we have something under Documentation/ that would fully
address the use of WARN?
BR, Jarkko
next prev parent reply other threads:[~2024-09-23 14:31 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-23 6:05 [PATCH] hwrng: core - Add WARN_ON for buggy read return values Herbert Xu
2024-09-23 7:52 ` Jarkko Sakkinen
2024-09-23 8:07 ` Jarkko Sakkinen
2024-09-23 8:09 ` Jarkko Sakkinen
2024-09-23 9:26 ` Herbert Xu
2024-09-23 14:31 ` Jarkko Sakkinen [this message]
2024-09-23 14:36 ` Jarkko Sakkinen
2024-09-23 14:48 ` Greg KH
2024-09-23 20:46 ` Jarkko Sakkinen
2024-09-23 22:32 ` Herbert Xu
2024-09-24 16:05 ` Jarkko Sakkinen
2024-09-24 17:43 ` Jarkko Sakkinen
2024-09-27 0:42 ` Herbert Xu
2024-10-07 23:28 ` Jarkko Sakkinen
2025-04-07 5:19 ` Herbert Xu
2025-04-07 6:26 ` [PATCH] tpm: Mask TPM RC in tpm2_start_auth_session() Jarkko Sakkinen
2025-04-07 7:17 ` [PATCH v2] " Jarkko Sakkinen
2025-04-07 7:20 ` [PATCH v3] " Jarkko Sakkinen
2025-04-07 8:04 ` Stefano Garzarella
2025-04-07 11:30 ` Jarkko Sakkinen
2025-04-07 13:20 ` Stefano Garzarella
2025-04-07 12:28 ` [PATCH v4] " Jarkko Sakkinen
2025-04-07 12:32 ` Jarkko Sakkinen
2025-04-07 13:51 ` Stefano Garzarella
2025-04-07 18:13 ` Jarkko Sakkinen
2025-04-08 16:03 ` Jarkko Sakkinen
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=D4DQJ34I5FSD.1K618VWEKI7IW@kernel.org \
--to=jarkko@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=gregkh@linuxfoundation.org \
--cc=guazhang@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=jgg@ziepe.ca \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=peterhuewe@gmx.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;
as well as URLs for NNTP newsgroup(s).