From patchwork Fri Mar 1 23:05:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777078 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1601220wrn; Fri, 1 Mar 2024 15:08:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX/bm+0Nw7QI3214vGXefB+K0gOHDf8w/MWiwObO997J2B8EpqAlLbP+y1EM4kc6M3eNvDaKpfn5uHfLvU5ZIoa X-Google-Smtp-Source: AGHT+IE1afy6158CFHDJ7yhMlSAy9mT26klvYXkiAJWsZRDKlkqcTV2z3do6yKEvqbw7I7uEKmJx X-Received: by 2002:a05:620a:c0c:b0:787:fb5d:489e with SMTP id l12-20020a05620a0c0c00b00787fb5d489emr2747813qki.30.1709334504222; Fri, 01 Mar 2024 15:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709334504; cv=none; d=google.com; s=arc-20160816; b=mMZPikyjW2rIZNVxkZ0vXnEGOlqJa/FfNBBB0D32nP6gfs/W4GdbnIDxY9+CYM69w9 lcuDbOJQurBC6mICTnBtXQUr0lnSuxpzgnGOmxXqbpa5JslMu12wiXzegzPh8rjrHiqR rg7h322p5PkjW6JoIdySdxWO5mtYEipYSSwuBgWb9sIyo9WkrmFzkfbWl5T9j12yDxl+ 3BX3OFVOp8d/DHmhvUFNQmNDh4W2YthW2ez5T7mGn3mY8NQCrGpwJziK+6A3Gq/ptNAY tgkyS6SC9/H6BtIBZjvC6MpQXPPpe88ySUmOx+hG/3w3wSHHwvqOVOhdckVKiXDEUXYO 4TMQ== 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:to:from :dkim-signature; bh=zYkpQqoaMHDWxrt9KPP15xrK5H9LSGOtZoW36Ee0L04=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=eMscwg9pIXCahfaLxUimeGoU/iOVrwk7ZLyAkiVhH/KddsXSL97vyo98ZMF2jEa0WO gHbGqCRKFF8R7RPhR9kdttDbAdhQoi84FTVnbnaWzQJQnJCEaWERpPYo2YtsXaVnvZmK MspgxXFxg2dAMcKCffVbEPdp5DjTYnQMI4Vgd3jBa4jbJUOHtQxZzOPgwMZyqVfidvH4 XWR6Vkn4UfTfWRF7cV05YMrzif1TiKEgLRKl+ZIGpQvBlNtId6M4e7Z+AyVSRFedvWP2 0b54jVqIfyb8kutn+RhlvFx6ZkRbd77mwz8k2h3f+mxEYp2K/VZCI5eE+EO5+0+FKejC iDAA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xhmLORuf; 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 c26-20020a05620a201a00b00787da0bf045si4403701qka.719.2024.03.01.15.08.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:08:24 -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=xhmLORuf; 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 1rgBy9-0005SR-7k; Fri, 01 Mar 2024 18:07:09 -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 1rgBxb-0004rK-Dp for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:06:37 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgBxZ-0004DK-VV for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:06:35 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1dcd0431f00so20092965ad.3 for ; Fri, 01 Mar 2024 15:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334391; x=1709939191; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zYkpQqoaMHDWxrt9KPP15xrK5H9LSGOtZoW36Ee0L04=; b=xhmLORufVFrs4Wlyc1lAnnduiPw2cZI3KC6yuNbI0pneuPJ8XUa4N2AzAai+aLxvnK 5icri/0GhBeIsWpJGPC0feazGh7l+CvFm609Ck2EhGx9z03Immb31sz1zuec1SuNMBVk ErZn2BldOLgeSohUjSG7/GpJA4G32tGh1LDylQLcpEallPgXR/Ap8VKzqeQOsHEcNEoG tWmTV5KaHllStVigB2lMcOJbI+iWHkVgn6DZc2d+99qFKaI62kj3DrPKY/nrCp6nCelg XCwVQGo/UG1ewu5U0v+cBmfHf4yHKYlW5vRQs75+QQl2Ha3oRaWWIsZsCMtnL2RE6jzL X2eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334391; x=1709939191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zYkpQqoaMHDWxrt9KPP15xrK5H9LSGOtZoW36Ee0L04=; b=EEM4jXTHIep5EHhb3SNsHIBRga6EZEE7hMbSBdbKyz+f35VUAq0CRTT64ildgMZRw5 3koFAjiOzpLMVAwyUGDeHJYJDX8t1GdAdCf7Xwxrx3JItW3wOcyu2Z6m7sgSQGsNkfa5 q+ssyIgL1TtwjZye/EhRIEGY9crJdojeaFHSkVh86YJuO5xr+HYtt35OhS1fU7kDxZdL h8ROvM9Y/AvG1KJoCxkN/rnIrHPmlnAxx6OgFwGHBpcAmU5wLjZ5IfMzFjiQDeZuUgv2 5xnDzKz4pEPWQtL7n8/Urwhaw8e959VpbEgc+CZFRAqLXnOitoTPFH4QgyJcp5cPFl/W wTag== X-Gm-Message-State: AOJu0Yyc8vwAMjKYM9aPJHRI7FyMz1qRi8HHZB+QV8Gge4Y2xO8LjEqn +VaFkIJZC2mORYFIo9dNiPwyGpsRjq1iE+YnqllXafnQQcGScfYDRff0Rmm6DF5/1aKdyl6xMUb n X-Received: by 2002:a17:902:c94f:b0:1db:5c84:9523 with SMTP id i15-20020a170902c94f00b001db5c849523mr3765895pla.67.1709334391394; Fri, 01 Mar 2024 15:06:31 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id lc11-20020a170902fa8b00b001dc668e145asm3988580plb.200.2024.03.01.15.06.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:06:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/60] linux-user/elfload: Truncate core file on open Date: Fri, 1 Mar 2024 13:05:26 -1000 Message-Id: <20240301230619.661008-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301230619.661008-1-richard.henderson@linaro.org> References: <20240301230619.661008-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 While we usually create a new corefile, truncate otherwise. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 877799e9c7..16dd08a828 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4652,7 +4652,7 @@ static int elf_core_dump(int signr, const CPUArchState *env) { g_autofree char *corefile = core_dump_filename(ts); - fd = open(corefile, O_WRONLY | O_CREAT, + fd = open(corefile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); } if (fd < 0) {