Skip to content

Commit 57f90c3

Browse files
amlutoIngo Molnar
authored andcommitted
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: moby/moby#23378 Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/8a30e0a07c3b47ff917a8daa2df5e407cc0c6698.1468878336.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent be8a18e commit 57f90c3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/x86/entry/vdso/vdso2c.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
2222

2323
ELF(Phdr) *pt = (ELF(Phdr) *)(raw_addr + GET_LE(&hdr->e_phoff));
2424

25+
if (hdr->e_type != ET_DYN)
26+
fail("input is not a shared object\n");
27+
2528
/* Walk the segment table. */
2629
for (i = 0; i < GET_LE(&hdr->e_phnum); i++) {
2730
if (GET_LE(&pt[i].p_type) == PT_LOAD) {
@@ -49,6 +52,9 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
4952
if (stripped_len < load_size)
5053
fail("stripped input is too short\n");
5154

55+
if (!dyn)
56+
fail("input has no PT_DYNAMIC section -- your toolchain is buggy\n");
57+
5258
/* Walk the dynamic table */
5359
for (i = 0; dyn + i < dyn_end &&
5460
GET_LE(&dyn[i].d_tag) != DT_NULL; i++) {

0 commit comments

Comments
 (0)