[lkml]   [2019]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] ftrace: enable trampoline when rec count decrement to one
Hi, Steven

On 2019/5/6 3:34, Steven Rostedt wrote:
> Thanks for the patch. There was some race condition that prevented me
> from doing this in the first place, but unfortunately, I don't remember
> what that was :-/
> I'll have to think about this before applying this patch.
> Maybe there isn't a race condition, and I was just playing it safe, as
> there was a race condition between switching from regs caller back to
> non regs caller.
> -- Steve
> .

function tracer uses ftrace_caller() and livepatch uses

I can modify my testcase to trigger this race condition.

#enable livepatch
insmod klp_unshare_files.ko
cat /sys/kernel/debug/tracing/enabled_functions
unshare_files (1) R I tramp: 0xffffffffc0008000 (klp_ftrace_handler+0x0/0xa0) ->ftrace_ops_assist_func+0x0/0xf0
[NOW, the rec caller is ftracer_regs_caller TRAMPOLINE]

#function tracer
echo unshare_files > /sys/kernel/debug/tracing/set_ftrace_filter
echo function > /sys/kernel/debug/tracing/current_tracer
cat /sys/kernel/debug/tracing/enabled_functions
unshare_files (2) R I ->ftrace_ops_list_func+0x0/0x170
[NOW, the rec caller is ftracer_regs_caller]

# disable livepatch
echo 0 > /sys/kernel/livepatch/klp_unshare_files/enabled
rmmod klp_unshare_files

cat /sys/kernel/debug/tracing/enabled_functions
unshare_files (1) tramp: 0xffffffffc0005000 (function_trace_call+0x0/0x120) ->function_trace_call+0x0/0x120
[NOW, the rec caller is ftrace_caller TRAMPOLINE]

So, the caller switch from regs caller back to non regs caller
when disable the livepatch. Could this testcase cause the race
condition ? BUT, Nothing happened here.

What will happen when the race triggers ? What can I do.


Cheng Jian.

 \ /
  Last update: 2019-05-08 17:06    [W:0.047 / U:28.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site