Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7674940rwb; Tue, 15 Nov 2022 16:13:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+Plv+bhSjJngE7sZam66GsT4ZGbS24D7gWBYbl7HMePK/ildR+mDHtatipawl/49vEkiF X-Received: by 2002:a17:906:b1c6:b0:783:5326:90e5 with SMTP id bv6-20020a170906b1c600b00783532690e5mr15499249ejb.374.1668557614016; Tue, 15 Nov 2022 16:13:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668557614; cv=none; d=google.com; s=arc-20160816; b=YUdefUtHsoKIwfpo8uTH9M07sqw0LjcEp4Jxg3l5D8UN/grc9lO/9FqNbqW09LnwDr K3kjN2n6dKUE71+Xjl5HYdgMXqWrmOYOT6/XvXGsbT217t7t20YfW9DqkWF74aRv4afR bVv9VgrCZYdsJZuXB9nNlMuQICnB0+qX9u4UmkQrUzL+xMJ4YpcW77Ew87GMpDqbt/1Y mAfOCILFx7/lb32822vPm/d0YWMmHxx1QUinGCp/qp58JrVtFiWnRCYautpP7IctRO/M pXTcXINOsc+69RDbqFohAzjNadZXCMxkwEV7vnDSHVZuXsvCAi9RgtqCcnaKEB8nPiOU cfYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ibQf+We/U9IVzfSxi5ZlJUKLsPTIPkzErZ9cN8zsh4I=; b=n4oTb6b5P9bml5F5qGjVPPba0VgSYtwLioLVQMn16/3XRIt+D0LEvHvKyPlZI/f86B 7ReYFr82utBCeNf2x0oUGvr3ymuCO6cX9BDZY/DHpFNv9y2c6dTJs79m91ZBybMGGJ6t AZlC+ZHtg2x4Or+gj1hwxsH696Y/7eiigYo1qMIoSQoIzJom842xMlUrtWi/sqPoVxTW /u88GV1wFrLS469VT/F2mVpkiOJOrNVwthdJmSTuF03q6c3NyGy/WGfdMsS9W7CLQVCT CSIZ2lvevZT1UzcmP9hbMhP0Bd9t0ADA2sKxFWW0oGTw7UxkI3wgj9CdSrGCGyhHSI9s 1KwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fsUI9EBx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020aa7c604000000b004615bea1d62si10374452edq.472.2022.11.15.16.13.10; Tue, 15 Nov 2022 16:13:34 -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=@kernel.org header.s=k20201202 header.b=fsUI9EBx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231420AbiKOX5c (ORCPT + 90 others); Tue, 15 Nov 2022 18:57:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbiKOX53 (ORCPT ); Tue, 15 Nov 2022 18:57:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EAA112AC5; Tue, 15 Nov 2022 15:57:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ED9A5B81B58; Tue, 15 Nov 2022 23:57:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D81CC433C1; Tue, 15 Nov 2022 23:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668556645; bh=F0EaFC7p9syKhNI6Yd5oUqZ8NWsDoe5Sl1JvY5LDLow=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fsUI9EBxoYEYbZAsP6HR91ZdaNCsAJpP6ooWEWF7Y3ii/URHsfceHnM5L4hsS+U9+ MaCK5wGQDxfK0c35tHrHTdf0f1cHNAFtgIrCUQnypDe7g8WIsl7sfwuNwmA8Yfma0T BWyMP3ggO2BW3/RCuotBKGLX3Vonaq2brYfB3WbFNeQkOdfPdvtQuYkJ5Z9cpZQ5PM NAmlN0JM3YQERjEvaNGBIFOKayF/y2Wzxk1MllYSu4REZDpgpl65jkvsYdxyUXehHL Jd77Rt5Ivc0KrqS0QxQf6IGIwy8I6JYHt5kaJ4SGk7kYw8JVA4bvr4v/ZLfOjgXsVc 3+pZCCD58ff6w== Date: Wed, 16 Nov 2022 01:57:22 +0200 From: Jarkko Sakkinen To: =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= Cc: Thomas =?iso-8859-1?Q?Wei=DFschuh?= , David Howells , David Woodhouse , 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> <8692915f-437c-56fd-8984-d6febf533fa9@digikod.net> <706c75af-9569-42fd-ba68-533ed931d55d@t-8ch.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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 > > > > > > --- > > > > > > 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