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-57-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:13:16 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 056/437] net: rfkill: convert to read/write iterators

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

diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index c3feb4f49d09..36271888c130 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1226,10 +1226,10 @@ static __poll_t rfkill_fop_poll(struct file *file, poll_table *wait)
 	return res;
 }
 
-static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
-			       size_t count, loff_t *pos)
+static ssize_t rfkill_fop_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rfkill_data *data = file->private_data;
+	struct rfkill_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct rfkill_int_event *ev;
 	unsigned long sz;
 	int ret;
@@ -1237,7 +1237,7 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
 	mutex_lock(&data->mtx);
 
 	while (list_empty(&data->events)) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			goto out;
 		}
@@ -1259,7 +1259,7 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
 	sz = min_t(unsigned long, sizeof(ev->ev), count);
 	sz = min_t(unsigned long, sz, data->max_size);
 	ret = sz;
-	if (copy_to_user(buf, &ev->ev, sz))
+	if (!copy_to_iter_full(&ev->ev, sz, to))
 		ret = -EFAULT;
 
 	list_del(&ev->list);
@@ -1269,10 +1269,10 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *pos)
+static ssize_t rfkill_fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct rfkill_data *data = file->private_data;
+	struct rfkill_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct rfkill *rfkill;
 	struct rfkill_event_ext ev;
 	int ret;
@@ -1288,7 +1288,7 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
 	 */
 	count = min(count, sizeof(ev));
 	count = min_t(size_t, count, data->max_size);
-	if (copy_from_user(&ev, buf, count))
+	if (!copy_from_iter_full(&ev, count, from))
 		return -EFAULT;
 
 	if (ev.type >= NUM_RFKILL_TYPES)
@@ -1392,8 +1392,8 @@ static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations rfkill_fops = {
 	.owner		= THIS_MODULE,
 	.open		= rfkill_fop_open,
-	.read		= rfkill_fop_read,
-	.write		= rfkill_fop_write,
+	.read_iter	= rfkill_fop_read,
+	.write_iter	= rfkill_fop_write,
 	.poll		= rfkill_fop_poll,
 	.release	= rfkill_fop_release,
 	.unlocked_ioctl	= rfkill_fop_ioctl,
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ