Re: [RFC PATCH] set TASK_TRACED before arch_ptrace code to fix a race

From: Luming Yu
Date: Mon May 26 2008 - 23:31:54 EST


>
> if happens, it should be a bug, right?

It does happen!!

Call Trace:
[<a000000100011bd0>] show_stack+0x50/0xa0
sp=e000000146bbfbb0 bsp=e000000146bb0e08
[<a000000100011c50>] dump_stack+0x30/0x60
sp=e000000146bbfd80 bsp=e000000146bb0de8
[<a0000001000979a0>] get_signal_to_deliver+0x60/0x6e0
sp=e000000146bbfd80 bsp=e000000146bb0d80
[<a0000001000343d0>] ia64_do_signal+0xb0/0xd00
sp=e000000146bbfd80 bsp=e000000146bb0cd8
[<a000000100012650>] do_notify_resume_user+0xf0/0x140
sp=e000000146bbfe20 bsp=e000000146bb0ca8
[<a00000010000aac0>] notify_resume_user+0x40/0x60
sp=e000000146bbfe20 bsp=e000000146bb0c58
[<a00000010000a9f0>] skip_rbs_switch+0xe0/0x110
sp=e000000146bbfe30 bsp=e000000146bb0c58
[<a000000000010740>] __kernel_syscall_via_break+0x0/0x20
sp=e000000146bc0000 bsp=e000000146bb0c58

>>
> I will try to customize kernel to capture call trace for a precise code path.

I applied the following patch , and got the call trace above..
If apply my RFC patch as antidote, I don't see "deliver" ...
Is the problem clear now? I will serve you until every thing is clear to you.

Thanks,
Luming

Signed-off-by: Yu Luming <luming.yu@xxxxxxxxx>

diff -Bru 1/kernel/signal.c 0/kernel/signal.c
--- 1/kernel/signal.c 2008-05-27 15:18:48.000000000 +0800
+++ 0/kernel/signal.c 2008-05-27 15:08:51.000000000 +0800
@@ -38,6 +38,7 @@
*/

static struct kmem_cache *sigqueue_cachep;
+unsigned long global_arch_ptrace_stop_flag =0;

static int __sig_ignored(struct task_struct *t, int sig)
{
@@ -1501,9 +1502,12 @@
* siglock. That must prevent us from sleeping in TASK_TRACED.
* So after regaining the lock, we must check for SIGKILL.
*/
+ global_arch_ptrace_stop_flag = 1;
spin_unlock_irq(&current->sighand->siglock);
arch_ptrace_stop(exit_code, info);
+
spin_lock_irq(&current->sighand->siglock);
+ global_arch_ptrace_stop_flag = 0;
killed = sigkill_pending(current);
}

@@ -1701,6 +1705,8 @@
struct signal_struct *signal = current->signal;
int signr;

+ if (global_arch_ptrace_stop_flag)
+ dump_stack();
relock:
/*
* We'll jump back here after any time we were stopped in TASK_STOPPED.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/