* [PATCH] sysctl: Use replace **void with **char in proc_put_*
@ 2026-09-16 11:44 Joel Granados
2026-09-16 11:52 ` Joel Granados
2026-09-16 16:34 ` Bradley Morgan
0 siblings, 2 replies; 3+ messages in thread
From: Joel Granados @ 2026-09-16 11:44 UTC (permalink / raw)
To: Kees Cook; +Cc: Bradley Morgan, linux-kernel, linux-fsdevel, Joel Granados
Replace **void argument with **char in the proc_put_* functions. These
are leftovers from before commit 32927393dc1c ("sysctl: pass kernel
pointers to ->proc_handler") where a cast to char __user** from void
_user** was needed before the put_user call.
Suggested-by: Bradley Morgan <include@grrlz.net>
Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
kernel/sysctl.c | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 25577ffc2801267cc69df60a1064ada9efd4b97d..1fefe18bf84e790433a1abf71a4b158f3c1f729f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -332,7 +332,7 @@ static int proc_get_long(char **buf, size_t *size,
* In case of success @buf and @size are updated with the amount of bytes
* written.
*/
-static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
+static void proc_put_long(char **buf, size_t *size, unsigned long val, bool neg)
{
int len;
char tmp[TMPBUFLEN], *p = tmp;
@@ -347,15 +347,12 @@ static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
}
#undef TMPBUFLEN
-static void proc_put_char(void **buf, size_t *size, char c)
+static void proc_put_char(char **buf, size_t *size, char c)
{
if (*size) {
- char **buffer = (char **)buf;
- **buffer = c;
-
+ **buf = c;
(*size)--;
- (*buffer)++;
- *buf = *buffer;
+ (*buf)++;
}
}
@@ -680,12 +677,12 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
const struct ctl_table *table,
const enum proc_vec_type data_type,
const size_t data_size, const int conv_dir,
- const size_t buf_nbyte, void *buf,
+ const size_t buf_nbyte, char *buf,
size_t *buf_left_final)
{
int vec_left, err = 0;
size_t buf_left, nr_conv = 0;
- char *data, *data_stage = NULL, *p;
+ char *data, *data_stage = NULL;
bool is_unsigned = data_type == PROC_VEC_UINT || data_type == PROC_VEC_ULONG;
buf_left = buf_nbyte;
@@ -694,7 +691,6 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
if (SYSCTL_USER_TO_KERN(conv_dir)) {
if (buf_left > PAGE_SIZE - 1)
buf_left = PAGE_SIZE - 1;
- p = buf;
if (table->maxlen > data_size) {
data_stage = kmemdup(table->data, table->maxlen, GFP_KERNEL);
@@ -712,11 +708,11 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
bool neg = false;
if (SYSCTL_USER_TO_KERN(conv_dir)) {
- proc_skip_spaces(&p, &buf_left);
+ proc_skip_spaces(&buf, &buf_left);
if (!buf_left)
break;
- err = proc_get_long(&p, &buf_left, &lval, &neg,
+ err = proc_get_long(&buf, &buf_left, &lval, &neg,
proc_wspace_sep,
sizeof(proc_wspace_sep), NULL);
if (!err && neg && is_unsigned)
@@ -740,7 +736,7 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
if (SYSCTL_USER_TO_KERN(conv_dir)) {
if (!err && buf_left)
- proc_skip_spaces(&p, &buf_left);
+ proc_skip_spaces(&buf, &buf_left);
if (!nr_conv) {
err = err ? : -EINVAL;
goto out;
@@ -1221,6 +1217,7 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
unsigned long *bitmap = *(unsigned long **) table->data;
unsigned long *tmp_bitmap = NULL;
char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c = 0;
+ char *p = buffer;
if (!bitmap || !bitmap_len || !left || (*ppos && SYSCTL_KERN_TO_USER(dir))) {
*lenp = 0;
@@ -1228,7 +1225,6 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
}
if (SYSCTL_USER_TO_KERN(dir)) {
- char *p = buffer;
size_t skipped = 0;
if (left > PAGE_SIZE - 1) {
@@ -1315,16 +1311,16 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
bit_a + 1) - 1;
if (!first)
- proc_put_char(&buffer, &left, ',');
- proc_put_long(&buffer, &left, bit_a, false);
+ proc_put_char(&p, &left, ',');
+ proc_put_long(&p, &left, bit_a, false);
if (bit_a != bit_b) {
- proc_put_char(&buffer, &left, '-');
- proc_put_long(&buffer, &left, bit_b, false);
+ proc_put_char(&p, &left, '-');
+ proc_put_long(&p, &left, bit_b, false);
}
first = 0; bit_b++;
}
- proc_put_char(&buffer, &left, '\n');
+ proc_put_char(&p, &left, '\n');
}
if (!err) {
---
base-commit: 99156fbf3562bed74aa57d93b0b3eeec7c7f1ca6
change-id: 20260916-lklm-sysctl-void-vs-char-40a0aab31c3e
Best regards,
--
Joel Granados <joel.granados@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sysctl: Use replace **void with **char in proc_put_*
2026-09-16 11:44 [PATCH] sysctl: Use replace **void with **char in proc_put_* Joel Granados
@ 2026-09-16 11:52 ` Joel Granados
2026-09-16 16:34 ` Bradley Morgan
1 sibling, 0 replies; 3+ messages in thread
From: Joel Granados @ 2026-09-16 11:52 UTC (permalink / raw)
To: Kees Cook; +Cc: Bradley Morgan, linux-kernel, linux-fsdevel
[-- Attachment #1: Type: text/plain, Size: 5035 bytes --]
On Wed, Sep 16, 2026 at 01:44:28PM +0200, Joel Granados wrote:
> Replace **void argument with **char in the proc_put_* functions. These
> are leftovers from before commit 32927393dc1c ("sysctl: pass kernel
> pointers to ->proc_handler") where a cast to char __user** from void
> _user** was needed before the put_user call.
>
> Suggested-by: Bradley Morgan <include@grrlz.net>
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
> ---
> kernel/sysctl.c | 34 +++++++++++++++-------------------
> 1 file changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 25577ffc2801267cc69df60a1064ada9efd4b97d..1fefe18bf84e790433a1abf71a4b158f3c1f729f 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -332,7 +332,7 @@ static int proc_get_long(char **buf, size_t *size,
> * In case of success @buf and @size are updated with the amount of bytes
> * written.
> */
> -static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
> +static void proc_put_long(char **buf, size_t *size, unsigned long val, bool neg)
> {
> int len;
> char tmp[TMPBUFLEN], *p = tmp;
> @@ -347,15 +347,12 @@ static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
> }
> #undef TMPBUFLEN
>
> -static void proc_put_char(void **buf, size_t *size, char c)
> +static void proc_put_char(char **buf, size_t *size, char c)
> {
> if (*size) {
> - char **buffer = (char **)buf;
> - **buffer = c;
> -
> + **buf = c;
> (*size)--;
> - (*buffer)++;
> - *buf = *buffer;
> + (*buf)++;
> }
> }
>
> @@ -680,12 +677,12 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
> const struct ctl_table *table,
> const enum proc_vec_type data_type,
> const size_t data_size, const int conv_dir,
> - const size_t buf_nbyte, void *buf,
> + const size_t buf_nbyte, char *buf,
> size_t *buf_left_final)
> {
> int vec_left, err = 0;
> size_t buf_left, nr_conv = 0;
> - char *data, *data_stage = NULL, *p;
> + char *data, *data_stage = NULL;
> bool is_unsigned = data_type == PROC_VEC_UINT || data_type == PROC_VEC_ULONG;
>
> buf_left = buf_nbyte;
> @@ -694,7 +691,6 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
> if (SYSCTL_USER_TO_KERN(conv_dir)) {
> if (buf_left > PAGE_SIZE - 1)
> buf_left = PAGE_SIZE - 1;
> - p = buf;
>
> if (table->maxlen > data_size) {
> data_stage = kmemdup(table->data, table->maxlen, GFP_KERNEL);
> @@ -712,11 +708,11 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
> bool neg = false;
>
> if (SYSCTL_USER_TO_KERN(conv_dir)) {
> - proc_skip_spaces(&p, &buf_left);
> + proc_skip_spaces(&buf, &buf_left);
>
> if (!buf_left)
> break;
> - err = proc_get_long(&p, &buf_left, &lval, &neg,
> + err = proc_get_long(&buf, &buf_left, &lval, &neg,
> proc_wspace_sep,
> sizeof(proc_wspace_sep), NULL);
> if (!err && neg && is_unsigned)
> @@ -740,7 +736,7 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
>
> if (SYSCTL_USER_TO_KERN(conv_dir)) {
> if (!err && buf_left)
> - proc_skip_spaces(&p, &buf_left);
> + proc_skip_spaces(&buf, &buf_left);
> if (!nr_conv) {
> err = err ? : -EINVAL;
> goto out;
> @@ -1221,6 +1217,7 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
> unsigned long *bitmap = *(unsigned long **) table->data;
> unsigned long *tmp_bitmap = NULL;
> char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c = 0;
> + char *p = buffer;
>
> if (!bitmap || !bitmap_len || !left || (*ppos && SYSCTL_KERN_TO_USER(dir))) {
> *lenp = 0;
> @@ -1228,7 +1225,6 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
> }
>
> if (SYSCTL_USER_TO_KERN(dir)) {
> - char *p = buffer;
> size_t skipped = 0;
>
> if (left > PAGE_SIZE - 1) {
> @@ -1315,16 +1311,16 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
> bit_a + 1) - 1;
>
> if (!first)
> - proc_put_char(&buffer, &left, ',');
> - proc_put_long(&buffer, &left, bit_a, false);
> + proc_put_char(&p, &left, ',');
> + proc_put_long(&p, &left, bit_a, false);
> if (bit_a != bit_b) {
> - proc_put_char(&buffer, &left, '-');
> - proc_put_long(&buffer, &left, bit_b, false);
> + proc_put_char(&p, &left, '-');
> + proc_put_long(&p, &left, bit_b, false);
> }
>
> first = 0; bit_b++;
> }
> - proc_put_char(&buffer, &left, '\n');
> + proc_put_char(&p, &left, '\n');
> }
>
> if (!err) {
>
> ---
> base-commit: 99156fbf3562bed74aa57d93b0b3eeec7c7f1ca6
Forgot to mention that this sits on top of the partial_ctlvec changes
which are included in next-20260915.
> change-id: 20260916-lklm-sysctl-void-vs-char-40a0aab31c3e
>
> Best regards,
> --
> Joel Granados <joel.granados@kernel.org>
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sysctl: Use replace **void with **char in proc_put_*
2026-09-16 11:44 [PATCH] sysctl: Use replace **void with **char in proc_put_* Joel Granados
2026-09-16 11:52 ` Joel Granados
@ 2026-09-16 16:34 ` Bradley Morgan
1 sibling, 0 replies; 3+ messages in thread
From: Bradley Morgan @ 2026-09-16 16:34 UTC (permalink / raw)
To: joel.granados; +Cc: include, kees, linux-fsdevel, linux-kernel
On 16 September 2026 12:44:28 BST, Joel Granados <joel.granados@kernel.org>
wrote:
>Replace **void argument with **char in the proc_put_* functions. These
>are leftovers from before commit 32927393dc1c ("sysctl: pass kernel
>pointers to ->proc_handler") where a cast to char __user** from void
>_user** was needed before the put_user call.
>
>Suggested-by: Bradley Morgan <include@grrlz.net>
>Signed-off-by: Joel Granados <joel.granados@kernel.org>
>---
> kernel/sysctl.c | 34 +++++++++++++++-------------------
> 1 file changed, 15 insertions(+), 19 deletions(-)
>
>diff --git a/kernel/sysctl.c b/kernel/sysctl.c
>index 25577ffc2801267cc69df60a1064ada9efd4b97d..1fefe18bf84e790433a1abf71a4b158f3c1f729f 100644
>--- a/kernel/sysctl.c
>+++ b/kernel/sysctl.c
>@@ -332,7 +332,7 @@ static int proc_get_long(char **buf, size_t *size,
> * In case of success @buf and @size are updated with the amount of bytes
> * written.
> */
>-static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
>+static void proc_put_long(char **buf, size_t *size, unsigned long val, bool neg)
> {
> int len;
> char tmp[TMPBUFLEN], *p = tmp;
>@@ -347,15 +347,12 @@ static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
> }
> #undef TMPBUFLEN
>
>-static void proc_put_char(void **buf, size_t *size, char c)
>+static void proc_put_char(char **buf, size_t *size, char c)
> {
> if (*size) {
>- char **buffer = (char **)buf;
>- **buffer = c;
>-
>+ **buf = c;
> (*size)--;
>- (*buffer)++;
>- *buf = *buffer;
>+ (*buf)++;
> }
> }
>
>@@ -680,12 +677,12 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
> const struct ctl_table *table,
> const enum proc_vec_type data_type,
> const size_t data_size, const int conv_dir,
>- const size_t buf_nbyte, void *buf,
>+ const size_t buf_nbyte, char *buf,
> size_t *buf_left_final)
> {
> int vec_left, err = 0;
> size_t buf_left, nr_conv = 0;
>- char *data, *data_stage = NULL, *p;
>+ char *data, *data_stage = NULL;
> bool is_unsigned = data_type == PROC_VEC_UINT || data_type == PROC_VEC_ULONG;
>
> buf_left = buf_nbyte;
>@@ -694,7 +691,6 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
> if (SYSCTL_USER_TO_KERN(conv_dir)) {
> if (buf_left > PAGE_SIZE - 1)
> buf_left = PAGE_SIZE - 1;
>- p = buf;
>
> if (table->maxlen > data_size) {
> data_stage = kmemdup(table->data, table->maxlen, GFP_KERNEL);
>@@ -712,11 +708,11 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
> bool neg = false;
>
> if (SYSCTL_USER_TO_KERN(conv_dir)) {
>- proc_skip_spaces(&p, &buf_left);
>+ proc_skip_spaces(&buf, &buf_left);
>
> if (!buf_left)
> break;
>- err = proc_get_long(&p, &buf_left, &lval, &neg,
>+ err = proc_get_long(&buf, &buf_left, &lval, &neg,
> proc_wspace_sep,
> sizeof(proc_wspace_sep), NULL);
> if (!err && neg && is_unsigned)
>@@ -740,7 +736,7 @@ static int apply_conv_on_vec(const union proc_vec_conv conv,
>
> if (SYSCTL_USER_TO_KERN(conv_dir)) {
> if (!err && buf_left)
>- proc_skip_spaces(&p, &buf_left);
>+ proc_skip_spaces(&buf, &buf_left);
> if (!nr_conv) {
> err = err ? : -EINVAL;
> goto out;
>@@ -1221,6 +1217,7 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
> unsigned long *bitmap = *(unsigned long **) table->data;
> unsigned long *tmp_bitmap = NULL;
> char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c = 0;
>+ char *p = buffer;
>
> if (!bitmap || !bitmap_len || !left || (*ppos && SYSCTL_KERN_TO_USER(dir))) {
> *lenp = 0;
>@@ -1228,7 +1225,6 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
> }
>
> if (SYSCTL_USER_TO_KERN(dir)) {
>- char *p = buffer;
> size_t skipped = 0;
>
> if (left > PAGE_SIZE - 1) {
>@@ -1315,16 +1311,16 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
> bit_a + 1) - 1;
>
> if (!first)
>- proc_put_char(&buffer, &left, ',');
>- proc_put_long(&buffer, &left, bit_a, false);
>+ proc_put_char(&p, &left, ',');
>+ proc_put_long(&p, &left, bit_a, false);
> if (bit_a != bit_b) {
>- proc_put_char(&buffer, &left, '-');
>- proc_put_long(&buffer, &left, bit_b, false);
>+ proc_put_char(&p, &left, '-');
>+ proc_put_long(&p, &left, bit_b, false);
> }
>
> first = 0; bit_b++;
> }
>- proc_put_char(&buffer, &left, '\n');
>+ proc_put_char(&p, &left, '\n');
> }
>
> if (!err) {
>
>---
>base-commit: 99156fbf3562bed74aa57d93b0b3eeec7c7f1ca6
>change-id: 20260916-lklm-sysctl-void-vs-char-40a0aab31c3e
>
>Best regards,
>
Hmm, looks okay
Reviewed-by: Bradley Morgan <brads@mainlining.org>
--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-16 16:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 11:44 [PATCH] sysctl: Use replace **void with **char in proc_put_* Joel Granados
2026-09-16 11:52 ` Joel Granados
2026-09-16 16:34 ` Bradley Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®