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-11-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:12:30 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 010/437] lib/string_helpers: add parse_int_array_iter()

Works just like parse_int_array_user(), except it takes and iov_iter
instead of a ubuf + length.

Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
 include/linux/string_helpers.h |  2 ++
 lib/string_helpers.c           | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index e93fbb5b0c01..f38157114fc0 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -11,6 +11,7 @@
 struct device;
 struct file;
 struct task_struct;
+struct iov_iter;
 
 static inline bool string_is_terminated(const char *s, int len)
 {
@@ -32,6 +33,7 @@ int string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
 		    char *buf, int len);
 
 int parse_int_array_user(const char __user *from, size_t count, int **array);
+int parse_int_array_iter(struct iov_iter *from, int **array);
 
 #define UNESCAPE_SPACE		BIT(0)
 #define UNESCAPE_OCTAL		BIT(1)
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 77f942809556..ced4f77dc5e8 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -188,6 +188,25 @@ int parse_int_array_user(const char __user *from, size_t count, int **array)
 }
 EXPORT_SYMBOL(parse_int_array_user);
 
+/**
+ * parse_int_array_iter - Split string into a sequence of integers
+ * @from:	The iov_iter buffer to read from
+ * @array:	Returned pointer to sequence of integers
+ *
+ * See @parse_int_array_user, this is just the iov_iter variant.
+ */
+int parse_int_array_iter(struct iov_iter *from, int **array)
+{
+	char *buf;
+
+	buf = iterdup_nul(from, iov_iter_count(from));
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
+
+	return __parse_int_array(buf, array);
+}
+EXPORT_SYMBOL(parse_int_array_iter);
+
 static bool unescape_space(char **src, char **dst)
 {
 	char *p = *dst, *q = *src;
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ