From nobody Tue Nov 4 00:53:14 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=1727328554; cv=none; d=zohomail.com; s=zohoarc; b=Gx4/9Ho2JVwpPOqT2q0sG7z1ixLadfOFNVQWlckT/tOm3M+L71oGND+JiEo/QLESX4rXRu1KEq+2NKVFW+A2l9fOfRv9+Gkt0a3Yx1zqFTubNrUT5mbSDKncRzAGth/BBjy0JQjjVvRNzc8u4xtFCtGfgxpWn0CdM1QQOMkMvrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727328554; 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=zv+yM3lvTRJQIA1+ZYdW3e6DFoAUNOBXydVMy3hCsps=; b=Ue+exQzfXuYLZphp28uxBFaci12QtaT5Hi0bYAVJQ74VxQTp9vhFXymarWyk5dx7GKYersKDLWpvG/NIUJx60XvwbflAO46+qOi8Yaegrx9MapfVNtKP/NeKD987uoqE4vHLPeUZYjF/dw+F8nnNERUtSnknrg7HHluAFhbJAcc= 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 1727328554315659.5985409395282; Wed, 25 Sep 2024 22:29:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.804855.1215847 (Exim 4.92) (envelope-from ) id 1sth3Z-0005Q2-De; Thu, 26 Sep 2024 05:28:49 +0000 Received: by outflank-mailman (output) from mailman id 804855.1215847; Thu, 26 Sep 2024 05:28:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sth3Z-0005PG-8k; Thu, 26 Sep 2024 05:28:49 +0000 Received: by outflank-mailman (input) for mailman id 804855; Thu, 26 Sep 2024 05:28:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sth3X-0004tb-Vu for xen-devel@lists.xenproject.org; Thu, 26 Sep 2024 05:28:47 +0000 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [2a00:1450:4864:20::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 339cb1b5-7bc8-11ef-a0ba-8be0dac302b0; Thu, 26 Sep 2024 07:28:46 +0200 (CEST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a8a6d1766a7so74315866b.3 for ; Wed, 25 Sep 2024 22:28:46 -0700 (PDT) Received: from fziglio-desktop.. ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9392f34086sm304441766b.41.2024.09.25.22.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 22:28:45 -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: 339cb1b5-7bc8-11ef-a0ba-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1727328525; x=1727933325; 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=zv+yM3lvTRJQIA1+ZYdW3e6DFoAUNOBXydVMy3hCsps=; b=Tl11MasvqyMEEVNu2Zy0hY094Do6YAepu5afUC+fhRr8wLp01qMpaHaj1/Cea5XEkn +2DhGVBqy9RYSPP4Typ4mdywdA5i3HXINv+Xb/kX7BnCWSHZ0w7N8lDgia2BemGslwFu 4Sax9WsHt2IwAUi3c+Ht4csndLoSf9JcOHZQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727328525; x=1727933325; 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=zv+yM3lvTRJQIA1+ZYdW3e6DFoAUNOBXydVMy3hCsps=; b=sAgjK4XnPKOHov4DBGBgaUA6UCDmfqk74l+CKCRtM6Af+oYKDNjlNE+NlOqOL2OL6T ZkJoH/al6DRS0kd0vvkY1+gKYjpnZDShVJU/rVKlsvDGXhl2ccw+Lrt+GIsaOMCZ6eoM zrpQk5speOkeD0u9eJb3sDrS4O8PyQuLgqHrvnSfZHQ9QvY/M6K9J48lzsozmyBUycxx 4yzQ7i2NVoRCuuExCeUuLPjmf69SZJ3mIAz92OkyClnLOY6tMnZuKL4bZmOo0962E2HN eOxaqUk5c+f6+9xCCYeve0HfB4lp2FK0OuFWPi1X7mFMtO+UwQo6HOqnkV8z3R1/cvEf /YoA== X-Gm-Message-State: AOJu0Yw27xLLdBSB9y3jBidu1vVaHKJBvYvnXbYhsySaxZE1aXDjQrQH YVkH1vDp5J5Q9UaRwuMTIK78IwFum4GRXkOuqbUvkVZJ6I83UN24RL1TULGsiXQoV+RC5aZMBcm d X-Google-Smtp-Source: AGHT+IGRWvTIxwDndToohXT5/azuh8J00Iya3wCj9TRYs6htW4NXGQDVi8fUAR+9R1599m1g32Qn9g== X-Received: by 2002:a17:907:9411:b0:a8a:809b:14ed with SMTP id a640c23a62f3a-a93a0646977mr393119466b.44.1727328525560; Wed, 25 Sep 2024 22:28:45 -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 v5 3/3] x86/boot: Improve MBI2 structure check Date: Thu, 26 Sep 2024 06:28:33 +0100 Message-Id: <20240926052833.465510-4-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240926052833.465510-1-frediano.ziglio@cloud.com> References: <20240926052833.465510-1-frediano.ziglio@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1727328556034116600 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 55a1777483..cae26d5e10 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)tag + tag->size, MULTIBOOT2_TAG_ALIGN)) ) --=20 2.34.1