Skip to content

Commit b6ec413

Browse files
keesKAGA-KOKO
authored andcommitted
core/entry: Report syscall correctly for trace and audit
On v5.8 when doing seccomp syscall rewrites (e.g. getpid into getppid as seen in the seccomp selftests), trace (and audit) correctly see the rewritten syscall on entry and exit: seccomp_bpf-1307 [000] .... 22974.874393: sys_enter: NR 110 (... seccomp_bpf-1307 [000] .N.. 22974.874401: sys_exit: NR 110 = 1304 With mainline we see a mismatched enter and exit (the original syscall is incorrectly visible on entry): seccomp_bpf-1030 [000] .... 21.806766: sys_enter: NR 39 (... seccomp_bpf-1030 [000] .... 21.806767: sys_exit: NR 110 = 1027 When ptrace or seccomp change the syscall, this needs to be visible to trace and audit at that time as well. Update the syscall earlier so they see the correct value. Fixes: d88d59b ("core/entry: Respect syscall number rewrites") Reported-by: Michael Ellerman <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 856deb8 commit b6ec413

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/entry/common.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,
6060
return ret;
6161
}
6262

63+
/* Either of the above might have changed the syscall number */
64+
syscall = syscall_get_nr(current, regs);
65+
6366
if (unlikely(ti_work & _TIF_SYSCALL_TRACEPOINT))
6467
trace_sys_enter(regs, syscall);
6568

6669
syscall_enter_audit(regs, syscall);
6770

68-
/* The above might have changed the syscall number */
69-
return ret ? : syscall_get_nr(current, regs);
71+
return ret ? : syscall;
7072
}
7173

7274
static __always_inline long

0 commit comments

Comments
 (0)