Skip to contentSkip to conversation

Explain panic() calls for keyring initialization

PATCH In review Mickaël Salaün 4 participants 5 messages Mar 22, 2022 – Mar 30, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Explain panic() calls for keyring initialization

As suggested by Jarkko and explained by Paul, let's document the panic() calls from the blacklist keyring initialization. This series applies on top of commit 50c486fe3108 ("certs: Allow root user to append signed hashes to the blacklist keyring"). This can smoothly be rebased on top of Jarkko's next branch.

This second version fixes some minor spelling issues.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/commit/?id=50c486fe310890c134b5cb36cf9a4135475a6074

Previous version:
https://lore.kernel.org/r/[email protected]

Regards,

Mickaël Salaün (1):
certs: Explain the rationale to call panic()

 certs/blacklist.c | 9 +++++++++
 1 file changed, 9 insertions(+)

base-commit: 50c486fe310890c134b5cb36cf9a4135475a6074

Signature · 1 line
2.35.1
#1 lore raw

PATCH v2 1/1 certs: Explain the rationale to call panic()

From: Mickaël Salaün <[email protected]>

The blacklist_init() function calls panic() for memory allocation errors. This change documents the reason why we don't return -ENODEV.

---

Changes since v1:
* Fix commit subject spelling spotted by David Woodhouse.
* Reword one sentence as suggested by Paul Moore.
* Add Reviewed-by Paul Moore.
* Add Reviewed-by Jarkko Sakkinen.

---
 certs/blacklist.c | 9 +++++++++
 1 file changed, 9 insertions(+)
certs/blacklist.c +9 -0
index 486ce0dd8e9c..25094ea73600 100644
@@ -307,6 +307,15 @@ static int restrict_link_for_blacklist(struct key *dest_keyring,
 
 /*
  * Initialise the blacklist
+ *
+ * The blacklist_init() function is registered as an initcall via
+ * device_initcall().  As a result if the blacklist_init() function fails for
+ * any reason the kernel continues to execute.  While cleanly returning -ENODEV
+ * could be acceptable for some non-critical kernel parts, if the blacklist
+ * keyring fails to load it defeats the certificate/key based deny list for
+ * signed modules.  If a critical piece of security functionality that users
+ * expect to be present fails to initialize, panic()ing is likely the right
+ * thing to do.
  */
 static int __init blacklist_init(void)
 {
Signature · 1 line
2.35.1
Reviewed-by on v2 1/1
#2 lore raw

Re: [PATCH v2 1/1] certs: Explain the rationale to call panic()

Quoted 5 lines · Mickaël Salaün

From: Mickaël Salaün <[email protected]>

The blacklist_init() function calls panic() for memory allocation errors. This change documents the reason why we don't return -ENODEV.

Quoted 7 lines

Tyler

Quoted 34 lines

---

Changes since v1:
* Fix commit subject spelling spotted by David Woodhouse.
* Reword one sentence as suggested by Paul Moore.
* Add Reviewed-by Paul Moore.
* Add Reviewed-by Jarkko Sakkinen.

---
 certs/blacklist.c | 9 +++++++++
 1 file changed, 9 insertions(+)
certs/blacklist.c +9 -0
index 486ce0dd8e9c..25094ea73600 100644
@@ -307,6 +307,15 @@ static int restrict_link_for_blacklist(struct key *dest_keyring,
 
 /*
  * Initialise the blacklist
+ *
+ * The blacklist_init() function is registered as an initcall via
+ * device_initcall().  As a result if the blacklist_init() function fails for
+ * any reason the kernel continues to execute.  While cleanly returning -ENODEV
+ * could be acceptable for some non-critical kernel parts, if the blacklist
+ * keyring fails to load it defeats the certificate/key based deny list for
+ * signed modules.  If a critical piece of security functionality that users
+ * expect to be present fails to initialize, panic()ing is likely the right
+ * thing to do.
  */
 static int __init blacklist_init(void)
 {
Signature · 1 line
2.35.1
maintainer
#3 lore raw

Re: [PATCH v2 1/1] certs: Explain the rationale to call panic()

In reply to Mickaël Salaün
Quoted 46 lines · Mickaël Salaün

From: Mickaël Salaün <[email protected]>

The blacklist_init() function calls panic() for memory allocation errors. This change documents the reason why we don't return -ENODEV.

---

Changes since v1:
* Fix commit subject spelling spotted by David Woodhouse.
* Reword one sentence as suggested by Paul Moore.
* Add Reviewed-by Paul Moore.
* Add Reviewed-by Jarkko Sakkinen.

---
 certs/blacklist.c | 9 +++++++++
 1 file changed, 9 insertions(+)
certs/blacklist.c +9 -0
index 486ce0dd8e9c..25094ea73600 100644
@@ -307,6 +307,15 @@ static int restrict_link_for_blacklist(struct key *dest_keyring,
 
 /*
  * Initialise the blacklist
+ *
+ * The blacklist_init() function is registered as an initcall via
+ * device_initcall().  As a result if the blacklist_init() function fails for
+ * any reason the kernel continues to execute.  While cleanly returning -ENODEV
+ * could be acceptable for some non-critical kernel parts, if the blacklist
+ * keyring fails to load it defeats the certificate/key based deny list for
+ * signed modules.  If a critical piece of security functionality that users
+ * expect to be present fails to initialize, panic()ing is likely the right
+ * thing to do.
  */
 static int __init blacklist_init(void)
 {
Signature · 1 line
2.35.1

Thank you, I'll put this into my "queue" folder and apply as soon I have bandwidth.

BR, Jarkko

maintainer
#4 lore raw

Re: [PATCH v2 1/1] certs: Explain the rationale to call panic()

In reply to Mickaël Salaün
Quoted 2 lines · Mickaël Salaün

The blacklist_init() function calls panic() for memory allocation errors. This change documents the reason why we don't return -ENODEV.

Why, though?

This is only called whilst the kernel is booting. If you hit ENOMEM, you aren't likely to get much further with the boot process.

David