From patchwork Sun Jan 21 00:20:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 764469 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp530441wrx; Sat, 20 Jan 2024 16:22:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDeaB3zP3VLXS6BtTiwqn2Fkb65axCMy8tg9l5nhjS+bPfYG+3yIg93FPOHYwCgzUq5Hwt X-Received: by 2002:a05:620a:4095:b0:783:4386:71a4 with SMTP id f21-20020a05620a409500b00783438671a4mr3242804qko.116.1705796570648; Sat, 20 Jan 2024 16:22:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705796570; cv=none; d=google.com; s=arc-20160816; b=KxmaK1Ha1RRgd3uknDBiFZ7xirow6FvQZ1KSgIYJdh1PrXc9rV3v3nZG5BS+FRjH0u nLZ/Ct8p+8IrG9cErcqaxV/9hX5Ekzhj88idB0+qWPW8NkDVn1bedP9U85y4rTKwxdps V1YhT3mG7m7n5HItXV1ZZpoxEM/IKJviIN42LyMkNEF5ZOmm3ujiltD90XXHfrgxCixX TaVxyIyzTLZUPToIxbnoV6iJTyh2Na6nkdz0+HQLOEs5iUTT3RyR/pjKY2tREZ+11i0D HgXZPKvCbrA3JYzzqLXiSXTQXMI6KuqcvA00aqNtd/Xljto2/JU71r4w8K8Dd9ijPWEL AO2g== 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=xu2jaDl0CebkWF1EGwbc5gC+5GyuWO8TNdEnyUmyH68=; fh=bMwgPfaZtp2zWGFrNOM6woPJjiMxnLFtehHnbkwxg4U=; b=VIIa7+WL0idndxC+W1RXm9+tjDv2xZY6+2j5sf/XhMCSWwaLxXcAzQRWpLrEaqK/X0 zOF5vQvgIPgEcDQtHTN1kNxmTIxm0R/7IqfucZVh7v+v539DYInePdn7lFC5KYumf9jx ULaYYR3mNIME58/lexMlaFl7EjRKz7oBPewaKnqrlTPVpvNl4NR3XgJ4oDuEgi3murVk 6KEXcXECxdRnSzTY/xCqbX+hVOSh1KqUk2HzNgeNAJYVhfR3V7YxKFEDes1cXKZHEUQu B9jtD56cOakAV51xi0PfxXH747fcQ3nJWEqubMqYcsWhnuTjHOm788f/y3Pix8T5MhAH 0xAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zB1ECvkm; 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 v19-20020a05620a0a9300b0078368f6a499si2485039qkg.742.2024.01.20.16.22.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Jan 2024 16:22:50 -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=zB1ECvkm; 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 1rRLaP-0002Yk-IQ; Sat, 20 Jan 2024 19:21:17 -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 1rRLaO-0002YQ-MY for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:16 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rRLaN-0007Qn-7O for qemu-devel@nongnu.org; Sat, 20 Jan 2024 19:21:16 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d6fbaaec91so16701885ad.3 for ; Sat, 20 Jan 2024 16:21:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705796473; x=1706401273; 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=xu2jaDl0CebkWF1EGwbc5gC+5GyuWO8TNdEnyUmyH68=; b=zB1ECvkmgrwdiPenZzDGtE9p4m1jwc6vpFoDjMd1cduNtOx/E929wuuMPYda6+eviD MWW/AKc4H7ENq2NfdjXW2wt5P8NTOD+p0zQULfV4UnQyxqyx6Z8uwZlvxqUK1AdRE0ML lQlz/AcoSmMqEYwmVhzthfFYPTM7CyhVQJi63hKdVRHfG4QYkoDXrzhFEE8kCaltIhAy g6W7iLyTYs2yfI6XN76SVsQfOJlHBujBn80Zp5/7SgtiWgd/UMd/Mqy4KJJnjznV3avi U9eEAvFkB/ADh8e9Thukz2ng9wiLQ2S69tkr/5zvOOPu9tQmTT1qTMZWvOE3oW7yktkJ xq4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705796473; x=1706401273; 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=xu2jaDl0CebkWF1EGwbc5gC+5GyuWO8TNdEnyUmyH68=; b=ewAIsSmCbFXPHmbryPZIuGUJA0hyWjv7s8sk+4QvZoKDA0OvpC5Gb6tvztLXeCdKBH lzMkJptjyqB+Ciyel6YhpAvSLTxolVloaHrLieY13RsNWjbCtX1iASzgouciXzNMVJbb C0vQk7kPcAbak6PFJiWz3trOQOraN8qxYQK/PBrfB7zx/1B4eVIsLIcAS+Q69fYieYOY vKUkH4vaT3ZhAVv9wUWPC/DK6haLs/kl4qu5bUI821SC9k/DO//uOtC/cpF/lSo5KFPZ h6LpP1LiDZvgzDQSEbgpk9Hxwa5WZHQccoxSU5hL+LcO6SVQJK4bLjqQUfn0gHoV8Buv rsCQ== X-Gm-Message-State: AOJu0Yzr9aM/FdUn3NzO0WFEjL+CcO+J8AdVAaWUZOnQIimPWMw5Mk2s 83FiVPxJe9LEr+5j+3z4Iw6unoEuaV8wvZoPQ54ti85wNLLPfpoIaVNaFanKL3GAyLlPdQ3QHLh Q5Gc= X-Received: by 2002:a17:902:e852:b0:1d7:41b7:332b with SMTP id t18-20020a170902e85200b001d741b7332bmr875256plg.14.1705796473556; Sat, 20 Jan 2024 16:21:13 -0800 (PST) Received: from stoup.net ([2001:8004:5170:1e39:1361:3840:4873:7990]) by smtp.gmail.com with ESMTPSA id j4-20020a17090276c400b001d5af7fbda0sm5023546plt.122.2024.01.20.16.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 16:21:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PULL 7/8] linux-user/elfload: test return value of getrlimit Date: Sun, 21 Jan 2024 11:20:46 +1100 Message-Id: <20240121002047.89234-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240121002047.89234-1-richard.henderson@linaro.org> References: <20240121002047.89234-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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 Should getrlimit() fail the value of dumpsize.rlimit_cur may not be initialized. Avoid reading garbage data by checking the return value of getrlimit. Reviewed-by: Richard Henderson Signed-off-by: Thomas Weißschuh Message-Id: <20240120-qemu-user-dumpable-v3-1-6aa410c933f1@t-8ch.de> Signed-off-by: Richard Henderson --- linux-user/elfload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index cf9e74468b..c596871938 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4667,9 +4667,9 @@ static int elf_core_dump(int signr, const CPUArchState *env) init_note_info(&info); errno = 0; - getrlimit(RLIMIT_CORE, &dumpsize); - if (dumpsize.rlim_cur == 0) + if (getrlimit(RLIMIT_CORE, &dumpsize) == 0 && dumpsize.rlim_cur == 0) { return 0; + } corefile = core_dump_filename(ts);