Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2125419rwb; Mon, 7 Nov 2022 09:25:11 -0800 (PST) X-Google-Smtp-Source: AMsMyM7/k5RFV92768d8I2jY/jETK5h2sXtygiX2slsXLmtJuJAsm3Vdh6uYUQ0SqgMpXeH82CMg X-Received: by 2002:a17:907:2714:b0:7ad:e2b5:e068 with SMTP id w20-20020a170907271400b007ade2b5e068mr37432056ejk.715.1667841910831; Mon, 07 Nov 2022 09:25:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667841910; cv=none; d=google.com; s=arc-20160816; b=STSqDcYZiRV7fNyaixmK0WHXaZyK/1VtEqAwukKLRzZKCw1IdG93xI65HweI+x8KnW 1MrJozwP05infnENvWeefNtghy0emMMBE/EFpUcQvzmaSvC2iFgowa6+OpZuzzNOjThI Pw0Ek1P7OJEMziwJ60r2MdlzPfk6q3IQTRNm0YcQXEykQGpVJ83r5kTS4tm9epBdZd90 IUQgDaf8VKuvAUGN2R+6+S0bfTvHw8mTpAU3USiK/Kgi8fsTILgvM9yghibezd9Mq/gK t7qYX3S/htLE8Qq0LJy6rPNZXP3/EHQvLK2ZqEY0LrN/jh5xrnQeVTgigPzg4jWUTmwf Y90w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:jabber-id:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:date; bh=nxkqpC3XK8QNTWHY5bMNz2PiWCBhC50yFg431RjFvjo=; b=Ik2IfLyH0/93kgo/Bm1XRCg4/xDePa1Qu20/2/kspCD+bj5m8Wctb6nN94+dl5cwuI 5zZBho/fKrSMen3nxOjz4+P7YfS9x8qJcOUaHF5Mt3e6ZUetnyftTwcrTPMmqLFuf82K Ls7cMqOaZpwY6rdWSfs0oake4IIkG6LkQTjLqXyRdUmbWtOLOe/N4UPOuoS0dq8C0bMr YjxFHZYIZC8qNGA2UIFpzCrol69RDHXS9qqIuSYcyDv/HZ6HPedM+V2Q2nmfGezg6wY2 NQ8aIILMIJJXDsy/N6mbH9OzRty5tXsqSQf7UphcHlsSy8CusoqWWnWh656PkBIQKMdJ hTqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b="NIU/RB62"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m23-20020aa7d357000000b004617e8811c4si8624385edr.28.2022.11.07.09.24.45; Mon, 07 Nov 2022 09:25:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b="NIU/RB62"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232083AbiKGQfj (ORCPT + 92 others); Mon, 7 Nov 2022 11:35:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbiKGQfh (ORCPT ); Mon, 7 Nov 2022 11:35:37 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA3ABBF; Mon, 7 Nov 2022 08:35:36 -0800 (PST) Date: Mon, 7 Nov 2022 17:35:30 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1667838934; bh=QO+AH8+RKxg573nBkHttain+idpepyb5rcFtAAmb7HI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NIU/RB62uXmFHonTf6LauX2MA6kUtmpix9Lr4zDDqAqHAAtjh5v4w8VKV/2fBuwmh +4IFlJ3a7Dz8WKSWefUIDM8tD9FVkvEkpcMIJKJJKhxZtasLWBayaLk6R+DgmClBxW LK8ufaNBmHhn87Dmchhfp0DAciqZAwTqMUUr4FSE= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= Cc: David Howells , David Woodhouse , Jarkko Sakkinen , keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Pearson , Eric Snowberg , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting Message-ID: <706c75af-9569-42fd-ba68-533ed931d55d@t-8ch.de> References: <20221104014704.3469-1-linux@weissschuh.net> <3b997266-067c-975c-911a-da146fe9033a@digikod.net> <8692915f-437c-56fd-8984-d6febf533fa9@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8692915f-437c-56fd-8984-d6febf533fa9@digikod.net> Jabber-ID: thomas@t-8ch.de X-Accept: text/plain, text/html;q=0.2, text/*;q=0.1 X-Accept-Language: en-us, en;q=0.8, de-de;q=0.7, de;q=0.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > > --- > > > > 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