Received: by 2002:ac2:48a3:0:0:0:0:0 with SMTP id u3csp552703lfg; Fri, 11 Mar 2022 13:03:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgQLtLnFefxR2dgiKmAloVEnHeSBERpJ8DkUuyKyzeBrUK27RPTK2UlPoWA9e5PsM8lEE0 X-Received: by 2002:a05:6a02:182:b0:374:5a57:cbf9 with SMTP id bj2-20020a056a02018200b003745a57cbf9mr9820308pgb.616.1647032591442; Fri, 11 Mar 2022 13:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647032591; cv=none; d=google.com; s=arc-20160816; b=b/0OL3zCTzRPvAZy/MNM3tfywdgtUYynwSdgB49Y/pl+jwkvQZ0zCua8QuJRCv0kWb j8/CJ11NAWi7ds7PvnBqddNWi7hOoPDbzc+MnGmzDFnKJR4HrJ0bIKCP9p3gBNrt3jGW wriAQDVU4iMdNsVzFWcWVuNXEQnxfDXP3oH1JAm4pXKRo+kS49+7rPwcNvuL4TIZaGKl 20L7k7tp1JsYqQrMS/IzZ59d8lHLXRFwmCGuSPcbFdPoPkY9SFrO3dxyxfShrqMtEdkH /aa3eXtSeFE5zrWahWVcY2B2rY9K2mdeZdYg2pGSSfdKIt6KUvIu0U4e3fhDuTMOxcfS uw4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nwLRuFzLU7L63HS/97D2kUVq45uc9tBiV4ITUZOQ7rU=; b=XdMzO/Jhhbx4OReuMjRce3cGgZXiv/V3/MvsqcTtX/3GkkgjnEiGqIFj/4A4TNA0PZ AeFnlSHlJVGJ9jLgtA5A2h5LNapBtgNxXPiaEF6e1hTe5gYXZCVxKFWUBDTJ4oPqDGTT qqQbYJSNQH7lIGEqMbMPoM2nvaHSljHx+CZFwrkUCDvZ0d4pVa+DflFCAB/tiPILkCE7 S5rhTgRuWL2jD3ku/3qgmX29JIxTlNI3FFKNSDx38jBj9SAmGkAwO6ZBE/8gFxMX6H2+ ZgnX5ByzzzXDtzh8tkliCRtO3Up/8JX0vjr0PFyZjbbACiuI2ZOBQLh++TnHDZQWkjRO NTrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u3-20020a63ef03000000b00372e41009a8si8376366pgh.220.2022.03.11.13.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:03:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3626611798E; Fri, 11 Mar 2022 12:48:57 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238619AbiCKRsr (ORCPT + 99 others); Fri, 11 Mar 2022 12:48:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236761AbiCKRsr (ORCPT ); Fri, 11 Mar 2022 12:48:47 -0500 Received: from smtp-190f.mail.infomaniak.ch (smtp-190f.mail.infomaniak.ch [IPv6:2001:1600:3:17::190f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B88C43381 for ; Fri, 11 Mar 2022 09:47:36 -0800 (PST) Received: from smtp-3-0000.mail.infomaniak.ch (unknown [10.4.36.107]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4KFYKz2khTzMqKrZ; Fri, 11 Mar 2022 18:47:35 +0100 (CET) Received: from localhost (unknown [23.97.221.149]) by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4KFYKz1CGvzlhRVr; Fri, 11 Mar 2022 18:47:35 +0100 (CET) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: David Howells , David Woodhouse , Jarkko Sakkinen Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , "David S . Miller" , Eric Snowberg , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Paul Moore , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] certs: Remove panic() calls from blacklist_init() Date: Fri, 11 Mar 2022 18:47:40 +0100 Message-Id: <20220311174741.250424-2-mic@digikod.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311174741.250424-1-mic@digikod.net> References: <20220311174741.250424-1-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Mickaël Salaün Replace panic() calls from device_initcall(blacklist_init) with proper error handling using -ENODEV. Suggested-by: Jarkko Sakkinen [1] Link: https://lore.kernel.org/r/Yik0C2t7G272YZ73@iki.fi [1] Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20220311174741.250424-2-mic@digikod.net --- certs/blacklist.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/certs/blacklist.c b/certs/blacklist.c index 486ce0dd8e9c..ea7a77f156da 100644 --- a/certs/blacklist.c +++ b/certs/blacklist.c @@ -313,12 +313,16 @@ static int __init blacklist_init(void) const char *const *bl; struct key_restriction *restriction; - if (register_key_type(&key_type_blacklist) < 0) - panic("Can't allocate system blacklist key type\n"); + if (register_key_type(&key_type_blacklist) < 0) { + pr_err("Can't allocate system blacklist key type\n"); + return -ENODEV; + } restriction = kzalloc(sizeof(*restriction), GFP_KERNEL); - if (!restriction) - panic("Can't allocate blacklist keyring restriction\n"); + if (!restriction) { + pr_err("Can't allocate blacklist keyring restriction\n"); + goto err_restriction; + } restriction->check = restrict_link_for_blacklist; blacklist_keyring = @@ -333,13 +337,24 @@ static int __init blacklist_init(void) , KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_SET_KEEP, restriction, NULL); - if (IS_ERR(blacklist_keyring)) - panic("Can't allocate system blacklist keyring\n"); + if (IS_ERR(blacklist_keyring)) { + pr_err("Can't allocate system blacklist keyring\n"); + goto err_keyring; + } for (bl = blacklist_hashes; *bl; bl++) if (mark_raw_hash_blacklisted(*bl) < 0) pr_err("- blacklisting failed\n"); return 0; + + +err_keyring: + kfree(restriction); + +err_restriction: + unregister_key_type(&key_type_blacklist); + + return -ENODEV; } /* -- 2.35.1