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-129-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:14:28 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 128/437] firmware: turris-mox-rwtm: convert to read/write iterators

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

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 31d962cdd6eb..c7733f4b9bd4 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -330,14 +330,14 @@ static int rwtm_debug_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t do_sign_read(struct file *file, char __user *buf, size_t len,
-			    loff_t *ppos)
+static ssize_t do_sign_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mox_rwtm *rwtm = file->private_data;
+	struct mox_rwtm *rwtm = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 
 	/* only allow one read, of 136 bytes, from position 0 */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (len < 136)
@@ -347,18 +347,18 @@ static ssize_t do_sign_read(struct file *file, char __user *buf, size_t len,
 		return -ENODATA;
 
 	/* 2 arrays of 17 32-bit words are 136 bytes */
-	ret = simple_read_from_buffer(buf, len, ppos, rwtm->last_sig, 136);
+	ret = simple_copy_to_iter(rwtm->last_sig, &iocb->ki_pos, 136, to);
 	rwtm->last_sig_done = 0;
 
 	return ret;
 }
 
-static ssize_t do_sign_write(struct file *file, const char __user *buf,
-			     size_t len, loff_t *ppos)
+static ssize_t do_sign_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mox_rwtm *rwtm = file->private_data;
+	struct mox_rwtm *rwtm = iocb->ki_filp->private_data;
 	struct armada_37xx_rwtm_rx_msg *reply = &rwtm->reply;
 	struct armada_37xx_rwtm_tx_msg msg;
+	size_t len = iov_iter_count(from);
 	loff_t dummy = 0;
 	ssize_t ret;
 
@@ -385,7 +385,7 @@ static ssize_t do_sign_write(struct file *file, const char __user *buf,
 	 *      stored by the rWTM firmware.
 	 */
 	memset(rwtm->buf, 0, 4);
-	ret = simple_write_to_buffer(rwtm->buf + 4, 64, &dummy, buf, len);
+	ret = simple_copy_from_iter(rwtm->buf + 4, &dummy, 64, from);
 	if (ret < 0)
 		goto unlock_mutex;
 	be32_to_cpu_array(rwtm->buf, rwtm->buf, 17);
@@ -426,8 +426,8 @@ static ssize_t do_sign_write(struct file *file, const char __user *buf,
 static const struct file_operations do_sign_fops = {
 	.owner	= THIS_MODULE,
 	.open	= rwtm_debug_open,
-	.read	= do_sign_read,
-	.write	= do_sign_write,
+	.read_iter	= do_sign_read,
+	.write_iter	= do_sign_write,
 	.llseek	= no_llseek,
 };
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ