Skip to content

Commit

Permalink
arm64: fix function types in COND_SYSCALL
Browse files Browse the repository at this point in the history
Define a weak function in COND_SYSCALL instead of a weak alias to
sys_ni_syscall, which has an incompatible type. This fixes indirect
call mismatches with Control-Flow Integrity (CFI) checking.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
samitolvanen authored and willdeacon committed Sep 17, 2019
1 parent bd3841c commit c27eccf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions arch/arm64/include/asm/syscall_wrapper.h
Expand Up @@ -8,6 +8,8 @@
#ifndef __ASM_SYSCALL_WRAPPER_H
#define __ASM_SYSCALL_WRAPPER_H

struct pt_regs;

#define SC_ARM64_REGS_TO_ARGS(x, ...) \
__MAP(x,__SC_ARGS \
,,regs->regs[0],,regs->regs[1],,regs->regs[2] \
Expand Down Expand Up @@ -35,8 +37,11 @@
ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \
asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused)

#define COND_SYSCALL_COMPAT(name) \
cond_syscall(__arm64_compat_sys_##name);
#define COND_SYSCALL_COMPAT(name) \
asmlinkage long __weak __arm64_compat_sys_##name(const struct pt_regs *regs) \
{ \
return sys_ni_syscall(); \
}

#define COMPAT_SYS_NI(name) \
SYSCALL_ALIAS(__arm64_compat_sys_##name, sys_ni_posix_timers);
Expand Down Expand Up @@ -70,7 +75,11 @@
#endif

#ifndef COND_SYSCALL
#define COND_SYSCALL(name) cond_syscall(__arm64_sys_##name)
#define COND_SYSCALL(name) \
asmlinkage long __weak __arm64_sys_##name(const struct pt_regs *regs) \
{ \
return sys_ni_syscall(); \
}
#endif

#ifndef SYS_NI
Expand Down

0 comments on commit c27eccf

Please sign in to comment.