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-397-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:18:56 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 396/437] macintosh: adb: convert to read/write iterators

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 drivers/macintosh/adb.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index b0407c5fadb2..1b95911ded5d 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -713,11 +713,11 @@ static int adb_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t adb_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t adb_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int ret = 0;
-	struct adbdev_state *state = file->private_data;
+	struct adbdev_state *state = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct adb_request *req;
 	DECLARE_WAITQUEUE(wait, current);
 	unsigned long flags;
@@ -741,7 +741,7 @@ static ssize_t adb_read(struct file *file, char __user *buf,
 		if (req != NULL || ret != 0)
 			break;
 		
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			break;
 		}
@@ -764,18 +764,18 @@ static ssize_t adb_read(struct file *file, char __user *buf,
 	ret = req->reply_len;
 	if (ret > count)
 		ret = count;
-	if (ret > 0 && copy_to_user(buf, req->reply, ret))
+	if (ret > 0 && !copy_to_iter_full(req->reply, ret, to))
 		ret = -EFAULT;
 
 	kfree(req);
 	return ret;
 }
 
-static ssize_t adb_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t adb_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret/*, i*/;
-	struct adbdev_state *state = file->private_data;
+	struct adbdev_state *state = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct adb_request *req;
 
 	if (count < 2 || count > sizeof(req->data))
@@ -794,7 +794,7 @@ static ssize_t adb_write(struct file *file, const char __user *buf,
 	req->complete = 0;
 	
 	ret = -EFAULT;
-	if (copy_from_user(req->data, buf, count))
+	if (!copy_from_iter_full(req->data, count, from))
 		goto out;
 
 	atomic_inc(&state->n_pending);
@@ -843,8 +843,8 @@ static ssize_t adb_write(struct file *file, const char __user *buf,
 static const struct file_operations adb_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= adb_read,
-	.write		= adb_write,
+	.read_iter	= adb_read,
+	.write_iter	= adb_write,
 	.open		= adb_open,
 	.release	= adb_release,
 };
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ