Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp788180pxb; Wed, 20 Jan 2021 22:40:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJytyeJAdWzTV/XAFNbe4PpkDT5T6TbTCDEC1xGT8BuAiBNM9CsT1xSNA4/n+YRQEgfXmdB5 X-Received: by 2002:a05:6402:c9c:: with SMTP id cm28mr10325404edb.281.1611211224612; Wed, 20 Jan 2021 22:40:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611211224; cv=none; d=google.com; s=arc-20160816; b=ROFeTUl1jaXX79GxhjFC0cFl7qi0iCkRlPObEF6+l/wVgOji2xbLVCXidFMLvcOhGJ KI753GRAuI/Yg9t3aI5klo39ALwnuTkbSTjQB6Br7dHD6Fsb0EY121RRYRd6O5TPEhxa 5wE+AAxAZbJRMs4DuUunkZYPfIFSn9WLcQ+Ub+iOCVef6VvsE8Qmf6h+X/A2O4sTZmDm rZBYNzWOaGGdyXCjYd45mrAmXscuCoMEeaJNqlWKs0zSkRyavoCe0GFDiRwXFUhS1dg8 5Aui/7ECoOjKZKoRLxiqCi7Tbna1wNJWsfqgQDofwGy5dGN+/rBRoo1OuAWtgK2J3Wzw YLGQ== 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=+vfi31ku3875wDCCsHlRatUMV7irbUKcF82qbpq+j8I=; b=XSkfQEk0EwvkyeWwlECGBZlc3HVTj3BL/8Ne1Pcm5DHMxD+lXt7rAb2LX1HJQZXQEU 3tVroIc/nO2bfLOJFPOtQ7PwSVS8NpDD+wBLIIbR5jPRIiaGhLH2b7fmDKJr3pIy5LAE NvI5yZ4yOHs1ZQLNsjWFnSYKyI/WHpam7mAs06cc/lYFYsvoxJQOjuuRboChSqxLQWol TTv8qAm6wR7AqskrO+BO0kurFBt43hE/vywqdDvIbVTJ/m5C4chTw5B61xh7VgbYlh0o DbOnPuQJHR/o8+Ofg1UgOclHxigvIxst2XYnxBDB+Fb2H/Lwnt2ksUtUyJPLWEJwFGfn TvXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E70AnGgr; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk22si1427131ejb.736.2021.01.20.22.40.01; Wed, 20 Jan 2021 22:40:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E70AnGgr; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S1725984AbhAUGis (ORCPT + 99 others); Thu, 21 Jan 2021 01:38:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:49450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387519AbhATXpp (ORCPT ); Wed, 20 Jan 2021 18:45:45 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3FF75221FE; Wed, 20 Jan 2021 23:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611186302; bh=DtYGGvkksfs7vXommXeJwl91lOsFd1rEuyBTgJv2+l0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E70AnGgrCqxaoh1vWdlhGmZ2hd7h/FB84wv2240pZVLQUYmrHgMKATyaqSOkK85F/ efCn9nc8j0I9yyif6cEaIBQ+Y8LWSf+T/dqeBGKToiPaLLnNeBV1+7hwW5AxIM/qIi msPEsJTYyd/Wx5bu8Da6KODI7Zbxlq/djYsCS3CT/WKtcjJxGMw81TsvZN0B0zv+fH yq1FOKDdleusG2CT5IJQua2USHSh1tGzSkT6kTlaaNQQJ6+uyly9wZta2XxuOIhExl bu2B36wdUYjoVyWPzvMvz8AUR+XPQHfHGGqkXP6OrYIbAY4z8Hgjlm7KTVPVLiVjYh Vr6VDSf5UWiWw== Date: Thu, 21 Jan 2021 01:44:56 +0200 From: Jarkko Sakkinen To: =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= Cc: David Howells , David Woodhouse , "David S . Miller" , Herbert Xu , James Morris , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , 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 Subject: Re: [PATCH v3 02/10] certs: Fix blacklisted hexadecimal hash string check Message-ID: References: <20210114151909.2344974-1-mic@digikod.net> <20210114151909.2344974-3-mic@digikod.net> <05e3ce56-c27c-877d-8ebe-d088ba95f248@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <05e3ce56-c27c-877d-8ebe-d088ba95f248@digikod.net> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Jan 20, 2021 at 12:12:50PM +0100, Micka?l Sala?n wrote: > > 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. Right the patches are just out of order then. /Jarkko > > 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 > > >