Skip to content

Commit 9440c42

Browse files
olsajirisuryasaimadhu
authored andcommitted
x86/syscall: Include asm/ptrace.h in syscall_wrapper header
With just the forward declaration of the 'struct pt_regs' in syscall_wrapper.h, the syscall stub functions: __[x64|ia32]_sys_*(struct pt_regs *regs) will have different definition of 'regs' argument in BTF data based on which object file they are defined in. If the syscall's object includes 'struct pt_regs' definition, the BTF argument data will point to a 'struct pt_regs' record, like: [226] STRUCT 'pt_regs' size=168 vlen=21 'r15' type_id=1 bits_offset=0 'r14' type_id=1 bits_offset=64 'r13' type_id=1 bits_offset=128 ... If not, it will point to a fwd declaration record: [15439] FWD 'pt_regs' fwd_kind=struct and make bpf tracing program hooking on those functions unable to access fields from 'struct pt_regs'. Include asm/ptrace.h directly in syscall_wrapper.h to make sure all syscalls see 'struct pt_regs' definition. This then results in BTF for '__*_sys_*(struct pt_regs *regs)' functions to point to the actual struct, not just the forward declaration. [ bp: No Fixes tag as this is not really a bug fix but "adjustment" so that BTF is happy. ] Reported-by: Akihiro HARAI <[email protected]> Signed-off-by: Jiri Olsa <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Cc: <[email protected]> # this is needed only for BTF so kernels >= 5.15 Link: https://lore.kernel.org/r/[email protected]
1 parent 247f34f commit 9440c42

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/include/asm/syscall_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifndef _ASM_X86_SYSCALL_WRAPPER_H
77
#define _ASM_X86_SYSCALL_WRAPPER_H
88

9-
struct pt_regs;
9+
#include <asm/ptrace.h>
1010

1111
extern long __x64_sys_ni_syscall(const struct pt_regs *regs);
1212
extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);

0 commit comments

Comments
 (0)