Skip to content

Commit 30bd93d

Browse files
committed
Apply use-after-free and empty-symbol-table fixes to Linux 5.10
We cannot compile Linux 5.10 with toolchains involving GCC 12 or newer without these patches.
1 parent d5d54c6 commit 30bd93d

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

Diff for: integration/linux/compile_linux.sh

+81
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,87 @@ ln -s goto-cc src/goto-cc/goto-g++
3232
configure_linux ()
3333
{
3434
pushd linux_5_10
35+
# GCC >= 12 correctly reports (and fails with) use-after-free, which was
36+
# eventually fixed in 5.16.11 (and 5.17+)
37+
curl https://github.com/torvalds/linux/commit/52a9dab6d892763b2a8334a568bd4e2c1a6fde66.patch | patch -p1
38+
# Some versions of binutils fail to generate a symbol table, pick up fix that
39+
# eventually landed in 6.0, see
40+
# https://github.com/torvalds/linux/commit/de979c83574abf6e78f3fa65b716515c91b2613d
41+
cat > de979c83574abf6e78f3fa65b716515c91b2613d-adjusted.patch << "EOF"
42+
diff --git a/arch/x86/entry/Makefile b/arch/x86/entry/Makefile
43+
index 08bf95dbc..83c98dae7 100644
44+
--- a/arch/x86/entry/Makefile
45+
+++ b/arch/x86/entry/Makefile
46+
@@ -21,12 +21,13 @@ CFLAGS_syscall_64.o += $(call cc-option,-Wno-override-init,)
47+
CFLAGS_syscall_32.o += $(call cc-option,-Wno-override-init,)
48+
CFLAGS_syscall_x32.o += $(call cc-option,-Wno-override-init,)
49+
50+
-obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o
51+
+obj-y := entry_$(BITS).o syscall_$(BITS).o
52+
obj-y += common.o
53+
54+
obj-y += vdso/
55+
obj-y += vsyscall/
56+
57+
+obj-$(CONFIG_PREEMPTION) += thunk_$(BITS).o
58+
obj-$(CONFIG_IA32_EMULATION) += entry_64_compat.o syscall_32.o
59+
obj-$(CONFIG_X86_X32_ABI) += syscall_x32.o
60+
61+
diff --git a/arch/x86/entry/thunk_32.S b/arch/x86/entry/thunk_32.S
62+
index f1f96d4d8..5997ec0b4 100644
63+
--- a/arch/x86/entry/thunk_32.S
64+
+++ b/arch/x86/entry/thunk_32.S
65+
@@ -29,10 +29,8 @@ SYM_CODE_START_NOALIGN(\name)
66+
SYM_CODE_END(\name)
67+
.endm
68+
69+
-#ifdef CONFIG_PREEMPTION
70+
THUNK preempt_schedule_thunk, preempt_schedule
71+
THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace
72+
EXPORT_SYMBOL(preempt_schedule_thunk)
73+
EXPORT_SYMBOL(preempt_schedule_notrace_thunk)
74+
-#endif
75+
76+
diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
77+
index ccd32877a..c7cf79be7 100644
78+
--- a/arch/x86/entry/thunk_64.S
79+
+++ b/arch/x86/entry/thunk_64.S
80+
@@ -36,14 +36,11 @@ SYM_FUNC_END(\name)
81+
_ASM_NOKPROBE(\name)
82+
.endm
83+
84+
-#ifdef CONFIG_PREEMPTION
85+
THUNK preempt_schedule_thunk, preempt_schedule
86+
THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace
87+
EXPORT_SYMBOL(preempt_schedule_thunk)
88+
EXPORT_SYMBOL(preempt_schedule_notrace_thunk)
89+
-#endif
90+
91+
-#ifdef CONFIG_PREEMPTION
92+
SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
93+
popq %r11
94+
popq %r10
95+
@@ -58,4 +55,3 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
96+
ret
97+
_ASM_NOKPROBE(.L_restore)
98+
SYM_CODE_END(.L_restore)
99+
-#endif
100+
diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile
101+
index 77f70b969..3113800da 100644
102+
--- a/arch/x86/um/Makefile
103+
+++ b/arch/x86/um/Makefile
104+
@@ -27,7 +27,8 @@ else
105+
106+
obj-y += syscalls_64.o vdso/
107+
108+
-subarch-y = ../lib/csum-partial_64.o ../lib/memcpy_64.o ../entry/thunk_64.o
109+
+subarch-y = ../lib/csum-partial_64.o ../lib/memcpy_64.o
110+
+subarch-$(CONFIG_PREEMPTION) += ../entry/thunk_64.o
111+
112+
endif
113+
114+
EOF
115+
patch -p1 < de979c83574abf6e78f3fa65b716515c91b2613d-adjusted.patch
35116

36117
cat > kvm-config <<EOF
37118
CONFIG_64BIT=y

0 commit comments

Comments
 (0)