Skip to content

uaccess: Introduce copy_from_user_nul helper

Fushuai Wang linux-trace-kernel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest6 patches 14 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6uaccess: Add copy_from_user_nul helperinclude/linux/uaccess.h+19 -011 replies
2/6x86/tlb: Use copy_from_user_nul() instead of copy_from_user()arch/x86/mm/tlb.c+1 -20 replies
3/6tracing: Use copy_from_user_nul() instead of copy_from_user()kernel/trace/trace.c+1 -23 replies
4/6userns: Use copy_from_user_nul() instead of copy_from_user()kernel/user_namespace.c+1 -20 replies
5/6time: Use copy_from_user_nul() instead of copy_from_user()kernel/time/test_udelay.c+1 -20 replies
6/6kstrtox: Use copy_from_user_nul() instead of copy_from_user()lib/kstrtox.c+2 -40 replies

Reviews trailers per patch

1 of 6 patches has a Reviewed-by or Acked-by.

PatchSteven Rostedt (Google)
1/6
2/6
3/6A-b
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/6] uaccess: Introduce copy_from_user_nul helper

From: Fushuai Wang <[email protected]>

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(-)
Signature · 1 line
2.36.1