Oleg Nesterov
fab840fc2d
ptrace: PTRACE_DETACH should do flush_ptrace_hw_breakpoint(child)
...
Change ptrace_detach() to call flush_ptrace_hw_breakpoint(child). This
frees the slots for non-ptrace PERF_TYPE_BREAKPOINT users, and this
ensures that the tracee won't be killed by SIGTRAP triggered by the
active breakpoints.
Test-case:
unsigned long encode_dr7(int drnum, int enable, unsigned int type, unsigned int len)
{
unsigned long dr7;
dr7 = ((len | type) & 0xf)
<< (DR_CONTROL_SHIFT + drnum * DR_CONTROL_SIZE);
if (enable)
dr7 |= (DR_GLOBAL_ENABLE << (drnum * DR_ENABLE_SIZE));
return dr7;
}
int write_dr(int pid, int dr, unsigned long val)
{
return ptrace(PTRACE_POKEUSER, pid,
offsetof (struct user, u_debugreg[dr]),
val);
}
void func(void)
{
}
int main(void)
{
int pid, stat;
unsigned long dr7;
pid = fork();
if (!pid) {
assert(ptrace(PTRACE_TRACEME, 0,0,0) == 0);
kill(getpid(), SIGHUP);
func();
return 0x13;
}
assert(pid == waitpid(-1, &stat, 0));
assert(WSTOPSIG(stat) == SIGHUP);
assert(write_dr(pid, 0, (long)func) == 0);
dr7 = encode_dr7(0, 1, DR_RW_EXECUTE, DR_LEN_1);
assert(write_dr(pid, 7, dr7) == 0);
assert(ptrace(PTRACE_DETACH, pid, 0,0) == 0);
assert(pid == waitpid(-1, &stat, 0));
assert(stat == 0x1300);
return 0;
}
Before this patch the child is killed after PTRACE_DETACH.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Prasad <prasad@linux.vnet.ibm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-07-09 10:33:26 -07:00
..
2013-06-14 23:01:05 +02:00
2013-04-30 17:04:10 -07:00
2013-06-23 11:52:57 +02:00
2013-01-11 11:39:33 -08:00
2013-07-06 12:37:04 -07:00
2013-07-03 17:12:13 -07:00
2013-07-06 14:09:38 -07:00
2013-07-05 11:09:28 +02:00
2013-06-11 13:58:46 -04:00
2013-04-22 07:09:06 -07:00
2013-05-04 14:57:58 -04:00
2013-03-12 13:59:14 -07:00
2013-06-12 16:29:46 -07:00
2013-01-11 14:54:55 -08:00
2013-06-12 16:29:45 -07:00
2013-07-09 10:33:19 -07:00
2013-07-09 10:33:19 -07:00
2013-07-09 10:33:19 -07:00
2013-04-14 10:06:31 -07:00
2012-11-19 08:13:38 -08:00
2013-06-29 14:06:10 -07:00
2013-05-01 07:21:43 -07:00
2013-05-01 17:29:18 -04:00
2013-06-20 08:18:35 -10:00
2013-06-12 16:29:44 -07:00
2013-07-02 20:04:25 -07:00
2012-12-18 10:55:28 -08:00
2013-01-27 19:23:31 +01:00
2013-07-09 10:33:26 -07:00
2013-04-15 13:25:16 +02:00
2013-07-03 16:08:03 -07:00
2013-05-12 14:16:22 +02:00
2013-02-23 18:50:11 -08:00
2013-06-25 23:11:19 +02:00
2013-07-06 14:09:38 -07:00
2013-02-05 00:48:46 +01:00
2013-04-15 15:17:26 +09:30
2012-12-20 17:40:19 -08:00
2013-05-28 08:50:00 +02:00
2013-04-30 17:04:07 -07:00
2013-07-03 16:08:02 -07:00
2013-07-03 16:07:46 -07:00
2012-12-11 18:10:49 -08:00
2013-04-30 17:04:02 -07:00
2012-10-24 12:39:09 +02:00
2013-05-12 14:16:21 +02:00
2013-05-05 10:58:06 -07:00
2013-03-15 15:09:43 +10:30
2012-12-20 17:40:21 -08:00
2012-12-05 11:27:24 +10:30
2012-10-19 17:30:40 -07:00
2013-05-17 09:53:36 +01:00
2013-06-26 12:10:56 +02:00
2013-05-01 17:29:39 -04:00
2012-12-06 17:16:23 +08:00
2013-07-09 10:33:25 -07:00
2013-03-18 11:40:21 +00:00
2013-05-01 17:51:54 -07:00
2013-07-03 16:08:05 -07:00
2013-07-03 16:54:42 +02:00
2013-04-18 12:51:19 +02:00
2013-06-12 16:29:44 -07:00
2013-05-01 17:29:18 -04:00
2013-07-09 10:33:26 -07:00
2013-06-18 11:32:10 -05:00
2013-01-28 22:06:21 -08:00
2013-06-10 13:46:44 -07:00
2013-06-10 13:45:53 -07:00
2013-06-10 13:45:53 -07:00
2013-06-10 13:45:25 -07:00
2013-06-10 13:46:44 -07:00
2013-05-05 00:16:35 -04:00
2013-07-03 16:07:41 -07:00
2013-06-10 13:44:56 -07:00
2013-05-08 10:13:35 -07:00
2012-12-18 15:02:12 -08:00
2013-07-03 16:08:06 -07:00
2013-02-07 20:51:08 +01:00
2013-04-10 14:48:37 +02:00
2013-05-28 09:23:52 +02:00
2013-03-23 15:53:52 -07:00
2013-03-26 11:07:19 +11:00
2013-04-30 17:04:08 -07:00
2013-05-12 14:16:23 +02:00
2013-04-30 17:04:03 -07:00
2013-04-12 14:18:43 +02:00
2013-07-02 16:14:35 -07:00
2013-02-07 15:19:36 -08:00
2013-02-26 22:25:17 +01:00
2013-05-09 13:46:38 -04:00
2013-07-03 16:08:02 -07:00
2013-05-09 14:53:20 -04:00
2013-06-23 11:52:57 +02:00
2012-10-06 03:05:31 +09:00
2013-04-29 18:28:42 -07:00
2013-06-19 12:58:42 +02:00
2013-02-16 23:17:25 +01:00
2013-06-28 17:10:11 +02:00
2013-04-29 13:55:38 -07:00
2013-01-27 19:23:31 +01:00
2013-03-03 22:58:33 -05:00
2013-05-01 17:51:54 -07:00
2013-02-27 19:10:24 -08:00
2013-05-01 17:51:54 -07:00
2013-02-27 19:10:22 -08:00
2013-05-01 17:29:39 -04:00
2013-05-15 13:50:38 +01:00
2013-03-14 08:24:05 +01:00
2013-06-19 12:58:42 +02:00
2013-07-02 19:53:30 -07:00