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

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 fs/fuse/control.c | 70 ++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 40 deletions(-)

diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 0ca1d1f418c3..e572013d345e 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -43,8 +43,7 @@ static ssize_t fuse_conn_abort_write(struct kiocb *iocb, struct iov_iter *from)
 	return iov_iter_count(from);
 }
 
-static ssize_t fuse_conn_waiting_read_iter(struct kiocb *iocb,
-					   struct iov_iter *to)
+static ssize_t fuse_conn_waiting_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char tmp[32];
 	size_t size;
@@ -63,27 +62,27 @@ static ssize_t fuse_conn_waiting_read_iter(struct kiocb *iocb,
 	return simple_copy_to_iter(tmp, &iocb->ki_pos, size, to);
 }
 
-static ssize_t fuse_conn_limit_read(struct file *file, char __user *buf,
-				    size_t len, loff_t *ppos, unsigned val)
+static ssize_t fuse_conn_limit_read(struct kiocb *iocb, struct iov_iter *to,
+				    unsigned val)
 {
 	char tmp[32];
 	size_t size = sprintf(tmp, "%u\n", val);
 
-	return simple_read_from_buffer(buf, len, ppos, tmp, size);
+	return simple_copy_to_iter(tmp, &iocb->ki_pos, size, to);
 }
 
-static ssize_t fuse_conn_limit_write(struct file *file, const char __user *buf,
-				     size_t count, loff_t *ppos, unsigned *val,
-				     unsigned global_limit)
+static ssize_t fuse_conn_limit_write(struct kiocb *iocb, struct iov_iter *from,
+				     unsigned *val, unsigned global_limit)
 {
 	unsigned long t;
 	unsigned limit = (1 << 16) - 1;
+	size_t count = iov_iter_count(from);
 	int err;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return -EINVAL;
 
-	err = kstrtoul_from_user(buf, count, 0, &t);
+	err = kstrtoul_from_iter(from, count, 0, &t);
 	if (err)
 		return err;
 
@@ -98,35 +97,31 @@ static ssize_t fuse_conn_limit_write(struct file *file, const char __user *buf,
 	return count;
 }
 
-static ssize_t fuse_conn_max_background_read(struct file *file,
-					     char __user *buf, size_t len,
-					     loff_t *ppos)
+static ssize_t fuse_conn_max_background_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	struct fuse_conn *fc;
 	unsigned val;
 
-	fc = fuse_ctl_file_conn_get(file);
+	fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 	if (!fc)
 		return 0;
 
 	val = READ_ONCE(fc->max_background);
 	fuse_conn_put(fc);
 
-	return fuse_conn_limit_read(file, buf, len, ppos, val);
+	return fuse_conn_limit_read(iocb, to, val);
 }
-FOPS_READ_ITER_HELPER(fuse_conn_max_background_read);
 
-static ssize_t fuse_conn_max_background_write(struct file *file,
-					      const char __user *buf,
-					      size_t count, loff_t *ppos)
+static ssize_t fuse_conn_max_background_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
 	unsigned val;
 	ssize_t ret;
 
-	ret = fuse_conn_limit_write(file, buf, count, ppos, &val,
-				    max_user_bgreq);
+	ret = fuse_conn_limit_write(iocb, from, &val, max_user_bgreq);
 	if (ret > 0) {
-		struct fuse_conn *fc = fuse_ctl_file_conn_get(file);
+		struct fuse_conn *fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 		if (fc) {
 			spin_lock(&fc->bg_lock);
 			fc->max_background = val;
@@ -140,38 +135,34 @@ static ssize_t fuse_conn_max_background_write(struct file *file,
 
 	return ret;
 }
-FOPS_WRITE_ITER_HELPER(fuse_conn_max_background_write);
 
-static ssize_t fuse_conn_congestion_threshold_read(struct file *file,
-						   char __user *buf, size_t len,
-						   loff_t *ppos)
+static ssize_t fuse_conn_congestion_threshold_read(struct kiocb *iocb,
+						   struct iov_iter *to)
 {
 	struct fuse_conn *fc;
 	unsigned val;
 
-	fc = fuse_ctl_file_conn_get(file);
+	fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 	if (!fc)
 		return 0;
 
 	val = READ_ONCE(fc->congestion_threshold);
 	fuse_conn_put(fc);
 
-	return fuse_conn_limit_read(file, buf, len, ppos, val);
+	return fuse_conn_limit_read(iocb, to, val);
 }
 
-static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
-						    const char __user *buf,
-						    size_t count, loff_t *ppos)
+static ssize_t fuse_conn_congestion_threshold_write(struct kiocb *iocb,
+						    struct iov_iter *from)
 {
 	unsigned val;
 	struct fuse_conn *fc;
 	ssize_t ret;
 
-	ret = fuse_conn_limit_write(file, buf, count, ppos, &val,
-				    max_user_congthresh);
+	ret = fuse_conn_limit_write(iocb, from, &val, max_user_congthresh);
 	if (ret <= 0)
 		goto out;
-	fc = fuse_ctl_file_conn_get(file);
+	fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 	if (!fc)
 		goto out;
 
@@ -180,7 +171,6 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
 out:
 	return ret;
 }
-FOPS_WRITE_ITER_HELPER(fuse_conn_congestion_threshold_write);
 
 static const struct file_operations fuse_ctl_abort_ops = {
 	.open = nonseekable_open,
@@ -190,21 +180,21 @@ static const struct file_operations fuse_ctl_abort_ops = {
 
 static const struct file_operations fuse_ctl_waiting_ops = {
 	.open = nonseekable_open,
-	.read_iter = fuse_conn_waiting_read_iter,
+	.read_iter = fuse_conn_waiting_read,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_conn_max_background_ops = {
 	.open = nonseekable_open,
-	.read_iter = fuse_conn_max_background_read_iter,
-	.write_iter = fuse_conn_max_background_write_iter,
+	.read_iter = fuse_conn_max_background_read,
+	.write_iter = fuse_conn_max_background_write,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_conn_congestion_threshold_ops = {
 	.open = nonseekable_open,
-	.read = fuse_conn_congestion_threshold_read,
-	.write_iter = fuse_conn_congestion_threshold_write_iter,
+	.read_iter = fuse_conn_congestion_threshold_read,
+	.write_iter = fuse_conn_congestion_threshold_write,
 	.llseek = no_llseek,
 };
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ