Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1273381 > unrolled thread
| Started by | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| First post | 2015-11-19 19:50 +0100 |
| Last post | 2015-11-24 00:10 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 1/2] ptrace: make wait_on_bit(JOBCTL_TRAPPING_BIT) in ptrace_attach() killable Oleg Nesterov <oleg@redhat.com> - 2015-11-19 19:50 +0100
Re: [PATCH 1/2] ptrace: make wait_on_bit(JOBCTL_TRAPPING_BIT) in ptrace_attach() killable Tejun Heo <tj@kernel.org> - 2015-11-24 00:10 +0100
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Date | 2015-11-19 19:50 +0100 |
| Subject | [PATCH 1/2] ptrace: make wait_on_bit(JOBCTL_TRAPPING_BIT) in ptrace_attach() killable |
| Message-ID | <qwCrp-4G9-39@gated-at.bofh.it> |
ptrace_attach() can hang waiting for STOPPED -> TRACED transition if the
tracee gets frozen in between, change wait_on_bit() to use TASK_KILLABLE.
This doesn't really solve the problem(s) and we probably need to fix the
freezer. In particular, note that this means that pm freezer will fail if
it races attach-to-stopped-task.
And otoh perhaps we can just remove JOBCTL_TRAPPING_BIT altogether, it is
not clear if we really need to hide this transition from debugger, WNOHANG
after PTRACE_ATTACH can fail anyway if it races with SIGCONT.
Reported-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/ptrace.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index c8e0e05..80b3604 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -364,8 +364,14 @@ unlock_creds:
mutex_unlock(&task->signal->cred_guard_mutex);
out:
if (!retval) {
- wait_on_bit(&task->jobctl, JOBCTL_TRAPPING_BIT,
- TASK_UNINTERRUPTIBLE);
+ /*
+ * We do not bother to change retval or clear JOBCTL_TRAPPING
+ * if wait_on_bit() was interrupted by SIGKILL. The tracer will
+ * not return to user-mode, it will exit and clear this bit in
+ * __ptrace_unlink() if it wasn't already cleared by the tracee;
+ * and until then nobody can ptrace this task.
+ */
+ wait_on_bit(&task->jobctl, JOBCTL_TRAPPING_BIT, TASK_KILLABLE);
proc_ptrace_connector(task, PTRACE_ATTACH);
}
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Date | 2015-11-24 00:10 +0100 |
| Message-ID | <qy8pc-8rU-7@gated-at.bofh.it> |
| In reply to | #1273381 |
On Thu, Nov 19, 2015 at 07:47:32PM +0100, Oleg Nesterov wrote: > ptrace_attach() can hang waiting for STOPPED -> TRACED transition if the > tracee gets frozen in between, change wait_on_bit() to use TASK_KILLABLE. > > This doesn't really solve the problem(s) and we probably need to fix the > freezer. In particular, note that this means that pm freezer will fail if > it races attach-to-stopped-task. > > And otoh perhaps we can just remove JOBCTL_TRAPPING_BIT altogether, it is > not clear if we really need to hide this transition from debugger, WNOHANG > after PTRACE_ATTACH can fail anyway if it races with SIGCONT. > > Reported-by: Andrey Ryabinin <aryabinin@virtuozzo.com> > Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Tejun Heo <tj@kernel.org> Thanks. -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web