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: 73277 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1419248qga; Thu, 4 Aug 2016 07:17:27 -0700 (PDT) X-Received: by 10.55.168.22 with SMTP id r22mr6325869qke.149.1470320247059; Thu, 04 Aug 2016 07:17:27 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v66si5763131qkc.104.2016.08.04.07.17.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 04 Aug 2016 07:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJSg-0004OR-Ls for patch@linaro.org; Thu, 04 Aug 2016 10:17:26 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.1.4 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);