Skip to contentSkip to conversation

certs: Prevent spurious errors on repeated blacklisting

PATCH Superseded Thomas Weißschuh 4 participants 8 messages Nov 4, 2022 – Nov 15, 2022

Subsystems (4)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 certs: Prevent spurious errors on repeated blacklisting

When the blacklist keyring was changed to allow updates from the root user it gained an ->update() function that disallows all updates. When the a hash is blacklisted multiple times from the builtin or firmware-provided blacklist this spams prominent logs during boot:

[    0.890814] blacklist: Problem blacklisting hash (-13)

As all these repeated calls to mark_raw_hash_blacklisted() would create the same keyring entry again anyways these errors can be safely ignored.

Fixes 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
---
 certs/blacklist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
certs/blacklist.c +3 -1
index 41f10601cc72..5f7f2882ced7 100644
@@ -191,7 +191,9 @@ static int mark_raw_hash_blacklisted(const char *hash)
 				   BLACKLIST_KEY_PERM,
 				   KEY_ALLOC_NOT_IN_QUOTA |
 				   KEY_ALLOC_BUILT_IN);
-	if (IS_ERR(key)) {
+
+	/* Blacklisting the same hash twice fails but would be idempotent */
+	if (IS_ERR(key) && PTR_ERR(key) != -EACCES) {
 		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
 		return PTR_ERR(key);
 	}

base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

Signature · 1 line
2.38.1
#1 lore raw

This is a follow-up of https://lore.kernel.org/r/[email protected]

Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.

Quoted 9 lines · Thomas Weißschuh

When the blacklist keyring was changed to allow updates from the root user it gained an ->update() function that disallows all updates. When the a hash is blacklisted multiple times from the builtin or firmware-provided blacklist this spams prominent logs during boot:

[    0.890814] blacklist: Problem blacklisting hash (-13)

As all these repeated calls to mark_raw_hash_blacklisted() would create the same keyring entry again anyways these errors can be safely ignored.

These errors can indeed be safely ignored, however they highlight issues with some firmware vendors not checking nor optimizing their blocked hashes. This raises security concerns, and it should be fixed by firmware vendors.

Quoted 12 lines
Fixes 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
---
  certs/blacklist.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
certs/blacklist.c +0 -0
index 41f10601cc72..5f7f2882ced7 100644

certs/blacklist.c static int mark_raw_hash_blacklisted(const char *hash) · line 196

Quoted 7 lines
certs/blacklist.c +3 -1
@@ -191,7 +191,9 @@ static int mark_raw_hash_blacklisted(const char *hash)
  				   BLACKLIST_KEY_PERM,
  				   KEY_ALLOC_NOT_IN_QUOTA |
  				   KEY_ALLOC_BUILT_IN);
-	if (IS_ERR(key)) {
+
+	/* Blacklisting the same hash twice fails but would be idempotent */
+	if (IS_ERR(key) && PTR_ERR(key) != -EACCES) {

We should not hide EACCES errors. This logs issues, which is correct for duplicate hashes, and can help firmware vendors to fix their database. I'd really like to see a different log message instead: change the duplicate entry error code from EACCES to EEXIST, and call pr_warn for this specific case.

Quoted 5 lines
certs/blacklist.c +0 -0
  		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
  		return PTR_ERR(key);
  	}

base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

#2 lore raw
Quoted 12 lines · Mickaël Salaün

This is a follow-up of
https://lore.kernel.org/r/[email protected]

Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.

Quoted 5 lines · Thomas Weißschuh

When the blacklist keyring was changed to allow updates from the root user it gained an ->update() function that disallows all updates. When the a hash is blacklisted multiple times from the builtin or firmware-provided blacklist this spams prominent logs during boot:

Quoted 8 lines
Quoted 4 lines
[    0.890814] blacklist: Problem blacklisting hash (-13)

As all these repeated calls to mark_raw_hash_blacklisted() would create the same keyring entry again anyways these errors can be safely ignored.

These errors can indeed be safely ignored, however they highlight issues with some firmware vendors not checking nor optimizing their blocked hashes. This raises security concerns, and it should be fixed by firmware vendors.

Thanks, I was not aware that these are worth fixing.

Quoted 16 lines
Quoted 16 lines
Fixes 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
---
  certs/blacklist.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
certs/blacklist.c +1 -1
index 41f10601cc72..5f7f2882ced7 100644
@@ -191,7 +191,9 @@ static int mark_raw_hash_blacklisted(const char *hash)
  				   BLACKLIST_KEY_PERM,
  				   KEY_ALLOC_NOT_IN_QUOTA |
  				   KEY_ALLOC_BUILT_IN);
-	if (IS_ERR(key)) {
+
Quoted 8 lines

certs/blacklist.c static int mark_raw_hash_blacklisted(const char *hash) · line 196

Quoted 2 lines
certs/blacklist.c +2 -0
+	/* Blacklisting the same hash twice fails but would be idempotent */
+	if (IS_ERR(key) && PTR_ERR(key) != -EACCES) {

We should not hide EACCES errors. This logs issues, which is correct for duplicate hashes, and can help firmware vendors to fix their database. I'd really like to see a different log message instead: change the duplicate entry error code from EACCES to EEXIST, and call pr_warn for this specific case.

Returning EACCES would require some deeper changes to how the keyring is set up or even changes to the keyring core itself to introduce a key_create() (without update) function.

Is this something you would take a look at, or should I try to do it? (I have no previous knowledge about the keyring subsystem)

In any case it probably would also be good to log the problematic hashes themselves, so users can properly report the issue to their firmware vendors.

Quoted 5 lines
Quoted 5 lines
certs/blacklist.c +0 -0
  		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
  		return PTR_ERR(key);
  	}

base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

#3 lore raw
Quoted 49 lines · Thomas Weißschuh
Quoted 12 lines · Mickaël Salaün

This is a follow-up of
https://lore.kernel.org/r/[email protected]

Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.

Quoted 5 lines · Thomas Weißschuh

When the blacklist keyring was changed to allow updates from the root user it gained an ->update() function that disallows all updates. When the a hash is blacklisted multiple times from the builtin or firmware-provided blacklist this spams prominent logs during boot:

Quoted 8 lines
Quoted 4 lines
[    0.890814] blacklist: Problem blacklisting hash (-13)

As all these repeated calls to mark_raw_hash_blacklisted() would create the same keyring entry again anyways these errors can be safely ignored.

These errors can indeed be safely ignored, however they highlight issues with some firmware vendors not checking nor optimizing their blocked hashes. This raises security concerns, and it should be fixed by firmware vendors.

Thanks, I was not aware that these are worth fixing.

Quoted 16 lines
Quoted 16 lines
Fixes 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
---
   certs/blacklist.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
certs/blacklist.c +1 -1
index 41f10601cc72..5f7f2882ced7 100644
@@ -191,7 +191,9 @@ static int mark_raw_hash_blacklisted(const char *hash)
   				   BLACKLIST_KEY_PERM,
   				   KEY_ALLOC_NOT_IN_QUOTA |
   				   KEY_ALLOC_BUILT_IN);
-	if (IS_ERR(key)) {
+
Quoted 8 lines

certs/blacklist.c static int mark_raw_hash_blacklisted(const char *hash) · line 196

Quoted 2 lines
certs/blacklist.c +2 -0
+	/* Blacklisting the same hash twice fails but would be idempotent */
+	if (IS_ERR(key) && PTR_ERR(key) != -EACCES) {

We should not hide EACCES errors. This logs issues, which is correct for duplicate hashes, and can help firmware vendors to fix their database. I'd really like to see a different log message instead: change the duplicate entry error code from EACCES to EEXIST, and call pr_warn for this specific case.

Quoted 1 line

Returning EACCES would require some deeper changes to how the keyring is set up

I guess you meant EEXIST?

Quoted 5 lines

or even changes to the keyring core itself to introduce a key_create() (without update) function.

Is this something you would take a look at, or should I try to do it? (I have no previous knowledge about the keyring subsystem)

Please take a look. I think it should not be too complex.

Quoted 3 lines

In any case it probably would also be good to log the problematic hashes themselves, so users can properly report the issue to their firmware vendors.

Agree

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
certs/blacklist.c +0 -0
   		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
   		return PTR_ERR(key);
   	}

base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

#4 lore raw
Quoted 50 lines · Mickaël Salaün
Quoted 49 lines · Thomas Weißschuh
Quoted 12 lines · Mickaël Salaün

This is a follow-up of
https://lore.kernel.org/r/[email protected]

Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.

Quoted 5 lines · Thomas Weißschuh

When the blacklist keyring was changed to allow updates from the root user it gained an ->update() function that disallows all updates. When the a hash is blacklisted multiple times from the builtin or firmware-provided blacklist this spams prominent logs during boot:

Quoted 8 lines
Quoted 4 lines
[    0.890814] blacklist: Problem blacklisting hash (-13)

As all these repeated calls to mark_raw_hash_blacklisted() would create the same keyring entry again anyways these errors can be safely ignored.

These errors can indeed be safely ignored, however they highlight issues with some firmware vendors not checking nor optimizing their blocked hashes. This raises security concerns, and it should be fixed by firmware vendors.

Thanks, I was not aware that these are worth fixing.

Quoted 24 lines
Quoted 11 lines
Fixes 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
---
   certs/blacklist.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
certs/blacklist.c +0 -0
index 41f10601cc72..5f7f2882ced7 100644

certs/blacklist.c static int mark_raw_hash_blacklisted(const char *hash) · line 196

Quoted 7 lines
certs/blacklist.c +3 -1
@@ -191,7 +191,9 @@ static int mark_raw_hash_blacklisted(const char *hash)
   				   BLACKLIST_KEY_PERM,
   				   KEY_ALLOC_NOT_IN_QUOTA |
   				   KEY_ALLOC_BUILT_IN);
-	if (IS_ERR(key)) {
+
+	/* Blacklisting the same hash twice fails but would be idempotent */
+	if (IS_ERR(key) && PTR_ERR(key) != -EACCES) {

We should not hide EACCES errors. This logs issues, which is correct for duplicate hashes, and can help firmware vendors to fix their database. I'd really like to see a different log message instead: change the duplicate entry error code from EACCES to EEXIST, and call pr_warn for this specific case.

Quoted 3 lines
Quoted 1 line

Returning EACCES would require some deeper changes to how the keyring is set up

I guess you meant EEXIST?

Indeed, sorry.

Quoted 7 lines
Quoted 5 lines

or even changes to the keyring core itself to introduce a key_create() (without update) function.

Is this something you would take a look at, or should I try to do it? (I have no previous knowledge about the keyring subsystem)

Please take a look. I think it should not be too complex.

Will do.

My plan is to create a new function key_create() that does takes the core logic of key_create_or_update() and fails with EEXIST if needed.

Quoted 4 lines
Quoted 2 lines

In any case it probably would also be good to log the problematic hashes themselves, so users can properly report the issue to their firmware vendors.

Agree

I'll send a patch for that, too.

As for this patch's Fixes-tag, it could refer to either the commit that introduced the logging in the first place or the one that actively started to trigger it:
* 734114f8782f ("KEYS: Add a system blacklist keyring")
* 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")

Personally I'd tend to use the latter.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
certs/blacklist.c +0 -0
   		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
   		return PTR_ERR(key);
   	}

base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

#5 lore raw
Quoted 70 lines · Thomas Weißschuh
Quoted 50 lines · Mickaël Salaün
Quoted 49 lines · Thomas Weißschuh
Quoted 12 lines · Mickaël Salaün

This is a follow-up of
https://lore.kernel.org/r/[email protected]

Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.

Quoted 5 lines · Thomas Weißschuh

When the blacklist keyring was changed to allow updates from the root user it gained an ->update() function that disallows all updates. When the a hash is blacklisted multiple times from the builtin or firmware-provided blacklist this spams prominent logs during boot:

Quoted 8 lines
Quoted 4 lines
[    0.890814] blacklist: Problem blacklisting hash (-13)

As all these repeated calls to mark_raw_hash_blacklisted() would create the same keyring entry again anyways these errors can be safely ignored.

These errors can indeed be safely ignored, however they highlight issues with some firmware vendors not checking nor optimizing their blocked hashes. This raises security concerns, and it should be fixed by firmware vendors.

Thanks, I was not aware that these are worth fixing.

Quoted 24 lines
Quoted 11 lines
Fixes 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
---
    certs/blacklist.c | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)
certs/blacklist.c +0 -0
index 41f10601cc72..5f7f2882ced7 100644

certs/blacklist.c static int mark_raw_hash_blacklisted(const char *hash) · line 196

Quoted 7 lines
certs/blacklist.c +3 -1
@@ -191,7 +191,9 @@ static int mark_raw_hash_blacklisted(const char *hash)
    				   BLACKLIST_KEY_PERM,
    				   KEY_ALLOC_NOT_IN_QUOTA |
    				   KEY_ALLOC_BUILT_IN);
-	if (IS_ERR(key)) {
+
+	/* Blacklisting the same hash twice fails but would be idempotent */
+	if (IS_ERR(key) && PTR_ERR(key) != -EACCES) {

We should not hide EACCES errors. This logs issues, which is correct for duplicate hashes, and can help firmware vendors to fix their database. I'd really like to see a different log message instead: change the duplicate entry error code from EACCES to EEXIST, and call pr_warn for this specific case.

Quoted 3 lines
Quoted 1 line

Returning EACCES would require some deeper changes to how the keyring is set up

I guess you meant EEXIST?

Indeed, sorry.

Quoted 7 lines
Quoted 5 lines

or even changes to the keyring core itself to introduce a key_create() (without update) function.

Is this something you would take a look at, or should I try to do it? (I have no previous knowledge about the keyring subsystem)

Please take a look. I think it should not be too complex.

Will do.

My plan is to create a new function key_create() that does takes the core logic of key_create_or_update() and fails with EEXIST if needed.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

In any case it probably would also be good to log the problematic hashes themselves, so users can properly report the issue to their firmware vendors.

Agree

I'll send a patch for that, too.

Good!

Jarkko, David, any though?

Quoted 8 lines

As for this patch's Fixes-tag, it could refer to either the commit that introduced the logging in the first place or the one that actively started to trigger it:
* 734114f8782f ("KEYS: Add a system blacklist keyring")
* 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")

Personally I'd tend to use the latter.

Even if commit 6364d106e041 is not directly the cause of the issue, it makes it visible, so I agree that you should keep the current Fixes tag.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
certs/blacklist.c +0 -0
    		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
    		return PTR_ERR(key);
    	}

base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

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

This is a follow-up of https://lore.kernel.org/r/[email protected]

Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.

Quoted 7 lines · Thomas Weißschuh

When the blacklist keyring was changed to allow updates from the root user it gained an ->update() function that disallows all updates. When the a hash is blacklisted multiple times from the builtin or firmware-provided blacklist this spams prominent logs during boot:

[    0.890814] blacklist: Problem blacklisting hash (-13)

As all these repeated calls to mark_raw_hash_blacklisted() would create the same keyring entry again anyways these errors can be safely ignored.

Quoted 1 line

These errors can indeed be safely ignored, however they highlight issues with some firmware vendors not checking nor optimizing their blocked hashes. This raises security concerns, and it should be fixed by firmware vendors.

I have seen error reports like this in the past. Some of the older UEFI Revocation List files up on the UEFI.org site [1] contain duplicates. If a firmware vendor uses one of these older Microsoft signed files, they are going to see these error messages.

1. https://uefi.org/revocationlistfile/archive

maintainer
#6 lore raw
In reply to Mickaël Salaün
Quoted 75 lines · Mickaël Salaün
Quoted 73 lines · Thomas Weißschuh
Quoted 50 lines · Mickaël Salaün
Quoted 49 lines · Thomas Weißschuh
Quoted 12 lines · Mickaël Salaün

This is a follow-up of
https://lore.kernel.org/r/[email protected]

Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.

Quoted 5 lines · Thomas Weißschuh

When the blacklist keyring was changed to allow updates from the root user it gained an ->update() function that disallows all updates. When the a hash is blacklisted multiple times from the builtin or firmware-provided blacklist this spams prominent logs during boot:

Quoted 8 lines
Quoted 4 lines
[    0.890814] blacklist: Problem blacklisting hash (-13)

As all these repeated calls to mark_raw_hash_blacklisted() would create the same keyring entry again anyways these errors can be safely ignored.

These errors can indeed be safely ignored, however they highlight issues with some firmware vendors not checking nor optimizing their blocked hashes. This raises security concerns, and it should be fixed by firmware vendors.

Thanks, I was not aware that these are worth fixing.

Quoted 24 lines
Quoted 11 lines
Fixes 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
---
    certs/blacklist.c | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)
certs/blacklist.c +0 -0
index 41f10601cc72..5f7f2882ced7 100644

certs/blacklist.c static int mark_raw_hash_blacklisted(const char *hash) · line 196

Quoted 7 lines
certs/blacklist.c +3 -1
@@ -191,7 +191,9 @@ static int mark_raw_hash_blacklisted(const char *hash)
    				   BLACKLIST_KEY_PERM,
    				   KEY_ALLOC_NOT_IN_QUOTA |
    				   KEY_ALLOC_BUILT_IN);
-	if (IS_ERR(key)) {
+
+	/* Blacklisting the same hash twice fails but would be idempotent */
+	if (IS_ERR(key) && PTR_ERR(key) != -EACCES) {

We should not hide EACCES errors. This logs issues, which is correct for duplicate hashes, and can help firmware vendors to fix their database. I'd really like to see a different log message instead: change the duplicate entry error code from EACCES to EEXIST, and call pr_warn for this specific case.

Quoted 3 lines
Quoted 1 line

Returning EACCES would require some deeper changes to how the keyring is set up

I guess you meant EEXIST?

Indeed, sorry.

Quoted 7 lines
Quoted 5 lines

or even changes to the keyring core itself to introduce a key_create() (without update) function.

Is this something you would take a look at, or should I try to do it? (I have no previous knowledge about the keyring subsystem)

Please take a look. I think it should not be too complex.

Will do.

My plan is to create a new function key_create() that does takes the core logic of key_create_or_update() and fails with EEXIST if needed.

Quoted 3 lines
Quoted 2 lines

In any case it probably would also be good to log the problematic hashes themselves, so users can properly report the issue to their firmware vendors.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Agree

I'll send a patch for that, too.

Good!

Jarkko, David, any though?

I'm happy to review a patch once it is available.

BR, Jarkko