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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-14-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:12:33 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 013/437] char/apm-emulation: convert to read/write iterators

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 drivers/char/apm-emulation.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index e795390b070f..6b0ea84cf9c6 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -31,6 +31,7 @@
 #include <linux/completion.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
+#include <linux/uio.h>
 
 /*
  * One option can be changed at boot time as follows:
@@ -200,9 +201,11 @@ static void queue_event(apm_event_t event)
 	wake_up_interruptible(&apm_waitqueue);
 }
 
-static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t apm_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *fp = iocb->ki_filp;
 	struct apm_user *as = fp->private_data;
+	size_t count = iov_iter_count(to);
 	apm_event_t event;
 	int i = count, ret = 0;
 
@@ -218,7 +221,7 @@ static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t
 		event = queue_get_event(&as->queue);
 
 		ret = -EFAULT;
-		if (copy_to_user(buf, &event, sizeof(event)))
+		if (!copy_to_iter_full(&event, sizeof(event), to))
 			break;
 
 		mutex_lock(&state_lock);
@@ -227,7 +230,6 @@ static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t
 			as->suspend_state = SUSPEND_READ;
 		mutex_unlock(&state_lock);
 
-		buf += sizeof(event);
 		i -= sizeof(event);
 	}
 
@@ -379,7 +381,7 @@ static int apm_open(struct inode * inode, struct file * filp)
 
 static const struct file_operations apm_bios_fops = {
 	.owner		= THIS_MODULE,
-	.read		= apm_read,
+	.read_iter	= apm_read,
 	.poll		= apm_poll,
 	.unlocked_ioctl	= apm_ioctl,
 	.open		= apm_open,
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ