Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2006377rwb; Mon, 7 Nov 2022 08:08:08 -0800 (PST) X-Google-Smtp-Source: AMsMyM5rcKS+pWU7XTGblstV6zp0VxGRVNQKBEL92oDU2253VxsHJ+MphZGhJhSw6443WP43ufVw X-Received: by 2002:a05:6402:2791:b0:461:c5b4:d114 with SMTP id b17-20020a056402279100b00461c5b4d114mr50470697ede.357.1667837288014; Mon, 07 Nov 2022 08:08:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667837288; cv=none; d=google.com; s=arc-20160816; b=JKe1KJbJGyhlDGoPVsTgZjKV0doHgyaeyaTqI7z6MSjcplVJSnbF4MaV3To+s+jKz+ n4n/dc42Pa6DwyVADfW37ZrwoggVSV/K/fMoyLOUKGX2KiF7nUQ+IKpJ8Ahd/24LKfDn gtx1epklfIFQ5rLKRFmMgM/ioiqT1f394KeqzfJCxz3kIJsvevN4p/NTZU4ov9Daa6su OPRoeLyAFSaiOJiV17EiFKXyMCZvVY5aibjmkbHXYgLgRiU/LUCAgXTCSM//DDDr4x1W 4MbGBcf3IO0lCKXexrzjKOEdMYQS8oQsjmgKmOuTrB99KRH5elPC/clQmjP84WcysmtI bNLQ== 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=fm4lzRgnLyjwfdJEo9+q5P4eAdrSLmTDy/D7ilGZfDE=; b=eJhSv96Ht9NP1lby7/frhBX2vloku+HK/irlm5g/BczFubyWWY5uWAe/Rve45Tn7mA PfYiut8OOpNuQbS7RcnDeFn1aZsC04Mp1xYi+Pcey+A7PHyXlXDUiv4UiJHoiLGrzY8n eyTNacFh6lnsyExV92Yf//CbRXJU2rFiRsUqgocRBUEk0zF/D3ucpzQ8etQa5EffQ71R MPN0xFmd7CtVB6eaEdJDXICalpIXWCH5ZiVXYQ8TsDGnNTwOjtQNUzBVNahPd7183OnE ffHd8Acg2uw4y44UtFjEcfD82IkKrSdK45dqSBHrBIFBZFpUAUtpCscQH2YXLNg/m1qU 7+2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=t2w+ilOe; 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 nd18-20020a170907629200b007ae417013desi11421297ejc.324.2022.11.07.08.07.44; Mon, 07 Nov 2022 08:08:08 -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=t2w+ilOe; 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 S232331AbiKGPz6 (ORCPT + 93 others); Mon, 7 Nov 2022 10:55:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232038AbiKGPz4 (ORCPT ); Mon, 7 Nov 2022 10:55:56 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 319E01A3BB; Mon, 7 Nov 2022 07:55:52 -0800 (PST) Date: Mon, 7 Nov 2022 16:55:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1667836549; bh=8zTpC0Fy2Y+ryo1EWrS+mIJEw8QPaHCeNSWdWYuR1eo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=t2w+ilOegQdsCnu613aY0f88x+1ZnbqtBzWLDHCCq6z9Xqnm9IeJtyY3JzDKhLvYK bWh1HUHK9Tok1JDFWWlDe4tC4t8duPEKAqIjksWU6Pe7OqJbtTquzDCkHUc1xcx8PW GlFZULFkS3hKr2ChfPHpusfgpDEoHgD6zrHBU+ik= 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: References: <20221104014704.3469-1-linux@weissschuh.net> <3b997266-067c-975c-911a-da146fe9033a@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3b997266-067c-975c-911a-da146fe9033a@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 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 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