[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-44-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:13:03 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 043/437] ecryptfs: miscdev: convert to read/write iterators
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
fs/ecryptfs/miscdev.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
index 4e62c3cef70f..6ea67a64e2ff 100644
--- a/fs/ecryptfs/miscdev.c
+++ b/fs/ecryptfs/miscdev.c
@@ -309,6 +309,7 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count,
mutex_unlock(&daemon->mux);
return rc;
}
+FOPS_READ_ITER_HELPER(ecryptfs_miscdev_read);
/**
* ecryptfs_miscdev_response - miscdevess response to message previously sent to daemon
@@ -342,22 +343,20 @@ static int ecryptfs_miscdev_response(struct ecryptfs_daemon *daemon, char *data,
/**
* ecryptfs_miscdev_write - handle write to daemon miscdev handle
- * @file: File for misc dev handle
- * @buf: Buffer containing user data
- * @count: Amount of data in @buf
- * @ppos: Pointer to offset in file (ignored)
+ * @iocb: Metadata for IO
+ * @from: Buffer containing user data
*
* Returns the number of bytes read from @buf
*/
static ssize_t
-ecryptfs_miscdev_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+ecryptfs_miscdev_write(struct kiocb *iocb, struct iov_iter *from)
{
__be32 counter_nbo;
u32 seq;
size_t packet_size, packet_size_length;
char *data;
unsigned char packet_size_peek[ECRYPTFS_MAX_PKT_LEN_SIZE];
+ size_t count = iov_iter_count(from);
ssize_t rc;
if (count == 0) {
@@ -372,8 +371,8 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
return -EINVAL;
}
- if (copy_from_user(packet_size_peek, &buf[PKT_LEN_OFFSET],
- sizeof(packet_size_peek))) {
+ if (!copy_from_iter_full(packet_size_peek, sizeof(packet_size_peek),
+ from)) {
printk(KERN_WARNING "%s: Error while inspecting packet size\n",
__func__);
return -EFAULT;
@@ -395,7 +394,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
}
memdup:
- data = memdup_user(buf, count);
+ data = iterdup(from, count);
if (IS_ERR(data)) {
printk(KERN_ERR "%s: memdup_user returned error [%ld]\n",
__func__, PTR_ERR(data));
@@ -416,7 +415,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
}
memcpy(&counter_nbo, &data[PKT_CTR_OFFSET], PKT_CTR_SIZE);
seq = be32_to_cpu(counter_nbo);
- rc = ecryptfs_miscdev_response(file->private_data,
+ rc = ecryptfs_miscdev_response(iocb->ki_filp->private_data,
&data[PKT_LEN_OFFSET + packet_size_length],
packet_size, seq);
if (rc) {
@@ -442,13 +441,12 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
return rc;
}
-
static const struct file_operations ecryptfs_miscdev_fops = {
.owner = THIS_MODULE,
.open = ecryptfs_miscdev_open,
.poll = ecryptfs_miscdev_poll,
- .read = ecryptfs_miscdev_read,
- .write = ecryptfs_miscdev_write,
+ .read_iter = ecryptfs_miscdev_read_iter,
+ .write_iter = ecryptfs_miscdev_write,
.release = ecryptfs_miscdev_release,
.llseek = noop_llseek,
};
--
2.43.0
Powered by blists - more mailing lists