linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] certs: Prevent spurious errors on repeated blacklisting
@ 2022-11-04  1:47 Thomas Weißschuh
  2022-11-07 13:12 ` Mickaël Salaün
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2022-11-04  1:47 UTC (permalink / raw)
  To: David Howells, David Woodhouse
  Cc: Thomas Weißschuh, keyrings, linux-kernel, Mickaël Salaün

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")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 certs/blacklist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/certs/blacklist.c b/certs/blacklist.c
index 41f10601cc72..5f7f2882ced7 100644
--- a/certs/blacklist.c
+++ b/certs/blacklist.c
@@ -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
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting
  2022-11-04  1:47 [PATCH] certs: Prevent spurious errors on repeated blacklisting Thomas Weißschuh
@ 2022-11-07 13:12 ` Mickaël Salaün
  2022-11-07 15:55   ` Thomas Weißschuh
  2022-11-09 15:50   ` Eric Snowberg
  0 siblings, 2 replies; 8+ messages in thread
From: Mickaël Salaün @ 2022-11-07 13:12 UTC (permalink / raw)
  To: Thomas Weißschuh, David Howells, David Woodhouse, Jarkko Sakkinen
  Cc: keyrings, linux-kernel, Mark Pearson, Eric Snowberg,
	linux-integrity, linux-security-module

This is a follow-up of 
https://lore.kernel.org/r/c8c65713-5cda-43ad-8018-20f2e32e4432@t-8ch.de

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


On 04/11/2022 02:47, Thomas Weißschuh wrote:
> 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.

> 
> Fixes: 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>   certs/blacklist.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/certs/blacklist.c b/certs/blacklist.c
> index 41f10601cc72..5f7f2882ced7 100644
> --- a/certs/blacklist.c
> +++ b/certs/blacklist.c
> @@ -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.


>   		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
>   		return PTR_ERR(key);
>   	}
> 
> base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting
  2022-11-07 13:12 ` Mickaël Salaün
@ 2022-11-07 15:55   ` Thomas Weißschuh
  2022-11-07 16:20     ` Mickaël Salaün
  2022-11-09 15:50   ` Eric Snowberg
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2022-11-07 15:55 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: David Howells, David Woodhouse, Jarkko Sakkinen, keyrings,
	linux-kernel, Mark Pearson, Eric Snowberg, linux-integrity,
	linux-security-module

On 2022-11-07 14:12+0100, Mickaël Salaün wrote:
> This is a follow-up of
> https://lore.kernel.org/r/c8c65713-5cda-43ad-8018-20f2e32e4432@t-8ch.de
> 
> Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.
> 
> 
> On 04/11/2022 02:47, Thomas Weißschuh wrote:
> > 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.

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

> > Fixes: 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > ---
> >   certs/blacklist.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/certs/blacklist.c b/certs/blacklist.c
> > index 41f10601cc72..5f7f2882ced7 100644
> > --- a/certs/blacklist.c
> > +++ b/certs/blacklist.c
> > @@ -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.

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.

> >   		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
> >   		return PTR_ERR(key);
> >   	}
> > 
> > base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting
  2022-11-07 15:55   ` Thomas Weißschuh
@ 2022-11-07 16:20     ` Mickaël Salaün
  2022-11-07 16:35       ` Thomas Weißschuh
  0 siblings, 1 reply; 8+ messages in thread
From: Mickaël Salaün @ 2022-11-07 16:20 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: David Howells, David Woodhouse, Jarkko Sakkinen, keyrings,
	linux-kernel, Mark Pearson, Eric Snowberg, linux-integrity,
	linux-security-module


On 07/11/2022 16:55, Thomas Weißschuh wrote:
> On 2022-11-07 14:12+0100, Mickaël Salaün wrote:
>> This is a follow-up of
>> https://lore.kernel.org/r/c8c65713-5cda-43ad-8018-20f2e32e4432@t-8ch.de
>>
>> Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.
>>
>>
>> On 04/11/2022 02:47, Thomas Weißschuh wrote:
>>> 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.
> 
> Thanks, I was not aware that these are worth fixing.
> 
>>> Fixes: 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
>>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>>> ---
>>>    certs/blacklist.c | 4 +++-
>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/certs/blacklist.c b/certs/blacklist.c
>>> index 41f10601cc72..5f7f2882ced7 100644
>>> --- a/certs/blacklist.c
>>> +++ b/certs/blacklist.c
>>> @@ -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.
> 
> Returning EACCES would require some deeper changes to how the keyring is set up

I guess you meant EEXIST?

> 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.

> 
> 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

> 
>>>    		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
>>>    		return PTR_ERR(key);
>>>    	}
>>>
>>> base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting
  2022-11-07 16:20     ` Mickaël Salaün
@ 2022-11-07 16:35       ` Thomas Weißschuh
  2022-11-07 19:40         ` Mickaël Salaün
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2022-11-07 16:35 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: David Howells, David Woodhouse, Jarkko Sakkinen, keyrings,
	linux-kernel, Mark Pearson, Eric Snowberg, linux-integrity,
	linux-security-module

On 2022-11-07 17:20+0100, Mickaël Salaün wrote:
> On 07/11/2022 16:55, Thomas Weißschuh wrote:
> > On 2022-11-07 14:12+0100, Mickaël Salaün wrote:
> > > This is a follow-up of
> > > https://lore.kernel.org/r/c8c65713-5cda-43ad-8018-20f2e32e4432@t-8ch.de
> > > 
> > > Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.
> > > 
> > > 
> > > On 04/11/2022 02:47, Thomas Weißschuh wrote:
> > > > 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.
> > 
> > Thanks, I was not aware that these are worth fixing.
> > 
> > > > Fixes: 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
> > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > > > ---
> > > >    certs/blacklist.c | 4 +++-
> > > >    1 file changed, 3 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/certs/blacklist.c b/certs/blacklist.c
> > > > index 41f10601cc72..5f7f2882ced7 100644
> > > > --- a/certs/blacklist.c
> > > > +++ b/certs/blacklist.c
> > > > @@ -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.
> > 
> > Returning EACCES would require some deeper changes to how the keyring is set up
> 
> I guess you meant EEXIST?

Indeed, sorry.

> > 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.

> > 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.

> > > >    		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
> > > >    		return PTR_ERR(key);
> > > >    	}
> > > > 
> > > > base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting
  2022-11-07 16:35       ` Thomas Weißschuh
@ 2022-11-07 19:40         ` Mickaël Salaün
  2022-11-15 23:57           ` Jarkko Sakkinen
  0 siblings, 1 reply; 8+ messages in thread
From: Mickaël Salaün @ 2022-11-07 19:40 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: David Howells, David Woodhouse, Jarkko Sakkinen, keyrings,
	linux-kernel, Mark Pearson, Eric Snowberg, linux-integrity,
	linux-security-module


On 07/11/2022 17:35, Thomas Weißschuh wrote:
> On 2022-11-07 17:20+0100, Mickaël Salaün wrote:
>> On 07/11/2022 16:55, Thomas Weißschuh wrote:
>>> On 2022-11-07 14:12+0100, Mickaël Salaün wrote:
>>>> This is a follow-up of
>>>> https://lore.kernel.org/r/c8c65713-5cda-43ad-8018-20f2e32e4432@t-8ch.de
>>>>
>>>> Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.
>>>>
>>>>
>>>> On 04/11/2022 02:47, Thomas Weißschuh wrote:
>>>>> 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.
>>>
>>> Thanks, I was not aware that these are worth fixing.
>>>
>>>>> Fixes: 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
>>>>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>>>>> ---
>>>>>     certs/blacklist.c | 4 +++-
>>>>>     1 file changed, 3 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/certs/blacklist.c b/certs/blacklist.c
>>>>> index 41f10601cc72..5f7f2882ced7 100644
>>>>> --- a/certs/blacklist.c
>>>>> +++ b/certs/blacklist.c
>>>>> @@ -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.
>>>
>>> Returning EACCES would require some deeper changes to how the keyring is set up
>>
>> I guess you meant EEXIST?
> 
> Indeed, sorry.
> 
>>> 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.
> 
>>> 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?

> 
> 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.


> 
>>>>>     		pr_err("Problem blacklisting hash (%ld)\n", PTR_ERR(key));
>>>>>     		return PTR_ERR(key);
>>>>>     	}
>>>>>
>>>>> base-commit: ee6050c8af96bba2f81e8b0793a1fc2f998fcd20

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting
  2022-11-07 13:12 ` Mickaël Salaün
  2022-11-07 15:55   ` Thomas Weißschuh
@ 2022-11-09 15:50   ` Eric Snowberg
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Snowberg @ 2022-11-09 15:50 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: Thomas Weißschuh, David Howells, David Woodhouse,
	Jarkko Sakkinen, keyrings, linux-kernel, Mark Pearson,
	linux-integrity, linux-security-module



> On Nov 7, 2022, at 6:12 AM, Mickaël Salaün <mic@digikod.net> wrote:
> 
> This is a follow-up of https://lore.kernel.org/r/c8c65713-5cda-43ad-8018-20f2e32e4432@t-8ch.de
> 
> Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.
> 
> 
> On 04/11/2022 02:47, Thomas Weißschuh wrote:
>> 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.

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting
  2022-11-07 19:40         ` Mickaël Salaün
@ 2022-11-15 23:57           ` Jarkko Sakkinen
  0 siblings, 0 replies; 8+ messages in thread
From: Jarkko Sakkinen @ 2022-11-15 23:57 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: Thomas Weißschuh, David Howells, David Woodhouse, keyrings,
	linux-kernel, Mark Pearson, Eric Snowberg, linux-integrity,
	linux-security-module

On Mon, Nov 07, 2022 at 08:40:09PM +0100, Mickaël Salaün wrote:
> 
> On 07/11/2022 17:35, Thomas Weißschuh wrote:
> > On 2022-11-07 17:20+0100, Mickaël Salaün wrote:
> > > On 07/11/2022 16:55, Thomas Weißschuh wrote:
> > > > On 2022-11-07 14:12+0100, Mickaël Salaün wrote:
> > > > > This is a follow-up of
> > > > > https://lore.kernel.org/r/c8c65713-5cda-43ad-8018-20f2e32e4432@t-8ch.de
> > > > > 
> > > > > Added Jarkko, Mark Pearson, Eric Snowberg and more ML in Cc.
> > > > > 
> > > > > 
> > > > > On 04/11/2022 02:47, Thomas Weißschuh wrote:
> > > > > > 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.
> > > > 
> > > > Thanks, I was not aware that these are worth fixing.
> > > > 
> > > > > > Fixes: 6364d106e041 ("certs: Allow root user to append signed hashes to the blacklist keyring")
> > > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > > > > > ---
> > > > > >     certs/blacklist.c | 4 +++-
> > > > > >     1 file changed, 3 insertions(+), 1 deletion(-)
> > > > > > 
> > > > > > diff --git a/certs/blacklist.c b/certs/blacklist.c
> > > > > > index 41f10601cc72..5f7f2882ced7 100644
> > > > > > --- a/certs/blacklist.c
> > > > > > +++ b/certs/blacklist.c
> > > > > > @@ -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.
> > > > 
> > > > Returning EACCES would require some deeper changes to how the keyring is set up
> > > 
> > > I guess you meant EEXIST?
> > 
> > Indeed, sorry.
> > 
> > > > 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.
> > 
> > > > 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?

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

BR, Jarkko

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-15 23:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04  1:47 [PATCH] certs: Prevent spurious errors on repeated blacklisting Thomas Weißschuh
2022-11-07 13:12 ` Mickaël Salaün
2022-11-07 15:55   ` Thomas Weißschuh
2022-11-07 16:20     ` Mickaël Salaün
2022-11-07 16:35       ` Thomas Weißschuh
2022-11-07 19:40         ` Mickaël Salaün
2022-11-15 23:57           ` Jarkko Sakkinen
2022-11-09 15:50   ` Eric Snowberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).