From: zohar@linux.vnet.ibm.com (Mimi Zohar)
To: linux-security-module@vger.kernel.org
Subject: [RFC PATCH] efivarfs: define integrity_read method
Date: Thu, 06 Jul 2017 08:14:01 -0400 [thread overview]
Message-ID: <1499343241.5500.15.camel@linux.vnet.ibm.com> (raw)
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 <zohar@linux.vnet.ibm.com>
---
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 <linux/efi.h>
#include <linux/fs.h>
#include <linux/slab.h>
+#include <linux/uio.h>
#include <linux/mount.h>
#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
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2017-07-06 12:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 12:14 Mimi Zohar [this message]
2017-07-06 12:45 ` [RFC PATCH] efivarfs: define integrity_read method Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499343241.5500.15.camel@linux.vnet.ibm.com \
--to=zohar@linux.vnet.ibm.com \
--cc=linux-security-module@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).