From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDD61C4160E for ; Wed, 20 Jan 2021 12:44:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FB7523383 for ; Wed, 20 Jan 2021 12:44:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387433AbhATMjy (ORCPT ); Wed, 20 Jan 2021 07:39:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388936AbhATLOQ (ORCPT ); Wed, 20 Jan 2021 06:14:16 -0500 Received: from smtp-42ac.mail.infomaniak.ch (smtp-42ac.mail.infomaniak.ch [IPv6:2001:1600:4:17::42ac]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 205E4C0613CF for ; Wed, 20 Jan 2021 03:13:12 -0800 (PST) Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4DLNDN5227zMqLkr; Wed, 20 Jan 2021 12:13:08 +0100 (CET) Received: from ns3096276.ip-94-23-54.eu (unknown [23.97.221.149]) by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4DLNDL1gRxzlh8T2; Wed, 20 Jan 2021 12:13:06 +0100 (CET) Subject: Re: [PATCH v3 02/10] certs: Fix blacklisted hexadecimal hash string check To: Jarkko Sakkinen Cc: David Howells , David Woodhouse , "David S . Miller" , Herbert Xu , James Morris , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Mimi Zohar , "Serge E . Hallyn" , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Ben Boeckel References: <20210114151909.2344974-1-mic@digikod.net> <20210114151909.2344974-3-mic@digikod.net> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Message-ID: <05e3ce56-c27c-877d-8ebe-d088ba95f248@digikod.net> Date: Wed, 20 Jan 2021 12:12:50 +0100 User-Agent: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-15 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: keyrings@vger.kernel.org On 20/01/2021 04:43, Jarkko Sakkinen wrote: > On Thu, Jan 14, 2021 at 04:19:01PM +0100, Mickaël Salaün wrote: >> From: Mickaël Salaün >> >> When looking for a blacklisted hash, bin2hex() is used to transform a >> binary hash to an ascii (lowercase) hexadecimal string. This string is >> then search for in the description of the keys from the blacklist >> keyring. When adding a key to the blacklist keyring, >> blacklist_vet_description() checks the hash prefix and the hexadecimal >> string, but not that this string is lowercase. It is then valid to set >> hashes with uppercase hexadecimal, which will be silently ignored by the >> kernel. >> >> Add an additional check to blacklist_vet_description() to check that >> hexadecimal strings are in lowercase. >> >> Cc: David Woodhouse >> Signed-off-by: Mickaël Salaün >> Signed-off-by: David Howells >> Reviewed-by: Ben Boeckel >> --- >> >> Changes since v2: >> * Cherry-pick v1 patch from >> https://lore.kernel.org/lkml/2659836.1607940186@warthog.procyon.org.uk/ >> to rebase on v5.11-rc3. >> * Rearrange Cc order. >> --- >> certs/blacklist.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/certs/blacklist.c b/certs/blacklist.c >> index 2719fb2fbc1c..a888b934a1cd 100644 >> --- a/certs/blacklist.c >> +++ b/certs/blacklist.c >> @@ -37,7 +37,7 @@ static int blacklist_vet_description(const char *desc) >> found_colon: >> desc++; >> for (; *desc; desc++) { >> - if (!isxdigit(*desc)) >> + if (!isxdigit(*desc) || isupper(*desc)) >> return -EINVAL; >> n++; >> } >> -- >> 2.30.0 >> > > Shouldn't this rather convert the upper case to lower case? I don't like > the ABI break that this causes. It doesn't break the ABI because keys loaded in the blacklist keyring can only happen with builtin hashes. Moreover these builtin hashes will be checked by patch 10/10 at build time. This patch is also important to remove a false sense of security and warns about mis-blacklisted certificates or binaries: https://lore.kernel.org/lkml/c9664a67-61b7-6b4a-86d7-5aca9ff06fa5@digikod.net/ Hot-patching keys doesn't seem a good idea, especially when these keys are signed. Moreover, it would bring additional complexity and will require to change the core of the key management. > > /Jarkko >