From d079fb19f239be3dfb7c7062ce7cae6e908a4f92 Mon Sep 17 00:00:00 2001 From: Elvira Khabirova Date: Wed, 19 Aug 2015 06:06:29 +0300 Subject: [PATCH] ipc_msg.c: fix multiple personalities support in msgrcv ipc subcall 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 | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/ipc_msg.c b/ipc_msg.c index fb126f53..5052eace 100644 --- 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], -- 2.50.1