Skip to contentSkip to conversation

Explain panic() calls for keyring initialization

PATCH Superseded Mickaël Salaün 4 participants 8 messages Mar 21, 2022 – Mar 22, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

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

Regards,

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

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

base-commit: 50c486fe310890c134b5cb36cf9a4135475a6074

Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/1 certs: Explain the rational 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.

---
 certs/blacklist.c | 8 ++++++++
 1 file changed, 8 insertions(+)
certs/blacklist.c +8 -0
index 486ce0dd8e9c..ac26bcf9b9a5 100644
@@ -307,6 +307,14 @@ 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 the functionality doesn't load and the
+ * kernel continues on executing.  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 v1 1/1
#2 lore raw

Re: [PATCH v1 1/1] certs: Explain the rational to call panic()

Quoted 6 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 8 lines
---
 certs/blacklist.c | 8 ++++++++
 1 file changed, 8 insertions(+)

I would suggest changing the second sentence as shown below, but otherwise it looks good to me.

certs/blacklist.c static int restrict_link_for_blacklist(struct key *dest_keyring, · line 312

Quoted 11 lines
certs/blacklist.c +3 -0
index 486ce0dd8e9c..ac26bcf9b9a5 100644
@@ -307,6 +307,14 @@ 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 the functionality doesn't load and the

"As a result if the blacklist_init() function fails for any reason the kernel continues to execute."

certs/blacklist.c static int restrict_link_for_blacklist(struct key *dest_keyring, · line 320

Quoted 8 lines
certs/blacklist.c +5 -0
+ * kernel continues on executing.  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)
 {

--
paul-moore.com

maintainer
#6 lore raw
In reply to Mickaël Salaün
Quoted 3 lines · Mickaël Salaün

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

Nit: "rationale". Even in Simplified English, I believe "rational" is a completely different word.

Quoted 2 lines
 certs/blacklist.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Also, isn't it about time we changed this to call it a denylist?

maintainer Reviewed-by
#3 lore raw

Re: [PATCH v1 1/1] certs: Explain the rational to call panic()

In reply to Paul Moore
Quoted 16 lines · Paul Moore
Quoted 6 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 8 lines
---
 certs/blacklist.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Quoted 4 lines

I would suggest changing the second sentence as shown below, but otherwise it looks good to me.

Mickaël, I think since your patch set was not huge in the first place, I'm considering making it part of rc2 pull request while I normally try to avoid any features after rc1. It's anyway throughly tested, and generally has been around for a *long time*. I've even tested it myself a few times.

Just trying to be responsible as a maintainer and if something does not feel right, I don't try to pretend that "I get it", if you know what I mean. This fully clarifies "not getting it" part :-)

Thanks!

BR, Jarkko

#5 lore raw

Re: [PATCH v1 1/1] certs: Explain the rational to call panic()

In reply to Paul Moore
Quoted 27 lines · Paul Moore
Quoted 6 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 8 lines
---
  certs/blacklist.c | 8 ++++++++
  1 file changed, 8 insertions(+)

I would suggest changing the second sentence as shown below, but otherwise it looks good to me.

Quoted 6 lines
certs/blacklist.c +0 -0
index 486ce0dd8e9c..ac26bcf9b9a5 100644
@@ -307,6 +307,14 @@ static int restrict_link_for_blacklist(struct key *dest_keyring,
 
Quoted 8 lines

certs/blacklist.c static int restrict_link_for_blacklist(struct key *dest_keyring, · line 312

Quoted 5 lines
certs/blacklist.c +3 -0
  /*
   * Initialise the blacklist
+ *
+ * The blacklist_init() function is registered as an initcall via
+ * device_initcall().  As a result the functionality doesn't load and the

"As a result if the blacklist_init() function fails for any reason the kernel continues to execute."

Thanks, I'll fix that.

Quoted 12 lines

certs/blacklist.c static int restrict_link_for_blacklist(struct key *dest_keyring, · line 320

Quoted 9 lines
certs/blacklist.c +5 -0
+ * kernel continues on executing.  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)
  {

--
paul-moore.com

#4 lore raw

Re: [PATCH v1 1/1] certs: Explain the rational to call panic()

In reply to Jarkko Sakkinen
Quoted 29 lines · Jarkko Sakkinen
Quoted 16 lines · Paul Moore
Quoted 6 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 8 lines
---
  certs/blacklist.c | 8 ++++++++
  1 file changed, 8 insertions(+)
Quoted 4 lines

I would suggest changing the second sentence as shown below, but otherwise it looks good to me.

Mickaël, I think since your patch set was not huge in the first place, I'm considering making it part of rc2 pull request while I normally try to avoid any features after rc1. It's anyway throughly tested, and generally has been around for a *long time*. I've even tested it myself a few times.

Quoted 5 lines

Just trying to be responsible as a maintainer and if something does not feel right, I don't try to pretend that "I get it", if you know what I mean. This fully clarifies "not getting it" part :-)

Thanks!

Thanks Jarkko, I get it. ;)

#7 lore raw
In reply to David Woodhouse
Quoted 7 lines · David Woodhouse
Quoted 3 lines · Mickaël Salaün

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

Nit: "rationale". Even in Simplified English, I believe "rational" is a completely different word.

Right, "rational" is an adjective.

Quoted 6 lines
Quoted 3 lines
  certs/blacklist.c | 8 ++++++++
  1 file changed, 8 insertions(+)

Also, isn't it about time we changed this to call it a denylist?

It is important to note that this word is part of the kernel ABI because of the keyring name.