From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752759AbdK0XZ5 (ORCPT ); Mon, 27 Nov 2017 18:25:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51122 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751318AbdK0XZ4 (ORCPT ); Mon, 27 Nov 2017 18:25:56 -0500 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <20171126030718.x4yu4s7ozzegu5cy@wfg-t540p.sh.intel.com> To: Linus Torvalds Cc: dhowells@redhat.com, Fengguang Wu , Kees Cook , Josh Boyer , Johannes Berg , Xiaolong Ye , LKML , LKP Subject: Re: d7be102f29 ("cfg80211: initialize regulatory keys/database later"): kernel BUG at crypto/asymmetric_keys/public_key.c:80! MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23793.1511825150.1@warthog.procyon.org.uk> Date: Mon, 27 Nov 2017 23:25:50 +0000 Message-ID: <23794.1511825150@warthog.procyon.org.uk> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 27 Nov 2017 23:25:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds 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