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-429-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:19:28 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 428/437] sbus: oradax: convert to read/write iterators

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 drivers/sbus/char/oradax.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/sbus/char/oradax.c b/drivers/sbus/char/oradax.c
index a536dd6f4f7c..2e99e25b4b50 100644
--- a/drivers/sbus/char/oradax.c
+++ b/drivers/sbus/char/oradax.c
@@ -204,24 +204,21 @@ struct dax_ctx {
 
 /* driver public entry points */
 static int dax_open(struct inode *inode, struct file *file);
-static ssize_t dax_read(struct file *filp, char __user *buf,
-			size_t count, loff_t *ppos);
-static ssize_t dax_write(struct file *filp, const char __user *buf,
-			 size_t count, loff_t *ppos);
+static ssize_t dax_read(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t dax_write(struct kiocb *iocb, struct iov_iter *from);
 static int dax_devmap(struct file *f, struct vm_area_struct *vma);
 static int dax_close(struct inode *i, struct file *f);
 
 static const struct file_operations dax_fops = {
 	.owner	=	THIS_MODULE,
 	.open	=	dax_open,
-	.read	=	dax_read,
-	.write	=	dax_write,
+	.read_iter	=	dax_read,
+	.write_iter	=	dax_write,
 	.mmap	=	dax_devmap,
 	.release =	dax_close,
 };
 
-static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,
-			size_t count, loff_t *ppos);
+static int dax_ccb_exec(struct dax_ctx *ctx, loff_t *ppos, struct iov_iter *from);
 static int dax_ccb_info(u64 ca, struct ccb_info_result *info);
 static int dax_ccb_kill(u64 ca, u16 *kill_res);
 
@@ -541,10 +538,10 @@ static int dax_close(struct inode *ino, struct file *f)
 	return 0;
 }
 
-static ssize_t dax_read(struct file *f, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t dax_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dax_ctx *ctx = f->private_data;
+	struct dax_ctx *ctx = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	if (ctx->client != current)
 		return -EUSERS;
@@ -553,15 +550,15 @@ static ssize_t dax_read(struct file *f, char __user *buf,
 
 	if (count != sizeof(union ccb_result))
 		return -EINVAL;
-	if (copy_to_user(buf, &ctx->result, sizeof(union ccb_result)))
+	if (!copy_to_iter_full(&ctx->result, sizeof(union ccb_result), to))
 		return -EFAULT;
 	return count;
 }
 
-static ssize_t dax_write(struct file *f, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t dax_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dax_ctx *ctx = f->private_data;
+	struct dax_ctx *ctx = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct dax_command hdr;
 	unsigned long ca;
 	int i, idx, ret;
@@ -573,7 +570,7 @@ static ssize_t dax_write(struct file *f, const char __user *buf,
 		return -EINVAL;
 
 	if (count % sizeof(struct dax_ccb) == 0)
-		return dax_ccb_exec(ctx, buf, count, ppos); /* CCB EXEC */
+		return dax_ccb_exec(ctx, &iocb->ki_pos, from); /* CCB EXEC */
 
 	if (count != sizeof(struct dax_command))
 		return -EINVAL;
@@ -582,7 +579,7 @@ static ssize_t dax_write(struct file *f, const char __user *buf,
 	if (ctx->owner != current)
 		return -EUSERS;
 
-	if (copy_from_user(&hdr, buf, sizeof(hdr)))
+	if (!copy_from_iter_full(&hdr, sizeof(hdr), from))
 		return -EFAULT;
 
 	ca = ctx->ca_buf_ra + hdr.ca_offset;
@@ -846,9 +843,9 @@ static int dax_preprocess_usr_ccbs(struct dax_ctx *ctx, int idx, int nelem)
 	return DAX_SUBMIT_OK;
 }
 
-static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,
-			size_t count, loff_t *ppos)
+static int dax_ccb_exec(struct dax_ctx *ctx, loff_t *ppos, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	unsigned long accepted_len, hv_rv;
 	int i, idx, nccbs, naccepted;
 
@@ -873,7 +870,7 @@ static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,
 	 * Copy CCBs into kernel buffer to prevent modification by the
 	 * user in between validation and submission.
 	 */
-	if (copy_from_user(ctx->ccb_buf, buf, count)) {
+	if (!copy_from_iter_full(ctx->ccb_buf, count, from)) {
 		dax_dbg("copyin of user CCB buffer failed");
 		ctx->result.exec.status = DAX_SUBMIT_ERR_CCB_ARR_MMU_MISS;
 		return 0;
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ