aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/vdso/vdso-fakesections.c
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@amacapital.net>2014-06-12 20:53:12 -0400
committerH. Peter Anvin <hpa@zytor.com>2014-06-12 22:02:30 -0400
commite0bf7b86dace87eccdabdd66d2769ccad19cb81c (patch)
tree25ca13ba0e165ab1d16faf266d4b8d8046b7a5f7 /arch/x86/vdso/vdso-fakesections.c
parentb4b31f6101433e4b8ee73779b69b935af07682f8 (diff)
x86/vdso: Hack to keep 64-bit Go programs working
The Go runtime has a buggy vDSO parser that currently segfaults. This writes an empty SHT_DYNSYM entry that causes Go's runtime to malfunction by thinking that the vDSO is empty rather than malfunctioning by running off the end and segfaulting. This affects x86-64 only as far as we know, so we do not need this for the i386 and x32 vdsos. Signed-off-by: Andy Lutomirski <luto@amacapital.net> Link: http://lkml.kernel.org/r/d10618176c4bd39b457a5e85c497295c90cab1bc.1402620737.git.luto@amacapital.net Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/vdso/vdso-fakesections.c')
-rw-r--r--arch/x86/vdso/vdso-fakesections.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/arch/x86/vdso/vdso-fakesections.c b/arch/x86/vdso/vdso-fakesections.c
new file mode 100644
index 000000000000..cb8a8d72c24b
--- /dev/null
+++ b/arch/x86/vdso/vdso-fakesections.c
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2014 Andy Lutomirski
3 * Subject to the GNU Public License, v.2
4 *
5 * Hack to keep broken Go programs working.
6 *
7 * The Go runtime had a couple of bugs: it would read the section table to try
8 * to figure out how many dynamic symbols there were (it shouldn't have looked
9 * at the section table at all) and, if there were no SHT_SYNDYM section table
10 * entry, it would use an uninitialized value for the number of symbols. As a
11 * workaround, we supply a minimal section table. vdso2c will adjust the
12 * in-memory image so that "vdso_fake_sections" becomes the section table.
13 *
14 * The bug was introduced by:
15 * https://code.google.com/p/go/source/detail?r=56ea40aac72b (2012-08-31)
16 * and is being addressed in the Go runtime in this issue:
17 * https://code.google.com/p/go/issues/detail?id=8197
18 */
19
20#ifndef __x86_64__
21#error This hack is specific to the 64-bit vDSO
22#endif
23
24#include <linux/elf.h>
25
26extern const __visible struct elf64_shdr vdso_fake_sections[];
27const __visible struct elf64_shdr vdso_fake_sections[] = {
28 {
29 .sh_type = SHT_DYNSYM,
30 .sh_entsize = sizeof(Elf64_Sym),
31 }
32};