public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Doug Flick via groups.io" <dougflick=microsoft.com@groups.io>
To: Leif Lindholm <quic_llindhol@quicinc.com>,
	"Douglas Flick [MSFT]" <doug.edk2@gmail.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	Saloni Kasbekar <saloni.kasbekar@intel.com>,
	Zachary Clark-williams <zachary.clark-williams@intel.com>,
	Andrew Fish <afish@apple.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH 2/3] [edk2-stable202402] NetworkPkg: Dhcp6Dxe: Additional Code Cleanup
Date: Mon, 12 Feb 2024 19:31:32 +0000	[thread overview]
Message-ID: <CY5PR21MB3684CAA3EA4AC2D30BEA664FB3482@CY5PR21MB3684.namprd21.prod.outlook.com> (raw)
In-Reply-To: <ZcpunAahi+sw/APZ@qc-i7.hemma.eciton.net>

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

> If this was one of the packages I maintain, I would ask
> you to break any "Additionally" out as a separate commit.

Thats fair enough. I can go ahead and do that.

> I see this exact pattern repeated identically 4 times in
> this file. After this deletion. If we're cleaning this up,
> someone should look into making a macro or static
> helper function.

That's a good suggestion

> That's not just cleanup though, this is a bugfix in its own > right? As in, even if the code is currently laid out in a way > that doesn't trigger an issue,
> Dhcp6AppendIaAddrOption () depends on this option
> being up to date when called. Or am I overreacting?

Ultimately, I think you're right. This issue was originally pointed on the original mail thread but it was merged in before it could be corrected. Should I create a bugzilla for this and then attach that to the change?

Douglas Flick
________________________________
From: Leif Lindholm <quic_llindhol@quicinc.com>
Sent: Monday, February 12, 2024 11:16:44 AM
To: Douglas Flick [MSFT] <doug.edk2@gmail.com>
Cc: devel@edk2.groups.io <devel@edk2.groups.io>; Doug Flick <dougflick@microsoft.com>; Saloni Kasbekar <saloni.kasbekar@intel.com>; Zachary Clark-williams <zachary.clark-williams@intel.com>; Andrew Fish <afish@apple.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [EXTERNAL] Re: [PATCH 2/3] [edk2-stable202402] NetworkPkg: Dhcp6Dxe: Additional Code Cleanup

[You don't often get email from quic_llindhol@quicinc.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

On Fri, Feb 09, 2024 at 19:04:57 -0800, Douglas Flick [MSFT] wrote:
> From: Doug Flick <dougflick@microsoft.com>
>
> Removes duplicate check after merge
>
> >
> >  //
> >  // Verify the PacketCursor is within the packet
> >  //
> >  if (  (*PacketCursor < Packet->Dhcp6.Option)
> >     || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size -
> sizeof (EFI_DHCP6_HEADER))))
> >  {
> >    return EFI_INVALID_PARAMETER;
> >  }
> >
>
> Additionally Calculates the Packet->Length before appending

If this was one of the packages I maintain, I would ask you to break
any "Additionally" out as a separate commit.

> Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
> Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>
> Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com>
> ---
>  NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
> index 705c665c519d..348602c4e1a8 100644
> --- a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
> +++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
> @@ -657,15 +657,6 @@ Dhcp6AppendOption (
>      return EFI_BUFFER_TOO_SMALL;
>    }
>
> -  //
> -  // Verify the PacketCursor is within the packet
> -  //
> -  if (  (*PacketCursor < Packet->Dhcp6.Option)
> -     || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER))))
> -  {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -

I see this exact pattern repeated identically 4 times in this
file. After this deletion.
If we're cleaning this up, someone should look into making a macro or
static helper function.

>    WriteUnaligned16 ((UINT16 *)*PacketCursor, OptType);
>    *PacketCursor += DHCP6_SIZE_OF_OPT_CODE;
>    WriteUnaligned16 ((UINT16 *)*PacketCursor, OptLen);
> @@ -929,6 +920,11 @@ Dhcp6AppendIaOption (
>      *PacketCursor += sizeof (T2);
>    }
>
> +  //
> +  // Update the packet length
> +  //
> +  Packet->Length += BytesNeeded;
> +

That's not just cleanup though, this is a bugfix in its own right?
As in, even if the code is currently laid out in a way that doesn't
trigger an issue, Dhcp6AppendIaAddrOption () depends on this option
being up to date when called.
Or am I overreacting?

/
    Leif

>    //
>    // Fill all the addresses belong to the Ia
>    //
> @@ -945,11 +941,6 @@ Dhcp6AppendIaOption (
>    //
>    *Len = HTONS ((UINT16)(*PacketCursor - (UINT8 *)Len - 2));
>
> -  //
> -  // Update the packet length
> -  //
> -  Packet->Length += BytesNeeded;
> -
>    return EFI_SUCCESS;
>  }
>
> @@ -957,6 +948,7 @@ Dhcp6AppendIaOption (
>    Append the appointed Elapsed time option to Buf, and move Buf to the end.
>
>    @param[in, out] Packet        A pointer to the packet, on success Packet->Length
> +                                will be updated.
>    @param[in, out] PacketCursor  The pointer in the packet, on success PacketCursor
>                                  will be moved to the end of the option.
>    @param[in]      Instance      The pointer to the Dhcp6 instance.
> --
> 2.43.0
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115372): https://edk2.groups.io/g/devel/message/115372
Mute This Topic: https://groups.io/mt/104272127/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: 12137 bytes --]

  reply	other threads:[~2024-02-12 19:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-10  3:04 [edk2-devel] [PATCH 0/3] [edk2-stable202402] Corrects additional concern in NetworkPkg Doug Flick via groups.io
2024-02-10  3:04 ` [edk2-devel] [PATCH 1/3] [edk2-stable202402] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 Related Patch Doug Flick via groups.io
2024-02-12 17:14   ` Saloni Kasbekar
2024-02-12 18:56   ` Leif Lindholm
2024-02-10  3:04 ` [edk2-devel] [PATCH 2/3] [edk2-stable202402] NetworkPkg: Dhcp6Dxe: Additional Code Cleanup Doug Flick via groups.io
2024-02-12 17:14   ` Saloni Kasbekar
2024-02-12 19:16   ` Leif Lindholm
2024-02-12 19:31     ` Doug Flick via groups.io [this message]
2024-02-10  3:04 ` [edk2-devel] [PATCH 3/3] [edk2-stable202402] NetworkPkg: : Updating SecurityFixes.yaml Doug Flick via groups.io
2024-02-12 17:14   ` Saloni Kasbekar
2024-02-12 17:14 ` [edk2-devel] [PATCH 0/3] [edk2-stable202402] Corrects additional concern in NetworkPkg Doug Flick via groups.io
2024-02-12 17:17 ` Saloni Kasbekar

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=CY5PR21MB3684CAA3EA4AC2D30BEA664FB3482@CY5PR21MB3684.namprd21.prod.outlook.com \
    --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