Skip to content

Commit f1c5d01

Browse files
minipligregkh
authored andcommitted
x86/vdso: Ensure vdso32_enabled gets set to valid values only
commit c06989da39cdb10604d572c8c7ea8c8c97f3c483 upstream. vdso_enabled can be set to arbitrary integer values via the kernel command line 'vdso32=' parameter or via 'sysctl abi.vsyscall32'. load_vdso32() only maps VDSO if vdso_enabled == 1, but ARCH_DLINFO_IA32 merily checks for vdso_enabled != 0. As a consequence the AT_SYSINFO_EHDR auxiliary vector for the VDSO_ENTRY is emitted with a NULL pointer which causes a segfault when the application tries to use the VDSO. Restrict the valid arguments on the command line and the sysctl to 0 and 1. Fixes: b0b49f2 ("x86, vdso: Remove compat vdso support") Signed-off-by: Mathias Krause <minipli@googlemail.com> Acked-by: Andy Lutomirski <luto@amacapital.net> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Roland McGrath <roland@redhat.com> Link: http://lkml.kernel.org/r/1491424561-7187-1-git-send-email-minipli@googlemail.com Link: http://lkml.kernel.org/r/20170410151723.518412863@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f42be33 commit f1c5d01

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

arch/x86/entry/vdso/vdso32-setup.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ static int __init vdso32_setup(char *s)
3131
{
3232
vdso32_enabled = simple_strtoul(s, NULL, 0);
3333

34-
if (vdso32_enabled > 1)
34+
if (vdso32_enabled > 1) {
3535
pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n");
36+
vdso32_enabled = 0;
37+
}
3638

3739
return 1;
3840
}
@@ -63,13 +65,18 @@ subsys_initcall(sysenter_setup);
6365
/* Register vsyscall32 into the ABI table */
6466
#include <linux/sysctl.h>
6567

68+
static const int zero;
69+
static const int one = 1;
70+
6671
static struct ctl_table abi_table2[] = {
6772
{
6873
.procname = "vsyscall32",
6974
.data = &vdso32_enabled,
7075
.maxlen = sizeof(int),
7176
.mode = 0644,
72-
.proc_handler = proc_dointvec
77+
.proc_handler = proc_dointvec_minmax,
78+
.extra1 = (int *)&zero,
79+
.extra2 = (int *)&one,
7380
},
7481
{}
7582
};

0 commit comments

Comments
 (0)