From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933689AbdDEUgi (ORCPT ); Wed, 5 Apr 2017 16:36:38 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:34886 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933135AbdDEUg2 (ORCPT ); Wed, 5 Apr 2017 16:36:28 -0400 From: Mathias Krause To: x86@kernel.org Cc: Mathias Krause , linux-kernel@vger.kernel.org, Andy Lutomirski , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Roland McGrath Subject: [PATCH] x86/vdso: ensure vdso32_enabled gets set to valid values only Date: Wed, 5 Apr 2017 22:36:01 +0200 Message-Id: <1491424561-7187-1-git-send-email-minipli@googlemail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If either via kernel command line 'vdso32=' or via 'sysctl abi.vsyscall32' vdso32_enabled gets set to a value below 0 or above 1, load_vdso32() won't map the vDSO but ARCH_DLINFO_IA32 would still pass an AT_SYSINFO_EHDR auxiliary vector, however with a NULL pointer. That'll make any program trying to make use of it fail with a segmentation fault. At least musl makes use of it if the kernel provides it. Ensure vdso32_enabled gets set to valid values only to fix this corner case. Fixes: b0b49f2673f0 ("x86, vdso: Remove compat vdso support") Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Roland McGrath Signed-off-by: Mathias Krause --- 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 7853b53959cd..ca312c174d6f 100644 --- a/arch/x86/entry/vdso/vdso32-setup.c +++ b/arch/x86/entry/vdso/vdso32-setup.c @@ -30,8 +30,10 @@ static int __init vdso32_setup(char *s) { vdso32_enabled = simple_strtoul(s, NULL, 0); - if (vdso32_enabled > 1) + if (vdso32_enabled > 1) { pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n"); + vdso32_enabled = 0; + } return 1; } @@ -62,13 +64,18 @@ int __init sysenter_setup(void) /* Register vsyscall32 into the ABI table */ #include +static const int zero; +static const int one = 1; + static struct ctl_table abi_table2[] = { { .procname = "vsyscall32", .data = &vdso32_enabled, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = proc_dointvec_minmax, + .extra1 = (int *)&zero, + .extra2 = (int *)&one, }, {} }; -- 1.7.10.4