Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1491168pxb; Thu, 16 Sep 2021 08:32:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqaEYhDIb+fCOa/TTb3XgTMbcRUFPP3ww9OLxwar3izXoMkaTghnbr19P37g8K42JHP5XW X-Received: by 2002:a17:906:3ed2:: with SMTP id d18mr7108338ejj.311.1631806360011; Thu, 16 Sep 2021 08:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631806360; cv=none; d=google.com; s=arc-20160816; b=sPnt7rHB7pv0sZdOQYgWS/tX7IOcK9Ma25u/+Sk/PEmewMqGY6r6Lfs/3af3TqTqHM q0Nua/kan/QA4OKX1TxcqK2p/x/9woJQ5cG+VBzPS8Uppbo91tWRO3DiXKdHOyQK+81I 5HJRfSgFNBYj0xU/dzMRvQwkH4s4E55X7/ISUu/cjboUpOreYakjZUWissPbIo0OEfaN u6MUnE+cw7nH27ASZosSjFyvvgIQ1LL0QmgUYEaNxetu7HoMBuJVxynTc8bXB3ofDjUr tnGTQNdPafZCmUZSoJUmFrssN/EpT4PoQkJdkiF+0sb5lor5YqHIljz3ezuzD4s5hFwH JYDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=tPdEopHtIwND5eI4dBXdvKLn9GgDIgKGXMMU4DIGVps=; b=O3W/zm20LWBFnoyiL2xK8YzINN7EjGc7jWOZ3FMz4PCwzbopuBB6ieWr7N2uTUrgVO rk4gcfKzPR6XkVAY1zCUbbMV/oy66PlhulN/J3nlrxsQQJ2ApsRy0QEbzLqbnxG7xRwz Vs9WY4+Q0x/r/XuStNjAycVQLNb5s9kCqFh3HDUS5kBAEoCoD9aK8w2ZQUcAFjMV+1/f a0C8Fb9RRXiW5wbb4a7gf+oVgEoT8sTcVbjjHqT8USNBsRpia6JD3NVTe8yk1jE26hlB l0aVzUGEtMF9z4DoBXsGUMvnOAewk23/kYJaCOoiN5SS5ass4VTARYjtWRFzONYn1CZ2 DWQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hxw7DtFO; 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 e11si3622234edj.557.2021.09.16.08.32.08; Thu, 16 Sep 2021 08:32:39 -0700 (PDT) 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=hxw7DtFO; 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 S239084AbhIPPRN (ORCPT + 99 others); Thu, 16 Sep 2021 11:17:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:42136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239101AbhIPPRN (ORCPT ); Thu, 16 Sep 2021 11:17:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D21260296; Thu, 16 Sep 2021 15:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631805352; bh=iOcCI1FHoB0yx/LZeXXa3I2QwmbANkTrrP6vNXsEUw4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=hxw7DtFO8S32GjJYJC0FktMBCncrxCACfS1q3EoiosYBTPIvVQ690Fg7xYbP0VvQ8 VWUqLGv5juTWxi+/FuLFoHxaLXtqpm8ZJtrVvZil5OVmMoEQDDNe5Oluw6Oa/OKrHU Or3HdOnQ41AbTQWipSCnD//Sh74OchHguokf1/063NZn0u4G9q6ihaZrNNYwKS/Epj iyZtkl6TTj7jWNaG1uLykwTEj950NFR9x3/WFso3Cp0eBOdB5/O/4N4l1gSFEtQclU jne8WE3thfzVdZ2gZj1mjfxb/y2u8ipVlEPkKyitLSL2Z93ywFPOMNGjJxjZVipHRG oTJT/egmzLzgQ== Message-ID: Subject: Re: [PATCH v6 00/13] Enroll kernel keys thru MOK From: Jarkko Sakkinen To: Eric Snowberg Cc: keyrings@vger.kernel.org, linux-integrity@vger.kernel.org, zohar@linux.ibm.com, dhowells@redhat.com, dwmw2@infradead.org, herbert@gondor.apana.org.au, davem@davemloft.net, jmorris@namei.org, serge@hallyn.com, keescook@chromium.org, gregkh@linuxfoundation.org, torvalds@linux-foundation.org, scott.branden@broadcom.com, weiyongjun1@huawei.com, nayna@linux.ibm.com, ebiggers@google.com, ardb@kernel.org, nramas@linux.microsoft.com, lszubowi@redhat.com, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, "konrad.wilk@oracle.com" Date: Thu, 16 Sep 2021 18:15:50 +0300 In-Reply-To: References: <20210914211416.34096-1-eric.snowberg@oracle.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, 2021-09-15 at 15:28 -0600, Eric Snowberg wrote: > > On Sep 15, 2021, at 11:57 AM, Jarkko Sakkinen wrote= : > >=20 > > On Tue, 2021-09-14 at 17:14 -0400, Eric Snowberg wrote: > > > Back in 2013 Linus requested a feature to allow end-users to have the= =20 > > > ability "to add their own keys and sign modules they trust". This was > > > his *second* order outlined here [1]. There have been many attempts= =20 > > > over the years to solve this problem, all have been rejected. Many= =20 > > > of the failed attempts loaded all preboot firmware keys into the kern= el, > > > including the Secure Boot keys. Many distributions carry one of these= =20 > > > rejected attempts [2], [3], [4]. This series tries to solve this prob= lem=20 > > > with a solution that takes into account all the problems brought up i= n=20 > > > the previous attempts. > > >=20 > > > On UEFI based systems, this series introduces a new Linux kernel keyr= ing=20 > > > containing the Machine Owner Keys (MOK) called machine. It also defin= es > > > a new MOK variable in shim. This variable allows the end-user to deci= de=20 > > > if they want to load MOK keys into the machine keyring. Mimi has sugg= ested=20 > > > that only CA keys contained within the MOK be loaded into the machine= =20 > > > keyring. All other certs will load into the platform keyring instead. > > >=20 > > > By default, nothing changes; MOK keys are not loaded into the machine > > > keyring. They are only loaded after the end-user makes the decision= =20 > > > themselves. The end-user would set this through mokutil using a new= =20 > > > --trust-mok option [5]. This would work similar to how the kernel use= s=20 > > > MOK variables to enable/disable signature validation as well as use/i= gnore=20 > > > the db. Any kernel operation that uses either the builtin or secondar= y=20 > > > trusted keys as a trust source shall also reference the new machine= =20 > > > keyring as a trust source. > > >=20 > > > Secure Boot keys will never be loaded into the machine keyring. They > > > will always be loaded into the platform keyring. If an end-user want= ed=20 > > > to load one, they would need to enroll it into the MOK. > > >=20 > > > Steps required by the end user: > > >=20 > > > Sign kernel module with user created key: > > > $ /usr/src/kernels/$(uname -r)/scripts/sign-file sha512 \ > > > machine_signing_key.priv machine_signing_key.x509 my_module.ko > > >=20 > > > Import the key into the MOK > > > $ mokutil --import machine_signing_key.x509 > > >=20 > > > Setup the kernel to load MOK keys into the .machine keyring > > > $ mokutil --trust-mok > > >=20 > > > Then reboot, the MokManager will load and ask if you want to trust th= e > > > MOK key and enroll the MOK into the MOKList. Afterwards the signed k= ernel > > > module will load. > > >=20 > > > I have included links to both the mokutil [5] and shim [6] changes I > > > have made to support this new functionality. > >=20 > > How hard it is to self-compile shim and boot it with QEMU (I > > do not know even the GIT location of Shim)? >=20 > It is not hard, that is the setup I use for my testing. Upstream shim= =20 > is located here [1]. Or you can use my repo which contains the necessary > changes [2]. >=20 > [1] https://github.com/rhboot/shim > [2] https://github.com/esnowberg/shim/tree/mokvars-v2 >=20 So, my 2nd Q would be: which order these should be upstreamed? Linux patch set cannot depend on "yet to be upstreamed" things. Code changes look good enough to me. /Jarkko