From da7364b282817ea9ea6a6f1ce196d415c1ab6926 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Tue, 10 Mar 2020 21:19:28 -0700 Subject: [PATCH] sys_ni: Fix cond_syscall() alias for LTO When using LTO, the conditional syscall aliases aren't weak, and instead override implemented syscalls rather than serve as a fallback for missing syscalls. Fix the cond_syscall() alias using an attribute so that it gets properly evaluated at link time. Signed-off-by: Sultan Alsawaf --- include/linux/linkage.h | 6 ++---- kernel/Makefile | 5 ----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/include/linux/linkage.h b/include/linux/linkage.h index f3ae8f3dea2c..76130c7fe8a8 100644 --- a/include/linux/linkage.h +++ b/include/linux/linkage.h @@ -23,10 +23,8 @@ #endif #ifndef cond_syscall -#define cond_syscall(x) asm( \ - ".weak " __stringify(x) "\n\t" \ - ".set " __stringify(x) "," \ - __stringify(sys_ni_syscall)) +#define cond_syscall(x) \ + long __attribute__((weak, alias("sys_ni_syscall"))) x(void); #endif #ifndef SYSCALL_ALIAS diff --git a/kernel/Makefile b/kernel/Makefile index a37175b6754c..cb91a1a3458a 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -32,11 +32,6 @@ KCOV_INSTRUMENT_kcov.o := n KASAN_SANITIZE_kcov.o := n CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -ifndef CONFIG_CFI_CLANG -# cond_syscall is currently not gcc LTO compatible -CFLAGS_sys_ni.o = $(DISABLE_LTO) -endif - # Don't instrument error handlers CFLAGS_cfi.o = $(DISABLE_CFI_CLANG)