From: "Mickaël Salaün" <mic@digikod.net>
To: David Howells <dhowells@redhat.com>,
David Woodhouse <dwmw2@infradead.org>,
Jarkko Sakkinen <jarkko@kernel.org>
Cc: "Mickaël Salaün" <mic@digikod.net>,
"David S . Miller" <davem@davemloft.net>,
"Eric Snowberg" <eric.snowberg@oracle.com>,
"Mickaël Salaün" <mic@linux.microsoft.com>,
"Paul Moore" <paul@paul-moore.com>,
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 [thread overview]
Message-ID: <20220311174741.250424-2-mic@digikod.net> (raw)
In-Reply-To: <20220311174741.250424-1-mic@digikod.net>
From: Mickaël Salaün <mic@linux.microsoft.com>
Replace panic() calls from device_initcall(blacklist_init) with proper
error handling using -ENODEV.
Suggested-by: Jarkko Sakkinen <jarkko@kernel.org> [1]
Link: https://lore.kernel.org/r/Yik0C2t7G272YZ73@iki.fi [1]
Signed-off-by: Mickaël Salaün <mic@linux.microsoft.com>
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
next prev parent reply other threads:[~2022-03-11 17:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 17:47 [PATCH v1 0/2] Remove panic() from keyring init calls Mickaël Salaün
2022-03-11 17:47 ` Mickaël Salaün [this message]
2022-03-11 22:00 ` [PATCH v1 1/2] certs: Remove panic() calls from blacklist_init() Paul Moore
2022-03-20 21:04 ` Jarkko Sakkinen
2022-03-11 17:47 ` [PATCH v1 2/2] certs: Remove panic() calls from system_trusted_keyring_init() Mickaël Salaün
2022-03-17 7:36 ` Jarkko Sakkinen
2022-03-17 8:30 ` Mickaël Salaün
2022-03-17 8:31 ` Mickaël Salaün
2022-03-20 21:07 ` Jarkko Sakkinen
2022-03-20 21:06 ` Jarkko Sakkinen
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=20220311174741.250424-2-mic@digikod.net \
--to=mic@digikod.net \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=eric.snowberg@oracle.com \
--cc=jarkko@kernel.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mic@linux.microsoft.com \
--cc=paul@paul-moore.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