From patchwork Fri Mar 1 23:05:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777074 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1600774wrn; Fri, 1 Mar 2024 15:07:05 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVd0RdHVVFzPnSKVl+z7l95FONkjpBhXSthRe+sT17YV5dZApV/xIFgU3Zc+kgf8Ngpm7dYiWFjNZ5+RLaTeDXS X-Google-Smtp-Source: AGHT+IFezRhd4qdaIumsRaX4arUPIo21PdBsmHY+KxPsWYa2i8x8QcX6fK34POSFSgIpElFJE4G/ X-Received: by 2002:a0c:f64e:0:b0:68f:89fe:28f2 with SMTP id s14-20020a0cf64e000000b0068f89fe28f2mr3102557qvm.9.1709334425676; Fri, 01 Mar 2024 15:07:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709334425; cv=none; d=google.com; s=arc-20160816; b=OpGJMovqVB7GpOzCoSOKagqqE6y7roj7aeV+Zsj7aHtY5KzuRJJhtX3eimmJ1hG/UP Jasdnhvi09Vu4kCJw/vdmeZJvxdC9iJDhsaR9AbWItDhMzWi6pozglujSxwNtShfyJmc tNLxpi2N2FjHNjC2W4YON6f/1C+KyzHXvHeYRxnJOkenAm7dioizgA0CDe2UebPC+glv 2xXdT5/qUKswGIplZriquTeKt7s+ZEnrjdkHONgDAP/UKiaPaAedgxE9EIx2Nw0OrnAV VRulFkNICiJzo0QIQuRmZTuC2Logh3eufjVUjQMUnWJ9jr86OqtHEPe5PXoqXo0XjaHR gFpQ== 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=WHvhcE4xVUGsA+1z7u9QEyHKVjaKd5k7EQymbD1rMkw=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=RTpx4ri7MpwRixC8UtZzAWvcY02+PCQxMxntHwOI7tU4JvdCQNrJBFmL2mj1lqcSgg QL9a2nCPIOVAHHhxLBUBKqsAdkYcSzURkdBJJX8fsTkl9m90N8wZ3RYyiXcCNNR64/z3 JeVL6cKHwNwwKdB8UwCZv9YdSGpwZDu96okZ3/mZnK9zdIWc1YfF2AGJNaIQmiwB//IA bP1rh6ONXK040RtOYQ4kJvL9Mc/qHc/kw27sVuan3w+KXqb88pTwTiYoPEazJva2N3P6 dgpt92C+H4TtqhHZJ1my7x9FZDs9a/VDQvB4XvhZSm4ByzjOEIDQ7Cntdm0QA0jntTHB mVTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GEJwmsmZ; 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 o3-20020ad45c83000000b0068fbf29117asi4841376qvh.225.2024.03.01.15.07.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:07:05 -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=GEJwmsmZ; 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 1rgBxW-0004q0-3S; Fri, 01 Mar 2024 18:06:30 -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 1rgBxT-0004pP-5o for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:06:27 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgBxR-0004CG-IC for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:06:26 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1dc1ff3ba1aso22774735ad.3 for ; Fri, 01 Mar 2024 15:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334384; x=1709939184; 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=WHvhcE4xVUGsA+1z7u9QEyHKVjaKd5k7EQymbD1rMkw=; b=GEJwmsmZnQu65aynPosZz4upVsiwc13h9zIiSXBGoaI20iaH6GV2ACvhgPtpwZB/L5 3VeqC4grZxzs0FF/04knQYU2RVFTahE72WCk/al0xsFCcEBXGOOQb8HbEKbPLgbyAfAO gPnA+2o5xPK/uD95X70NVX54SMWVT0Vh32owOxoIOUAUdwn+/ayMnmUvLFyq20Fl5WQe I1rYir96NZhnphnRzOLCEmN9JsMvl74yAukn+XMtvMvfnH6kKbwYDljr0hjHz7CZ4SIw DPcRCbvAcymfN4hKSrIB26XItFZx0WewmElLWzDsda5/qd8/lxzXWpmhHJMiBnfaNqFd h6hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334384; x=1709939184; 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=WHvhcE4xVUGsA+1z7u9QEyHKVjaKd5k7EQymbD1rMkw=; b=C7eCdMtWdrajWTvsP2OJUSV+0cWlvyQiJId/Inpeug/JnDrsLnUguWjC+LiD+53RIR 5Cb3Ff0ad4zSO3Pvd2IBvfso7Fr9mRyV+xD1r4iWXj5gtbHpIABVYzFmYuOeowccaFcY v16PfU9MOS52oMm14i+gy2+DtOB30k1yJ2Jg7tS312ui417KgxK9+Zc/y49MsBwKQ4nV 4/gjkz1LdiGUuIkl7A9RpKobDwaAj12fl6CxiUmW/ulbDhLdwS2XUyFHV7DYtWQ7QRK/ g+pg+QM0Ozu0iknFo4AcP4IUeZwTj/WIUUVFOcwgpC0bDSyuDPAhGSsGOjokMxhbykIW tzOw== X-Gm-Message-State: AOJu0YzIVMm8OYHt2IdgDuqGKvTfu1mluKIMW55SBWMZV/c1UVFrHQLb yYD8RJ2drM+90+hfCawyEErx11Fiz8JaSrSQMmTYsZc5FddsKoxEyqRNJJ+j5rAlCrEElXENift N X-Received: by 2002:a17:902:d491:b0:1db:c6a0:d023 with SMTP id c17-20020a170902d49100b001dbc6a0d023mr3659462plg.8.1709334383888; Fri, 01 Mar 2024 15:06:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:06:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 01/60] linux-user/elfload: Disable core dump if getrlimit fails Date: Fri, 1 Mar 2024 13:05:20 -1000 Message-Id: <20240301230619.661008-2-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::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 Do not dump core at all if getrlimit fails; this ensures that dumpsize is valid throughout the function, not just for the initial test vs rlim_cur. Reviewed-by: Alex Bennée 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 b8eef893d0..fb47fe39c9 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4673,7 +4673,7 @@ static int elf_core_dump(int signr, const CPUArchState *env) return 0; } - if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0) { + if (getrlimit(RLIMIT_CORE, &dumpsize) < 0 || dumpsize.rlim_cur == 0) { return 0; }