]> granicus.if.org Git - strace/commitdiff
ipc_msg.c: fix multiple personalities support in msgrcv ipc subcall
authorElvira Khabirova <lineprinter0@gmail.com>
Wed, 19 Aug 2015 03:06:29 +0000 (06:06 +0300)
committerElvira Khabirova <lineprinter0@gmail.com>
Thu, 20 Aug 2015 19:21:04 +0000 (22:21 +0300)
When msgrcv syscall is an ipc subcall, msgp (pointer to struct msgbuf)
and msgtyp (message type) syscall arguments are passed via proxy
structure which definition significantly depends on tracee's
wordsize.

* ipc_msg.c (fetch_msgrcv_args): New function.
(sys_msgrcv): Use it.

ipc_msg.c

index fb126f5384eac921cdf3191d049bbc5dcfd1eac0..5052eacea8b73c100d9abc5b40a76666079630eb 100644 (file)
--- a/ipc_msg.c
+++ b/ipc_msg.c
@@ -81,22 +81,35 @@ tprint_msgrcv(struct tcb *tcp, const long addr, const unsigned long count,
        tprintf("%ld, ", msgtyp);
 }
 
+static int
+fetch_msgrcv_args(struct tcb *tcp, const long addr, long *pair)
+{
+       if (current_wordsize == sizeof(long)) {
+               if (umoven_or_printaddr(tcp, addr, 2 * sizeof(long), pair))
+                       return -1;
+       } else {
+               unsigned int tmp[2];
+
+               if (umove_or_printaddr(tcp, addr, &tmp))
+                       return -1;
+               pair[0] = tmp[0];
+               pair[1] = tmp[1];
+       }
+       return 0;
+}
+
 SYS_FUNC(msgrcv)
 {
        if (entering(tcp)) {
                tprintf("%d, ", (int) tcp->u_arg[0]);
        } else {
                if (indirect_ipccall(tcp)) {
-                       struct ipc_wrapper {
-                               struct msgbuf *msgp;
-                               long msgtyp;
-                       } tmp;
+                       long pair[2];
 
-                       if (umove_or_printaddr(tcp, tcp->u_arg[3], &tmp))
+                       if (fetch_msgrcv_args(tcp, tcp->u_arg[3], pair))
                                tprintf(", %lu, ", tcp->u_arg[1]);
                        else
-                               tprint_msgrcv(tcp, (long) tmp.msgp,
-                                       tcp->u_arg[1], tmp.msgtyp);
+                               tprint_msgrcv(tcp, pair[0], tcp->u_arg[1], pair[1]);
                        printflags(ipc_msg_flags, tcp->u_arg[2], "MSG_???");
                } else {
                        tprint_msgrcv(tcp, tcp->u_arg[1],