* [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
@ 2021-05-25 11:36 Andrew Zaborowski
2021-05-25 11:53 ` Greg KH
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Zaborowski @ 2021-05-25 11:36 UTC (permalink / raw)
To: keyrings; +Cc: Jarkko Sakkinen, stable
From: Jarkko Sakkinen <jarkko@kernel.org>
BUG_ON() should not be used in the kernel code, unless there are
exceptional reasons to do so. Replace BUG_ON() with WARN() and
return.
Cc: stable@vger.kernel.org
Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
No changes from original submission by Jarkko.
crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index ad8af3d70ac..a00bed3e04d 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
char *req, *p;
int len;
- BUG_ON(!id_0 && !id_1);
+ if (!id_0 && !id_1) {
+ WARN(1, "All ID's are NULL\n");
+ return ERR_PTR(-EINVAL);
+ }
if (id_0) {
lookup = id_0->data;
--
2.27.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
2021-05-25 11:36 [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key() Andrew Zaborowski
@ 2021-05-25 11:53 ` Greg KH
2021-05-25 17:36 ` Eric Biggers
2021-06-14 8:54 ` Andrew Zaborowski
0 siblings, 2 replies; 9+ messages in thread
From: Greg KH @ 2021-05-25 11:53 UTC (permalink / raw)
To: Andrew Zaborowski; +Cc: keyrings, Jarkko Sakkinen, stable
On Tue, May 25, 2021 at 01:36:27PM +0200, Andrew Zaborowski wrote:
> From: Jarkko Sakkinen <jarkko@kernel.org>
>
> BUG_ON() should not be used in the kernel code, unless there are
> exceptional reasons to do so. Replace BUG_ON() with WARN() and
> return.
>
> Cc: stable@vger.kernel.org
> Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> ---
> No changes from original submission by Jarkko.
>
> crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
> index ad8af3d70ac..a00bed3e04d 100644
> --- a/crypto/asymmetric_keys/asymmetric_type.c
> +++ b/crypto/asymmetric_keys/asymmetric_type.c
> @@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
> char *req, *p;
> int len;
>
> - BUG_ON(!id_0 && !id_1);
> + if (!id_0 && !id_1) {
> + WARN(1, "All ID's are NULL\n");
You still just rebooted a machine (panic-on-warn is commonly set).
Please just handle this properly, print an error message with dev_err()
or pr_err() and move on, don't crash things.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
2021-05-25 11:53 ` Greg KH
@ 2021-05-25 17:36 ` Eric Biggers
2021-06-14 8:54 ` Andrew Zaborowski
1 sibling, 0 replies; 9+ messages in thread
From: Eric Biggers @ 2021-05-25 17:36 UTC (permalink / raw)
To: Greg KH; +Cc: Andrew Zaborowski, keyrings, Jarkko Sakkinen, stable
On Tue, May 25, 2021 at 01:53:49PM +0200, Greg KH wrote:
> On Tue, May 25, 2021 at 01:36:27PM +0200, Andrew Zaborowski wrote:
> > From: Jarkko Sakkinen <jarkko@kernel.org>
> >
> > BUG_ON() should not be used in the kernel code, unless there are
> > exceptional reasons to do so. Replace BUG_ON() with WARN() and
> > return.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
> > Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> > ---
> > No changes from original submission by Jarkko.
> >
> > crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
> > index ad8af3d70ac..a00bed3e04d 100644
> > --- a/crypto/asymmetric_keys/asymmetric_type.c
> > +++ b/crypto/asymmetric_keys/asymmetric_type.c
> > @@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
> > char *req, *p;
> > int len;
> >
> > - BUG_ON(!id_0 && !id_1);
> > + if (!id_0 && !id_1) {
> > + WARN(1, "All ID's are NULL\n");
>
> You still just rebooted a machine (panic-on-warn is commonly set).
>
> Please just handle this properly, print an error message with dev_err()
> or pr_err() and move on, don't crash things.
>
If this case is a kernel bug (which looks to be the case here), then WARN() is
correct. The whole point of panic_on_warn is to panic the kernel when it
encounters something that has been flagged as a kernel bug, even if it would
otherwise be recoverable.
- Eric
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
2021-05-25 11:53 ` Greg KH
2021-05-25 17:36 ` Eric Biggers
@ 2021-06-14 8:54 ` Andrew Zaborowski
2021-06-14 8:58 ` Greg KH
1 sibling, 1 reply; 9+ messages in thread
From: Andrew Zaborowski @ 2021-06-14 8:54 UTC (permalink / raw)
To: Greg KH; +Cc: keyrings, Jarkko Sakkinen, # 3.4.x
Hi Greg,
On Tue, 25 May 2021 at 13:53, Greg KH <greg@kroah.com> wrote:
> On Tue, May 25, 2021 at 01:36:27PM +0200, Andrew Zaborowski wrote:
> > From: Jarkko Sakkinen <jarkko@kernel.org>
> >
> > BUG_ON() should not be used in the kernel code, unless there are
> > exceptional reasons to do so. Replace BUG_ON() with WARN() and
> > return.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
> > Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> > ---
> > No changes from original submission by Jarkko.
> >
> > crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
> > index ad8af3d70ac..a00bed3e04d 100644
> > --- a/crypto/asymmetric_keys/asymmetric_type.c
> > +++ b/crypto/asymmetric_keys/asymmetric_type.c
> > @@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
> > char *req, *p;
> > int len;
> >
> > - BUG_ON(!id_0 && !id_1);
> > + if (!id_0 && !id_1) {
> > + WARN(1, "All ID's are NULL\n");
>
> You still just rebooted a machine (panic-on-warn is commonly set).
>
> Please just handle this properly, print an error message with dev_err()
> or pr_err() and move on, don't crash things.
Like Eric Biggers said, a panic is probably what you want here since
this would be a basic bug, if you even want to check this. You can't
be looking for a key if you don't have any of the identifiers. There
a 4 current callers, 2 that have checks right before the call and 2
where this could be triggered by a bug in an ASN.1 parser or
corruption.
What's the right way to get this change merged? There's clearly no
need to coordinate with whoever would merge 2/2 of the series.
Best regards
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
2021-06-14 8:54 ` Andrew Zaborowski
@ 2021-06-14 8:58 ` Greg KH
2021-06-14 9:21 ` Andrew Zaborowski
0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2021-06-14 8:58 UTC (permalink / raw)
To: Andrew Zaborowski; +Cc: keyrings, Jarkko Sakkinen, # 3.4.x
On Mon, Jun 14, 2021 at 10:54:00AM +0200, Andrew Zaborowski wrote:
> Hi Greg,
>
> On Tue, 25 May 2021 at 13:53, Greg KH <greg@kroah.com> wrote:
> > On Tue, May 25, 2021 at 01:36:27PM +0200, Andrew Zaborowski wrote:
> > > From: Jarkko Sakkinen <jarkko@kernel.org>
> > >
> > > BUG_ON() should not be used in the kernel code, unless there are
> > > exceptional reasons to do so. Replace BUG_ON() with WARN() and
> > > return.
> > >
> > > Cc: stable@vger.kernel.org
> > > Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
> > > Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> > > ---
> > > No changes from original submission by Jarkko.
> > >
> > > crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
> > > 1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
> > > index ad8af3d70ac..a00bed3e04d 100644
> > > --- a/crypto/asymmetric_keys/asymmetric_type.c
> > > +++ b/crypto/asymmetric_keys/asymmetric_type.c
> > > @@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
> > > char *req, *p;
> > > int len;
> > >
> > > - BUG_ON(!id_0 && !id_1);
> > > + if (!id_0 && !id_1) {
> > > + WARN(1, "All ID's are NULL\n");
> >
> > You still just rebooted a machine (panic-on-warn is commonly set).
> >
> > Please just handle this properly, print an error message with dev_err()
> > or pr_err() and move on, don't crash things.
>
> Like Eric Biggers said, a panic is probably what you want here since
> this would be a basic bug, if you even want to check this.
Ok, then keep the BUG_ON(), no change needed.
> You can't
> be looking for a key if you don't have any of the identifiers. There
> a 4 current callers, 2 that have checks right before the call and 2
> where this could be triggered by a bug in an ASN.1 parser or
> corruption.
>
> What's the right way to get this change merged? There's clearly no
> need to coordinate with whoever would merge 2/2 of the series.
Why do you need to change this if BUG_ON() is the correct thing to do
here?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
2021-06-14 8:58 ` Greg KH
@ 2021-06-14 9:21 ` Andrew Zaborowski
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Zaborowski @ 2021-06-14 9:21 UTC (permalink / raw)
To: Greg KH; +Cc: keyrings, Jarkko Sakkinen, # 3.4.x
On Mon, 14 Jun 2021 at 10:59, Greg KH <greg@kroah.com> wrote:
> On Mon, Jun 14, 2021 at 10:54:00AM +0200, Andrew Zaborowski wrote:
> > Hi Greg,
> >
> > On Tue, 25 May 2021 at 13:53, Greg KH <greg@kroah.com> wrote:
> > > On Tue, May 25, 2021 at 01:36:27PM +0200, Andrew Zaborowski wrote:
> > > > From: Jarkko Sakkinen <jarkko@kernel.org>
> > > >
> > > > BUG_ON() should not be used in the kernel code, unless there are
> > > > exceptional reasons to do so. Replace BUG_ON() with WARN() and
> > > > return.
> > > >
> > > > Cc: stable@vger.kernel.org
> > > > Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
> > > > Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> > > > ---
> > > > No changes from original submission by Jarkko.
> > > >
> > > > crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
> > > > 1 file changed, 4 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
> > > > index ad8af3d70ac..a00bed3e04d 100644
> > > > --- a/crypto/asymmetric_keys/asymmetric_type.c
> > > > +++ b/crypto/asymmetric_keys/asymmetric_type.c
> > > > @@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
> > > > char *req, *p;
> > > > int len;
> > > >
> > > > - BUG_ON(!id_0 && !id_1);
> > > > + if (!id_0 && !id_1) {
> > > > + WARN(1, "All ID's are NULL\n");
> > >
> > > You still just rebooted a machine (panic-on-warn is commonly set).
> > >
> > > Please just handle this properly, print an error message with dev_err()
> > > or pr_err() and move on, don't crash things.
> >
> > Like Eric Biggers said, a panic is probably what you want here since
> > this would be a basic bug, if you even want to check this.
>
> Ok, then keep the BUG_ON(), no change needed.
>
> > You can't
> > be looking for a key if you don't have any of the identifiers. There
> > a 4 current callers, 2 that have checks right before the call and 2
> > where this could be triggered by a bug in an ASN.1 parser or
> > corruption.
> >
> > What's the right way to get this change merged? There's clearly no
> > need to coordinate with whoever would merge 2/2 of the series.
>
> Why do you need to change this if BUG_ON() is the correct thing to do
> here?
At this function's level the situation is easily recoverable, I guess
the idea is to allow the kernel to continue in the "continue at any
cost" type scenario where you'd have panic_on_* set false.
Best regards
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
@ 2021-04-30 23:27 Andrew Zaborowski
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Zaborowski @ 2021-04-30 23:27 UTC (permalink / raw)
To: keyrings; +Cc: David Howells, Jarkko Sakkinen, stable
From: Jarkko Sakkinen <jarkko@kernel.org>
BUG_ON() should not be used in the kernel code, unless there are
exceptional reasons to do so. Replace BUG_ON() with WARN() and
return.
Cc: stable@vger.kernel.org
Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
No changes from original submission by Jarkko.
crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index ad8af3d70ac..a00bed3e04d 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
char *req, *p;
int len;
- BUG_ON(!id_0 && !id_1);
+ if (!id_0 && !id_1) {
+ WARN(1, "All ID's are NULL\n");
+ return ERR_PTR(-EINVAL);
+ }
if (id_0) {
lookup = id_0->data;
--
2.27.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
@ 2021-04-07 14:21 Andrew Zaborowski
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Zaborowski @ 2021-04-07 14:21 UTC (permalink / raw)
To: keyrings; +Cc: David Howells, Jarkko Sakkinen, stable
From: Jarkko Sakkinen <jarkko@kernel.org>
BUG_ON() should not be used in the kernel code, unless there are
exceptional reasons to do so. Replace BUG_ON() with WARN() and
return.
Cc: stable@vger.kernel.org
Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
No changes from original submission by Jarkko.
crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index ad8af3d70ac..a00bed3e04d 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
char *req, *p;
int len;
- BUG_ON(!id_0 && !id_1);
+ if (!id_0 && !id_1) {
+ WARN(1, "All ID's are NULL\n");
+ return ERR_PTR(-EINVAL);
+ }
if (id_0) {
lookup = id_0->data;
--
2.27.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()
@ 2021-03-12 15:59 Andrew Zaborowski
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Zaborowski @ 2021-03-12 15:59 UTC (permalink / raw)
To: keyrings; +Cc: David Howells, Jarkko Sakkinen, stable
From: Jarkko Sakkinen <jarkko@kernel.org>
BUG_ON() should not be used in the kernel code, unless there are
exceptional reasons to do so. Replace BUG_ON() with WARN() and
return.
Cc: stable@vger.kernel.org
Fixes: b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
No changes from original submission by Jarkko.
crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index 33e77d846ca..47cc88fa0fa 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
char *req, *p;
int len;
- BUG_ON(!id_0 && !id_1);
+ if (!id_0 && !id_1) {
+ WARN(1, "All ID's are NULL\n");
+ return ERR_PTR(-EINVAL);
+ }
if (id_0) {
lookup = id_0->data;
--
2.27.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-06-14 9:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-25 11:36 [RESEND][PATCH 1/2] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key() Andrew Zaborowski
2021-05-25 11:53 ` Greg KH
2021-05-25 17:36 ` Eric Biggers
2021-06-14 8:54 ` Andrew Zaborowski
2021-06-14 8:58 ` Greg KH
2021-06-14 9:21 ` Andrew Zaborowski
-- strict thread matches above, loose matches on Subject: below --
2021-04-30 23:27 Andrew Zaborowski
2021-04-07 14:21 Andrew Zaborowski
2021-03-12 15:59 Andrew Zaborowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox