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-333-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:17:52 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 332/437] x86/mm: convert to read/write iterators

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 arch/x86/mm/pat/memtype.c    |  2 +-
 arch/x86/mm/pat/set_memory.c |  2 +-
 arch/x86/mm/pkeys.c          | 15 +++++++--------
 arch/x86/mm/tlb.c            | 15 +++++++--------
 4 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index 36b603d0cdde..46f1d1966f96 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -1194,7 +1194,7 @@ static int memtype_seq_open(struct inode *inode, struct file *file)
 
 static const struct file_operations memtype_fops = {
 	.open    = memtype_seq_open,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release,
 };
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 80c9037ffadf..ee1888fbd218 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -186,7 +186,7 @@ static int cpastats_open(struct inode *inode, struct file *file)
 
 static const struct file_operations cpastats_fops = {
 	.open		= cpastats_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
diff --git a/arch/x86/mm/pkeys.c b/arch/x86/mm/pkeys.c
index 7418c367e328..7f084e4f6bd2 100644
--- a/arch/x86/mm/pkeys.c
+++ b/arch/x86/mm/pkeys.c
@@ -127,25 +127,24 @@ u32 init_pkru_value = PKRU_AD_MASK( 1) | PKRU_AD_MASK( 2) |
 		      PKRU_AD_MASK(13) | PKRU_AD_MASK(14) |
 		      PKRU_AD_MASK(15);
 
-static ssize_t init_pkru_read_file(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t init_pkru_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "0x%x\n", init_pkru_value);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t init_pkru_write_file(struct file *file,
-		 const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t init_pkru_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 	u32 new_init_pkru;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	/* Make the buffer a valid string that we can not overrun */
@@ -166,8 +165,8 @@ static ssize_t init_pkru_write_file(struct file *file,
 }
 
 static const struct file_operations fops_init_pkru = {
-	.read = init_pkru_read_file,
-	.write = init_pkru_write_file,
+	.read_iter = init_pkru_read_file,
+	.write_iter = init_pkru_write_file,
 	.llseek = default_llseek,
 };
 
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 44ac64f3a047..97edf3026036 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -1303,25 +1303,24 @@ bool nmi_uaccess_okay(void)
 	return true;
 }
 
-static ssize_t tlbflush_read_file(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t tlbflush_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "%ld\n", tlb_single_page_flush_ceiling);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t tlbflush_write_file(struct file *file,
-		 const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t tlbflush_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 	int ceiling;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1336,8 +1335,8 @@ static ssize_t tlbflush_write_file(struct file *file,
 }
 
 static const struct file_operations fops_tlbflush = {
-	.read = tlbflush_read_file,
-	.write = tlbflush_write_file,
+	.read_iter = tlbflush_read_file,
+	.write_iter = tlbflush_write_file,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ