Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1081434imm; Fri, 13 Jul 2018 11:07:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf3x9VuJwE+Vqlqgm+/dFU41Aavv11/u5scL7g9TeN21wocMHsaSwYo7MOAeRSPfDxExvRC X-Received: by 2002:a62:e0d5:: with SMTP id d82-v6mr8197905pfm.59.1531505270326; Fri, 13 Jul 2018 11:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531505270; cv=none; d=google.com; s=arc-20160816; b=CtysNsOiWUQRMo4HyEOYS3sJEwPJaqQjGN0VKiJmTaMYP1RXMWU2kWWphZPxEz/gpU M9yXckHjCZbQbpPbp4WiQKatMZCSN8kgmIpO7Eqg38YrIrCNTAXJQU/CvrTA0hxc1HP2 5Jyu/DEtngMcAiuupVkwbusp6db89UAA2FENfRjmBKowKNhZAZMU/Z0Nl5IZqgKFgZ/Y ZztjoJGTwFqcc+F0QxnRXOsUXaXILgW1dkwRBX6wCBqvIN2QAoScoXSL+W28yWUhywnR AoLJ/Y53dmi6r7MVgQjX5xUHxmo2MHnJUvl9SuoDkhOMbJdAFe4dmw6mS3OKhdLthpZd gLKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=vVWaXD0cwgTLTd5BVeSbYAI8bwIHG2hTRcao7uNmTC0=; b=Kp056j/jRJ959wp05fefTkpHe0dXvg40G3PbvKyI5pWQY2u6VokuYZtp558HblmMPM V51tdPQdewKMy1z6WCz/PY704qkdBpxDN/MsG/fdi4sAsRSUoY3Q9Ofg9NmHlHWGQjz8 hAJaftwEIPAXrmUkCoun+In2IA0NvSUkQnUni14My5fNaOafXnKBFcAXyx3izSHEgpdH j/mjSW/65YOBeNHMnOz60nhQtBpXwDpUhQCcGQDbUj+5exwWciLI4k57bJnUqaXqij+U GCfhLVQIk0BpQ8Sz1+cyKFv0CzsLWIFV5pRmokUNA3Tt5w4PxxmLXmjPPavNeVvIr/J7 N1nQ== 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 ce9-v6si25588988plb.364.2018.07.13.11.07.35; Fri, 13 Jul 2018 11:07:50 -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 S2387771AbeGMSWV (ORCPT + 99 others); Fri, 13 Jul 2018 14:22:21 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48634 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387717AbeGMSWU (ORCPT ); Fri, 13 Jul 2018 14:22:20 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6DI4FEH071605 for ; Fri, 13 Jul 2018 14:06:38 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k6yvf2r34-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 13 Jul 2018 14:06:38 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Jul 2018 19:06:35 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 13 Jul 2018 19:06:32 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6DI6VEq41418796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 13 Jul 2018 18:06:31 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F55B42045; Fri, 13 Jul 2018 21:06:52 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBDF342041; Fri, 13 Jul 2018 21:06:50 +0100 (BST) Received: from dhcp-9-31-103-18.watson.ibm.com (unknown [9.31.103.18]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 13 Jul 2018 21:06:50 +0100 (BST) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Mimi Zohar , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis R . Rodriguez" , Eric Biederman , kexec@lists.infradead.org, Andres Rodriguez , Greg Kroah-Hartman , "Luis R . Rodriguez" , Stephen Boyd , Bjorn Andersson , Ard Biesheuvel Subject: [PATCH v6 8/8] ima: based on policy warn about loading firmware (pre-allocated buffer) Date: Fri, 13 Jul 2018 14:06:03 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1531505163-20227-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1531505163-20227-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18071318-0016-0000-0000-000001E691DB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071318-0017-0000-0000-0000323B2F85 Message-Id: <1531505163-20227-9-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-13_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=5 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807130159 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some systems are memory constrained but they need to load very large firmwares. The firmware subsystem allows drivers to request this firmware be loaded from the filesystem, but this requires that the entire firmware be loaded into kernel memory first before it's provided to the driver. This can lead to a situation where we map the firmware twice, once to load the firmware into kernel memory and once to copy the firmware into the final resting place. To resolve this problem, commit a098ecd2fa7d ("firmware: support loading into a pre-allocated buffer") introduced request_firmware_into_buf() API that allows drivers to request firmware be loaded directly into a pre-allocated buffer. Do devices using pre-allocated memory run the risk of the firmware being accessible to the device prior to the completion of IMA's signature verification any more than when using two buffers? (Refer to mailing list discussion[1]). Only on systems with an IOMMU can the access be prevented. As long as the signature verification completes prior to the DMA map is performed, the device can not access the buffer. This implies that the same buffer can not be re-used. Can we ensure the buffer has not been DMA mapped before using the pre-allocated buffer? [1] https://lkml.org/lkml/2018/7/10/56 Signed-off-by: Mimi Zohar Cc: Luis R. Rodriguez Cc: Stephen Boyd Cc: Bjorn Andersson Cc: Ard Biesheuvel --- Changelog v6: - Change warning to comment. Changelog v5: - Instead of preventing loading firmware from a pre-allocate buffer, emit a warning. security/integrity/ima/ima_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index ef349a761609..b82500cd6fbd 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -429,6 +429,14 @@ void ima_post_path_mknod(struct dentry *dentry) */ int ima_read_file(struct file *file, enum kernel_read_file_id read_id) { + /* + * READING_FIRMWARE_PREALLOC_BUFFER + * + * Do devices using pre-allocated memory run the risk of the + * firmware being accessible to the device prior to the completion + * of IMA's signature verification any more than when using two + * buffers? + */ return 0; } -- 2.7.5