mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: dhowells@redhat.com, Fengguang Wu <fengguang.wu@intel.com>,
	Kees Cook <keescook@chromium.org>,
	Josh Boyer <jwboyer@redhat.com>,
	Johannes Berg <johannes.berg@intel.com>,
	Xiaolong Ye <xiaolong.ye@intel.com>,
	LKML <linux-kernel@vger.kernel.org>, LKP <lkp@01.org>
Subject: Re: d7be102f29 ("cfg80211: initialize regulatory keys/database later"): kernel BUG at crypto/asymmetric_keys/public_key.c:80!
Date: Mon, 27 Nov 2017 23:25:50 +0000	[thread overview]
Message-ID: <23794.1511825150@warthog.procyon.org.uk> (raw)
In-Reply-To: <CA+55aFzviYrQa8Tn-R96nAL8YRv9t-wQfqOWNW05g6_WCWfgAA@mail.gmail.com>

Linus Torvalds <torvalds@linux-foundation.org> wrote:

> I'm not seeing why it would ever be ok to do BUG_ON() instead of just
> returning an error, though.

This function has a list of requisite parameters for the caller:

	BUG_ON(!pkey);		<-- You need the public key to use,
	BUG_ON(!sig);
	BUG_ON(!sig->digest);	<-- the message digest to check
	BUG_ON(!sig->s);	<-- and you need the signature.

If you fail to obtain any one of these parameters, you can't use this function
and you should have errored out before calling this function.  It seems
reasonable for the function to assume that you've provided them - they're kind
of essential to the operation.  If you want, I can just remove the checks
entirely.  Many of the kernel's functions don't perform argument checking, but
just assume you've done it right and will oops if you haven't.

I could just return -EINVAL, yes, but I'm not sure that's really the right
thing to do, at least not without printing an error message, since it's a
kernel programming error not a userspace error or data error.

David

  parent reply	other threads:[~2017-11-27 23:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-26  3:07 Fengguang Wu
2017-11-27 21:46 ` Linus Torvalds
2017-11-27 21:52   ` Johannes Berg
2017-11-27 23:25 ` David Howells [this message]
2017-11-27 23:30   ` Kees Cook
2017-11-27 23:31   ` Linus Torvalds

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=23794.1511825150@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=fengguang.wu@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=jwboyer@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=torvalds@linux-foundation.org \
    --cc=xiaolong.ye@intel.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

all inboxes | Powered by JetHome®