Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1824288pxb; Wed, 2 Feb 2022 13:22:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzufGYPbAWVnbIHsjgZZvb/0IWg7azmOlIDSGju5fUUAVpVGjlXPRSNEOfT1Q6GQTiqQNRS X-Received: by 2002:a05:6402:b64:: with SMTP id cb4mr10880268edb.453.1643836975140; Wed, 02 Feb 2022 13:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643836975; cv=none; d=google.com; s=arc-20160816; b=jNyHaQaiO4JATnPUPhnbjqjBK6Gmb6fJx5Ew26eiRKp3W7HI5NzZjdav1pSLCylLlN 5gtSewtGy5fcL8JyHXD7HSuEfEHQ3cHaKcpyMCtptm6LLxl+tlVCpt2cX1Mhco+BegFt abQrIsD1/toKg/5umrR7chmjT6S0jrT4jHNkD6X1jt/pAly2v0T3dL7YuOJakqrZCJt5 sLEe2j/XMIl5fpAObo87kVvE+f7PTihGqSakLinnwHPW15PC+WTBp4yzM33xwZZHIY83 zZrCXQqS0WywC2+Dwt+7f6cQiCEG81h6h1SHoq8TcD+6qXZLLPKg5WwwrFsoKFI35sLN cIeA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MyaJSjL0Dz4PWQLKWTTGsW9XoK3E6CFP4+bGWUvW21Q=; b=aKq0oRzpz1o7e50VT5N71/l1iKkADa14DGD9ohlmIlCNpzutVvm3JxP2N3AZM+ySoM 2W91NWF0a+D7soWUGUGoJ2qHyDJETExz9jKiubCEL06VNvma06xkA6s3my+GYQ7lSOdF JIIfcSXpnbgkqS3lWT8gCxOZ7Ps6mueoHXmnpqYfhrPlvKzgbGPvjNdavby20/Zk/Dnx fGT9Kr5FSscARjEfw8jZbgIevrnjodD+rula/EaLL6rIV6eMJfkGoifc4+jK0+CckfmG +kN/yL0HyaTuNrpr/Lf//keFAVBieFhZHIpw3nWz0CizZoVXbCEmzK0bOfp57CbiXBdr gPdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BljXGuv+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 cr11si6354522ejc.665.2022.02.02.13.22.28; Wed, 02 Feb 2022 13:22:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=BljXGuv+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S1344992AbiBBObl (ORCPT + 99 others); Wed, 2 Feb 2022 09:31:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56012 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbiBBObk (ORCPT ); Wed, 2 Feb 2022 09:31:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643812299; 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: in-reply-to:in-reply-to:references:references; bh=MyaJSjL0Dz4PWQLKWTTGsW9XoK3E6CFP4+bGWUvW21Q=; b=BljXGuv+HB2tCEZiXn3Tuyghocf7fD7Ayw0F+aU0mlWKiNbN29Zr3nfnVHQtQzfVEpprYa +ZxB3y4eG3T74FeF1vdbR7KVdOPnRMXi0WL9WliLGrkLLwPgTtzE+OP0thBHB9UjbcSfHB h8uBHMqfybuMX3d+1CNC3dxSPB0lEOQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-466-zZTGoK3OOuqJAf2vIECu4Q-1; Wed, 02 Feb 2022 09:31:36 -0500 X-MC-Unique: zZTGoK3OOuqJAf2vIECu4Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3BA44801B26; Wed, 2 Feb 2022 14:31:32 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAB1E57F2D; Wed, 2 Feb 2022 14:31:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 69AE51800397; Wed, 2 Feb 2022 15:31:28 +0100 (CET) Date: Wed, 2 Feb 2022 15:31:28 +0100 From: Gerd Hoffmann To: Dov Murik Cc: linux-efi@vger.kernel.org, Borislav Petkov , Ashish Kalra , Brijesh Singh , Tom Lendacky , Ard Biesheuvel , James Morris , "Serge E. Hallyn" , Andi Kleen , Greg KH , Andrew Scull , Dave Hansen , "Dr. David Alan Gilbert" , Lenny Szubowicz , Peter Gonda , James Bottomley , Tobin Feldman-Fitzthum , Jim Cadden , Daniele Buono , linux-coco@lists.linux.dev, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 4/5] efi: Load efi_secret module if EFI secret area is populated Message-ID: <20220202143128.jgadmr7tzetlobt7@sirius.home.kraxel.org> References: <20220201124413.1093099-1-dovmurik@linux.ibm.com> <20220201124413.1093099-5-dovmurik@linux.ibm.com> <20220202084723.ushasiekb3cxami4@sirius.home.kraxel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 02, 2022 at 01:08:43PM +0200, Dov Murik wrote: > > > On 02/02/2022 10:47, Gerd Hoffmann wrote: > > On Tue, Feb 01, 2022 at 12:44:12PM +0000, Dov Murik wrote: > >> If the efi_secret module is built, register a late_initcall in the EFI > >> driver which checks whether the EFI secret area is available and > >> populated, and then requests to load the efi_secret module. > > > >> + area = memremap(efi.coco_secret, sizeof(*area), MEMREMAP_WB); > >> + if (!area) { > >> + pr_err("Failed to map confidential computing secret area descriptor\n"); > >> + return -ENOMEM; > >> + } > >> + if (!area->base_pa || area->size < sizeof(*header_guid)) > >> + goto unmap_desc; > >> + > >> + header_guid = (void __force *)ioremap_encrypted(area->base_pa, sizeof(*header_guid)); > >> + if (!header_guid) { > >> + pr_err("Failed to map secret area\n"); > >> + ret = -ENOMEM; > >> + goto unmap_desc; > >> + } > >> + if (efi_guidcmp(*header_guid, EFI_SECRET_TABLE_HEADER_GUID)) > >> + goto unmap_encrypted; > > > > Why these sanity checks are here and not in the efi_secret module? > > The same checks indeed appear in the efi_secret module (see in patch 3: > efi_secret_map_area() and the beginning of efi_secret_securityfs_setup()). > > However, in the efi_secret module, the checks are noisy, because they > expect the secret area to be populated. For example: > > + if (efi.coco_secret == EFI_INVALID_TABLE_ADDR) { > + pr_err("Secret area address is not available\n"); > + return -EINVAL; > + } Note I explicitly excluded that check ;) Checking whenever efi.coco_secret looks valid and only try load efi_secret if that is the case (and otherwise stay silent) makes perfect sense. The other checks should be dropped IMHO. > Another approach could be to just try to load the module anyway, and > the module will fail (silently? noisily?) if there's no designated > secret area or it's not populated. I feel that will be harder to > understand what's going on. I think the module should fail noisily. See above for autoload. In case the module is loaded (either manually by the admin, or because efi.coco_secret != EFI_INVALID_TABLE_ADDR) and it can't actually load the secrets we want know why ... take care, Gerd