Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1581303pxb; Wed, 2 Feb 2022 08:04:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1P/BQO78t3miYGjX60GbxW08VeZhftFtTB9TYUaWaex8Ed7W0P8Dyn0WLx8cehyWGcVQj X-Received: by 2002:a63:1d4:: with SMTP id 203mr15856898pgb.462.1643817885289; Wed, 02 Feb 2022 08:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643817885; cv=none; d=google.com; s=arc-20160816; b=NNMTZKMIMa/tP4irP6bcbvbzq/wpB7+TBTc7GRGzOiQnPTu8qexBWWVkNRzKAmSHWr e1ExOw0ey0c2Oabx4WtSlZP5C8evnt7QkmvyTo5k0bFAPlQCoVjgDh69/ZLbkSjSkU25 YU+2XplslN//hBGuVqz+RRt5hpK+S7rihv5Sd/522PlsZHWVe179ryJ1WLTaVuhgx0MA HyZzkpcl0kuiF2JcSaq6Qfbc+b2Ih6OjO1nYC1jSmjxDClNYfWCDxonP0Se4NNcRofv8 kYuPQrsW4iT5AtALbRuYkQOp8ZvYIxZZM4gTcUYOKFj0BtNmELlGlaS2JosUKv4fvaUt z3PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=/L7LgOqBnUWKyovGdW9Yyvs7GhfLMvadBzkskdLQKG0=; b=Rcdc9wXr+NObxMwR6X4A2NKDM5YIBSNf7gCp1/hxayRefTPa2v+j02g903VU2l3uu8 cM8dsgdR1QDB8NxTTtg1BtfDEhjAuw2uWdQ0v0R4rZDsoG38jo+feo+17QZecexCua6K vHwmVhAwTZ6zyL/PFo+cuXyrvAFREnXNrKi2EHPQxLIQBK3D0c73XfbYweWD6iVm4p+5 OV0zq6i4p64+RZPiZSQITDiYcb/Tin9D0gNEVMpHHMytC7ZBIYlul9DUT2fpL8eA/OMB vOZKBsXVbXSUTsFTyzlEBHoWGk2MY/H/4zWjOMUd4lf7AGz2MSTnKiNnLpjcNmYH7ZiL g+fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=kInV1hwU; 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=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k26si23020467pgm.320.2022.02.02.08.04.31; Wed, 02 Feb 2022 08:04:45 -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=@ibm.com header.s=pp1 header.b=kInV1hwU; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345337AbiBBPJb (ORCPT + 99 others); Wed, 2 Feb 2022 10:09:31 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:27646 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231908AbiBBPJa (ORCPT ); Wed, 2 Feb 2022 10:09:30 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 212DK5dS012616; Wed, 2 Feb 2022 15:09:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=/L7LgOqBnUWKyovGdW9Yyvs7GhfLMvadBzkskdLQKG0=; b=kInV1hwU5kAwk6ywy95F+7svUiu2lATh8cw8EPJAX60kwK+1SOVxNCC6HTgjzYq4pgX7 ILngONIfUeWt7FajEf5kpeOaSwv23onvwAQ1YCyRYqTg1X4YmUXFhjWanCTSQmB2RFL2 hJo3GQCzDfX5s/3tw/+ZoMCel+cZ3aIsONil9EasG8P4C4LkOiA19V0ceCfv4TWYrhnT O/AwcMeWgmDQZsPhKRKA5zEXS1LvpZ3CsS4DCAbNaqUsnRMW13gkE1UpJoYAxhdJpi6r 3hZhdjnnW8v0xvXM1TK9oiWh3MV4uD2zjbdw5OQwvASHa2lekVgO04TAXy587BNQphUX kA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dyr2ce17h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Feb 2022 15:09:15 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 212DWSHw009862; Wed, 2 Feb 2022 15:09:14 GMT Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dyr2ce16y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Feb 2022 15:09:14 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 212F2nja021440; Wed, 2 Feb 2022 15:09:13 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma04dal.us.ibm.com with ESMTP id 3dvw7brrfp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Feb 2022 15:09:13 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 212F9Awu35848628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Feb 2022 15:09:11 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD67428065; Wed, 2 Feb 2022 15:09:10 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD93228059; Wed, 2 Feb 2022 15:09:04 +0000 (GMT) Received: from [9.65.240.79] (unknown [9.65.240.79]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 2 Feb 2022 15:09:04 +0000 (GMT) Message-ID: Date: Wed, 2 Feb 2022 17:09:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v7 4/5] efi: Load efi_secret module if EFI secret area is populated Content-Language: en-US To: Gerd Hoffmann 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, Dov Murik References: <20220201124413.1093099-1-dovmurik@linux.ibm.com> <20220201124413.1093099-5-dovmurik@linux.ibm.com> <20220202084723.ushasiekb3cxami4@sirius.home.kraxel.org> <20220202143128.jgadmr7tzetlobt7@sirius.home.kraxel.org> From: Dov Murik In-Reply-To: <20220202143128.jgadmr7tzetlobt7@sirius.home.kraxel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Dzdajyehst2K1ofnbMtB5uQv7AKyejMc X-Proofpoint-ORIG-GUID: -oktOVuqy-KseV4GOevec6u13hg_4yEt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-02_07,2022-02-01_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202020084 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/02/2022 16:31, Gerd Hoffmann wrote: > 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 ... > Note that the AmdSev build of OVMF always publishes LINUX_EFI_COCO_SECRET_TABLE_GUID in the EFI table. Even when LAUNCH_SECRET was not executed. In such cases the secret area will be empty. If we keep only the 'efi.coco_secret != EFI_INVALID_TABLE_ADDR' check, we'll get errors from efi_secret for every VM launch that doesn't undergo LAUNCH_SECRET. I don't think that's good. If we *do* want to check that the area starts with EFI_SECRET_TABLE_HEADER_GUID (like I think we should), we need all the checks before that, like checking that the area is big enough, and that all the memremap()s succeed -- before actually comparing the header_guid. The checks are basically prerequisites for calling efi_guidcmp() safely. -Dov