Skip to content

Commit 6a2e92a

Browse files
oleg-nesterovgregkh
authored andcommitted
tracing: Fix syscall_*regfunc() vs copy_process() race
commit 4af4206 upstream. syscall_regfunc() and syscall_unregfunc() should set/clear TIF_SYSCALL_TRACEPOINT system-wide, but do_each_thread() can race with copy_process() and miss the new child which was not added to the process/thread lists yet. Change copy_process() to update the child's TIF_SYSCALL_TRACEPOINT under tasklist. Link: http://lkml.kernel.org/p/20140413185854.GB20668@redhat.com Fixes: a871bd3 "tracing: Add syscall tracepoints" Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d2b095b commit 6a2e92a

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎include/trace/syscall.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/tracepoint.h>
55
#include <linux/unistd.h>
66
#include <linux/ftrace_event.h>
7+
#include <linux/thread_info.h>
78

89
#include <asm/ptrace.h>
910

@@ -32,4 +33,18 @@ struct syscall_metadata {
3233
struct ftrace_event_call *exit_event;
3334
};
3435

36+
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
37+
static inline void syscall_tracepoint_update(struct task_struct *p)
38+
{
39+
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
40+
set_tsk_thread_flag(p, TIF_SYSCALL_TRACEPOINT);
41+
else
42+
clear_tsk_thread_flag(p, TIF_SYSCALL_TRACEPOINT);
43+
}
44+
#else
45+
static inline void syscall_tracepoint_update(struct task_struct *p)
46+
{
47+
}
48+
#endif
49+
3550
#endif /* _TRACE_SYSCALL_H */

‎kernel/fork.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
14841484

14851485
total_forks++;
14861486
spin_unlock(&current->sighand->siglock);
1487+
syscall_tracepoint_update(p);
14871488
write_unlock_irq(&tasklist_lock);
1489+
14881490
proc_fork_connector(p);
14891491
cgroup_post_fork(p);
14901492
if (clone_flags & CLONE_THREAD)

0 commit comments

Comments
 (0)