Received: by 10.192.165.148 with SMTP id m20csp4837353imm; Tue, 24 Apr 2018 09:08:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/faT84uF35B6PSY7BGIdhrUrs+JHLhtIMOWITpbQtAM1vMKmviz6VoFAb10/0Ae6ff6PYs X-Received: by 2002:a17:902:1682:: with SMTP id h2-v6mr20466186plh.127.1524586138573; Tue, 24 Apr 2018 09:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524586138; cv=none; d=google.com; s=arc-20160816; b=pZzQwGTCp6Avxo7q1SHUfZ66JDauy42WM74QQxBsb/plDlEJzmUkkH4u+1SObB+gEy 4HG7iR97w9oQJYcSQyWvAVe2xpGMJJDkcknNJQ23VDLg85TzGBQPEvpdB1rctc2yDqij 0DYPPQDjEYQ2TPYaE0uSJM44a1QsaauL5askcV+LLOqyadAZ7rkWKlU4D1kKQ+VIm6VL znjG2CyDsuuUiC4PLo5lIZs27ZK3JVGsoyT3UrXqYxbNzKipXnlAsIC1JC7i+NgjE+LA DVb581iWE3S8/M2SygX0+C4W7kGWWoL9rnwkq6apJFzu8VWXIc4EKglC2n7El6pg1TOA MYUw== 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=iNqEB40QbE2HWEbUkBVQgCwP0S8hDHwcy5gURElcwDs=; b=0SYpRTCARa+3cxEufxtJBVrnZvpRFPaeRMku+6fBZ7tAMd3tScsC4v+G5abi7Qde+q pJikqdxjq9IjISdN6ucQnXCm+RVCz8TnDXEv1GEGrPDTgje6wHCZrJDFjkYbP5CR74cL bOJ2NjT150FGCyQV9I6QFrU0ZCbqxQhB015PyOTUd3qcWbPoAXFqRnD1R6Bz5ZbeZ9NW HDKlnzRzuRLOIhtrIb8LjwBArk2MFsMeG4Kc5jOwGyuQBBdYzpQq4DlZJIv0pbbu3PM1 +pjwhii5ln+uRNNoDtfhbw8iAgQf6UaJUm8IZILyK2rG/n4UXzrfAj/P2hqOopOSsosR PudA== 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 m20si2415911pgc.209.2018.04.24.09.08.43; Tue, 24 Apr 2018 09:08:58 -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 S1752141AbeDXQH3 (ORCPT + 99 others); Tue, 24 Apr 2018 12:07:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58880 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752049AbeDXQHY (ORCPT ); Tue, 24 Apr 2018 12:07:24 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3OG2BaD041393 for ; Tue, 24 Apr 2018 12:07:23 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hj522t5hb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 24 Apr 2018 12:07:21 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Apr 2018 17:07:14 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 24 Apr 2018 17:07:07 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3OG77Lv10158540; Tue, 24 Apr 2018 16:07:07 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6FDAAE04D; Tue, 24 Apr 2018 16:56:49 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18011AE053; Tue, 24 Apr 2018 16:56:45 +0100 (BST) Received: from localhost.localdomain (unknown [9.80.105.184]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 24 Apr 2018 16:56:44 +0100 (BST) Subject: Re: [PATCH v3 2/5] efi: Add embedded peripheral firmware support From: Mimi Zohar To: Hans de Goede , "Luis R. Rodriguez" , Kees Cook Cc: Darren Hart , Andy Shevchenko , Ard Biesheuvel , Greg Kroah-Hartman , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, 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 , x86@kernel.org, linux-efi@vger.kernel.org Date: Tue, 24 Apr 2018 12:07:01 -0400 In-Reply-To: <71e6a45a-398d-b7a4-dab0-8b9936683226@redhat.com> References: <20180408174014.21908-1-hdegoede@redhat.com> <20180408174014.21908-3-hdegoede@redhat.com> <20180423211143.GZ14440@wotan.suse.de> <71e6a45a-398d-b7a4-dab0-8b9936683226@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: 7bit X-TM-AS-GCONF: 00 x-cbid: 18042416-0040-0000-0000-000004326A53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042416-0041-0000-0000-000026369A0B Message-Id: <1524586021.3364.20.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-24_04:,, 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=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804240153 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-04-24 at 17:09 +0200, Hans de Goede wrote: > Hi, > > On 23-04-18 23:11, Luis R. Rodriguez wrote: > > Hans, please see use of READING_FIRMWARE_PREALLOC_BUFFER, we'll need a new ID > > and security for this type of request so IMA can reject it if the policy is > > configured for it. > > Hmm, interesting, actually it seems like the whole existence > of READING_FIRMWARE_PREALLOC_BUFFER is a mistake, the IMA > framework really does not care if we are loading the firmware > into memory allocated by the firmware-loader code, or into > memory allocated by the device-driver requesting the firmware. > > As such the current IMA code (from v4.17-rc2) actually does > not handle READING_FIRMWARE_PREALLOC_BUFFER at all, Right, it doesn't yet address READING_FIRMWARE_PREALLOC_BUFFER, but should. Depending on whether the device requesting the firmware has access to the DMA memory, before the signature verification, will determine how IMA-appraisal addresses READING_FIRMWARE_PREALLOC_BUFFER. Mimi > here > are bits of code from: security/integrity/ima/ima_main.c: > > static int read_idmap[READING_MAX_ID] = { > [READING_FIRMWARE] = FIRMWARE_CHECK, > [READING_MODULE] = MODULE_CHECK, > [READING_KEXEC_IMAGE] = KEXEC_KERNEL_CHECK, > [READING_KEXEC_INITRAMFS] = KEXEC_INITRAMFS_CHECK, > [READING_POLICY] = POLICY_CHECK > }; > > int ima_post_read_file(struct file *file, void *buf, loff_t size, > ... > if (!file && read_id == READING_FIRMWARE) { > if ((ima_appraise & IMA_APPRAISE_FIRMWARE) && > (ima_appraise & IMA_APPRAISE_ENFORCE)) > return -EACCES; /* INTEGRITY_UNKNOWN */ > return 0; > } > > Which show that the IMA code is not handling > READING_FIRMWARE_PREALLOC_BUFFER as it should (I believe it > should handle it the same as READING_FIRMWARE). > > Now we could fix that, but the only user of > READING_FIRMWARE_PREALLOC_BUFFER is the code which originally > introduced it: > > https://patchwork.kernel.org/patch/9162011/ > > So I believe it might be better to instead replace it > with just READING_FIRMWARE and find another way to tell > kernel_read_file() that there is a pre-allocated buffer, > perhaps the easiest way there is that *buf must be > NULL when the caller wants kernel_read_file() to > vmalloc the mem. This would of course require auditing > all callers that the buf which the pass in is initialized > to NULL. > > Either way adding a third READING_FIRMWARE_FOO to the > kernel_read_file_id enum seems like a bad idea, from > the IMA pov firmware is firmware. > > What this whole exercise has shown me though is that > I need to call security_kernel_post_read_file() when > loading EFI embedded firmware. I will add a call to > security_kernel_post_read_file() for v4 of the patch-set. > > > Please Cc Kees in future patches. > > Will do. > > Regards, > > Hans >