]> granicus.if.org Git - strace/commit
Move two global flags to tracee scope
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 26 Nov 2016 18:08:01 +0000 (18:08 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 26 Nov 2016 19:47:38 +0000 (19:47 +0000)
commit634a6a55e8bbf1e77ad28c144eb45dbbd666d31d
tree676d65139278b14cde72fffdb245b7b78f214f06
parent7910ac9638d9d3ae8c727fff32e165d2f44071bf
Move two global flags to tracee scope

A simultaneous use of -p option and tracing of a command available
since commit v4.11-183-gfa8c286 introduces a race condition because
the flags whether the first exec has happened are global.

Fix the race by moving hide_log_until_execve and hide_log_until_execve
global variables to TCB_HIDE_LOG and TCB_SKIP_DETACH_ON_FIRST_EXEC bits
in struct tcb.flags, correspondingly.

* defs.h (TCB_HIDE_LOG, TCB_SKIP_DETACH_ON_FIRST_EXEC, hide_log):
New macros.
(hide_log_until_execve): Remove prototype.
* strace.c (skip_one_b_execve, hide_log_until_execve): Remove.
(startup_child): Set TCB_HIDE_LOG and TCB_SKIP_DETACH_ON_FIRST_EXEC bits
in the allocated tcb structure.
(init): Remove initialization of hide_log_until_execve and
skip_one_b_execve.
(print_stopped): Use hide_log() instead of hide_log_until_execve.
(trace): Check and clear TCB_SKIP_DETACH_ON_FIRST_EXEC flag instead
of skip_one_b_execve.
* syscall.c (trace_syscall_entering): Clear TCB_HIDE_LOG flag instead of
hide_log_until_execve.
(trace_syscall_entering, trace_syscall_exiting): Check hide_log()
instead of hide_log_until_execve.
defs.h
strace.c
syscall.c