Received: by 10.192.165.148 with SMTP id m20csp5298991imm; Tue, 1 May 2018 12:29:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrfu9K8FWub4Uv0AiuLjx61p2fXgU5QMB2BRT/6270uWgMBfiphbnOTlySQxCncw5CSFuuH X-Received: by 2002:a17:902:d20a:: with SMTP id t10-v6mr17237570ply.364.1525202963053; Tue, 01 May 2018 12:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525202963; cv=none; d=google.com; s=arc-20160816; b=S5OVcEPm45mYEF4HIZEq5YhlG4NZ8ct0zLLl+xnTq4FGuEVFqIg4SHAyRGaDGB4DGL OdlOuQDexQEYQcmYHgQZf8d6vAQsb9PHrmz78uPphRx01h+KB55mwaO50tBb4n5/RTvp jbve7oXX7mrJfKOf165Pfklfz7KNa8HYwaGEKEpskMWjGBsU/WRziKTsesGjBXUSZ3Ek fHJUOoM21ksiWzaT689fqlEXba2cW+Jhq93EBYog/Yr9a1un4TbQJqV6hz8oOe2IOMTb GNoTjtPfutp0IqKzuuX7tQHp27JQZA4cOoReDWU5V1CK61/+kWqrX/fPbkLnVFHEjD1D 6bFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject :arc-authentication-results; bh=v+n4Lxehqca6ZNWU7pECzPqTC4SvY42XoFYoPMXuXQc=; b=RFWMDJT7lfCDAzrczpBZyseCY6ab92Vu0oL1EQjEElRIeSHuM3DpozUESNSpaSzwqc 8qsDjf041bmFuUQwEfM6orRhQ+SWUmSWkMr2nRyXrn7QFXsZ9dIG3PiWu6E2OT0NKaxF InYh0XSobPPSKVphdjZzvpU1f+2+H2DYU/C03kSgrTcX/F7Y1Hh0/647oXQfvUiKNPC7 npxDfsV6HWK6S+S4zE9ywmCT3ClvCvd60tEf5hA7IpK0G3DKFRljN8i/X7/65TmoxyNK wIYYJYY1Dfbq/+0IlEp4OyVaNyeCgqpzYhHk9t7+y4p9Y1ib3rhDo8v81tN/2gkOF4mJ 6HGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y25si1559326pfn.248.2018.05.01.12.29.08; Tue, 01 May 2018 12:29:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751134AbeEAT1q (ORCPT + 99 others); Tue, 1 May 2018 15:27:46 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34364 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbeEAT1n (ORCPT ); Tue, 1 May 2018 15:27:43 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w41JQoHj005945 for ; Tue, 1 May 2018 15:27:43 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hpsmec1p7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 01 May 2018 15:27:42 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 1 May 2018 20:27:39 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 1 May 2018 20:27:31 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w41JRVV85964120; Tue, 1 May 2018 19:27:31 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A70911C058; Tue, 1 May 2018 20:19:07 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D68B511C050; Tue, 1 May 2018 20:19:04 +0100 (BST) Received: from dhcp-9-2-55-83.watson.ibm.com (unknown [9.2.55.83]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 1 May 2018 20:19:04 +0100 (BST) Subject: Re: [PATCH v5 2/5] efi: Add embedded peripheral firmware support From: Mimi Zohar To: Hans de Goede , Ard Biesheuvel , "Luis R . Rodriguez" , Greg Kroah-Hartman , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: Peter Jones , Dave Olsthoorn , Will Deacon , Andy Lutomirski , Matt Fleming , David Howells , Josh Triplett , dmitry.torokhov@gmail.com, mfuzzey@parkeon.com, Kalle Valo , Arend Van Spriel , Linus Torvalds , nbroeking@me.com, bjorn.andersson@linaro.org, Torsten Duwe , Kees Cook , x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module Date: Tue, 01 May 2018 15:27:27 -0400 In-Reply-To: References: <20180429093558.5411-1-hdegoede@redhat.com> <20180429093558.5411-3-hdegoede@redhat.com> <1525185374.5669.49.camel@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18050119-0020-0000-0000-00000417DCCF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050119-0021-0000-0000-000042ACF576 Message-Id: <1525202847.5669.64.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-01_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805010187 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-05-01 at 21:11 +0200, Hans de Goede wrote: > Hi, > > On 01-05-18 16:36, Mimi Zohar wrote: > > [Cc'ing linux-security] > > > > On Sun, 2018-04-29 at 11:35 +0200, Hans de Goede wrote: > > [...] > >> diff --git a/drivers/base/firmware_loader/fallback_efi.c b/drivers/base/firmware_loader/fallback_efi.c > >> new file mode 100644 > >> index 000000000000..82ba82f48a79 > >> --- /dev/null > >> +++ b/drivers/base/firmware_loader/fallback_efi.c > >> @@ -0,0 +1,51 @@ > >> +// SPDX-License-Identifier: GPL-2.0 > >> + > >> +#include > >> +#include > >> +#include > >> +#include > >> + > >> +#include "fallback.h" > >> +#include "firmware.h" > >> + > >> +int fw_get_efi_embedded_fw(struct device *dev, struct fw_priv *fw_priv, > >> + enum fw_opt *opt_flags, int ret) > >> +{ > >> + enum kernel_read_file_id id = READING_FIRMWARE; > > > > Please define a new kernel_read_file_id for this (eg. > > READING_FIRMWARE_EFI_EMBEDDED). > > Are you sure, I wonder how useful it is to add a new > kernel_read_file_id every time a new way to get firmware > comes up? > > I especially wonder about the sense in adding a new id > given that the quite old FIRMWARE_PREALLOC_BUFFER is > still not supported / checked properly by the security code. I posted patches earlier today[1], which address this.  Patch 5/6 just makes it equivalent to READING_FIRMWARE.  Patch 6/6 questions whether the device has access to the pre-allocated buffer *before* the signature has been verified. [1] kernsec.org/pipermail/linux-security-module-archive/2018-May/006639.html > > Anyways I can add a new id if you want me to, what about > when fw_get_efi_embedded_fw is reading into a driver allocated > buffer, do you want a separate EADING_FIRMWARE_EFI_EMBEDDED_PREALLOC_BUFFER > for that ? Without the kernel being able to verify the firmware's signature, I'm not sure it makes much of a difference. > > > > >> + size_t size, max = INT_MAX; > >> + int rc; > >> + > >> + if (!dev) > >> + return ret; > >> + > >> + if (!device_property_read_bool(dev, "efi-embedded-firmware")) > >> + return ret; > > > > Instead of calling security_kernel_post_read_file(), either in > > device_property_read_bool() or here call security_kernel_read_file(). > > > > The pre read call is for deciding whether to allow this call > > independent of the firmware being loaded, whereas the post security > > call is currently being used by IMA-appraisal for verifying a > > signature.  There might be other LSMs using the post hook as well.  As > > there is no kernel signature associated with this firmware, use the > > security pre read_file hook. > > Only the pre hook? I believe the post-hook should still be called too, > right? So that we've hashes of all loaded firmwares in the IMA core. Good catch!  Right, if IMA-measurement is enabled, then we would want to add the measurement. Mimi