Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp802868pxb; Fri, 22 Apr 2022 11:27:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWGS18gTPz9LRT/rTbaSM9at5o1pTratQr12BJrOyXLe1YjkJL3qaoK95Kerg4pp+SgjnY X-Received: by 2002:a62:ed0b:0:b0:505:7675:1119 with SMTP id u11-20020a62ed0b000000b0050576751119mr6202226pfh.4.1650652063524; Fri, 22 Apr 2022 11:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650652063; cv=none; d=google.com; s=arc-20160816; b=go5jZP7cD24q2T6vUlS6kF3Ma1I/VC/klXPzt+kfEhsJ0GKJR5lYhGHAq2aSLQ/dUp iCVHhHCBcyT+Sl1zBEdU9OOi1nvTouGUEI1M/DCwpQ64bQGmSpSOlnhfn/4/f/hXPOcG fDgCJazu5eIWaciowaJ9u7pTb+vW+xyiNNd5NpwGH5AYxWEelLNJKY1EwkZaCauQxymY XhNdw35tCeo4GOpuG50ZlkvPEiX0n7VL4XplFrHldaVkTOf+2dB13G3tlUieMdPz1VAE MYcEtLDsOJFGyf84gxR/Cq1dmpfg4sgjrIgfYQnedGM/3n3Vh7lCwD3Gl+P+Y3MOR2vi o+0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :mime-version:subject:cc:to:references:in-reply-to:from:organization :dkim-signature; bh=KIJu0PnDJV4/uO0UdPgu/58WGciQu1suUPJ1SFUvK60=; b=Mzt5ipz0igpMaCZuQe20KQLiGOxG8Su9DBkqiv8NM++JoP5S/VLeYOaDA6uOeGzGEx n39KQctYmWJa7Z7sbbEo42ekPd6fmGbwC48moatVuvICOmlE6T7DZU4QBiGEk6TeQIvm c++QrdsXcigjkyLRhIfzrAgTUpluxj5fmNUcKGakFs376iTsKj3aJjEqEgibg1ZjQzhW e/+kXciLi0Rl+4F0ZJhAV5d9Hi/3kbQIbXAHfu2HnnXV5U6PWPd8BP9EoZFoahp6ZV3B K8iiz89TNyzgLd/QK4r0zjJrFOOLUpPE5VINKY+tX5U/uOQPs96r0vdDfLBQ2KL071d2 qtPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SM0CWFeQ; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d17-20020a634f11000000b003aa4b850540si9156405pgb.151.2022.04.22.11.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:27:43 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SM0CWFeQ; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F0783106DC5; Fri, 22 Apr 2022 10:56:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351715AbiDTKcF (ORCPT + 99 others); Wed, 20 Apr 2022 06:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234821AbiDTKcB (ORCPT ); Wed, 20 Apr 2022 06:32:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7D06C3F890 for ; Wed, 20 Apr 2022 03:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650450555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KIJu0PnDJV4/uO0UdPgu/58WGciQu1suUPJ1SFUvK60=; b=SM0CWFeQRknY+2vXhIKwxZDRIEAcagCUbNhNyNGPN3vin+UWjSybQYLQlbLX0z1tv3E0Mz E4r0wCSEM5GiDEDVfjJ/SF6jp9wPb+EF+DER2runUmY6dMeB/H4AdFbJcWvqP42Yl+PGDn 3lp/IhsoPd9ZuaRyJNtF3PvgPQcibWg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-5Q0XG3XRM2uJXHWtLXv0tg-1; Wed, 20 Apr 2022 06:29:12 -0400 X-MC-Unique: 5Q0XG3XRM2uJXHWtLXv0tg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 83F2338149C1; Wed, 20 Apr 2022 10:29:11 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id E39654022C4; Wed, 20 Apr 2022 10:29:08 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20210312171232.2681989-4-mic@digikod.net> References: <20210312171232.2681989-4-mic@digikod.net> <20210312171232.2681989-1-mic@digikod.net> To: =?us-ascii?Q?=3D=3FUTF-8=3Fq=3FMicka=3DC3=3DABl=3D20Sala=3DC3=3DBCn=3F?= =?us-ascii?Q?=3D?= Cc: dhowells@redhat.com, David Woodhouse , Jarkko Sakkinen , "David S . Miller" , Eric Snowberg , Herbert Xu , James Morris , =?us-ascii?Q?=3D=3FUTF-8=3Fq=3FMicka=3DC3=3DABl?= =?us-ascii?Q?=3D20Sala=3DC3=3DBCn=3F=3D?= , Mimi Zohar , "Serge E . Hallyn" , Tyler Hicks , 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 Subject: Re: [PATCH v7 3/5] certs: Make blacklist_vet_description() more strict MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 20 Apr 2022 11:29:08 +0100 Message-ID: <648218.1650450548@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE 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-crypto@vger.kernel.org Micka=C3=ABl Sala=C3=BCn wrote: > + /* The following algorithm only works if prefix lengths match. */ > + BUILD_BUG_ON(sizeof(tbs_prefix) !=3D sizeof(bin_prefix)); > + prefix_len =3D sizeof(tbs_prefix) - 1; > + for (i =3D 0; *desc; desc++, i++) { > + if (*desc =3D=3D ':') { > + if (tbs_step =3D=3D prefix_len) > + goto found_colon; > + if (bin_step =3D=3D prefix_len) > + goto found_colon; > + return -EINVAL; > + } > + if (i >=3D prefix_len) > + return -EINVAL; > + if (*desc =3D=3D tbs_prefix[i]) > + tbs_step++; > + if (*desc =3D=3D bin_prefix[i]) > + bin_step++; > + } I wonder if: static const char tbs_prefix[] =3D "tbs:"; static const char bin_prefix[] =3D "bin:"; if (strncmp(desc, tbs_prefix, sizeof(tbs_prefix) - 1) =3D=3D 0 || strncmp(desc, bin_prefix, sizeof(bin_prefix) - 1) =3D=3D 0) goto found_colon; might be better. David