From nobody Thu Jan 2 13:49:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1727244717; cv=none; d=zohomail.com; s=zohoarc; b=myXH5dzvoj8dZBYWCABCwWW53X+/v7CIpfJPKZsHg5EUEG+feG+1Mvt6SYZ6/6x+wiFjAF9Zp7oRhg8jNltbsMH9yAoLRkFSR9BihXvXsTtaJUdcFQ+x9K4BKoe3v+AEfXG0m6jSRrGstqAP7HqVusLpayud5kxUUVlIl/j7T/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727244717; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wVxz4I4vyQGmSKY6Ub9yCNA7tMFmaRorNjlXLxFtjUc=; b=JRK0A7eQYcuW0PGBgaiicW2E5E3iYfRNsUt+bw+vdIpo9k1jQv0tUkPNYI2/HTQEMWuaobi+bp3jpSIv8Mkw71zqnjZT3/qNsx+hHqgpRDP3fVe5WiIsNnG4GoXZYk3XLREyAzSqA7LlOD+VBiljXxXApV64uw6QbHs5vpL70m8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1727244717460681.5196835345332; Tue, 24 Sep 2024 23:11:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.803450.1214041 (Exim 4.92) (envelope-from ) id 1stL5a-0003e7-0f; Wed, 25 Sep 2024 06:01:26 +0000 Received: by outflank-mailman (output) from mailman id 803450.1214041; Wed, 25 Sep 2024 06:01:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1stL5Z-0003dt-T1; Wed, 25 Sep 2024 06:01:25 +0000 Received: by outflank-mailman (input) for mailman id 803450; Wed, 25 Sep 2024 06:01:24 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1stL5Y-0002f5-On for xen-devel@lists.xenproject.org; Wed, 25 Sep 2024 06:01:24 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 96c229ce-7b03-11ef-99a2-01e77a169b0f; Wed, 25 Sep 2024 08:01:21 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a8d2b24b7a8so102347766b.1 for ; Tue, 24 Sep 2024 23:01:21 -0700 (PDT) Received: from fziglio-desktop.. ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c5cf49de00sm1498937a12.55.2024.09.24.23.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Sep 2024 23:01:19 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 96c229ce-7b03-11ef-99a2-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1727244080; x=1727848880; darn=lists.xenproject.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=wVxz4I4vyQGmSKY6Ub9yCNA7tMFmaRorNjlXLxFtjUc=; b=icRQhwcV9C7fgPmLZok0xPqhq5SFvUEVzCqtzXCwIs0Nuc6zQHmbBubgL3wqOrFZmn XMyMj+R3G93nTQgkvZ3/XnhByMbPl+j14zMWpIsFZRTFC7Hwsl6Tbc5GM859uvfDcJ0u 4+8X7E59LLpn7bc0PTcSOf84CWd3U+yL/10wQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727244080; x=1727848880; 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=wVxz4I4vyQGmSKY6Ub9yCNA7tMFmaRorNjlXLxFtjUc=; b=iNOM75fkBOFkbCchF2A5VsnzYBodMxdiww/ePrb4d08VCRDt4ci5I9iSqaY2EaTtzu 9AvA88qVELfUNlUEj31Oq0FECOYJVT4tI2STHLFa0jqeW8kYMZDyZLzApfaNMs880PnO en07pzV2uCjnf3nksCn7MuxHH6nSmVV8VZixuwXN0d639/MrE3yaP1QYcTJQZoJ5irLR IOrwWefZtfSxxI7ro547DNx+9Fz3XPDSl429D6Y1xQCZqW2sQP8r7F+DZ4x+/82EpGx4 woIydejcZUglH811925pAa+2/+tkI0U11v/LPIHSkyRh6Gh8QMSqWCpuY/DCYK3sjTHo rY6Q== X-Gm-Message-State: AOJu0Yyi9RWiCwZUGZbVY8BWebFHKrGagalBfs/M4s8cElrQdbMOsAra SF4CWSVw1kyzE6N0y7D1KYonQ75XMrafyHMSvLrbULZ5vfjXMtdgevwaiaS5p1GvaYumAu/GQMt + X-Google-Smtp-Source: AGHT+IGKaqBd9awEa1SGJvtToFN9ateo9a6+kddKbdn9a5nrY01jZMuIldAOnRilgdVuoUaZ6Ndk5w== X-Received: by 2002:a17:907:9447:b0:a90:c4a0:9b17 with SMTP id a640c23a62f3a-a92c4810ee5mr641184766b.9.1727244080231; Tue, 24 Sep 2024 23:01:20 -0700 (PDT) From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , "Daniel P. Smith" , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 4/4] x86/boot: Improve MBI2 structure check Date: Wed, 25 Sep 2024 07:01:01 +0100 Message-Id: <20240925060101.259244-5-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240925060101.259244-1-frediano.ziglio@cloud.com> References: <20240925060101.259244-1-frediano.ziglio@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1727244734933116600 Content-Type: text/plain; charset="utf-8" Tag structure should contain at least the tag header. Entire tag structure must be contained inside MBI2 data. Signed-off-by: Frediano Ziglio --- xen/arch/x86/efi/parse-mbi2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/efi/parse-mbi2.c b/xen/arch/x86/efi/parse-mbi2.c index 89c562cf6a..0b080dfa92 100644 --- a/xen/arch/x86/efi/parse-mbi2.c +++ b/xen/arch/x86/efi/parse-mbi2.c @@ -13,6 +13,7 @@ efi_multiboot2_prelude(uint32_t magic, const multiboot2_f= ixed_t *mbi) EFI_HANDLE ImageHandle =3D NULL; EFI_SYSTEM_TABLE *SystemTable =3D NULL; const char *cmdline =3D NULL; + const void *const mbi_end =3D (const void *)mbi + mbi->total_size; bool have_bs =3D false; =20 if ( magic !=3D MULTIBOOT2_BOOTLOADER_MAGIC ) @@ -21,7 +22,9 @@ efi_multiboot2_prelude(uint32_t magic, const multiboot2_f= ixed_t *mbi) /* Skip Multiboot2 information fixed part. */ tag =3D _p(ROUNDUP((unsigned long)(mbi + 1), MULTIBOOT2_TAG_ALIGN)); =20 - for ( ; (const void *)tag - (const void *)mbi < mbi->total_size + for ( ; (const void *)(tag + 1) <=3D mbi_end + && tag->size >=3D sizeof(*tag) + && (const void *)tag + tag->size <=3D mbi_end && tag->type !=3D MULTIBOOT2_TAG_TYPE_END; tag =3D _p(ROUNDUP((unsigned long)((const void *)tag + tag->size= ), MULTIBOOT2_TAG_ALIGN)) ) --=20 2.34.1