From nobody Thu Nov 6 08:37:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537866023355142.79889788433434; Tue, 25 Sep 2018 02:00:23 -0700 (PDT) Received: from localhost ([::1]:51724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4jCR-00074J-IT for importer@patchew.org; Tue, 25 Sep 2018 05:00:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4j7w-0003S1-0I for qemu-devel@nongnu.org; Tue, 25 Sep 2018 04:55:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4j7n-0000DF-OU for qemu-devel@nongnu.org; Tue, 25 Sep 2018 04:55:24 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:42249) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g4j7n-0000CS-Dv for qemu-devel@nongnu.org; Tue, 25 Sep 2018 04:55:19 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mdva2-1fX2CL3HM6-00azBI; Tue, 25 Sep 2018 10:55:07 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 25 Sep 2018 10:54:32 +0200 Message-Id: <20180925085432.3791-6-laurent@vivier.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180925085432.3791-1-laurent@vivier.eu> References: <20180925085432.3791-1-laurent@vivier.eu> X-Provags-ID: V03:K1:0VNIbOyDGca8rd1l3pOCUu+0dkjl7YCp3wllQ+Syh3NstwCI9pk TlH8U22ujQzdeV9Nni5gqdYzCXIliDw+4UCb/d3KePAZv79dJBamIlk+ka5h4+OeDDW7y14 A6Qu7/zltsv6r7JW3+zCEoEbujRmkIBpWFiTgYmSzRQ1dyCFzXGh/qHKzCy6/jYBvSQz/TJ /9PohDhfjY4FR7GtiR4Jg== X-UI-Out-Filterresults: notjunk:1;V01:K0:+vYfhZcjYSU=:JWiWxiPtd+idLZxI5n36Cd mN/fIRHu+hyrDpvMbAon0NdgsW5WgvAieOBnsWWedtr8MRGoEUDMuU1Ija49mCzThYtehyA11 9A244+pIJYoDd7sWyyz+FE03yrT9mZhwOeKAGF9BgX460uilVxEYd1+kI5m28EPI3YuMV7GAE PP+yRr2dZBOARklZUUDH8lZO10veallap1Iw2AnfZCQEobyMrKzvtpzNuTWQ5x4NuhbdSIrjc t6omOrxQWVjjul4hUyhz7fRkfhN4zxSBcv0OgLo3V/GI68SoAcA+IpuUv8WM8KcuwA2GUjnQ4 GbGUfYhprvZzEwUqTGb7OavJeftKwUI7LNSS4jIFYZWKvW7p+bh7u/OuJ61Z7dkBmy3Hcpg+X oqkgbLlgF5VOJKDx3H7YvCL2bltBygukPbfEuCvc3V3uA821yg44yfX9xNkaPvy6P6m9FBAPx 20BW4hBNlb0IV1//Dkqg6FGP2jGeKMMbvkHoMYuJLOIuB7vt5jKqP1HBJboommsml5uLq6brk ilr7iBiugBArHTQ/uiklXrUo6L3LO4/pxXtLidqBbA431Yo+8pluLaBEuk0vkIKBu8fUzCdFG kbyyJjfgnKQgBmAize804kcb2E66WjXsJ1z5Jf6U2dZYGfKmfXY68tMplKJZbqzZkX+EMaE2y rA1e0KhmrwqnFP7o+DAWse8l3v3J6Dv8ASwprkt3hxz8Zmvo2VB7OkJxyAMmMZ4ZbWEo= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PULL 5/5] linux-user: do setrlimit selectively 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: Max Filippov , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Filippov setrlimit guest calls that affect memory resources (RLIMIT_{AS,DATA,STACK}) may interfere with QEMU internal memory management. They may result in QEMU lockup because mprotect call in page_unprotect would fail with ENOMEM error code, causing infinite loop of SIGSEGV. E.g. it happens when running libstdc++ testsuite for xtensa target on x86_64 host. Don't call host setrlimit for memory-related resources. Reviewed-by: Peter Maydell Signed-off-by: Max Filippov Message-Id: <20180917181314.22551-1-jcmvbkbc@gmail.com> [lv: rebase on master] Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 019af632df..ae3c0dfef7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7879,7 +7879,21 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, rlim.rlim_cur =3D target_to_host_rlim(target_rlim->rlim_cur); rlim.rlim_max =3D target_to_host_rlim(target_rlim->rlim_max); unlock_user_struct(target_rlim, arg2, 0); - return get_errno(setrlimit(resource, &rlim)); + /* + * If we just passed through resource limit settings for memor= y then + * they would also apply to QEMU's own allocations, and QEMU w= ill + * crash or hang or die if its allocations fail. Ideally we wo= uld + * track the guest allocations in QEMU and apply the limits ou= rselves. + * For now, just tell the guest the call succeeded but don't a= ctually + * limit anything. + */ + if (resource !=3D RLIMIT_AS && + resource !=3D RLIMIT_DATA && + resource !=3D RLIMIT_STACK) { + return get_errno(setrlimit(resource, &rlim)); + } else { + return 0; + } } #endif #ifdef TARGET_NR_getrlimit --=20 2.17.1