From patchwork Thu Jul 6 12:14:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 9828107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A2F3460361 for ; Thu, 6 Jul 2017 12:15:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90BC5283A5 for ; Thu, 6 Jul 2017 12:15:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8210B2863D; Thu, 6 Jul 2017 12:15:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45F48283A5 for ; Thu, 6 Jul 2017 12:15:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752256AbdGFMP2 (ORCPT ); Thu, 6 Jul 2017 08:15:28 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40812 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751952AbdGFMP0 (ORCPT ); Thu, 6 Jul 2017 08:15:26 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v66CE15j014276 for ; Thu, 6 Jul 2017 08:15:26 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bhm96t4dw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 06 Jul 2017 08:15:25 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Jul 2017 22:15:23 +1000 Received: from d23relay06.au.ibm.com (202.81.31.225) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 6 Jul 2017 22:15:21 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v66CE5u161669572; Thu, 6 Jul 2017 22:14:05 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v66CDvKv019002; Thu, 6 Jul 2017 22:13:57 +1000 Received: from localhost.localdomain ([9.80.82.146]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v66CDreV018927; Thu, 6 Jul 2017 22:13:54 +1000 Subject: [RFC PATCH] efivarfs: define integrity_read method From: Mimi Zohar To: Matthew Garrett , Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-security-module , linux-ima-user , linux-efi Date: Thu, 06 Jul 2017 08:14:01 -0400 X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17070612-0040-0000-0000-0000034019DC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070612-0041-0000-0000-00000CBB49F3 Message-Id: <1499343241.5500.15.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-06_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1707060212 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch defines an ->integrity_read file operation method to read data for integrity hash collection. (Posting separately for review, before being squashed with the others.) Signed-off-by: Mimi Zohar --- fs/efivarfs/file.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c index 5f22e74bbade..b687c982e0a1 100644 --- a/fs/efivarfs/file.c +++ b/fs/efivarfs/file.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "internal.h" @@ -64,8 +65,9 @@ static ssize_t efivarfs_file_write(struct file *file, return bytes; } -static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, - size_t count, loff_t *ppos) +static ssize_t __efivarfs_file_read(struct file *file, char __user *userbuf, + size_t count, loff_t *ppos, + struct iov_iter *iter) { struct efivar_entry *var = file->private_data; unsigned long datasize = 0; @@ -96,14 +98,32 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, goto out_free; memcpy(data, &attributes, sizeof(attributes)); - size = simple_read_from_buffer(userbuf, count, ppos, - data, datasize + sizeof(attributes)); + + if (!iter) + size = simple_read_from_buffer(userbuf, count, ppos, data, + datasize + sizeof(attributes)); + else + size = copy_to_iter(data, datasize + sizeof(attributes), iter); out_free: kfree(data); return size; } +static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, + size_t count, loff_t *ppos) +{ + return __efivarfs_file_read(file, userbuf, count, ppos, NULL); +} + +static ssize_t efivarfs_file_read_iter(struct kiocb *iocb, + struct iov_iter *iter) +{ + struct file *file = iocb->ki_filp; + + return __efivarfs_file_read(file, NULL, 0, NULL, iter); +} + static int efivarfs_ioc_getxflags(struct file *file, void __user *arg) { @@ -178,4 +198,5 @@ const struct file_operations efivarfs_file_operations = { .write = efivarfs_file_write, .llseek = no_llseek, .unlocked_ioctl = efivarfs_file_ioctl, + .integrity_read = efivarfs_file_read_iter, };