From patchwork Thu Aug 4 14:15:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9263725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 90EFA6048B for ; Thu, 4 Aug 2016 14:15:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 833BC28330 for ; Thu, 4 Aug 2016 14:15:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77E1328405; Thu, 4 Aug 2016 14:15:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 276AC28330 for ; Thu, 4 Aug 2016 14:15:50 +0000 (UTC) Received: from localhost ([::1]:40134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJR7-0003aU-Bi for patchwork-qemu-devel@patchwork.kernel.org; Thu, 04 Aug 2016 10:15:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJQb-0003Xc-Tw for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVJQZ-0000TZ-TM for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:16 -0400 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]:34855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJQZ-0000TM-LN for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:15 -0400 Received: by mail-lf0-x22e.google.com with SMTP id f93so183268808lfi.2 for ; Thu, 04 Aug 2016 07:15:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uZggTXG+YgJnne4z5WgqUGXNGt13hOWMdgxZAX/bDNA=; b=IZ76fTmrUL5gluSyHGO6h2SJ437x4l5aSJKbebANzaspq50LWvDo7NKaym0wu02HMn 1qiuhraURSo9oTJLgHb9A+jQxYCHbr4hwguB4C2h+lEJ4kE4aPaK/gD0EXdxHstYz/OL POxODcqCsMqPdf0Ku49ZTP4FA5tkvX7cCyVc0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uZggTXG+YgJnne4z5WgqUGXNGt13hOWMdgxZAX/bDNA=; b=X18GhZrdJ2Vv9cGLnNLUdWtVHPzvkQJ/bdK4qhpcS36i6m+IZEFl5YHvHtpG+rCtjj D0jbtw+/uBjNxS9SSMivn0+OVgrf1GKHlBgWs3vKPPGhTAvu2N4kB9A3QmCgDb94OEJ4 FbQflxLPC871MqbNHdySNFvpuKhzzIxUAMeagBp9Y/DxRJciFyRZ+p9Xjbojp3BFp4ny I3hZV8LQfNbwNdz1hhmZ9kYCycNatNnpMIwDBYUJ7gFchL4vUSEJT/FgA6IB5mIJX4UR xVQF17+oB09+6p2T66J4IDpS9GYzeV+AamsFIh2FZSZTrWbTiWPUH+oJzrEihORNkoha yi0w== X-Gm-Message-State: AEkoouu9Zx1hdaBmWCnG3NjPSU/BE1lRyxYF6pXJlUluftMoB/Q/clwOLSUaKKE4d3U/6m49 X-Received: by 10.25.43.204 with SMTP id r195mr13451546lfr.176.1470320114561; Thu, 04 Aug 2016 07:15:14 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id r76sm2407266lfi.35.2016.08.04.07.15.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 07:15:13 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 4 Aug 2016 17:15:05 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22e Subject: [Qemu-devel] [PULL 5/5] linux-user: Handle brk() attempts with very large sizes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell In do_brk(), we were inadvertently truncating the size of a requested brk() from the guest by putting it into an 'int' variable. This meant that we would incorrectly report success back to the guest rather than a failed allocation, typically resulting in the guest then segfaulting. Use abi_ulong instead. This fixes a crash in the '31370.cc' test in the gcc libstdc++ test suite (the test case starts by trying to allocate a very large size and reduces the size until the allocation succeeds). Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index df6f2a9..833f853 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -839,7 +839,7 @@ void target_set_brk(abi_ulong new_brk) abi_long do_brk(abi_ulong new_brk) { abi_long mapped_addr; - int new_alloc_size; + abi_ulong new_alloc_size; DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk);