Received: by 10.192.165.148 with SMTP id m20csp5008065imm; Tue, 1 May 2018 07:37:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoDM/BFlAGfBU/hYvA4Ke31FQOTezPyxEAGM0QY66HhYLF+XV0d+86C2IolM/YHc2m91FBF X-Received: by 2002:a17:902:7795:: with SMTP id o21-v6mr16295257pll.8.1525185436534; Tue, 01 May 2018 07:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525185436; cv=none; d=google.com; s=arc-20160816; b=xIbLNR1ZAO0uwhXt7smgUlXsVXzPBMLRLL9w7jW0rrN96OQ5TbVk54v/BxubbZhPew F+exhVxsqK4DvG6NfBmOkH+lz+Cx4fN0RXQTftbeHfFB7qzoGBxe3wf3uuWyQAVQa2eE Jyw+nhsk+OZYxs3dYElGqYHeZbXwMrZ8BYuaR33yzKEruqNWZlt0POrkbvp9sr8TN5O5 fCvtoShIYTAwLYuxX7KRw0XTn9L6D9nNnS32yUf9AsbHN6ZDeXBZ0W9iDBoOQ77ELtPs 0bFOdHsnPWaZjvTerB9DYkhQML6HbcYm/zWjwn4My2ghijadp5g+vC4pMIsSZMKK89UH Tn/w== 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=rvYGNe/6Y9r+d3NAAxO7svE/13UTujnGPDH9dRwdRdk=; b=fg/Z60SLcoPIhuJ9VlzRaKtL8zz+d2BnxwUNLAj7E+EV/rhY9ak+g9TMRmp3V6kNqG aSz+QRMwLX15uLakgEOnEc2jqVQ+BdP4WG9iyg2qwI8ZgwzKuh+aRjxjHr4NH6XUZHpr IsdtnYyqStBr7N5VXagmiMkL9jfwV0EQymKPbKOGQrjD1QepbUgy9FeIXSY88O2RpqPr j5eN87TvvQjBYmu0h+tn6h/6GPoCK6SXaHV6QiyIQTokTd7U7+LH0lElVN/UWRqvgDsB YcI1yF6bIrhZTnABYhV1JXQDn4ttc4bQH9Dp2M4/+LlvW9rMJvZgSiIy7S+zaojiGq4z S0aw== 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 q9-v6si7754842pgt.5.2018.05.01.07.37.02; Tue, 01 May 2018 07:37:16 -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 S1756098AbeEAOgb (ORCPT + 99 others); Tue, 1 May 2018 10:36:31 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36250 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755284AbeEAOg3 (ORCPT ); Tue, 1 May 2018 10:36:29 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w41EYSrM088235 for ; Tue, 1 May 2018 10:36:28 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hpsgcsp8r-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 01 May 2018 10:36:28 -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 15:36:25 +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 15:36:19 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w41EaIH63932486; Tue, 1 May 2018 14:36:18 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 038EB4C040; Tue, 1 May 2018 15:28:30 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D09BE4C046; Tue, 1 May 2018 15:28:26 +0100 (BST) Received: from localhost.localdomain (unknown [9.80.105.194]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 1 May 2018 15:28:26 +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 10:36:14 -0400 In-Reply-To: <20180429093558.5411-3-hdegoede@redhat.com> References: <20180429093558.5411-1-hdegoede@redhat.com> <20180429093558.5411-3-hdegoede@redhat.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: 18050114-0020-0000-0000-00000417CD54 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050114-0021-0000-0000-000042ACE528 Message-Id: <1525185374.5669.49.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-01_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1805010146 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [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). > + 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. thanks, Mimi > + > + *opt_flags |= FW_OPT_NO_WARN | FW_OPT_NOCACHE | FW_OPT_NOFALLBACK; > + > + /* Already populated data member means we're loading into a buffer */ > + if (fw_priv->data) { > + id = READING_FIRMWARE_PREALLOC_BUFFER; > + max = fw_priv->allocated_size; > + } > + > + rc = efi_get_embedded_fw(fw_priv->fw_name, &fw_priv->data, &size, max); > + if (rc) { > + dev_warn(dev, "Firmware %s not in EFI\n", fw_priv->fw_name); > + return ret; > + } > + > + rc = security_kernel_post_read_file(NULL, fw_priv->data, size, id); > + if (rc) { > + if (id != READING_FIRMWARE_PREALLOC_BUFFER) { > + vfree(fw_priv->data); > + fw_priv->data = NULL; > + } > + return rc; > + } > + > + dev_dbg(dev, "using efi-embedded fw %s\n", fw_priv->fw_name); > + fw_priv->size = size; > + fw_state_done(fw_priv); > + return 0; > +}