From nobody Tue Nov 26 19:56:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1705787206; cv=none; d=zohomail.com; s=zohoarc; b=Zg52IVVQuFRZbdi9tN6rthsrcaDGQhp5FuvFqiBCzA1Z3QB2F43DnUrvh216Lor0hNQTkXP0FFUXAet+qL4QyzMY+K2tfh8YyrXp6hitl/ijhPxUro8GZ6LD4lNoLu9+NQftwRFjC+xvaIipAX48tS2BplyAHUi2dEur1RFqCEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705787206; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=98bn7bRe215/NGeMGGXmBR9tUetxprrBCr9mKYwsqW0=; b=NPiaR9X09MTCWpONtUX1cf3yLlrPp2v6cvL7sGDu3Z6cCmUGMqeuzRy4mqqtMDDcvqzWtakaNYQzzqeZKc8lh6sWibk4zOdmybSkUV5QE1cLtUcn09tQnyqvlCJ+jfkP3c13cjeh2lOWaIhfkTYirRu8ZO62srxnBRMbTT3JnfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705787205854842.6774149022444; Sat, 20 Jan 2024 13:46:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRJ9z-0006sT-1r; Sat, 20 Jan 2024 16:45:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRJ9x-0006s7-P7 for qemu-devel@nongnu.org; Sat, 20 Jan 2024 16:45:50 -0500 Received: from todd.t-8ch.de ([159.69.126.157]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rRJ9v-00089r-Jc for qemu-devel@nongnu.org; Sat, 20 Jan 2024 16:45:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1705787141; bh=dbh+bIjKa1C8kqFOnFCmAjsBglPryxzUjTBooCsU9zc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BdEn63ZLi8t/QSNAcWBoluRf/uwvULQwNvu0usC1Ag9zMnW2+ZXLcCdpCTA2br5HL in77vuUbDkWebtJwLYr67LXkTo8HLz28rdElrkrsbzxEXsl4cwKOhFblEBa4IlnZJH uRM96LcwgYx+SKW84QrN9qftyxOkk9B1e5E1a+w4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Jan 2024 22:45:25 +0100 Subject: [PATCH v3 2/2] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240120-qemu-user-dumpable-v3-2-6aa410c933f1@t-8ch.de> References: <20240120-qemu-user-dumpable-v3-0-6aa410c933f1@t-8ch.de> In-Reply-To: <20240120-qemu-user-dumpable-v3-0-6aa410c933f1@t-8ch.de> To: Laurent Vivier Cc: qemu-devel@nongnu.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Richard Henderson X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705787141; l=1100; i=thomas@t-8ch.de; s=20221212; h=from:subject:message-id; bh=dbh+bIjKa1C8kqFOnFCmAjsBglPryxzUjTBooCsU9zc=; b=aLfoaPrngn/sYo9CWNAgWa4woJiFVVM8K9S6WpDwjTJVCWqZJ/BQeXeXgZoCrvazNl+dsqUfK 4MUeXI5FeQ9BDC7xcOenMfuaHhvmb26Jma01xeBN/06/FZ9+B7IToBZ X-Developer-Key: i=thomas@t-8ch.de; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=159.69.126.157; envelope-from=thomas@t-8ch.de; helo=todd.t-8ch.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @t-8ch.de) X-ZM-MESSAGEID: 1705787207994100008 A process can opt-out of coredump creation by calling prctl(PR_SET_DUMPABLE, 0). linux-user passes this call from the guest through to the operating system. From there it can be read back again to avoid creating coredumps from qemu-user itself if the guest chose so. Reviewed-by: Richard Henderson Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/elfload.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c5968719380a..daf7ef843564 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2,6 +2,7 @@ #include "qemu/osdep.h" #include =20 +#include #include #include =20 @@ -4667,6 +4668,11 @@ static int elf_core_dump(int signr, const CPUArchSta= te *env) init_note_info(&info); =20 errno =3D 0; + + if (prctl(PR_GET_DUMPABLE) =3D=3D 0) { + return 0; + } + if (getrlimit(RLIMIT_CORE, &dumpsize) =3D=3D 0 && dumpsize.rlim_cur = =3D=3D 0) { return 0; } --=20 2.43.0