Skip to content

Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()

Fushuai Wang lkml 2 versions – Applied

Status from this message: The following commit has been merged into the sched/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesApplied
  2. v12 patches 1 replySuperseded

v1 from the cover letter

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2sched/debug: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()kernel/sched/debug.c+4 -100 replies
2/2x86/tlb: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()arch/x86/mm/tlb.c+4 -90 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchYury Norov
1/2R-b
2/2R-b

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/2] Convert copy_from_user() + kstrtouint() to kstrtouint_from_user()

From: Fushuai Wang <[email protected]>

Hi,

There are several places use copy_from_user() to copy a string from userspase, followed by kstrtoXXX() to convert it to a desired type. This approach requires manually handling NUL-termination and proper buffer sizing, which is error-prone and unnecessarily complex. The kernel provides kstrtoXXX_from_user() helpers to copy a string from userspace and perform the conversion in one step. So use a kstrtoXXX_from_user() instead of copy_from_user() + kstrtoXXX().

Recent discussion:
https://lore.kernel.org/all/[email protected]/T/

v1:
https://lore.kernel.org/all/[email protected]/T/#t

Fushuai Wang (2):
sched/debug: Convert copy_from_user() + kstrtouint() to
kstrtouint_from_user()
x86/tlb: Convert copy_from_user() + kstrtouint() to
kstrtouint_from_user()

 arch/x86/mm/tlb.c    | 13 ++++---------
 kernel/sched/debug.c | 14 ++++----------
 2 files changed, 8 insertions(+), 19 deletions(-)
Signature · 1 line
2.36.1