From nobody Tue Dec 16 12:37:39 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1752254663; cv=none; d=zohomail.com; s=zohoarc; b=hAa3isKVS1w1ruTNExlbztA9OiW8l/5bdYv2EcqoVPme12ySepBTFFH006q7qh1bspd/MfvBfosDQx/L6RHJ7fPYIygc4yuO1LsOf317+95fmdgWREAZT1zO0Ht9K1cF2EoMzBNYwyy0SztyFk2x6lpeSZWmQm77b42OQow8kl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752254663; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KbvFJbF5XPFsYap/Rj9OWqngvL2EB4p0iDRPnlUGu/U=; b=J4m8tQ/AB3kUGMJbiCNLdZhVw8qE1uoL/fKWMR5sLwdbWL/wnS3ATcwfL3TJEBTTNj5QQT/qx8sNFf35UBD9XlR/nP7++4ht/iQI+xHgVvLyJqvwuKVtj//CUmWuZEUgyJyv97PAkDgJRK/D356TK/wX/ZNl5ppAdUIzeS91XH8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752254663146783.9058432079323; Fri, 11 Jul 2025 10:24:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uaHSm-0001ob-OC; Fri, 11 Jul 2025 13:23:08 -0400 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 1uaHSj-0001jv-7g for qemu-devel@nongnu.org; Fri, 11 Jul 2025 13:23:05 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uaHSh-00030m-Iz for qemu-devel@nongnu.org; Fri, 11 Jul 2025 13:23:04 -0400 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-40b31468da3so742593b6e.0 for ; Fri, 11 Jul 2025 10:23:03 -0700 (PDT) Received: from localhost.localdomain (fixed-187-189-51-143.totalplay.net. [187.189.51.143]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4141c77ada0sm602041b6e.44.2025.07.11.10.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jul 2025 10:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752254582; x=1752859382; 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=KbvFJbF5XPFsYap/Rj9OWqngvL2EB4p0iDRPnlUGu/U=; b=y7YNWV8Hbn7MsX7taoPKf03IL900ngkmaJklhsLLCFxTQJNaKeLG7WE3/CtGbSNtJC RMBEnEIJIBaHXcfRzlzbwJOTdn9z2xZR8UqoSSDnN//LQ7dxmsYKjZX/5MFjlJIq9Lei KgWSGLgXUASrptzOAhOdNeIQw0jAT0U6AmF0qlb3qBVVCsljCQ2hYKcQgUmPDsya/LbN MmwCZ9taTimzdxBZIP0HrW7rSGewEtYdeJVwusKgJm+OUBERXGXZYTAoBlDNGxz+fuiU APv62OKLY7waLbfNISRpoPTMIMyuQcnTtWgQAtaDNYMDSC5rzJ1wk8JTxZqrRJVQQkPj ekuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752254582; x=1752859382; 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=KbvFJbF5XPFsYap/Rj9OWqngvL2EB4p0iDRPnlUGu/U=; b=Xg8MiwAT+hP8SqRnaNudOH9kCOOV7nYHEr8b9IY8v0QHdKA+kXTDgeQ9P6mzl3xn92 wfO+PmnmWzLIrNq2hxpOIEcT3MG/54tvIUxBbltNmM378cDWcnxAYHrZI1ORTBgLgNYt cjoyo1jimVfmow/cumlxNZq+TExNcpc5hXkMfLdWs71xoL6/htLn6WD2RJ58sGz4b62x zhiNzoKieeJBkc/mexY6oHHKI0lnSe5BpyD5Fpru58btqI9E/axUvyRja1ly0RnKTZhg 4mPJhywdm+WCuAGtOvTK4mxHlxAfY/N80fcED0p9KzjQyaMRO3ItR+iXgBdoYbO9IqUj 8OBw== X-Gm-Message-State: AOJu0Yy6VYkh2rN9J/jgpN92Lo5I/GG44QCLJ7Pw2y9UrqMh2wGhNikV uj2yY1iFLLhlmwbDwF9bE2XfVbKWIF0d1RCTrjgLWF5ZASnCU4hVNexFfzRG+8XXQ0dg9MtAtZk 6WQJ2j+s= X-Gm-Gg: ASbGncuI0hS0JIKxEEZDDM0sw+T5hsyRclhyDxpEPIS54jc0m8Pm18HHAHOnG2gisuc odI+Rx99zefhKa+fWeMx+ZyV/QgNyAX0FwFqzibKMOxi2YEp7Htypsfx0qFvNsIgKWxzfSKAuTN 6O/U/mow4PW/IOxZ1Wqb6ZJ9Us/nD9i8fpSobDGkyIpuOvZiiaUqYhHfTHDdduyMRKtA97vEujw I2ovw8LoK0I7gmIrEB5VUj7aB7vEdk6zCI/PU8vT8Cry3W8YNIqvlRrUIF3beKnWft1NAmnfoRw S3I7RftLcMDuZjT32GSxSvvxodbNiKbZa1LSu8hbaBuuCRcXqDTKBALsw5j5yHWOqlzTKIX9JF6 qnMpD7XF+5Ycmx2E1zf9BAjF20+9Oe7gsmyuvhsaLQeb/BQ/rrkWuLggyu2So0oKT6o63Lxau7l 4hzC7wAeWj X-Google-Smtp-Source: AGHT+IESlgROdwpepOV+/wYlJRog07cgPlcOGuNab3KUFrXmBvMGhd5f8grJwmewYoCab7KqCd8G8g== X-Received: by 2002:a05:6808:6547:20b0:40b:9948:f26c with SMTP id 5614622812f47-4150dc288bbmr2277044b6e.12.1752254582130; Fri, 11 Jul 2025 10:23:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 4/9] linux-user/gen-vdso: Handle fseek() failure Date: Fri, 11 Jul 2025 11:22:49 -0600 Message-ID: <20250711172254.229201-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250711172254.229201-1-richard.henderson@linaro.org> References: <20250711172254.229201-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::233; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x233.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1752254663662116600 Content-Type: text/plain; charset="utf-8" From: Peter Maydell Coverity points out that we don't check for fseek() failure in gen-vdso.c, and so we might pass -1 to malloc(). Add the error checking. (This is a standalone executable that doesn't link against glib, so we can't do the easy thing and use g_file_get_contents().) Coverity: CID 1523742 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson Message-ID: <20250710170707.1299926-2-peter.maydell@linaro.org> --- linux-user/gen-vdso.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/linux-user/gen-vdso.c b/linux-user/gen-vdso.c index fce9d5cbc3..1c406d1b10 100644 --- a/linux-user/gen-vdso.c +++ b/linux-user/gen-vdso.c @@ -113,9 +113,16 @@ int main(int argc, char **argv) * We expect the vdso to be small, on the order of one page, * therefore we do not expect a partial read. */ - fseek(inf, 0, SEEK_END); + if (fseek(inf, 0, SEEK_END) < 0) { + goto perror_inf; + } total_len =3D ftell(inf); - fseek(inf, 0, SEEK_SET); + if (total_len < 0) { + goto perror_inf; + } + if (fseek(inf, 0, SEEK_SET) < 0) { + goto perror_inf; + } =20 buf =3D malloc(total_len); if (buf =3D=3D NULL) { --=20 2.43.0