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 EADE6740047 for ; Thu, 11 Jan 2024 06:54:07 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=FeuitjMZd2fcqEeRC+SyFBGBzBmYbiO2nYvW6sLT000=; 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=1704956046; v=1; b=YELStkQ/ZoWIcL3BwNYvEpNrFtpTpXXoQmGOmNWzhuSQpViOXBPQKJJTszmGU76X0xO9AmsD HvZjD6GSMIww2loEJB1nZXN20sReFrNPkLZd4urS4PWdhMo6uBAQQj+Tk+6dMx4yovoNaPAXYj5 qLoHvSDTsu8hTcxyPwO24jTM= X-Received: by 127.0.0.2 with SMTP id 2kd4YY7687511xpIRKr5lL9G; Wed, 10 Jan 2024 22:54:06 -0800 X-Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by mx.groups.io with SMTP id smtpd.web11.6310.1704956045661460567 for ; Wed, 10 Jan 2024 22:54:06 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 49F43CE1E73 for ; Thu, 11 Jan 2024 06:54:02 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79D97C43394 for ; Thu, 11 Jan 2024 06:54:01 +0000 (UTC) X-Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-50e6ee8e911so5472897e87.1 for ; Wed, 10 Jan 2024 22:54:01 -0800 (PST) X-Gm-Message-State: ezse7cUPTfCDTtFwjlHIu3sax7686176AA= X-Google-Smtp-Source: AGHT+IF3Pt6E4508hCrSkjq6OgCRSX5ZWio8oxwEMpzLlEDSP6BoMt91QTMjSnBv795W0p23FLXcpCluAIKtnaPsCb0= X-Received: by 2002:ac2:4213:0:b0:50e:8d0c:5ef0 with SMTP id y19-20020ac24213000000b0050e8d0c5ef0mr276233lfh.9.1704956039732; Wed, 10 Jan 2024 22:53:59 -0800 (PST) MIME-Version: 1.0 References: <20240111051521.1366-1-gua.guo@intel.com> <20240111051521.1366-4-gua.guo@intel.com> In-Reply-To: <20240111051521.1366-4-gua.guo@intel.com> From: "Ard Biesheuvel" Date: Thu, 11 Jan 2024 07:53:48 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v1 3/4] EmbeddedPkg/Hob: Integer Overflow in CreateHob() To: gua.guo@intel.com Cc: devel@edk2.groups.io, Gerd Hoffmann , Marc Beatove , Leif Lindholm , Abner Chang , 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="YELStkQ/"; 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: Leif Lindholm > Cc: Ard Biesheuvel > Cc: Abner Chang > Cc: John Mathew > Signed-off-by: Gerd Hoffmann This is missing a signed-off line from the sender. (the signoff is not a statement of authorship, it is a promise by the sender that the contribution complies with the license) With that fixed: Reviewed-by: Ard Biesheuvel > --- > EmbeddedPkg/Library/PrePiHobLib/Hob.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/EmbeddedPkg/Library/PrePiHobLib/Hob.c b/EmbeddedPkg/Library/PrePiHobLib/Hob.c > index 8eb175aa96..ee2e3176be 100644 > --- a/EmbeddedPkg/Library/PrePiHobLib/Hob.c > +++ b/EmbeddedPkg/Library/PrePiHobLib/Hob.c > @@ -110,6 +110,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 (#113584): https://edk2.groups.io/g/devel/message/113584 Mute This Topic: https://groups.io/mt/103657273/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-