From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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 Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Message-Id: <1499343241.5500.15.camel@linux.vnet.ibm.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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, }; -- 2.7.4