From patchwork Tue Feb 27 18:48: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: 776271 Delivered-To: patch@linaro.org Received: by 2002:adf:a113:0:b0:33d:f458:43ce with SMTP id o19csp308248wro; Tue, 27 Feb 2024 10:49:10 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUAGDOrhlvZ/SrCBF9nQxQ3KEUDOIrbCfDBZJb/yV8U4IfFLzcociUJ37MzFslO03bE1KD0+IuSYKPVb0FpsRLu X-Google-Smtp-Source: AGHT+IHBtCQZg818AMMANNeftK4y/duXLYh4MWMrhsadER728kvaTzgDihDVpTWmlvx1DK0FPubZ X-Received: by 2002:a0c:8bc9:0:b0:68f:5fd5:80cd with SMTP id a9-20020a0c8bc9000000b0068f5fd580cdmr2652597qvc.6.1709059749970; Tue, 27 Feb 2024 10:49:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709059749; cv=none; d=google.com; s=arc-20160816; b=VXh8BMtdCkR9z55q7JNfmRHYOmP6rBV+cl64c32fRuLa/6hHyGqTXpkQ2BpnuxRDxi 3K3+ddicwT9N3wejLyfOA3XZB0IXdzgKW3CijSYaQo4ruWp6YTh2x2GK9Xedrcyvwiyd eq1QaRbzgiFfhClALbObteEaIH381RQ3K6LV1xVdoV3A5PUzUm9prUq2BGO/WKrnOUhL 5E+Qj96+IeMimlVFo2Q+m91LbfXN7BIbl1M89bz5WnOiZezjXNu5SQC32ZIiKwPVbM9V 1Ml9CCvueY1J0BovGWR63unoBYJjU1pgnFlnujPkZZpLNVoMHmt1TArOAtHfnB5aRIAy ihDg== 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=jYBkGoMMC9wjPymAcLzdiqwt32NykwjmDLE/jmy3uYA=; fh=Vvliz9ENSk/yCY42nG87aL5dW+Zo0lduSx74U3lH2V8=; b=nwiFvPypPaRhQsiS8mdI3F2I03iAce+twiV8urPAA4j1qlX5G/m88PS4EU5kv0+8g3 L4pdgeuUA8BC2L/RW9/xtNTk0AwZEZkxZe7Goe9CtiBWZGjmIw6lg7GKfSTMPhijI+sD VSt1mRccsspGgrCE8g/wyQlXvCcHi0DCYG48aclVbawqVe3LOicnZbhcEKq9lP4d/979 34J8Lo5cJnOX6/gNyH/MQY3WsG7zA/x395skL0MRA6nIKUUgnIRuYZwTElxTNorCAnld 2qoWbxfmD61g9g5gAvZmK0+BhURV2hGW5H7q3aPVMZJ0SttWzDT0mJC6xWQgZ1SUuD00 kLPQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PTWOgijn; 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 if4-20020a0562141c4400b0068f761b112esi8230165qvb.357.2024.02.27.10.49.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Feb 2024 10:49:09 -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=PTWOgijn; 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 1rf2VO-0006Ua-Ih; Tue, 27 Feb 2024 13:48:42 -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 1rf2VN-0006U2-5h for qemu-devel@nongnu.org; Tue, 27 Feb 2024 13:48:41 -0500 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rf2VL-0001ST-JZ for qemu-devel@nongnu.org; Tue, 27 Feb 2024 13:48:40 -0500 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6e4957ff05cso1621046a34.2 for ; Tue, 27 Feb 2024 10:48:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709059718; x=1709664518; 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=jYBkGoMMC9wjPymAcLzdiqwt32NykwjmDLE/jmy3uYA=; b=PTWOgijnVwgQfa5nMUkRjVR5K3R0he76rfrErF9KisHjaKTDaJFh0Z42IDGsZab/8M BVuQaio33mtUA9L2XCBiqJePIWohU8mGEmzK+Sm77RCFuexvrJmbfh5tg1MwJWviOU9W k1XlgdZQbJ5/X7Sn1CZLHbc3/x0bXVwzaOkAEEj5UGRtDDQHskp+t57GaMJUMyCRqAhv j4i0r8zHJu9hb6ljI3+LcQPynMMfk7mqmwSpLj8/xItp69QK/ZjVQFfJcvl320KU4q01 RBLFAfyQZsTwtGkc+JJJs0bhJFxxZTvshPwlCvJ66qLstYjC022lu8cp5GkAGUoTA0jP d30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709059718; x=1709664518; 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=jYBkGoMMC9wjPymAcLzdiqwt32NykwjmDLE/jmy3uYA=; b=NMqiNn9gC5p7+XMhCyXqd2KsL8XekO4/d9ya1k+0SJwjSLrxIbY80ft2fi0rEUiSJN fxF8ojgPZw0bgqa6QcD/SkGj1AOfJeB82TW0Fo93jsB07JXj7u9kWvkeQ6KhWplm4Mc6 sk245Dmr7biXOlDMuy00HL+yh5JF5RkQLx7UN9njatm/bUQgYNZFj0zldHskV22xIN/7 CJv4FSxoYjDrgrD8Cr0mdy49qTnc8zjUQuY/cx+YZDDWg3XRtjvTCJ4ztFsTizO0qOOV //0MnW5xBDgtkiODX2QToMds5RWKkPWXDmAH5PJl6SgiQ6I157tGkPSmrMFzXMv2bweV 35lQ== X-Gm-Message-State: AOJu0YyZo3sAnL6lT9hqFhNY5NdA2QJvayKg+rzde6j5m7D7WrvzLEeR irizTmGkV35R9LESl7VkyVXH1SumdCqF9b8Pf4yW12su2KZaFia7osksaQ53Q98VKDFkzAXiN/v j X-Received: by 2002:a05:6830:1390:b0:6e4:7a7b:700b with SMTP id d16-20020a056830139000b006e47a7b700bmr10732280otq.14.1709059718356; Tue, 27 Feb 2024 10:48:38 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id h26-20020aa786da000000b006e555d40951sm533465pfo.188.2024.02.27.10.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 10:48:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH 01/14] linux-user/elfload: Disable core dump if getrlimit fails Date: Tue, 27 Feb 2024 08:48:20 -1000 Message-Id: <20240227184833.193836-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227184833.193836-1-richard.henderson@linaro.org> References: <20240227184833.193836-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::333; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x333.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. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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; }