Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp695261pxp; Fri, 11 Mar 2022 12:37:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1q6BHZl538thIv2Xlmcpym6cZPNKUfZPbhwONaKXvSeBqKl1P6XKNsXmKzRLuoHialTAu X-Received: by 2002:a17:902:c40e:b0:151:a264:288c with SMTP id k14-20020a170902c40e00b00151a264288cmr12359482plk.42.1647031020542; Fri, 11 Mar 2022 12:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647031020; cv=none; d=google.com; s=arc-20160816; b=ZkGzXkkNAtHcSsK0vnFMz/J0JjD9u6P15+2OtNwZayemE9WmZKAIbYUDQgMHVhVgVr HnetihGw26ExJC8UX8JPYUUjO8Zubey/PywT+DzBxR+1bD9EUPAxdvBYoxvocj2ZS1Xs XIHJc7piRf/9rtV+hyz3YeVDDG4ebyGRsxePUBm+3ChLSNJmDqrj0sP3rBxu9oZkSAU1 gnbam/bpvoh4aigj2YqcWeRW4UISuwuMwlYypIHn7NvDu01QkIPMJyQ16sCuIAOZB9K6 FRIiaO1IaXANXQ50revmkEC0KJSD//GEFhtG4npPQzB+Or2dzBjg3GF7FbrmCF5K7OBj ImkA== 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=yb5lnmITu+fxFGMke6PdANT4xkuRpAMiGAq/IbrW8U0=; b=vrhuiTcWrnqpbnEU5UBVet1u7qfyhG/YY2HvvWxiusyYBnyMtNh+BIKxPV1XwvNHdR r/0FmX0HEXvMKNYWYUr6SG+0pNH1B02K6r2EoWTscXqp+Dw+gAM+mBPBxnJEbqqmo/qi AZ0AWSZTXhyIsl3PHM+I9MWZmzCHOhaZ53aYuf/5VsnLTGjjD4aKw8KJ18K2yILQnKxo Jw/tu9C1YjB/6lsKj6GSPij2ecx61gJjOS3M+vqHZoucIOeQglP9V7dEccTDe0w+5QpB YmQNEXcBnp2+eWJItrc9iLXY0/iT/FLAEXOFkxAhy8DOVWitzahK+PHfbxQun3lIqQEc drMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h9-20020a654809000000b0037581c96e66si8889826pgs.743.2022.03.11.12.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 12:37:00 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B508D1CFA2B; Fri, 11 Mar 2022 12:36:55 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350106AbiCKRsx (ORCPT + 99 others); Fri, 11 Mar 2022 12:48:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242962AbiCKRss (ORCPT ); Fri, 11 Mar 2022 12:48:48 -0500 Received: from smtp-bc0b.mail.infomaniak.ch (smtp-bc0b.mail.infomaniak.ch [IPv6:2001:1600:3:17::bc0b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 914B2483B4 for ; Fri, 11 Mar 2022 09:47:37 -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 4KFYKz6xSbzMqC3M; 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 4KFYKz5L1xzlj4bl; 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 2/2] certs: Remove panic() calls from system_trusted_keyring_init() Date: Fri, 11 Mar 2022 18:47:41 +0100 Message-Id: <20220311174741.250424-3-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-kernel@vger.kernel.org From: Mickaël Salaün Replace panic() calls from device_initcall(system_trusted_keyring_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-3-mic@digikod.net --- certs/system_keyring.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/certs/system_keyring.c b/certs/system_keyring.c index 05b66ce9d1c9..428046a7aa7f 100644 --- a/certs/system_keyring.c +++ b/certs/system_keyring.c @@ -148,8 +148,10 @@ static __init int system_trusted_keyring_init(void) KEY_USR_VIEW | KEY_USR_READ | KEY_USR_SEARCH), KEY_ALLOC_NOT_IN_QUOTA, NULL, NULL); - if (IS_ERR(builtin_trusted_keys)) - panic("Can't allocate builtin trusted keyring\n"); + if (IS_ERR(builtin_trusted_keys)) { + pr_err("Can't allocate builtin trusted keyring\n"); + return -ENODEV; + } #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING secondary_trusted_keys = @@ -161,14 +163,26 @@ static __init int system_trusted_keyring_init(void) KEY_ALLOC_NOT_IN_QUOTA, get_builtin_and_secondary_restriction(), NULL); - if (IS_ERR(secondary_trusted_keys)) - panic("Can't allocate secondary trusted keyring\n"); + if (IS_ERR(secondary_trusted_keys)) { + pr_err("Can't allocate secondary trusted keyring\n"); + goto err_secondary; + } - if (key_link(secondary_trusted_keys, builtin_trusted_keys) < 0) - panic("Can't link trusted keyrings\n"); + if (key_link(secondary_trusted_keys, builtin_trusted_keys) < 0) { + pr_err("Can't link trusted keyrings\n"); + goto err_link; + } #endif return 0; + +err_link: + key_put(secondary_trusted_keys); + +err_secondary: + key_put(builtin_trusted_keys); + + return -ENODEV; } /* -- 2.35.1