From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 8CE7E74003B for ; Thu, 11 Jan 2024 06:52:26 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=E63T3lyEyEuAfvGm3CBMGLk2IFat1oaowLyNsuclh90=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1704955944; v=1; b=MkV+OrlzBYYEKq9EKHTiRpw063GARWoO1URo3v1JB5w51lVgrOPcV2gGP/L/oM9Q72xH5Jg4 2qbljXHa/x4N8/uRdlZgW7/xmp727zjI8RnUmADRErNgTZUG/9AtvmGhnMGabZfxYxgxpYm741p 1ARWWXkHfNGvBpOmpbduOWHI= X-Received: by 127.0.0.2 with SMTP id kRIGYY7687511xbMrhvP0cKe; Wed, 10 Jan 2024 22:52:24 -0800 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.6348.1704955944202302391 for ; Wed, 10 Jan 2024 22:52:24 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B318961975 for ; Thu, 11 Jan 2024 06:52:23 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B916C433F1 for ; Thu, 11 Jan 2024 06:52:23 +0000 (UTC) X-Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-50e9e5c97e1so5959140e87.0 for ; Wed, 10 Jan 2024 22:52:23 -0800 (PST) X-Gm-Message-State: hqBs29W8oiAm38fw3e9AyyBMx7686176AA= X-Google-Smtp-Source: AGHT+IEpVshWPjDVqIc3L8E0BWRsUryw59KTnyweRmMgGdW5cGH1zRGspiDTSJA0pUU+xGTyESjavmTaa1cIpUNj4NU= X-Received: by 2002:a05:6512:34cb:b0:50e:6935:eae1 with SMTP id w11-20020a05651234cb00b0050e6935eae1mr265656lfr.126.1704955941503; Wed, 10 Jan 2024 22:52:21 -0800 (PST) MIME-Version: 1.0 References: <20240111051521.1366-1-gua.guo@intel.com> <20240111051521.1366-3-gua.guo@intel.com> In-Reply-To: <20240111051521.1366-3-gua.guo@intel.com> From: "Ard Biesheuvel" Date: Thu, 11 Jan 2024 07:52:10 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v1 2/4] StandaloneMmPkg/Hob: Integer Overflow in CreateHob() To: gua.guo@intel.com Cc: devel@edk2.groups.io, Gerd Hoffmann , Marc Beatove , Sami Mujawar , Ray Ni , John Mathew Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=MkV+Orlz; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Thu, 11 Jan 2024 at 06:15, wrote: > > From: Gerd Hoffmann > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4166 > > Fix integer overflow in various CreateHob instances. > Fixes: CVE-2022-36765 > > The CreateHob() function aligns the requested size to 8 > performing the following operation: > ``` > HobLength = (UINT16)((HobLength + 0x7) & (~0x7)); > ``` > > No checks are performed to ensure this value doesn't > overflow, and could lead to CreateHob() returning a smaller > HOB than requested, which could lead to OOB HOB accesses. > > Reported-by: Marc Beatove > Cc: Ard Biesheuvel > Cc: Sami Mujawar > Cc: Ray Ni > Cc: John Mathew > Signed-off-by: Gerd Hoffmann Reviewed-by: Ard Biesheuvel > --- > .../StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c > index 1550e1babc..29ade2e4ef 100644 > --- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c > +++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c > @@ -34,6 +34,12 @@ CreateHob ( > > HandOffHob = GetHobList (); > > + // > + // Check Length to avoid data overflow. > + // > + if (HobLength > MAX_UINT16 - 0x7) { > + return NULL; > + } > HobLength = (UINT16)((HobLength + 0x7) & (~0x7)); > > FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom; > -- > 2.39.2.windows.1 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113581): https://edk2.groups.io/g/devel/message/113581 Mute This Topic: https://groups.io/mt/103657272/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-