From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753501AbcGSHd7 (ORCPT ); Tue, 19 Jul 2016 03:33:59 -0400 Received: from terminus.zytor.com ([198.137.202.10]:46770 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752366AbcGSHdz (ORCPT ); Tue, 19 Jul 2016 03:33:55 -0400 Date: Tue, 19 Jul 2016 00:33:03 -0700 From: tip-bot for Andy Lutomirski Message-ID: Cc: linux-kernel@vger.kernel.org, luto@kernel.org, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org, brgerst@gmail.com, bp@alien8.de, hpa@zytor.com, torvalds@linux-foundation.org, dvlasenk@redhat.com, jpoimboe@redhat.com Reply-To: mingo@kernel.org, brgerst@gmail.com, peterz@infradead.org, tglx@linutronix.de, luto@kernel.org, linux-kernel@vger.kernel.org, jpoimboe@redhat.com, dvlasenk@redhat.com, hpa@zytor.com, torvalds@linux-foundation.org, bp@alien8.de In-Reply-To: <8a30e0a07c3b47ff917a8daa2df5e407cc0c6698.1468878336.git.luto@kernel.org> References: <8a30e0a07c3b47ff917a8daa2df5e407cc0c6698.1468878336.git.luto@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/vdso: Error out if the vDSO isn't a valid DSO Git-Commit-ID: 57f90c3dfc75da89358735c06bf9bc9815b4183e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 57f90c3dfc75da89358735c06bf9bc9815b4183e Gitweb: http://git.kernel.org/tip/57f90c3dfc75da89358735c06bf9bc9815b4183e Author: Andy Lutomirski AuthorDate: Mon, 18 Jul 2016 14:46:35 -0700 Committer: Ingo Molnar CommitDate: Tue, 19 Jul 2016 08:50:24 +0200 x86/vdso: Error out if the vDSO isn't a valid DSO Some distros has been playing with toolchain changes that can affect the type of ELF objects built. Occasionally, this goes wrong and the vDSO ends up not being a DSO at all. This causes the kernel to end up broken in a surprisingly subtle way -- glibc apparently silently ignores a vDSO that isn't a DSO, so everything works, albeit slowly, until users try a different libc implementation. Make the kernel build process a bit more robust: fail outright if the vDSO isn't ET_DYN or is missing its PT_DYNAMIC segment. I've never seen this in an unmodified kernel. See: https://github.com/docker/docker/issues/23378 Signed-off-by: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/8a30e0a07c3b47ff917a8daa2df5e407cc0c6698.1468878336.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/entry/vdso/vdso2c.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/entry/vdso/vdso2c.h b/arch/x86/entry/vdso/vdso2c.h index 63a03bb..4f74119 100644 --- a/arch/x86/entry/vdso/vdso2c.h +++ b/arch/x86/entry/vdso/vdso2c.h @@ -22,6 +22,9 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, ELF(Phdr) *pt = (ELF(Phdr) *)(raw_addr + GET_LE(&hdr->e_phoff)); + if (hdr->e_type != ET_DYN) + fail("input is not a shared object\n"); + /* Walk the segment table. */ for (i = 0; i < GET_LE(&hdr->e_phnum); i++) { if (GET_LE(&pt[i].p_type) == PT_LOAD) { @@ -49,6 +52,9 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, if (stripped_len < load_size) fail("stripped input is too short\n"); + if (!dyn) + fail("input has no PT_DYNAMIC section -- your toolchain is buggy\n"); + /* Walk the dynamic table */ for (i = 0; dyn + i < dyn_end && GET_LE(&dyn[i].d_tag) != DT_NULL; i++) {