public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "bryan-bt.tan via groups.io" <bryan-bt.tan=broadcom.com@groups.io>
To: Doug Flick <dougflick@microsoft.com>,devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH v2 01/15] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 Patch
Date: Mon, 05 Feb 2024 05:41:00 -0800	[thread overview]
Message-ID: <18011.1707140460470094636@groups.io> (raw)
In-Reply-To: <a673060790a9056f68b7772664b4a8626b3d49bb.1706219324.git.doug.edk2@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4914 bytes --]

On Thu, Jan 25, 2024 at 11:06 PM, Doug Flick wrote:

> 
> <snip>
> @@ -607,35 +616,95 @@ Dhcp6AppendOption (
> // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+=
> =0D
> //=0D
> =0D
> - ASSERT (OptLen !=3D 0);=0D
> + //=0D
> + // Verify the arguments are valid=0D
> + //=0D
> + if (Packet =3D=3D NULL) {=0D
> + return EFI_INVALID_PARAMETER;=0D
> + }=0D
> =0D
> - WriteUnaligned16 ((UINT16 *)Buf, OptType);=0D
> - Buf +=3D 2;=0D
> - WriteUnaligned16 ((UINT16 *)Buf, OptLen);=0D
> - Buf +=3D 2;=0D
> - CopyMem (Buf, Data, NTOHS (OptLen));=0D
> - Buf +=3D NTOHS (OptLen);=0D
> + if ((PacketCursor =3D=3D NULL) || (*PacketCursor =3D=3D NULL)) {=0D
> + return EFI_INVALID_PARAMETER;=0D
> + }=0D
> =0D
> - return Buf;=0D
> + if (Data =3D=3D NULL) {=0D
> + return EFI_INVALID_PARAMETER;=0D
> + }=0D
> +=0D
> + if (OptLen =3D=3D 0) {=0D
> + return EFI_INVALID_PARAMETER;=0D
> + }=0D
> +=0D
> + //=0D
> + // Verify the PacketCursor is within the packet=0D
> + //=0D
> + if ( (*PacketCursor < Packet->Dhcp6.Option)=0D
> + || (*PacketCursor >=3D Packet->Dhcp6.Option + (Packet->Size - sizeof =
> (EFI_DHCP6_HEADER))))=0D
> + {=0D
> + return EFI_INVALID_PARAMETER;=0D
> + }=0D
> +=0D
> + //=0D
> + // Calculate the bytes needed for the option=0D
> + //=0D
> + BytesNeeded =3D DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN + NTOHS (OptLen);=0D
> 
> +=0D
> + //=0D
> + // Space remaining in the packet=0D
> + //=0D
> + Length =3D Packet->Size - Packet->Length;=0D
> + if (Length < BytesNeeded) {=0D
> + return EFI_BUFFER_TOO_SMALL;=0D
> + }=0D
> +=0D
> + //=0D
> + // Verify the PacketCursor is within the packet=0D
> + //=0D
> + if ( (*PacketCursor < Packet->Dhcp6.Option)=0D
> + || (*PacketCursor >=3D Packet->Dhcp6.Option + (Packet->Size - sizeof =
> (EFI_DHCP6_HEADER))))=0D
> + {=0D
> + return EFI_INVALID_PARAMETER;=0D
> + }=0D

This check is unnecessary; the same check is done above.

> 
> <snip>
> @@ -766,35 +934,51 @@ Dhcp6AppendIaOption (
> //=0D
> for (Index =3D 0; Index < Ia->IaAddressCount; Index++) {=0D
> AddrOpt =3D (UINT8 *)Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDR=
> ESS);=0D
> - Buf =3D Dhcp6AppendIaAddrOption (Buf, (EFI_DHCP6_IA_ADDRESS *)Addr=
> Opt, MessageType);=0D
> + Status =3D Dhcp6AppendIaAddrOption (Packet, PacketCursor, (EFI_DHCP6_=
> IA_ADDRESS *)AddrOpt, MessageType);=0D
> + if (EFI_ERROR (Status)) {=0D
> + return Status;=0D
> + }=0D
> }=0D
> =0D
> //=0D
> // Fill the value of Ia option length=0D
> //=0D
> - *Len =3D HTONS ((UINT16)(Buf - (UINT8 *)Len - 2));=0D
> + *Len =3D HTONS ((UINT16)(*PacketCursor - (UINT8 *)Len - 2));=0D
> =0D
> - return Buf;=0D
> + //=0D
> + // Update the packet length=0D
> + //=0D
> + Packet->Length +=3D BytesNeeded;=0D

Shouldn't we update Packet->Length before calling Dhcp6AppendIaAddrOption
as it needs to know how much space is left in the Packet?

> 
> +=0D
> + return EFI_SUCCESS;=0D
> }=0D
> =0D
> /**=0D
> Append the appointed Elapsed time option to Buf, and move Buf to the end=
> .=0D
> =0D
> - @param[in, out] Buf The pointer to the position to append.=0D
> + @param[in, out] Packet A pointer to the packet, on success Packet=
> ->Length=0D

Nit: Missing "will be updated." like other function header comments.

> 
> + @param[in, out] PacketCursor The pointer in the packet, on success Pack=
> 
> etCursor=0D
> + will be moved to the end of the option.=0D
> @param[in] Instance The pointer to the Dhcp6 instance.=0D
> @param[out] Elapsed The pointer to the elapsed time value in=0D
> - the generated packet.=0D
> + the generated packet.=0D
> =0D
> - @return Buf The position to append the next Ia option.=
> =0D
> + @retval EFI_INVALID_PARAMETER An argument provided to the function was=
> invalid=0D
> + @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the op=
> tion.=0D
> + @retval EFI_SUCCESS The option is appended successfully.=0D
> =0D
> **/=0D
> -UINT8 *=0D
> +EFI_STATUS=0D
> Dhcp6AppendETOption (=0D
> - IN OUT UINT8 *Buf,=0D
> - IN DHCP6_INSTANCE *Instance,=0D
> - OUT UINT16 **Elapsed=0D
> + IN OUT EFI_DHCP6_PACKET *Packet,=0D
> + IN OUT UINT8 **PacketCursor,=0D
> + IN DHCP6_INSTANCE *Instance,=0D
> + OUT UINT16 **Elapsed=0D
> )=0D
> {=0D
> + UINT32 BytesNeeded;=0D
> + UINT32 Length;=0D
> +=0D
> //=0D
> // The format of elapsed time option:=0D
> //=0D

Apologies for any poor formatting, this is my first time posting on this
mailing list and I'm using the web interface.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115120): https://edk2.groups.io/g/devel/message/115120
Mute This Topic: https://groups.io/mt/103964976/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 5746 bytes --]

  parent reply	other threads:[~2024-02-05 16:44 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 21:54 [edk2-devel] [PATCH v2 00/15] Security Patches for EDK II Network Stack Doug Flick via groups.io
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 01/15] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 Patch Doug Flick via groups.io
2024-02-01 19:35   ` Saloni Kasbekar
2024-02-05 13:41   ` bryan-bt.tan via groups.io [this message]
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 02/15] NetworkPkg: : Add Unit tests to CI and create Host Test DSC Doug Flick via groups.io
2024-02-01 19:36   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 03/15] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 Unit Tests Doug Flick via groups.io
2024-02-01 19:40   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 04/15] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 Patch Doug Flick via groups.io
2024-02-01 19:42   ` Saloni Kasbekar
2024-02-05 13:46   ` bryan-bt.tan via groups.io
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 05/15] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 Unit Tests Doug Flick via groups.io
2024-02-01 19:49   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 06/15] NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45231 Patch Doug Flick via groups.io
2024-02-01 19:52   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 07/15] NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45231 Unit Tests Doug Flick via groups.io
2024-02-01 19:59   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 08/15] NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45232 Patch Doug Flick via groups.io
2024-02-01 20:48   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 09/15] NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45232 Unit Tests Doug Flick via groups.io
2024-02-01 21:16   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 10/15] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45234 Patch Doug Flick via groups.io
2024-02-01 21:22   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 11/15] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45234 Unit Tests Doug Flick via groups.io
2024-02-01 21:32   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 12/15] MdePkg: Test: Add gRT_GetTime Google Test Mock Doug Flick via groups.io
2024-01-26 19:52   ` Michael D Kinney
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 13/15] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45235 Patch Doug Flick via groups.io
2024-02-01 21:37   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 14/15] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45235 Unit Tests Doug Flick via groups.io
2024-02-01 22:03   ` Saloni Kasbekar
2024-01-25 21:54 ` [edk2-devel] [PATCH v2 15/15] NetworkPkg: : Adds a SecurityFix.yaml file Doug Flick via groups.io
2024-02-01 22:18   ` Saloni Kasbekar
2024-01-31  5:22 ` [edk2-devel] 回复: [edk2-stable202402][PATCH v2 00/15] Security Patches for EDK II Network Stack gaoliming via groups.io
     [not found] ` <17AF5718015C1866.16460@groups.io>
2024-02-07 14:26   ` 回复: " gaoliming via groups.io

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18011.1707140460470094636@groups.io \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox