From patchwork Tue Jan 23 10:24:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 765191 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp1528724wrx; Tue, 23 Jan 2024 02:25:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEq5J5pqgadVsCTfwhHFc6n8olfGvspaWirvSa0oyg5SI0F2fm487RiVWvBLjlJrbh7iMMe X-Received: by 2002:a05:6214:e86:b0:682:54de:bf99 with SMTP id hf6-20020a0562140e8600b0068254debf99mr850897qvb.26.1706005538182; Tue, 23 Jan 2024 02:25:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706005538; cv=none; d=google.com; s=arc-20160816; b=jntajadNIYSJJepIMe7QT/Mowu7sfFZnyQ0jWREf3s2Zc38HWVgL7F/VIjHV8r2dq+ 1Ym9n9cErYn27yBhkoRDQ6wdOWyDSUJ9m+qXl6h3IW+dOVkV8VwroIUWqnahscSGQtTz yGW+Y0PD61BkjbN1FoDcxzVO9iw/pJ2gwAK3vLtQc6wDbvIN1AXPoAo9PZgu48V0ExkU bQRQyVQpdCu4JCyPW9J0L5HuQUd9Mdw7Vokpxcfl+3G4/T3H1vJ3qOT2wsY2qOsiRUSu jLvJogHovd4zp8WOa6p4mzp4of+7Vsr6V34DXd9FbI8AoVZHR+/PmPNVgaxbGjyRSR6i I1yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=McCaPLIJxvTbADv66BEO7sWToPqj2hCMM+otAiFa5d4=; fh=pIQ/pnZIlSJRqn3IY6OfXgsfIYxl32er/DT+ShnNqYA=; b=enUSboaeR1rw7wF2ZeqUy36ZEWetVM/V/zi4jz4AAmi4uZ3QkgCO5x/tIdHd3Es8iq f4lFlC4+JhGYwjOK1poXqAMCwghdWjgM/O9Dh7N38j3LIrbhEHvvCD/zd7IUdLRXiyQv gZzj3o4WHqOQFK7UNQRvIA22YZljZuJdDrVFlsRAdT4fYOO++6gwB46kt3Th59NemAvH WGM2gR3T5WsaKd5r7B0WI35Aq1I9ZWYpgpDDODPlqhQaOR4bwSo+RO4derxTvXOc3flx Vf7PI9Dw6TDGQK/Hv2sS1af38lFTIX38Zj+tq/461XLI7p96+gpQQ7tVKUKFXqhQTbWu 1Udg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AQKv+fNA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q19-20020a0cf5d3000000b006816c8e3a8esi7637311qvm.193.2024.01.23.02.25.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2024 02:25:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AQKv+fNA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSDxR-0000QJ-FS; Tue, 23 Jan 2024 05:24:41 -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 1rSDxQ-0000Q8-Ih for qemu-devel@nongnu.org; Tue, 23 Jan 2024 05:24:40 -0500 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rSDxP-0004dp-0z for qemu-devel@nongnu.org; Tue, 23 Jan 2024 05:24:40 -0500 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6d9344f30caso2556378b3a.1 for ; Tue, 23 Jan 2024 02:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706005478; x=1706610278; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=McCaPLIJxvTbADv66BEO7sWToPqj2hCMM+otAiFa5d4=; b=AQKv+fNArFTzeLgw7mDKhKdqnNm9cP0JQu4QCwk5UTbURygHnNhjDCEKUClHRjic9B rdTsPRLTyf2Rx3Pu6xMMT3Gz9DEBWB1EHxZsaXjeMTXypHOtG70W5uk/MnfqFJiRkGwy V4J24KJZOA11sNop/Bx8vM9Lopk9rtv49rNb+57s91phKK9T+jDde4tzEfkspLT1UXT1 hLHwoFLj3OcnYVkxHaI9DawFDLq8uEo/qhiHuy5yRpWPUgTIHnZdJ762Z9bSXs3tEAzO FOdocvJH8TSoLHEjzckUVQMFinvF/T15ptLA9CsjwiOuRdIu1YMJ9fXu0ITzsZ1tUe4J z+Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706005478; x=1706610278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=McCaPLIJxvTbADv66BEO7sWToPqj2hCMM+otAiFa5d4=; b=qBsBmmlT8fvMqm35Tn0taEhZN/m+jdBUFVRuGl33AlOr1wwB/HVwrB523DHZXLHuB4 k+s2o/Jv7i7NZUM0TWUiYGUG4fqEO6EMfrIzzhrm7KrQceLFs091nJ0ToXWQZMHc7LFb zvMfX3ZMbiqF4heelhPiJR5rof/Wd8dmYF/T4v2xIrOqM9iCMkyqr4RQfNulsyUHXnS1 JtP2HGEauuKxlmfL9VpMgFW0WmKo3V1cDHVzlfiDbm64Oad3Eg//f7ciqxBO/UgY7+lC 6nW6oaVFgAFuqutaak4taRa/9SKu+zQ7fjSK06/Qo1D4JvYxrvn1to6z7x1kybqmtLZs e8oA== X-Gm-Message-State: AOJu0YxNF/d3/K99CU/gx1Zste6L/VD6yqPZBG0YO+7+8ZvfuS+/f6w0 C4poTP3mzyhLNVWkRgbwSbohRsGxg4k5ABbGGJDWLJuMHfIqvvVEsEUoqNfuijidHkAQAktn4rH 8NJY= X-Received: by 2002:a05:6a20:4329:b0:199:89a0:9f2b with SMTP id h41-20020a056a20432900b0019989a09f2bmr6537956pzk.26.1706005477681; Tue, 23 Jan 2024 02:24:37 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-b8a0-0408-58be-7d2e.static.ipv6.internode.on.net. [2001:44b8:2176:c800:b8a0:408:58be:7d2e]) by smtp.gmail.com with ESMTPSA id d8-20020a62f808000000b006d9ce7d3258sm11072408pfh.204.2024.01.23.02.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 02:24:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , =?utf-8?q?Philippe_?= =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL v2 7/8] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Date: Tue, 23 Jan 2024 20:24:11 +1000 Message-Id: <20240123102412.4569-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123102412.4569-1-richard.henderson@linaro.org> References: <20240123102412.4569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Thomas Weißschuh 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: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Thomas Weißschuh Message-Id: <20240120-qemu-user-dumpable-v3-2-6aa410c933f1@t-8ch.de> Signed-off-by: Richard Henderson --- linux-user/elfload.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c596871938..daf7ef8435 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,11 @@ 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; }