x86/vdso: Improve vdso=/vdso32= boot parameter validation
Subsystems (4)
cover x86/vdso: Improve vdso=/vdso32= boot parameter validation
Replace the deprecated simple_strtoul() [1] with kstrtouint() when parsing the vDSO boot parameters. This provides strict input validation, rejects partial input, and warns when disabling vDSO for invalid values.
Adjust both warnings for consistency and update the documentation.
Thorsten Blum (3):
x86/vdso: Use kstrtouint() to validate vdso= boot parameter x86/vdso: Use kstrtouint() to validate vdso32= boot parameter Documentation/arch/x86: Remove obsolete vdso32=2 compatibility note
Documentation/admin-guide/kernel-parameters.txt | 5 +---- arch/x86/entry/vdso/vdso32-setup.c | 10 ++++------ arch/x86/entry/vdso/vma.c | 6 +++++- 3 files changed, 10 insertions(+), 11 deletions(-)
base-commit: 979c294509f9248fe1e7c358d582fb37dd5ca12d
PATCH RESEND 1/3 x86/vdso: Use kstrtouint() to validate vdso= boot parameter
Replace the deprecated simple_strtoul() with kstrtouint() when parsing the vdso= boot parameter.
simple_strtoul() accepts partial input and silently converts invalid input to 0. Use kstrtouint() for strict input validation instead and reject malformed input. Accept only 0 and 1; warn and disable vDSO support otherwise.
kstrtouint() converts the input string directly to an unsigned int, avoiding an implicit conversion when assigning to vdso64_enabled.
--- arch/x86/entry/vdso/vma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/entry/vdso/vma.c +5 -1
@@ -299,7 +299,11 @@ 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 ); +if (kstrtouint (s,0 , &vdso64_enabled) || vdso64_enabled >1 ) { +pr_warn ("vdso= values other than 0 and 1 are invalid; vdso disabled\n" ); + vdso64_enabled =0 ; + } +return 1 ; }__setup ("vdso=" , vdso_setup);
PATCH RESEND 2/3 x86/vdso: Use kstrtouint() to validate vdso32= boot parameter
In reply to Thorsten BlumReplace the deprecated simple_strtoul() with kstrtouint() when parsing the vdso32= boot parameter and its X86_32 vdso= alias.
simple_strtoul() accepts partial input and silently converts invalid input to 0. Use kstrtouint() for strict input validation instead and reject malformed input. Accept only 0 and 1; warn and disable vDSO support otherwise.
kstrtouint() converts the input string directly to an unsigned int, avoiding an implicit conversion when assigning to vdso32_enabled.
Update the vdso32= handler comment to reflect the supported values.
--- arch/x86/entry/vdso/vdso32-setup.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/x86/entry/vdso/vdso32-setup.c +4 -6
@@ -30,10 +30,8 @@ unsigned int __read_mostly vdso32_enabled = VDSO_DEFAULT;static int __init vdso32_setup (char *s) { - vdso32_enabled =simple_strtoul (s,NULL ,0 ); - -if (vdso32_enabled >1 ) { -pr_warn ("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n" ); +if (kstrtouint (s,0 , &vdso32_enabled) || vdso32_enabled >1 ) { +pr_warn ("vdso32= values other than 0 and 1 are invalid; vdso disabled\n" ); vdso32_enabled =0 ; }
@@ -41,9 +39,9 @@ static int __init vdso32_setup(char *s) }/* -* For consistency, the argument vdso32=[012] affects the 32-bit vDSO +* For consistency, the argument vdso32=[01] affects the 32-bit vDSO * behavior on both 64-bit and 32-bit kernels. -* On 32-bit kernels, vdso=[012] means the same thing. +* On 32-bit kernels, vdso=[01] means the same thing. */ __setup ("vdso32=" , vdso32_setup);
PATCH RESEND 3/3 Documentation/arch/x86: Remove obsolete vdso32=2 compatibility note
In reply to Thorsten BlumCommit b0b49f2673f0 ("x86, vdso: Remove compat vdso support") removed compat vDSO support and documented vdso32=2 as an alias for vdso32=0.
However, since commit c06989da39cd ("x86/vdso: Ensure vdso32_enabled gets set to valid values only"), vdso32_setup() accepts only 0 and 1.
Remove the obsolete vdso32=2 compatibility note and document only the supported values.
--- Documentation/admin-guide/kernel-parameters.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -4
@@ -8260,15 +8260,12 @@ Kernel parameters vdso32= [X86] Control the 32-bit vDSO vdso32=1: enable 32-bit VDSO - vdso32=0 or vdso32=2: disable 32-bit VDSO + vdso32=0: disable 32-bit VDSO See the help text for CONFIG_COMPAT_VDSO for more details. If CONFIG_COMPAT_VDSO is set, the default is vdso32=0; otherwise, the default is vdso32=1. - For compatibility with older kernels, vdso32=2 is an - alias for vdso32=0. - Try vdso32=0 if you encounter an error that says: dl_main: Assertion `(void *) ph->p_vaddr == _rtld_local._dl_sysinfo_dso' failed!
Quoted 3 lines · Thorsten Blum
Replace the deprecated
simple_strtoul()[1] withkstrtouint()when parsing the vDSO boot parameters. This provides strict input validation, rejects partial input, and warns when disabling vDSO for invalid values.
Hey Thorsten,
I'm curious what motivated this change. Were you trying to manipulate the VDSO and ran into some difficulties? Or is it a larger effort to audit and simple_strtoul() users?
Quoted 10 lines · Dave Hansen
Quoted 3 lines · Thorsten Blum
Replace the deprecated
simple_strtoul()[1] withkstrtouint()when parsing the vDSO boot parameters. This provides strict input validation, rejects partial input, and warns when disabling vDSO for invalid values.Hey Thorsten,
I'm curious what motivated this change. Were you trying to manipulate the VDSO and ran into some difficulties? Or is it a larger effort to audit and
simple_strtoul()users?
I just stumbled upon it while studying the code, and simple_strto*() calls are often an opportunity to improve input validation.