lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-291-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:17:10 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 290/437] fs/ocfs2: convert to read/write iterators

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 fs/ocfs2/cluster/netdebug.c | 11 ++++++-----
 fs/ocfs2/dlmfs/dlmfs.c      | 38 +++++++++++++++++--------------------
 2 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c
index fde10358c8ee..877955f35aef 100644
--- a/fs/ocfs2/cluster/netdebug.c
+++ b/fs/ocfs2/cluster/netdebug.c
@@ -468,17 +468,18 @@ static int o2net_debug_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t o2net_debug_read(struct file *file, char __user *buf,
-				size_t nbytes, loff_t *ppos)
+static ssize_t o2net_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
-				       i_size_read(file->f_mapping->host));
+	struct file *file = iocb->ki_filp;
+
+	return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+				       i_size_read(file->f_mapping->host), to);
 }
 
 static const struct file_operations nodes_fops = {
 	.open		= nodes_fop_open,
 	.release	= o2net_debug_release,
-	.read		= o2net_debug_read,
+	.read_iter	= o2net_debug_read,
 	.llseek		= generic_file_llseek,
 };
 
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 7fc0e920eda7..a13b80cb11f1 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -28,6 +28,7 @@
 #include <linux/string.h>
 #include <linux/backing-dev.h>
 #include <linux/poll.h>
+#include <linux/uio.h>
 
 #include <linux/uaccess.h>
 
@@ -219,47 +220,42 @@ static __poll_t dlmfs_file_poll(struct file *file, poll_table *wait)
 	return event;
 }
 
-static ssize_t dlmfs_file_read(struct file *file,
-			       char __user *buf,
-			       size_t count,
-			       loff_t *ppos)
+static ssize_t dlmfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char lvb[DLM_LVB_LEN];
 
-	if (!user_dlm_read_lvb(file_inode(file), lvb))
+	if (!user_dlm_read_lvb(file_inode(iocb->ki_filp), lvb))
 		return 0;
 
-	return simple_read_from_buffer(buf, count, ppos, lvb, sizeof(lvb));
+	return simple_copy_to_iter(lvb, &iocb->ki_pos, sizeof(lvb), to);
 }
 
-static ssize_t dlmfs_file_write(struct file *filp,
-				const char __user *buf,
-				size_t count,
-				loff_t *ppos)
+static ssize_t dlmfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char lvb_buf[DLM_LVB_LEN];
-	int bytes_left;
-	struct inode *inode = file_inode(filp);
+	int copied;
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 
 	mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
-		inode->i_ino, count, *ppos);
+		inode->i_ino, count, iocb->ki_pos);
 
-	if (*ppos >= DLM_LVB_LEN)
+	if (iocb->ki_pos >= DLM_LVB_LEN)
 		return -ENOSPC;
 
 	/* don't write past the lvb */
-	if (count > DLM_LVB_LEN - *ppos)
-		count = DLM_LVB_LEN - *ppos;
+	if (count > DLM_LVB_LEN - iocb->ki_pos)
+		count = DLM_LVB_LEN - iocb->ki_pos;
 
 	if (!count)
 		return 0;
 
-	bytes_left = copy_from_user(lvb_buf, buf, count);
-	count -= bytes_left;
+	copied = copy_from_iter(lvb_buf, count, from);
+	count -= copied;
 	if (count)
 		user_dlm_write_lvb(inode, lvb_buf, count);
 
-	*ppos = *ppos + count;
+	iocb->ki_pos += count;
 	mlog(0, "wrote %zu bytes\n", count);
 	return count;
 }
@@ -525,8 +521,8 @@ static const struct file_operations dlmfs_file_operations = {
 	.open		= dlmfs_file_open,
 	.release	= dlmfs_file_release,
 	.poll		= dlmfs_file_poll,
-	.read		= dlmfs_file_read,
-	.write		= dlmfs_file_write,
+	.read_iter	= dlmfs_file_read,
+	.write_iter	= dlmfs_file_write,
 	.llseek		= default_llseek,
 };
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ