[PATCH 0/31] utrace for 3.1 kernel

2011-08-03 Thread Oleg Nesterov
On 08/02, Oleg Nesterov wrote: utrace patches for 3.1 kernel. Untested, will try to do some tests tomorrow. I tried to test it a bit, seems to work. But see the new [PATCH 31/31] utrace_resume: check irqs_disabled() to shut up lockdep. The whole series is available in

[PATCH 04/31] tracehooks: reintroduce tracehook_consider_fatal_signal()

2011-08-03 Thread Oleg Nesterov
Add the killed tracehook_consider_fatal_signal() back. It has multiple callers and it is not easy add the necessary checks inline. Signed-off-by: Oleg Nesterov o...@redhat.com --- arch/s390/kernel/traps.c |4 ++-- include/linux/tracehook.h | 22 ++ kernel/signal.c

[PATCH 08/31] restore the DEATH/REAP utrace hooks

2011-08-03 Thread Oleg Nesterov
Restore the necessary hooks in release_task() and exit_notify(), add the corresponding helpers into utrace.h. Note: the @signal argument passed to -report_death() does not match the previous behaviour. I think this shouldn't affect the current users, and I bet nobody can really understand what

[PATCH 09/31] utrace: remove jobctl bits

2011-08-03 Thread Oleg Nesterov
- change utrace_get_signal() to check JOBCTL_STOP_PENDING instead of signal-group_stop_count. With the recent changes group_stop_count doesn't necessarily mean this task should participate in group stop. - remove the participate in group stop code from utrace_wakeup() and utrace_stop(),

[PATCH 05/31] add utrace hooks into sig_ignored() and recalc_sigpending()

2011-08-03 Thread Oleg Nesterov
Add the necessary and somewhat special hooks into sig_ignored() and recalc_sigpending(). Basically this restores _force_sigpending() and _consider_ignored_signal() tracehook logic. Signed-off-by: Oleg Nesterov o...@redhat.com --- include/linux/utrace.h |2 ++ kernel/signal.c|7

[PATCH 11/31] introduce wake_up_quiescent()

2011-08-03 Thread Oleg Nesterov
No functional changes. Add the new helper, wake_up_quiescent(task, state), which simply returns wake_up_state(task, state). Change all callers which do wake_up_state(STOPPED/TRACED) to use the new helper. ptrace_stop() is a bit special, it does __set_current_state(RUNNING) in the very unlikely

[PATCH 16/31] reintroduce tracehook_finish_jctl() as utrace_end_stop()

2011-08-03 Thread Oleg Nesterov
utrace_finish_stop() is needed to avoid the races with SIGKILL which wakes up UTRACED task, and thus it should be called every time after the STOPPED/TRACED/UTRACED returns from schedule(), remember that TASK_UTRACED can be added while the task is STOPPED/UTRACED. - change do_signal_state() to

[PATCH 15/31] utrace: use TASK_UTRACED instead of TASK_TRACED

2011-08-03 Thread Oleg Nesterov
Change utrace.c to use TASK_UTRACED instead of TASK_TRACED. - utrace_stop/utrace_wakeup: simply use the new state - utrace_do_stop: do not clear STOPPED/TRACED, but add the new __TASK_UTRACED bit to state the fact that both ptrace and utrace want this task to be stopped - naturally, do not

[PATCH 12/31] introduce ptrace_signal_wake_up()

2011-08-03 Thread Oleg Nesterov
Add the new helper, ptrace_signal_wake_up(), change ptrace.c/signal.c to use it instead of signal_wake_up() to wake up a STOPPED/TRACED task. The new helper does almost the same, except: - it doesn't use the TASK_WAKEKILL bit to wake up the TRACED or STOPPED task, it uses

[PATCH 18/31] ptrace_stop: do not assume the task is running after wake_up_quiescent()

2011-08-03 Thread Oleg Nesterov
If ptrace_stop() sets TASK_TRACED and then detects we should not stop, it can race with utrace_do_stop() which can see TASK_TRACED and add TASK_UTRACED. In this case we should stop for utrace needs. Signed-off-by: Oleg Nesterov o...@redhat.com --- kernel/signal.c |8 1 files

[PATCH 14/31] introduce TASK_UTRACED state

2011-08-03 Thread Oleg Nesterov
Introduce TASK_UTRACED state, will be used by utrace instead of TASK_TRACED. Note: this state is reported as t (tracing stop) to the user-space to avoid the confusion. IOW, it looks like TASK_TRACED in /proc/pid/status. Signed-off-by: Oleg Nesterov o...@redhat.com --- fs/proc/array.c |

[PATCH 19/31] get_signal_to_deliver: restore/restructure utrace/ptrace signal reporting

2011-08-03 Thread Oleg Nesterov
- Reintroduce tracehook_get_signal() as utrace_hook_signal(). - Change get_signal_to_deliver() to call utrace_hook_signal() first, before dequeue_signal() - Always call ptrace_signal() if signal != SIGKILL, no matter whether this signal comes from utrace or not. Since this can change

[PATCH 20/31] utrace_get_signal: s/JOBCTL_STOP_PENDING/JOBCTL_PENDING_MASK/

2011-08-03 Thread Oleg Nesterov
utrace_get_signal() checks JOBCTL_STOP_PENDING to detect the case when we should not try to dequeue the signal but should try to participate in the group-stop. With the recent changes this is not enough, everything which contrbutes to recalc_sigpending_tsk() should be respected. Check

[PATCH 17/31] teach wake_up_quiescent() to do selective wake_up

2011-08-03 Thread Oleg Nesterov
Both utrace and ptrace can want the same thread to be quiescent, in this case its state is TASK_TRACED | TASK_UTRACED. And this also means that this task must not run unless both utrace and ptrace resume it. Change wake_up_quiescent(p, state) to do p-state = ~state and return false unless there

[PATCH 22/31] introduce PT_SYSCALL_TRACE flag

2011-08-03 Thread Oleg Nesterov
Currently tracehooks assume that if the ptraced task has TIF_SYSCALL_TRACE set, the tracee should report the syscall. This is not true, this thread flag can be set by utrace. Add the new internal ptrace flag, PT_SYSCALL_TRACE. Change ptrace_set_syscall_trace() to set/clear this bit along with

[PATCH 21/31] introduce ptrace_set_syscall_trace()

2011-08-03 Thread Oleg Nesterov
No functional changes. Add the new helper, ptrace_set_syscall_trace(), which should be used to set/clear TIF_SYSCALL_TRACE in ptrace code. Currently it does nothing more. Signed-off-by: Oleg Nesterov o...@redhat.com --- kernel/ptrace.c | 15 ++- 1 files changed, 10 insertions(+), 5

[PATCH 23/31] utrace: don't clear TIF_SYSCALL_TRACE if it is needed by ptrace

2011-08-03 Thread Oleg Nesterov
TIF_SYSCALL_TRACE should be cleared only if both ptrace and utrace do not want it, change utrace_reset() to check PT_SYSCALL_TRACE before clear_tsk_thread_flag(TIF_SYSCALL_TRACE). Signed-off-by: Oleg Nesterov o...@redhat.com --- kernel/utrace.c |1 + 1 files changed, 1 insertions(+), 0

[PATCH 02/31] utrace: add utrace_init_task/utrace_free_task calls

2011-08-03 Thread Oleg Nesterov
Add the necessary copy_process()-utrace_init_task() and free_task()-utrace_free_task() calls. Originally this was the part of utrace core patch, but since tracehooks are dying it doesn't make sense to reintroduce them. Instead, just call the utrace_ helpers directly. This is fine even without

[PATCH 24/31] introduce task_utrace_lock/task_utrace_unlock

2011-08-03 Thread Oleg Nesterov
- Add task_utrace_lock(task). It simply takes task-utrace-lock if this task was ever utraced. Otherwise it takes task_lock(), this serializes with utrace_attach_task()-utrace_task_alloc(). In both case the caller can be sure it can't race with anything which needs utrace-lock. - Add

[PATCH 27/31] utrace: finish_resume_report: don't do user_xxx_step() if ptrace_wants_step()

2011-08-03 Thread Oleg Nesterov
finish_resume_report() should not enable/disable the stepping if ptrace_wants_step() == T. If ptrace wants block_step while utrace wants single_step we could promote the stepping, but I do not think this really makes sense. Unless the tracee is killed this can't race with ptrace, this is called

[PATCH 30/31] ptrace_report_syscall: check TIF_SYSCALL_EMU

2011-08-03 Thread Oleg Nesterov
4d16a64 introduce PT_SYSCALL_TRACE flag breaks PTRACE_SYSEMU which doesn't set PT_SYSCALL_TRACE. Change ptrace_report_syscall() to check TIF_SYSCALL_EMU as well. This can't conflict with utrace, this flag can only be set by ptrace. Signed-off-by: Oleg Nesterov o...@redhat.com ---