Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1621568pxb; Wed, 30 Mar 2022 07:13:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4VYm6vaIkt+llMnv+UkwCICAM7w9da9nQyoBT71FyiajofBpg+ViG55w+fgZz5LrxpB1z X-Received: by 2002:a17:907:7e8c:b0:6dc:b357:2f4 with SMTP id qb12-20020a1709077e8c00b006dcb35702f4mr40112273ejc.434.1648649624251; Wed, 30 Mar 2022 07:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648649624; cv=none; d=google.com; s=arc-20160816; b=0KOEEdBqZ8Ehiekqh/O+T95BUCTPXrHweUxYIitGQgZMigNZYXs7PsfVgwHj2MwUgy AU6a+uKAf+fmtVPjC5WWRYw+j8g0QWHV5fCbFNDMam5J+5xGj3n6Y1Q5LSLcfkTkKDsZ yP14ZkZLll5/gMwubwi0Cw979ZoGIvqu84zhRoizuVQmSvEJ3EXF+vXRjwL1CxhGIgdy THP0HPZ8/bKERCu1na2ZLlOt+BzkmZlmthtY7NqOrRIBMcQd2KdLXcjb8b727fAs1qmp y+vtk1LsLPMxiz882o9BUbCqqIz92eD8Nl0Ab+nbcnpQS0nT1CvEe73dX7YjbbLLZ2mW IM5g== 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=F8QQxxoffEN8D0iWzQeDRqRj76sBJ6MkIp9Ef6hGM1Y=; b=Q0KnP91aJ+RLdBQ6ePZjwbPAd/C338XINo3cbQbiM450DPJjvNfWyy0o38YOxiszOV a9kTm6Ybl+A6iwITM8EsF5Bn7SZhyp0CZo6zmFeIKljX0gGH0MHj3/PYmQcBMpGraLEl kgtMHmdM1VxeOZ08a6zxphFLrHLL6LCtFYiKrQC6v8gm1bEFsc7ZwV+ssBCqrZW0HqOA BFL8cpv7FSs4HfhVkMoVFCdQwJWWETGLWhuJJIwVfZfzI+jRQ5IuFPnQG387B15IJ037 iz4kJasUytFgXQxenmczb34aikgqGSsncVkIJaADfUJE/A5KLk80voJIDEWB/O/9X1PG iovA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="fXA4PS/+"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky3-20020a170907778300b006df76385f1fsi20745057ejc.959.2022.03.30.07.13.05; Wed, 30 Mar 2022 07:13:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@redhat.com header.s=mimecast20190719 header.b="fXA4PS/+"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346284AbiC3NqZ (ORCPT + 99 others); Wed, 30 Mar 2022 09:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346266AbiC3NqW (ORCPT ); Wed, 30 Mar 2022 09:46:22 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9DF226FA0F for ; Wed, 30 Mar 2022 06:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648647875; 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=F8QQxxoffEN8D0iWzQeDRqRj76sBJ6MkIp9Ef6hGM1Y=; b=fXA4PS/+MaXXYH5hubiYUTmerdgMylpyv2auaAkf8khlYSpkxrImEjhVRa3v10J7HgCpPe rOgxRwzSNgayFKzwh7vZ1DTuymLmxmZCyC/V8icAN5n1L3I+7LzhcXoar/G7XlpjaXm0Ya 0xHMGqWZxPfnXlt3TLXWgJTuArtA+HE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-390-NtZGEiU0PnqW3s2Gsn_boQ-1; Wed, 30 Mar 2022 09:44:31 -0400 X-MC-Unique: NtZGEiU0PnqW3s2Gsn_boQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BA68B899ED9; Wed, 30 Mar 2022 13:44:16 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF7B0400E545; Wed, 30 Mar 2022 13:44:00 +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: References: <20210712170313.884724-1-mic@digikod.net> <20210712170313.884724-6-mic@digikod.net> To: Jarkko Sakkinen Cc: dhowells@redhat.com, =?us-ascii?Q?=3D=3Fiso-8859-1=3FQ=3FMicka=3DEBl?= =?us-ascii?Q?=5FSala=3DFCn=3F=3D?= , David Woodhouse , "David S . Miller" , Eric Snowberg , Herbert Xu , James Morris , =?us-ascii?Q?=3D=3Fiso-8859-1=3FQ=3FMicka=3DEBl?= =?us-ascii?Q?=5FSala=3DFCn=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 v8 5/5] certs: Allow root user to append signed hashes to the blacklist keyring MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 30 Mar 2022 14:44:00 +0100 Message-ID: <2937432.1648647840@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Jarkko Sakkinen wrote: > > /* > > * Initialise the blacklist > > */ > > static int __init blacklist_init(void) > > { > > const char *const *bl; > > + struct key_restriction *restriction; > >=20=20 > > if (register_key_type(&key_type_blacklist) < 0) > > panic("Can't allocate system blacklist key type\n"); > >=20=20 > > + restriction =3D kzalloc(sizeof(*restriction), GFP_KERNEL); > > + if (!restriction) > > + panic("Can't allocate blacklist keyring restriction\n"); >=20 >=20 > This prevents me from taking this to my pull request. In moderns standard= s, > no new BUG_ON(), panic() etc. should never added to the kernel. I would argue that in this case, though, it is reasonable. This should only be called during kernel initialisation and, as Micka=C3=ABl points out, if = you can't allocate that small amount of memory, the kernel isn't going to boot much further. > I missed this in my review. >=20 > This should rather be e.g. >=20 > restriction =3D kzalloc(sizeof(*restriction), GFP_KERNEL); > if (!restriction) { > pr_err("Can't allocate blacklist keyring restriction\n"); > return 0; > } You can't just return 0. That indicates success - but if by some miracle, = the kernel actually gets to a point where userspace can happen, it could mean t= hat we're missing the security restrictions of the blacklist. Now, we could defer the panic to add_key_to_revocation_list(), but if you can't set in place the required security restrictions, I think it's arguable that the kernel either needs to panic or it needs to blacklist everything. David