The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Bradley Morgan <include@grrlz.net>
To: Joel Granados <joel.granados@kernel.org>
Cc: Kees Cook <kees@kernel.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	include@grrlz.net
Subject: [PATCH] sysctl: drop the pointer dance in proc_put_char()
Date: Sat, 22 Aug 2026 18:42:44 +0000	[thread overview]
Message-ID: <20260822184244.13569-1-include@grrlz.net> (raw)

proc_put_char() still drags around a char **buffer alias, writing
the char through it, advancing it, then copying it back into the
slot it was loaded from. That only made sense when the buffer was
__user and the char went through put_user() (which could fail).

Since commit 32927393dc1c ("sysctl: pass kernel pointers to
->proc_handler") the buffer is just a kernel pointer, so the alias
is dead weight. proc_put_long() and the skip helpers already advance
*buf directly, so do the same here. No functional change.

Signed-off-by: Bradley Morgan <include@grrlz.net>
---
 kernel/sysctl.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index f7b7598..2b92b30 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -350,12 +350,9 @@ static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
 static void proc_put_char(void **buf, size_t *size, char c)
 {
 	if (*size) {
-		char **buffer = (char **)buf;
-		**buffer = c;
-
+		*(char *)*buf = c;
 		(*size)--;
-		(*buffer)++;
-		*buf = *buffer;
+		(*buf)++;
 	}
 }
 
-- 
2.47.3


                 reply	other threads:[~2026-08-22 18:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260822184244.13569-1-include@grrlz.net \
    --to=include@grrlz.net \
    --cc=joel.granados@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox