From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0148C47073 for ; Sun, 7 Jan 2024 14:03:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMTjk-00031P-Bi; Sun, 07 Jan 2024 09:02:48 -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 1rMTje-00030Z-V6 for qemu-devel@nongnu.org; Sun, 07 Jan 2024 09:02:43 -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 1rMTjY-0006Rn-47 for qemu-devel@nongnu.org; Sun, 07 Jan 2024 09:02:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1704636150; bh=ThaR2lQ9ugwXxp2czupmIpBn0zcwkOa611yJbG1gw/g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=B6v95y3loNFiXd2xFJtGBVsGhAHlI+XD2DZmE88Ycu4vZQY95MV6a+rOlw6H+/AVN /OtJ/lbOOFhkCgSKac5tX1dQ2whIYYD1m1gbFdvlLJoCRsjSERpu2gMgXBWv8bVZQL reKyi/lH3VTL2ClJRyZDf9sDSZQ+Il1sQXlACr8g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 07 Jan 2024 15:01:54 +0100 Subject: [PATCH v2 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: 8bit Message-Id: <20240107-qemu-user-dumpable-v2-2-54e3bcfc00c9@t-8ch.de> References: <20240107-qemu-user-dumpable-v2-0-54e3bcfc00c9@t-8ch.de> In-Reply-To: <20240107-qemu-user-dumpable-v2-0-54e3bcfc00c9@t-8ch.de> To: Laurent Vivier Cc: qemu-devel@nongnu.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1704636150; l=1019; i=thomas@t-8ch.de; s=20221212; h=from:subject:message-id; bh=ThaR2lQ9ugwXxp2czupmIpBn0zcwkOa611yJbG1gw/g=; b=EeLEta/e+iYcE4nuuKzAHvGZTBIAebQo6lNg0wLOuy2lgkV9SNkgE4NJ8f4el1s5Tfwz8cVlZ CEjV47enDzQAg7Yk1BZQlQMaKnXLLUJrmNMs4SAEA1dmakQEHXad3sx X-Developer-Key: i=thomas@t-8ch.de; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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. Signed-off-by: Thomas Weißschuh --- linux-user/elfload.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 74c9ecda1806..956cb3ae2da5 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2,6 +2,7 @@ #include "qemu/osdep.h" #include +#include #include #include @@ -4667,6 +4668,10 @@ static int elf_core_dump(int signr, const CPUArchState *env) init_note_info(&info); errno = 0; + + if (prctl(PR_GET_DUMPABLE) == 0) + return 0; + if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0) return 0; -- 2.43.0