From 0c6f7555256a0eb0f3e728bed53964dcb565b2e7 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Tue, 20 Dec 2016 01:13:21 +0300 Subject: [PATCH] x32: fix decoding of 3rd argument of preadv* and pwritev* syscalls In x32 personality these syscalls use compat type for the 3rd argument, therefore it has to be truncated there. * io.c (do_preadv, do_pwritev): Truncate tcp->u_arg[2] using widen_to_ulong. --- io.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/io.c b/io.c index 53419ed8..713a1ce4 100644 --- a/io.c +++ b/io.c @@ -222,10 +222,12 @@ do_preadv(struct tcb *tcp, const int flags_arg) printfd(tcp, tcp->u_arg[0]); tprints(", "); } else { - tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], + unsigned long len = widen_to_ulong(tcp->u_arg[2]); + + tprint_iov_upto(tcp, len, tcp->u_arg[1], syserror(tcp) ? IOV_DECODE_ADDR : IOV_DECODE_STR, tcp->u_rval); - tprintf(", %lu, ", tcp->u_arg[2]); + tprintf(", %lu, ", len); print_lld_from_low_high_val(tcp, 3); if (flags_arg >= 0) { tprints(", "); @@ -248,10 +250,12 @@ SYS_FUNC(preadv2) static int do_pwritev(struct tcb *tcp, const int flags_arg) { + unsigned long len = widen_to_ulong(tcp->u_arg[2]); + printfd(tcp, tcp->u_arg[0]); tprints(", "); - tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR); - tprintf(", %lu, ", tcp->u_arg[2]); + tprint_iov(tcp, len, tcp->u_arg[1], IOV_DECODE_STR); + tprintf(", %lu, ", len); print_lld_from_low_high_val(tcp, 3); if (flags_arg >= 0) { tprints(", "); -- 2.40.0