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

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

diff --git a/drivers/hsi/clients/hsi_char.c b/drivers/hsi/clients/hsi_char.c
index 71ce7dbfe31d..47ddfe14459b 100644
--- a/drivers/hsi/clients/hsi_char.c
+++ b/drivers/hsi/clients/hsi_char.c
@@ -409,10 +409,10 @@ static inline void hsc_tx_get(struct hsi_client *cl, struct hsc_tx_config *txc)
 	txc->arb_mode = cl->tx_cfg.arb_mode;
 }
 
-static ssize_t hsc_read(struct file *file, char __user *buf, size_t len,
-						loff_t *ppos __maybe_unused)
+static ssize_t hsc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hsc_channel *channel = file->private_data;
+	struct hsc_channel *channel = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	struct hsi_msg *msg;
 	ssize_t ret;
 
@@ -451,8 +451,8 @@ static ssize_t hsc_read(struct file *file, char __user *buf, size_t len,
 	msg = hsc_get_first_msg(channel, &channel->rx_msgs_queue);
 	if (msg) {
 		if (msg->status != HSI_STATUS_ERROR) {
-			ret = copy_to_user((void __user *)buf,
-			sg_virt(msg->sgt.sgl), hsc_msg_len_get(msg));
+			ret = !copy_to_iter_full(sg_virt(msg->sgt.sgl),
+						 hsc_msg_len_get(msg), to);
 			if (ret)
 				ret = -EFAULT;
 			else
@@ -468,10 +468,10 @@ static ssize_t hsc_read(struct file *file, char __user *buf, size_t len,
 	return ret;
 }
 
-static ssize_t hsc_write(struct file *file, const char __user *buf, size_t len,
-						loff_t *ppos __maybe_unused)
+static ssize_t hsc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hsc_channel *channel = file->private_data;
+	struct hsc_channel *channel = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct hsi_msg *msg;
 	ssize_t ret;
 
@@ -488,7 +488,7 @@ static ssize_t hsc_write(struct file *file, const char __user *buf, size_t len,
 		clear_bit(HSC_CH_WRITE, &channel->flags);
 		return -ENOSPC;
 	}
-	if (copy_from_user(sg_virt(msg->sgt.sgl), (void __user *)buf, len)) {
+	if (!copy_from_iter_full(sg_virt(msg->sgt.sgl), len, from)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -655,8 +655,8 @@ static int hsc_release(struct inode *inode __maybe_unused, struct file *file)
 
 static const struct file_operations hsc_fops = {
 	.owner		= THIS_MODULE,
-	.read		= hsc_read,
-	.write		= hsc_write,
+	.read_iter	= hsc_read,
+	.write_iter	= hsc_write,
 	.unlocked_ioctl	= hsc_ioctl,
 	.open		= hsc_open,
 	.release	= hsc_release,
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ