From patchwork Fri Jan 15 07:21:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 364659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A275C433DB for ; Fri, 15 Jan 2021 07:22:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CDBA221FE for ; Fri, 15 Jan 2021 07:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731027AbhAOHWf (ORCPT ); Fri, 15 Jan 2021 02:22:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:49230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730752AbhAOHWf (ORCPT ); Fri, 15 Jan 2021 02:22:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 49733235F7; Fri, 15 Jan 2021 07:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610695272; bh=t6bsm3dj66JCfiLBroS4enLdk9jAAlpGroganagjz7s=; h=From:To:Cc:Subject:Date:From; b=Q5SFEGXz77cRcyn6xhNzxLqPBYPfvV5WsJT9/8Bzr2syrUNTY3OhMwTY6ggLF0Qq3 iD9SMyLAKEHjq6xw7G84TqhaAvVxC+EYI9L5nSKvCU8mMJymOJjgR2L5Bflio/qc1o ZfAtvsg2PrOLtpfwvLlUkkQy2oegmRfIj174mTejSWSpB2vnQjFKQryajRy7k7/iAY Z2/as+lqrAwh3V3YPYoN/bdn3nTUHV2bgJZvEjGs4x+WnfnWWkFqjONK3clWSbSBEK d+m5M4IdpkTtPqxc60CmfHLEsijqhWwCFWhBw/ivGvk9IE+zwpqqsHJ2U5CGDTjy9n sciXfrnyF6BVg== From: jarkko@kernel.org To: dhowells@redhat.com Cc: andrew.zaborowski@intel.com, joeyli.kernel@gmail.com, Jarkko Sakkinen , stable@vger.kernel.org, Herbert Xu , "David S. Miller" Subject: [PATCH] keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key() Date: Fri, 15 Jan 2021 09:21:08 +0200 Message-Id: <20210115072108.96163-1-jarkko@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jarkko Sakkinen 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 --- 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 33e77d846caa..47cc88fa0fa7 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;