From 2c42f32518e43b1e5ccb00c19010a799be6858d4 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 20 Mar 2013 09:48:44 +0000 Subject: Do not use off_t in sendfile decoding sendfile parser used to decode off_t* parameter as a pointer to host off_t type. With this change, it is decoded as a pointer to target long type. * io.c (print_off_t): New function. (sys_sendfile): Use it. * linux/aarch64/syscallent1.h: Use sys_sendfile64 for sendfile decoding. * linux/tile/syscallent.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * linux/hppa/syscallent.h: Use sys_sendfile64 for sendfile64 decoding. * linux/metag/syscallent.h: Correct sendfile syscall name. * linux/or1k/syscallent.h: Likewise. --- io.c | 43 +++++++++++++++++++++++++++---------------- linux/aarch64/syscallent1.h | 4 ++-- linux/hppa/syscallent.h | 2 +- linux/metag/syscallent.h | 2 +- linux/or1k/syscallent.h | 2 +- linux/tile/syscallent.h | 2 +- linux/x32/syscallent.h | 2 +- linux/x86_64/syscallent.h | 2 +- 8 files changed, 35 insertions(+), 24 deletions(-) diff --git a/io.c b/io.c index 0e9bb32..b7bf832 100644 --- a/io.c +++ b/io.c @@ -250,30 +250,41 @@ sys_pwritev(struct tcb *tcp) } #endif /* HAVE_SYS_UIO_H */ +static void +print_off_t(struct tcb *tcp, long addr) +{ + unsigned long offset; + + if (!addr) { + tprints("NULL"); + return; + } + +#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 + if (current_wordsize == 4) { + uint32_t off; + + if (umove(tcp, addr, &off) < 0) + tprintf("%#lx", addr); + else + tprintf("[%u]", off); + } else +#endif + if (umove(tcp, addr, &offset) < 0) + tprintf("%#lx", addr); + else + tprintf("[%lu]", offset); +} + int sys_sendfile(struct tcb *tcp) { if (entering(tcp)) { - off_t offset; - printfd(tcp, tcp->u_arg[0]); tprints(", "); printfd(tcp, tcp->u_arg[1]); tprints(", "); - if (!tcp->u_arg[2]) - tprints("NULL"); -//FIXME: obviously bogus. -//Probably should use explicit long. -//Arches with long long offset param should use -//sys_sendfile64, not this fn. - else if (umove(tcp, tcp->u_arg[2], &offset) < 0) - tprintf("%#lx", tcp->u_arg[2]); - else -#ifdef HAVE_LONG_LONG_OFF_T - tprintf("[%llu]", offset); -#else - tprintf("[%lu]", offset); -#endif + print_off_t(tcp, tcp->u_arg[2]); tprintf(", %lu", tcp->u_arg[3]); } return 0; diff --git a/linux/aarch64/syscallent1.h b/linux/aarch64/syscallent1.h index 7b4413d..ef95e4f 100644 --- a/linux/aarch64/syscallent1.h +++ b/linux/aarch64/syscallent1.h @@ -69,7 +69,7 @@ { 5, TD, sys_pwrite, "pwrite64" }, /* 68 */ { 5, TD, sys_preadv, "preadv" }, /* 69 */ { 5, TD, sys_pwritev, "pwritev" }, /* 70 */ - { 4, TD|TN, sys_sendfile, "sendfile" }, /* 71 */ + { 4, TD|TN, sys_sendfile64, "sendfile" }, /* 71 */ { 6, TD, sys_pselect6, "pselect6" }, /* 72 */ { 5, TD, sys_ppoll, "ppoll" }, /* 73 */ { 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 74 */ @@ -294,7 +294,7 @@ { 0, TD, sys_inotify_init, "inotify_init" }, /* 1043 */ { 1, TD, sys_eventfd, "eventfd" }, /* 1044 */ { 3, TD|TS, sys_signalfd, "signalfd" }, /* 1045 */ - { 4, TD|TN, sys_sendfile, "sendfile" }, /* 1046 */ + { 4, TD|TN, sys_sendfile64, "sendfile" }, /* 1046 */ { 2, TD, sys_ftruncate, "ftruncate" }, /* 1047 */ { 2, TF, sys_truncate, "truncate" }, /* 1048 */ { 2, TF, sys_stat, "stat" }, /* 1049 */ diff --git a/linux/hppa/syscallent.h b/linux/hppa/syscallent.h index 8d2c090..3969450 100644 --- a/linux/hppa/syscallent.h +++ b/linux/hppa/syscallent.h @@ -211,7 +211,7 @@ { 0, 0, sys_gettid, "gettid" }, /* 206 */ { 4, TD, sys_readahead, "readahead" }, /* 207 */ { 2, TS, sys_kill, "tkill" }, /* 208 */ - { 4, TD|TN, sys_sendfile, "sendfile64" }, /* 209 */ + { 4, TD|TN, sys_sendfile64, "sendfile64" }, /* 209 */ { 6, 0, sys_futex, "futex" }, /* 210 */ { 3, 0, sys_sched_setaffinity, "sched_setaffinity" }, /* 211 */ { 3, 0, sys_sched_getaffinity, "sched_getaffinity" }, /* 212 */ diff --git a/linux/metag/syscallent.h b/linux/metag/syscallent.h index 95f41c2..d03a552 100644 --- a/linux/metag/syscallent.h +++ b/linux/metag/syscallent.h @@ -69,7 +69,7 @@ { 5, TD, sys_pwrite, "pwrite64" }, /* 68 */ { 5, TD, sys_preadv, "preadv" }, /* 69 */ { 5, TD, sys_pwritev, "pwritev" }, /* 70 */ - { 4, TD|TN, sys_sendfile64, "sendfile64" }, /* 71 */ + { 4, TD|TN, sys_sendfile64, "sendfile" }, /* 71 */ { 6, TD, sys_pselect6, "pselect6" }, /* 72 */ { 5, TD, sys_ppoll, "ppoll" }, /* 73 */ { 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 74 */ diff --git a/linux/or1k/syscallent.h b/linux/or1k/syscallent.h index 6b8a791..d646897 100644 --- a/linux/or1k/syscallent.h +++ b/linux/or1k/syscallent.h @@ -69,7 +69,7 @@ { 6, TD, sys_pwrite, "pwrite64" }, /* 68 */ { 5, TD, sys_preadv, "preadv" }, /* 69 */ { 5, TD, sys_pwritev, "pwritev" }, /* 70 */ - { 4, TD|TN, sys_sendfile64, "sendfile64" }, /* 71 */ + { 4, TD|TN, sys_sendfile64, "sendfile" }, /* 71 */ { 6, TD, sys_pselect6, "pselect6" }, /* 72 */ { 5, TD, sys_ppoll, "ppoll" }, /* 73 */ { 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 74 */ diff --git a/linux/tile/syscallent.h b/linux/tile/syscallent.h index a8e603a..eb5023b 100644 --- a/linux/tile/syscallent.h +++ b/linux/tile/syscallent.h @@ -69,7 +69,7 @@ { 6, TD, sys_pwrite, "pwrite64" }, /* 68 */ { 5, TD, sys_preadv, "preadv" }, /* 69 */ { 5, TD, sys_pwritev, "pwritev" }, /* 70 */ - { 4, TD|TN, sys_sendfile, "sendfile" }, /* 71 */ + { 4, TD|TN, sys_sendfile64, "sendfile" }, /* 71 */ { 6, TD, sys_pselect6, "pselect6" }, /* 72 */ { 5, TD, sys_ppoll, "ppoll" }, /* 73 */ { 4, TD|TS, sys_signalfd4, "signalfd4" }, /* 74 */ diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h index 0e656a1..4adf66b 100644 --- a/linux/x32/syscallent.h +++ b/linux/x32/syscallent.h @@ -38,7 +38,7 @@ { 1, 0, sys_alarm, "alarm" }, /* 37 */ { 3, 0, sys_setitimer, "setitimer" }, /* 38 */ { 0, 0, sys_getpid, "getpid" }, /* 39 */ - { 4, TD|TN, sys_sendfile, "sendfile" }, /* 40 */ + { 4, TD|TN, sys_sendfile64, "sendfile" }, /* 40 */ { 3, TN, sys_socket, "socket" }, /* 41 */ { 3, TN, sys_connect, "connect" }, /* 42 */ { 3, TN, sys_accept, "accept" }, /* 43 */ diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h index 56261d8..e56bd8e 100644 --- a/linux/x86_64/syscallent.h +++ b/linux/x86_64/syscallent.h @@ -38,7 +38,7 @@ { 1, 0, sys_alarm, "alarm" }, /* 37 */ { 3, 0, sys_setitimer, "setitimer" }, /* 38 */ { 0, 0, sys_getpid, "getpid" }, /* 39 */ - { 4, TD|TN, sys_sendfile, "sendfile" }, /* 40 */ + { 4, TD|TN, sys_sendfile64, "sendfile" }, /* 40 */ { 3, TN, sys_socket, "socket" }, /* 41 */ { 3, TN, sys_connect, "connect" }, /* 42 */ { 3, TN, sys_accept, "accept" }, /* 43 */ -- cgit v1.2.3