public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] uaccess: Introduce copy_from_user_nul helper
@ 2026-01-12  7:30 Fushuai Wang
  2026-01-12  7:30 ` [PATCH v2 1/6] uaccess: Add " Fushuai Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 21+ messages in thread
From: Fushuai Wang @ 2026-01-12  7:30 UTC (permalink / raw)
  To: tglx, peterz, mathieu.desnoyers, akpm, aliceryhl, yury.norov,
	vmalik, kees, dave.hansen, luto, mingo, bp, hpa, rostedt,
	mhiramat, brauner, jack, cyphar
  Cc: linux-kernel, x86, linux-trace-kernel, wangfushuai

From: Fushuai Wang <wangfushuai@baidu.com>

Hi all,

This patch series introduces a new helper function, copy_from_user_nul,
to simplify cases where a buffer copied from userspace needs to be
NUL-terminated. In many places, after using copy_from_user, we manually
add a NUL byte to the end of the buffer to prevent string overflows and
ensure safe string handling.

The new helper performs both the copy and the NUL-termination in one
step, reducing repetitive code and the chance of errors.

v1 -> v2: Rewrite commit message and add some actual code improvements

--WANG

Fushuai Wang (6):
  uaccess: Add copy_from_user_nul helper
  x86/tlb: Use copy_from_user_nul() instead of copy_from_user()
  tracing: Use copy_from_user_nul() instead of copy_from_user()
  userns: Use copy_from_user_nul() instead of copy_from_user()
  time: Use copy_from_user_nul() instead of copy_from_user()
  kstrtox: Use copy_from_user_nul() instead of copy_from_user()

 arch/x86/mm/tlb.c         |  3 +--
 include/linux/uaccess.h   | 19 +++++++++++++++++++
 kernel/time/test_udelay.c |  3 +--
 kernel/trace/trace.c      |  3 +--
 kernel/user_namespace.c   |  3 +--
 lib/kstrtox.c             |  6 ++----
 6 files changed, 25 insertions(+), 12 deletions(-)

-- 
2.36.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2026-01-16  8:43 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12  7:30 [PATCH v2 0/6] uaccess: Introduce copy_from_user_nul helper Fushuai Wang
2026-01-12  7:30 ` [PATCH v2 1/6] uaccess: Add " Fushuai Wang
2026-01-12  9:23   ` Alice Ryhl
2026-01-12 10:00     ` Fushuai Wang
2026-01-12 11:20       ` Alice Ryhl
2026-01-12 12:22         ` Fushuai Wang
2026-01-12 13:22           ` Borislav Petkov
2026-01-12 15:40             ` Alice Ryhl
2026-01-12 16:28               ` Steven Rostedt
2026-01-12 16:37                 ` Alice Ryhl
2026-01-13 18:00   ` Yury Norov
2026-01-13 18:17     ` Yury Norov
2026-01-16  8:42     ` Fushuai Wang
2026-01-12  7:30 ` [PATCH v2 2/6] x86/tlb: Use copy_from_user_nul() instead of copy_from_user() Fushuai Wang
2026-01-12  7:30 ` [PATCH v2 3/6] tracing: " Fushuai Wang
2026-01-12 15:43   ` Steven Rostedt
2026-01-13 17:05   ` Yury Norov
2026-01-13 18:03     ` Steven Rostedt
2026-01-12  7:30 ` [PATCH v2 4/6] userns: " Fushuai Wang
2026-01-12  7:30 ` [PATCH v2 5/6] time: " Fushuai Wang
2026-01-12  7:30 ` [PATCH v2 6/6] kstrtox: " Fushuai Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox