Received: from eggs.gnu.org ([140.186.70.92]:49637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RS947-0000G9-Sk for qemu-devel@nongnu.org; Sun, 20 Nov 2011 10:12:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RS946-00018m-Ia for qemu-devel@nongnu.org; Sun, 20 Nov 2011 10:12:19 -0500 Received: from cantor2.suse.de ([195.135.220.15]:40850 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RS946-00018i-Cb for qemu-devel@nongnu.org; Sun, 20 Nov 2011 10:12:18 -0500 From: Alexander Graf Date: Sun, 20 Nov 2011 13:06:26 +0100 Message-Id: <1321790786-28518-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH] linux-user: fix QEMU_STRACE=1 segfault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Developers Cc: riku.voipio@iki.fi While debugging some issues with QEMU_STRACE I stumbled over segmentation faults that were pretty reproducible. Turns out we tried to treat a normal return value as errno, resulting in an access over array boundaries for the resolution. Fix this by hard-mapping values above valid errnos to the original value. Signed-off-by: Alexander Graf --- linux-user/syscall.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f227097..312aec5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -711,6 +711,9 @@ static inline int host_to_target_errno(int err) static inline int target_to_host_errno(int err) { + if (err >= ERRNO_TABLE_SIZE) { + return err; + } if (target_to_host_errno_table[err]) return target_to_host_errno_table[err]; return err; -- 1.6.0.2