Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2071594rwb; Mon, 7 Nov 2022 08:50:51 -0800 (PST) X-Google-Smtp-Source: AMsMyM7nFg0topO5zOC89Q6+X1HvBBmpFThBA6aGr+zyFEywU/4f9wX20RkyVaIqtuPYnYLjN7xU X-Received: by 2002:a50:950d:0:b0:463:298a:448c with SMTP id u13-20020a50950d000000b00463298a448cmr45324966eda.153.1667839851524; Mon, 07 Nov 2022 08:50:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667839851; cv=none; d=google.com; s=arc-20160816; b=KELuPeXDOm65xY1gifWNN/er0gqMDZun1Hkpgd6lSLLKCkDMoXMghHur0Ki+ay/9j5 q+7sjfGUHQvAy2aCNFoEn3FSoXxtdGiAFU1AFdZbHs3gFiRSA3KDDAHXha5zW3mkNxWn UrG6cr0dSLP4Xvc3v9k0q2328WykxvuNGbDxrEU8cMa9uEZWXBFzqifRlsCDOMs7ym0M av+ZuWdB6VC/KhQPfRzj97GSRPdS2QXISs6lRl/vc8PlkLXoSwzvf3xsemvq471OF73B FZU71Xl26Hfa9KA5HiXg4LH3hrbtmsTMkvC2bsGdMSUR1cd02bBA1KgquidLdycX2A33 ocvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ibXYAmBTd/ZNRqKGfxknyV7CzlZ+2/i42p4LnO+ezS8=; b=BncxqsQ55/+qLcq6jO8H5RtHMw5QwjQmuUVHy43XFOIsvjuoZPS25SCMPjhgGyRluq d0NJ2mFWSD4JVj+EwIsOSvACw415pJxwTXFEbBgjiYwmJMNbNv/TI+W7CSWtQstLB5D0 iFuIKpG0/9f2SBCfNw0HzyPVAIw83FPS390af2sRWwKCabWqYz9PP09hmVemIPyv7I26 N2RYk68P9OTZqZDig+INHOPbHCfFjigyv3qN2lqymZhIrx89ET82wisIrs8jSFjy0Ydh xVFugBqrcMn119hvScauB02/TvA9fABPee0fHrBmbvzoPkZfcUsoRm2h5O6oExAkSsGp Ll5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=gFUGW4Fw; 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 jj21-20020a170907985500b007a641e472f0si7241970ejc.139.2022.11.07.08.50.28; Mon, 07 Nov 2022 08:50:51 -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=pass header.i=@digikod.net header.s=20191114 header.b=gFUGW4Fw; 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 S232465AbiKGQXm (ORCPT + 93 others); Mon, 7 Nov 2022 11:23:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232133AbiKGQXL (ORCPT ); Mon, 7 Nov 2022 11:23:11 -0500 Received: from smtp-1908.mail.infomaniak.ch (smtp-1908.mail.infomaniak.ch [IPv6:2001:1600:4:17::1908]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9DC4240BB for ; Mon, 7 Nov 2022 08:21:00 -0800 (PST) Received: from smtp-2-0000.mail.infomaniak.ch (unknown [10.5.36.107]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4N5c0n3vwFzMq4Rq; Mon, 7 Nov 2022 17:20:57 +0100 (CET) Received: from ns3096276.ip-94-23-54.eu (unknown [23.97.221.149]) by smtp-2-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4N5c0k0hNRzMppDn; Mon, 7 Nov 2022 17:20:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1667838057; bh=/Hxzji7LOlrPI3D4EEkzO0ARX8DsTpF3mgj/GUpF6Pk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gFUGW4Fw6Ro4F87y5z93lAFXMNDQZkpgvZFUYBth1xVO6RFSg0Y/jNrArCaLGqe35 TSBOCoY9PGKmpc3SkoK5uTdTeNIgngOdglJXnnNg5tnBX8WbJBdiO5Hlt012/cN+7y 1VhNMm1AnRtPLiI+eoj2usye0DamHZ44AldN0MM8= Message-ID: <8692915f-437c-56fd-8984-d6febf533fa9@digikod.net> Date: Mon, 7 Nov 2022 17:20:53 +0100 MIME-Version: 1.0 User-Agent: Subject: Re: [PATCH] certs: Prevent spurious errors on repeated blacklisting Content-Language: en-US To: =?UTF-8?Q?Thomas_Wei=c3=9fschuh?= 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 References: <20221104014704.3469-1-linux@weissschuh.net> <3b997266-067c-975c-911a-da146fe9033a@digikod.net> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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=unavailable 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 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? > 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