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-106-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:14:05 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 105/437] drivers/acpi: convert to read/write iterators

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 drivers/acpi/acpi_dbg.c      |  6 ++++--
 drivers/acpi/apei/erst-dbg.c | 23 ++++++++++++-----------
 drivers/acpi/ec_sys.c        |  6 ++++--
 drivers/acpi/pfr_update.c    |  3 ++-
 4 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index d50261d05f3a..2ee3bc767693 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -638,6 +638,7 @@ static ssize_t acpi_aml_read(struct file *file, char __user *buf,
 	}
 	return size > 0 ? size : ret;
 }
+FOPS_READ_ITER_HELPER(acpi_aml_read);
 
 static int acpi_aml_write_user(const char __user *buf, int len)
 {
@@ -707,6 +708,7 @@ static ssize_t acpi_aml_write(struct file *file, const char __user *buf,
 	}
 	return size > 0 ? size : ret;
 }
+FOPS_WRITE_ITER_HELPER(acpi_aml_write);
 
 static __poll_t acpi_aml_poll(struct file *file, poll_table *wait)
 {
@@ -722,8 +724,8 @@ static __poll_t acpi_aml_poll(struct file *file, poll_table *wait)
 }
 
 static const struct file_operations acpi_aml_operations = {
-	.read		= acpi_aml_read,
-	.write		= acpi_aml_write,
+	.read_iter	= acpi_aml_read_iter,
+	.write_iter	= acpi_aml_write_iter,
 	.poll		= acpi_aml_poll,
 	.open		= acpi_aml_open,
 	.release	= acpi_aml_release,
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 8bc71cdc2270..293fac1a2821 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 #include <acpi/apei.h>
 #include <linux/miscdevice.h>
 
@@ -79,20 +80,20 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 	}
 }
 
-static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf,
-			     size_t usize, loff_t *off)
+static ssize_t erst_dbg_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t usize = iov_iter_count(to);
 	int rc, *pos;
 	ssize_t len = 0;
 	u64 id;
 
-	if (*off)
+	if (iocb->ki_pos)
 		return -EINVAL;
 
 	if (mutex_lock_interruptible(&erst_dbg_mutex) != 0)
 		return -EINTR;
 
-	pos = (int *)&filp->private_data;
+	pos = (int *)&iocb->ki_filp->private_data;
 
 retry_next:
 	rc = erst_get_record_id_next(pos, &id);
@@ -141,7 +142,7 @@ static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf,
 		goto out;
 
 	rc = -EFAULT;
-	if (copy_to_user(ubuf, erst_dbg_buf, len))
+	if (!copy_to_iter_full(erst_dbg_buf, len, to))
 		goto out;
 	rc = 0;
 out:
@@ -149,9 +150,9 @@ static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf,
 	return rc ? rc : len;
 }
 
-static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
-			      size_t usize, loff_t *off)
+static ssize_t erst_dbg_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t usize = iov_iter_count(from);
 	int rc;
 	struct cper_record_header *rcd;
 
@@ -175,8 +176,8 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
 		erst_dbg_buf = p;
 		erst_dbg_buf_len = usize;
 	}
-	rc = copy_from_user(erst_dbg_buf, ubuf, usize);
-	if (rc) {
+	rc = copy_from_iter_full(erst_dbg_buf, usize, from);
+	if (!rc) {
 		rc = -EFAULT;
 		goto out;
 	}
@@ -196,8 +197,8 @@ static const struct file_operations erst_dbg_ops = {
 	.owner		= THIS_MODULE,
 	.open		= erst_dbg_open,
 	.release	= erst_dbg_release,
-	.read		= erst_dbg_read,
-	.write		= erst_dbg_write,
+	.read_iter	= erst_dbg_read,
+	.write_iter	= erst_dbg_write,
 	.unlocked_ioctl	= erst_dbg_ioctl,
 	.llseek		= no_llseek,
 };
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index c074a0fae059..47c811cb75f4 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -60,6 +60,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
 	}
 	return count;
 }
+FOPS_READ_ITER_HELPER(acpi_ec_read_io);
 
 static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
 				size_t count, loff_t *off)
@@ -98,12 +99,13 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
 	}
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(acpi_ec_write_io);
 
 static const struct file_operations acpi_ec_io_ops = {
 	.owner = THIS_MODULE,
 	.open  = simple_open,
-	.read  = acpi_ec_read_io,
-	.write = acpi_ec_write_io,
+	.read_iter  = acpi_ec_read_io_iter,
+	.write_iter = acpi_ec_write_io_iter,
 	.llseek = default_llseek,
 };
 
diff --git a/drivers/acpi/pfr_update.c b/drivers/acpi/pfr_update.c
index 8b2910995fc1..a7a4d3bb74d3 100644
--- a/drivers/acpi/pfr_update.c
+++ b/drivers/acpi/pfr_update.c
@@ -481,10 +481,11 @@ static ssize_t pfru_write(struct file *file, const char __user *buf,
 
 	return ret ?: len;
 }
+FOPS_WRITE_ITER_HELPER(pfru_write);
 
 static const struct file_operations acpi_pfru_fops = {
 	.owner		= THIS_MODULE,
-	.write		= pfru_write,
+	.write_iter	= pfru_write_iter,
 	.unlocked_ioctl = pfru_ioctl,
 	.llseek		= noop_llseek,
 };
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ