Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1742653rwb; Mon, 7 Nov 2022 05:22:46 -0800 (PST) X-Google-Smtp-Source: AMsMyM5VvuBztUUawV4HBJyE8qyrLloT4B6gmeKxepV7AQp5SPEN/X96wT2uapZ/0b0U8BJqhb8P X-Received: by 2002:a05:6402:11cc:b0:462:76cd:1215 with SMTP id j12-20020a05640211cc00b0046276cd1215mr49993395edw.318.1667827365820; Mon, 07 Nov 2022 05:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667827365; cv=none; d=google.com; s=arc-20160816; b=TVafYuHj1i+W0ZmHAyk3IvBZ+BoJqOGXsAGIx6GGQ7scpm/qVUX/fnU5etsfPtWmDg OcGSWkbECpaRe6ocRS0PWs9MHYSnUm696BlJ0s/Wg/RTX3rZne9cizDr7vCfwPWLQsmw qNsGBnU9NGKPaxUSs+gpEqlEE6HvmjQYj3ZeyxC5qOl8B+0hXZ3Y2jxIhh4hqtE/RUP+ +itOtkNTyiFQ8gwkKXTAFvibVy5HdARworJESXQ0acrp9xZNDtMdM2elxsn9QAzkLhMl QhOu1U34Db9DfaHG6jtTt2ky08n12ZiHBfZpBFJKHZp30NT8e72JGvQb38fYOs2wU3AI zNmg== 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=oW/AKrwW6QjZB4DnzqB+V2VIUsg2kYBKAqug9a7nqB8=; b=dyy5MYpCzigJwvDlKqzVGGUNqm6778UU7jU+Igt8nzxKzGDMnTFH4uhuGKB0McORI7 IXThRHFO+ZHuxd7VciTTSND07U2g/b9SBQE/wPV7frTcl3sVWfKzHGpEd+HAN9KDL8av KxXzf5/Q44tNzqxLH+UtnvMF1CuzwYJrYkZr0cgImZm9KIhu4oOZme0s6Zi8+RXhkwM9 zL9uE1NJP+IhVnKmXgGBjKxytR43g/fVsyG+agWhl6eqBR/3lEsmrDu72ljYBo41o+OY SQT+lGzsVUWHjRq2gVu20hdiYBprM69RQZsr04Dw6LgO8TLdobnOKRoprGwLV/Ab9WYm sjbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b="VbS4/VdM"; 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 b9-20020a056402278900b004637e16cfa4si9738937ede.599.2022.11.07.05.22.23; Mon, 07 Nov 2022 05:22:45 -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="VbS4/VdM"; 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 S232295AbiKGNMV (ORCPT + 93 others); Mon, 7 Nov 2022 08:12:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232230AbiKGNMU (ORCPT ); Mon, 7 Nov 2022 08:12:20 -0500 Received: from smtp-42ab.mail.infomaniak.ch (smtp-42ab.mail.infomaniak.ch [IPv6:2001:1600:3:17::42ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 764B719C1A for ; Mon, 7 Nov 2022 05:12:17 -0800 (PST) Received: from smtp-3-0000.mail.infomaniak.ch (unknown [10.4.36.107]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4N5Wq32j5GzMpqsG; Mon, 7 Nov 2022 14:12:15 +0100 (CET) Received: from ns3096276.ip-94-23-54.eu (unknown [23.97.221.149]) by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4N5Wq22b21zy8; Mon, 7 Nov 2022 14:12:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1667826735; bh=ogv1+vns4rwJNA++R69lZzH0fX4ZziizzJbx9zelCzc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=VbS4/VdMRvoiR4R/DPzce5YO/bNFNZ2z4S3DvPuY3yq5aLOvKr4ga49L49OpXrxF8 SCh2qAdjw/LIP0uwiy26PdwUl/sse2AzMLyQZOdbuETSYDW4GWHDkrF4EBMrsE+Qth SQLgClXpRnQoDDyf7XUwtW5GZWHwFPEfYAP63O/s= Message-ID: <3b997266-067c-975c-911a-da146fe9033a@digikod.net> Date: Mon, 7 Nov 2022 14:12:13 +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?= , David Howells , David Woodhouse , Jarkko Sakkinen Cc: 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> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= In-Reply-To: <20221104014704.3469-1-linux@weissschuh.net> 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=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 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 > --- > 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