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: <20251219-jag-dovec_consolidate-v1-4-1413b92c6040@kernel.org>
Date: Fri, 19 Dec 2025 13:15:55 +0100
From: Joel Granados <joel.granados@...nel.org>
To: Kees Cook <kees@...nel.org>, Alexander Viro <viro@...iv.linux.org.uk>, 
 Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org, 
 Joel Granados <joel.granados@...nel.org>
Subject: [PATCH 4/9] sysctl: Add negp parameter to douintvec converter
 functions

Updates all douintvec converter function signatures to include a bool
*negp parameter. This is a preparation commit required to eventually
generate do_proc_douintvec with a macro. The negp argument will be
ignored as it is not relevant for the uint type. Note that
do_proc_uint_conv_pipe_maxsz in pipe.c is also modified.

Signed-off-by: Joel Granados <joel.granados@...nel.org>
---
 fs/pipe.c              |  2 +-
 include/linux/sysctl.h |  2 +-
 kernel/sysctl.c        | 25 +++++++++++++------------
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/fs/pipe.c b/fs/pipe.c
index 22647f50b286d3bca024ee4c6de51b100ddc5402..e4a8b6d43bee873ceb1928afab9909e6cd6e4418 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1492,7 +1492,7 @@ static int u2k_pipe_maxsz(const ulong *u_ptr, uint *k_ptr)
 	return proc_uint_u2k_conv_uop(u_ptr, k_ptr, round_pipe_size_ul);
 }
 
-static int do_proc_uint_conv_pipe_maxsz(ulong *u_ptr, uint *k_ptr,
+static int do_proc_uint_conv_pipe_maxsz(bool *negp, ulong *u_ptr, uint *k_ptr,
 					int dir, const struct ctl_table *table)
 {
 	return proc_uint_conv(u_ptr, k_ptr, dir, table, true,
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 5c8c17f98513983a459c54eae99d1cc8bd63b011..8f8e357b1f4d377a0891fbc85d34073cd30469b1 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -102,7 +102,7 @@ int proc_douintvec_minmax(const struct ctl_table *table, int write, void *buffer
 		size_t *lenp, loff_t *ppos);
 int proc_douintvec_conv(const struct ctl_table *table, int write, void *buffer,
 			size_t *lenp, loff_t *ppos,
-			int (*conv)(unsigned long *lvalp, unsigned int *valp,
+			int (*conv)(bool *negp, ulong *lvalp, uint *valp,
 				    int write, const struct ctl_table *table));
 int proc_uint_k2u_conv(ulong *u_ptr, const uint *k_ptr);
 int proc_uint_u2k_conv_uop(const ulong *u_ptr, uint *k_ptr,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d21eeb2bca19ab927a604e8de137958eb08f82a6..8d0796b45b0101096ee395c7ed7c37f7b7199db4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -444,7 +444,7 @@ static int proc_uint_u2k_conv(const ulong *u_ptr, uint *k_ptr)
 	return proc_uint_u2k_conv_uop(u_ptr, k_ptr, NULL);
 }
 
-static int do_proc_uint_conv(ulong *u_ptr, uint *k_ptr, int dir,
+static int do_proc_uint_conv(bool *negp, ulong *u_ptr, uint *k_ptr, int dir,
 			     const struct ctl_table *tbl)
 {
 	return proc_uint_conv(u_ptr, k_ptr, dir, tbl, false,
@@ -652,7 +652,7 @@ do_proc_dotypevec(ulong)
 
 static int do_proc_douintvec_w(const struct ctl_table *table, void *buffer,
 			       size_t *lenp, loff_t *ppos,
-			       int (*conv)(unsigned long *u_ptr,
+			       int (*conv)(bool *negp, unsigned long *u_ptr,
 					   unsigned int *k_ptr, int dir,
 					   const struct ctl_table *table))
 {
@@ -705,17 +705,18 @@ static int do_proc_douintvec_w(const struct ctl_table *table, void *buffer,
 
 static int do_proc_douintvec_r(const struct ctl_table *table, void *buffer,
 			       size_t *lenp, loff_t *ppos,
-			       int (*conv)(unsigned long *u_ptr,
+			       int (*conv)(bool *negp, unsigned long *u_ptr,
 					   unsigned int *k_ptr, int dir,
 					   const struct ctl_table *table))
 {
 	unsigned long lval;
 	int err = 0;
 	size_t left;
+	bool negp;
 
 	left = *lenp;
 
-	if (conv(&lval, (unsigned int *) table->data, 0, table)) {
+	if (conv(&negp, &lval, (unsigned int *) table->data, 0, table)) {
 		err = -EINVAL;
 		goto out;
 	}
@@ -735,9 +736,8 @@ static int do_proc_douintvec_r(const struct ctl_table *table, void *buffer,
 
 static int do_proc_douintvec(const struct ctl_table *table, int dir,
 			     void *buffer, size_t *lenp, loff_t *ppos,
-			      int (*conv)(unsigned long *u_ptr,
-					  unsigned int *k_ptr, int dir,
-					  const struct ctl_table *table))
+			     int (*conv)(bool *negp, ulong *u_ptr, uint *k_ptr,
+					 int dir, const struct ctl_table *table))
 {
 	unsigned int vleft;
 
@@ -758,9 +758,6 @@ static int do_proc_douintvec(const struct ctl_table *table, int dir,
 		return -EINVAL;
 	}
 
-	if (!conv)
-		conv = do_proc_uint_conv;
-
 	if (SYSCTL_USER_TO_KERN(dir))
 		return do_proc_douintvec_w(table, buffer, lenp, ppos, conv);
 	return do_proc_douintvec_r(table, buffer, lenp, ppos, conv);
@@ -784,9 +781,13 @@ static int do_proc_douintvec(const struct ctl_table *table, int dir,
  */
 int proc_douintvec_conv(const struct ctl_table *table, int dir, void *buffer,
 			size_t *lenp, loff_t *ppos,
-			int (*conv)(unsigned long *u_ptr, unsigned int *k_ptr,
+			int (*conv)(bool *negp, ulong *u_ptr, uint *k_ptr,
 				    int dir, const struct ctl_table *table))
 {
+
+	if (!conv)
+		conv = do_proc_uint_conv;
+
 	return do_proc_douintvec(table, dir, buffer, lenp, ppos, conv);
 }
 
@@ -1314,7 +1315,7 @@ int proc_douintvec_minmax(const struct ctl_table *table, int dir,
 
 int proc_douintvec_conv(const struct ctl_table *table, int write, void *buffer,
 			size_t *lenp, loff_t *ppos,
-			int (*conv)(unsigned long *lvalp, unsigned int *valp,
+			int (*conv)(bool *negp, ulong *lvalp, uint *valp,
 				    int write, const struct ctl_table *table))
 {
 	return -ENOSYS;

-- 
2.50.1



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ