• Peter Zijlstra's avatar
    x86/ibt, objtool: Don't discard text references from tracepoint section · 38e0e4d0
    Peter Zijlstra authored
    On Tue, Jun 28, 2022 at 04:28:58PM +0800, Pengfei Xu wrote:
    
    > # ./ftracetest
    > === Ftrace unit tests ===
    > [1] Basic trace file check      [PASS]
    > [2] Basic test for tracers      [PASS]
    > [3] Basic trace clock test      [PASS]
    > [4] Basic event tracing check   [PASS]
    > [5] Change the ringbuffer size  [PASS]
    > [6] Snapshot and tracing setting        [PASS]
    > [7] trace_pipe and trace_marker [PASS]
    > [8] Test ftrace direct functions against tracers        [UNRESOLVED]
    > [9] Test ftrace direct functions against kprobes        [UNRESOLVED]
    > [10] Generic dynamic event - add/remove eprobe events   [FAIL]
    > [11] Generic dynamic event - add/remove kprobe events
    >
    > It 100% reproduced in step 11 and then missing ENDBR BUG generated:
    > "
    > [ 9332.752836] mmiotrace: enabled CPU7.
    > [ 9332.788612] mmiotrace: disabled.
    > [ 9337.103426] traps: Missing ENDBR: syscall_regfunc+0x0/0xb0
    
    It turns out that while syscall_regfunc() does have an ENDBR when
    generated, it gets sealed by objtool's .ibt_endbr_seal list.
    
    Since the only text references to this function:
    
      $ git grep syscall_regfunc
      include/linux/tracepoint.h:extern int syscall_regfunc(void);
      include/trace/events/syscalls.h:        syscall_regfunc, syscall_unregfunc
      include/trace/events/syscalls.h:        syscall_regfunc, syscall_unregfunc
      kernel/tracepoint.c:int syscall_regfunc(void)
    
    appear in the __tracepoint section which is excluded by objtool.
    
    Fixes: 3c6f9f77 ("objtool: Rework ibt and extricate from stack validation")
    Reported-by: Pengfei Xu <pengfei.xu@intel.com
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/Yrrepdaow4F5kqG0@hirez.programming.kicks-ass.net
    38e0e4d0
check.c 93 KB