lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260112073039.1185-7-fushuai.wang@linux.dev>
Date: Mon, 12 Jan 2026 15:30:39 +0800
From: Fushuai Wang <fushuai.wang@...ux.dev>
To: tglx@...nel.org,
	peterz@...radead.org,
	mathieu.desnoyers@...icios.com,
	akpm@...ux-foundation.org,
	aliceryhl@...gle.com,
	yury.norov@...il.com,
	vmalik@...hat.com,
	kees@...nel.org,
	dave.hansen@...ux.intel.com,
	luto@...nel.org,
	mingo@...hat.com,
	bp@...en8.de,
	hpa@...or.com,
	rostedt@...dmis.org,
	mhiramat@...nel.org,
	brauner@...nel.org,
	jack@...e.cz,
	cyphar@...har.com
Cc: linux-kernel@...r.kernel.org,
	x86@...nel.org,
	linux-trace-kernel@...r.kernel.org,
	wangfushuai@...du.com
Subject: [PATCH v2 6/6] kstrtox: Use copy_from_user_nul() instead of copy_from_user()

From: Fushuai Wang <wangfushuai@...du.com>

Use copy_from_user_nul() instead of copy_from_user() to simplify
the code.

No functional change.

Signed-off-by: Fushuai Wang <wangfushuai@...du.com>
---
 lib/kstrtox.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/kstrtox.c b/lib/kstrtox.c
index bdde40cd69d7..e4ee72b75e09 100644
--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -402,9 +402,8 @@ int kstrtobool_from_user(const char __user *s, size_t count, bool *res)
 	char buf[4];
 
 	count = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, s, count))
+	if (copy_from_user_nul(buf, s, count))
 		return -EFAULT;
-	buf[count] = '\0';
 	return kstrtobool(buf, res);
 }
 EXPORT_SYMBOL(kstrtobool_from_user);
@@ -416,9 +415,8 @@ int f(const char __user *s, size_t count, unsigned int base, type *res)	\
 	char buf[1 + sizeof(type) * 8 + 1 + 1];				\
 									\
 	count = min(count, sizeof(buf) - 1);				\
-	if (copy_from_user(buf, s, count))				\
+	if (copy_from_user_nul(buf, s, count))				\
 		return -EFAULT;						\
-	buf[count] = '\0';						\
 	return g(buf, base, res);					\
 }									\
 EXPORT_SYMBOL(f)
-- 
2.36.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ