]> granicus.if.org Git - strace/commitdiff
2008-05-19 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Tue, 20 May 2008 00:34:34 +0000 (00:34 +0000)
committerRoland McGrath <roland@redhat.com>
Tue, 20 May 2008 00:34:34 +0000 (00:34 +0000)
* util.c [LINUX] (setbpt): Use correct SYS_clone number for current
personality.
Fixes RH#447475.

util.c

diff --git a/util.c b/util.c
index 70011e2171c23b973c27f0ab21764d0df864d262..fc54f1ad97a772b838e6f4149c0e50d4a65c6335 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1275,6 +1275,8 @@ struct tcb *tcp;
 
 #if defined LINUX
 
+#include "syscall.h"
+
 #include <sys/syscall.h>
 #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)