mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint()
@ 2026-10-05 16:33 Habil Eren Türker
  2026-10-05 16:33 ` [PATCH v2 1/2] " Habil Eren Türker
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Habil Eren Türker @ 2026-10-05 16:33 UTC (permalink / raw)
  To: luto, tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, linux-kernel, Habil Eren Türker

This patch series replaces the deprecated simple_strtoul() function
with the safer kstrtouint() variant in the x86 vdso setup code.

The simple_strtoul() function is deprecated as it silently ignores
overflows. Proper bounds and lineer error checking are introduced.

Changes in v2:
- Fixed the logical short-circuit operator bug in parsing error paths
  where invalid inputs could trigger deceptive warning logs.
- Refactored error handling into a linear flow with unlikely() macros
  to avoid branch misprediction.
 
Habil Eren Türker (2):
  x86/vdso: Replace deprecated simple_strtoul() with kstrtouint()
  x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() in
    vdso_setup

 arch/x86/entry/vdso/vdso32-setup.c | 11 +++++++++--
 arch/x86/entry/vdso/vma.c          | 15 ++++++++++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)

-- 
2.47.3


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

* [PATCH v2 1/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint()
  2026-10-05 16:33 [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() Habil Eren Türker
@ 2026-10-05 16:33 ` Habil Eren Türker
  2026-10-05 16:33 ` [PATCH v2 2/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() in vdso_setup Habil Eren Türker
  2026-10-05 17:07 ` [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() Thorsten Blum
  2 siblings, 0 replies; 4+ messages in thread
From: Habil Eren Türker @ 2026-10-05 16:33 UTC (permalink / raw)
  To: luto, tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, linux-kernel, Habil Eren Türker

The simple_strtoul() function is deprecated because it explicitly ignores
overflows. Replace it with the proper variant, kstrtouint(),
in vdso32_setup().

It was detected while running a static analysis on the use of
simple_strtoul() in the kernel.

Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
---
 arch/x86/entry/vdso/vdso32-setup.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c
index 8894013ee..126c0398d 100644
--- a/arch/x86/entry/vdso/vdso32-setup.c
+++ b/arch/x86/entry/vdso/vdso32-setup.c
@@ -30,13 +30,20 @@ unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;
 
 static int __init vdso32_setup(char *s)
 {
-	vdso32_enabled = simple_strtoul(s, NULL, 0);
+	unsigned int val;
 
-	if (vdso32_enabled > 1) {
+	if (unlikely(kstrtouint(s, 0, &val))) {
+		vdso32_enabled = 0;
+		return 1;
+	}
+
+	if (val > 1) {
 		pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n");
 		vdso32_enabled = 0;
+		return 1;
 	}
 
+	vdso32_enabled = val;
 	return 1;
 }
 
-- 
2.47.3


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

* [PATCH v2 2/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() in vdso_setup
  2026-10-05 16:33 [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() Habil Eren Türker
  2026-10-05 16:33 ` [PATCH v2 1/2] " Habil Eren Türker
@ 2026-10-05 16:33 ` Habil Eren Türker
  2026-10-05 17:07 ` [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() Thorsten Blum
  2 siblings, 0 replies; 4+ messages in thread
From: Habil Eren Türker @ 2026-10-05 16:33 UTC (permalink / raw)
  To: luto, tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, linux-kernel, Habil Eren Türker

The simple_strtoul() function is deprecated because it explicitly ignores
overflows. Replace it with the proper variant, kstrtouint(),
in vdso_setup(). Also add pr_warn().

It was detected while running a static analysis on the use of
simple_strtoul() in the kernel.

Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
---
 arch/x86/entry/vdso/vma.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 18dfd80a8..62d96a537 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -299,7 +299,20 @@ bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
 #ifdef CONFIG_X86_64
 static __init int vdso_setup(char *s)
 {
-	vdso64_enabled = simple_strtoul(s, NULL, 0);
+	unsigned int val;
+
+	if (unlikely(kstrtouint(s, 0, &val))) {
+		vdso64_enabled = 0;
+		return 1;
+	}
+
+	if (val > 1) {
+		pr_warn("vdso64 values other than 0 and 1 are no longer allowed; vdso disabled\n");
+		vdso64_enabled = 0;
+		return 1;
+	}
+
+	vdso64_enabled = val;
 	return 1;
 }
 __setup("vdso=", vdso_setup);
-- 
2.47.3


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

* Re: [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint()
  2026-10-05 16:33 [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() Habil Eren Türker
  2026-10-05 16:33 ` [PATCH v2 1/2] " Habil Eren Türker
  2026-10-05 16:33 ` [PATCH v2 2/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() in vdso_setup Habil Eren Türker
@ 2026-10-05 17:07 ` Thorsten Blum
  2 siblings, 0 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-10-05 17:07 UTC (permalink / raw)
  To: Habil Eren Türker
  Cc: luto, tglx, mingo, bp, dave.hansen, x86, hpa, linux-kernel

On Mon, Oct 05, 2026 at 04:33:37PM +0000, Habil Eren Türker wrote:
> This patch series replaces the deprecated simple_strtoul() function
> with the safer kstrtouint() variant in the x86 vdso setup code.
> 
> The simple_strtoul() function is deprecated as it silently ignores
> overflows. Proper bounds and lineer error checking are introduced.
> 
> Changes in v2:
> - Fixed the logical short-circuit operator bug in parsing error paths
>   where invalid inputs could trigger deceptive warning logs.
> - Refactored error handling into a linear flow with unlikely() macros
>   to avoid branch misprediction.
>  
> Habil Eren Türker (2):
>   x86/vdso: Replace deprecated simple_strtoul() with kstrtouint()
>   x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() in
>     vdso_setup
> 
>  arch/x86/entry/vdso/vdso32-setup.c | 11 +++++++++--
>  arch/x86/entry/vdso/vma.c          | 15 ++++++++++++++-
>  2 files changed, 23 insertions(+), 3 deletions(-)

I submitted a very similar series a while ago [1], but haven't received
feedback yet (besides a Reviewed-by from Randy on the documentation
change).

Dave, did you have a chance to take a look at my series yet?

Thanks,
Thorsten

[1] https://lore.kernel.org/lkml/20260831101657.2947-5-blum@kernel.org/

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

end of thread, other threads:[~2026-10-05 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05 16:33 [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() Habil Eren Türker
2026-10-05 16:33 ` [PATCH v2 1/2] " Habil Eren Türker
2026-10-05 16:33 ` [PATCH v2 2/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() in vdso_setup Habil Eren Türker
2026-10-05 17:07 ` [PATCH v2 0/2] x86/vdso: Replace deprecated simple_strtoul() with kstrtouint() Thorsten Blum

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

all inboxes | Powered by JetHome®