From 3291ef2013cf9510f8ca493ab1c81862fd3a5e15 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 20 May 2008 00:34:34 +0000 Subject: [PATCH] 2008-05-19 Roland McGrath * util.c [LINUX] (setbpt): Use correct SYS_clone number for current personality. Fixes RH#447475. --- util.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index 70011e21..fc54f1ad 100644 --- a/util.c +++ b/util.c @@ -1275,6 +1275,8 @@ struct tcb *tcp; #if defined LINUX +#include "syscall.h" + #include #ifndef CLONE_PTRACE # define CLONE_PTRACE 0x00002000 @@ -1473,6 +1475,7 @@ int setbpt(tcp) struct tcb *tcp; { + static int clone_scno[SUPPORTED_PERSONALITIES] = { SYS_clone }; extern int change_syscall(struct tcb *, int); arg_setup_state state; @@ -1481,6 +1484,20 @@ struct tcb *tcp; return -1; } + /* + * It's a silly kludge to initialize this with a search at runtime. + * But it's better than maintaining another magic thing in the + * godforsaken tables. + */ + if (clone_scno[current_personality] == 0) { + int i; + for (i = 0; i < nsyscalls; ++i) + if (sysent[i].sys_func == sys_clone) { + clone_scno[current_personality] = i; + break; + } + } + switch (known_scno(tcp)) { #ifdef SYS_vfork case SYS_vfork: @@ -1492,7 +1509,7 @@ struct tcb *tcp; if (arg_setup (tcp, &state) < 0 || get_arg0 (tcp, &state, &tcp->inst[0]) < 0 || get_arg1 (tcp, &state, &tcp->inst[1]) < 0 - || change_syscall(tcp, SYS_clone) < 0 + || change_syscall(tcp, clone_scno[current_personality]) < 0 || set_arg0 (tcp, &state, CLONE_PTRACE|SIGCHLD) < 0 || set_arg1 (tcp, &state, 0) < 0 || arg_finish_change (tcp, &state) < 0)