From patchwork Sun Nov 20 12:06:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 126652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 05183B70C0 for ; Mon, 21 Nov 2011 02:12:28 +1100 (EST) Received: from localhost ([::1]:53234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RS94C-0000GR-M8 for incoming@patchwork.ozlabs.org; Sun, 20 Nov 2011 10:12:24 -0500 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 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 2C1EF90182; Sun, 20 Nov 2011 16:12:16 +0100 (CET) From: Alexander Graf To: qemu-devel Developers Date: Sun, 20 Nov 2011 13:06:26 +0100 Message-Id: <1321790786-28518-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: riku.voipio@iki.fi Subject: [Qemu-devel] [PATCH] linux-user: fix QEMU_STRACE=1 segfault X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;