public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Jiaxin Wu <jiaxin.wu@intel.com>, edk2-devel@ml01.01.org
Cc: Ye Ting <ting.ye@intel.com>, Fu Siyuan <siyuan.fu@intel.com>,
	Santhapur Naveen <naveens@amiindia.co.in>
Subject: Re: [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid subnet check
Date: Fri, 11 Nov 2016 13:42:39 +0100	[thread overview]
Message-ID: <c665c82a-efaa-2e32-7f3d-9fb1b39d4719@redhat.com> (raw)
In-Reply-To: <1478841521-232036-2-git-send-email-jiaxin.wu@intel.com>

On 11/11/16 06:18, Jiaxin Wu wrote:
> v2:
> * Separate out the return status fix.
> * Replace IP4_MASK_MAX with IP4_MASK_MAX.
> * Remove the ON_EXIT label.
> 
> This patch is used to add the wrong/invalid subnet check.
> 
> Cc: Santhapur Naveen <naveens@amiindia.co.in>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
> ---
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 10 +++++++---
>  MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c          |  8 +++++---
>  2 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> index a931bb3..5b01b35 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
> @@ -1253,10 +1253,17 @@ Ip4Config2SetMaunualAddress (
>      return EFI_WRITE_PROTECTED;
>    }
>  
>    NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data);
>  
> +  StationAddress = EFI_NTOHL (NewAddress.Address);
> +  SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
> +
> +  if (NetGetMaskLength (SubnetMask) == IP4_MASK_NUM) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
>    //
>    // Store the new data, and init the DataItem status to EFI_NOT_READY because
>    // we may have an asynchronous configuration process.
>    //
>    Ptr = AllocateCopyPool (DataSize, Data);
> @@ -1271,13 +1278,10 @@ Ip4Config2SetMaunualAddress (
>    
>    DataItem->Data.Ptr = Ptr;
>    DataItem->DataSize = DataSize;
>    DataItem->Status   = EFI_NOT_READY;
>  
> -  StationAddress = EFI_NTOHL (NewAddress.Address);
> -  SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
> -
>    IpSb->Reconfig = TRUE;
>    Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);
>    if (EFI_ERROR (Status)) {
>      goto ON_EXIT;
>    }  
> diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
> index 9cd5dd5..b0cc6a3 100644
> --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
> +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
> @@ -562,10 +562,15 @@ Ip4SetAddress (
>    EFI_STATUS                Status;
>    INTN                      Len;
>  
>    NET_CHECK_SIGNATURE (Interface, IP4_INTERFACE_SIGNATURE);
>  
> +  Len = NetGetMaskLength (SubnetMask);
> +  if (Len == IP4_MASK_NUM) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
>    //
>    // Set the ip/netmask, then compute the subnet broadcast
>    // and network broadcast for easy access. When computing
>    // nework broadcast, the subnet mask is most like longer
>    // than the default netmask (not subneted) as defined in
> @@ -573,13 +578,10 @@ Ip4SetAddress (
>    // networks, use the subnet's mask instead.
>    //
>    Interface->Ip             = IpAddr;
>    Interface->SubnetMask     = SubnetMask;
>    Interface->SubnetBrdcast  = (IpAddr | ~SubnetMask);
> -
> -  Len                       = NetGetMaskLength (SubnetMask);
> -  ASSERT (Len <= IP4_MASK_MAX);
>    Interface->NetBrdcast     = (IpAddr | ~SubnetMask);
>  
>    //
>    // Do clean up for Arp child
>    //
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>


  reply	other threads:[~2016-11-11 12:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-11  5:18 [PATCH v2 0/2] MdeModulePkg/Ip4Dxe: Issue fix for Ip4Dxe Jiaxin Wu
2016-11-11  5:18 ` [PATCH v2 1/2] MdeModulePkg/Ip4Dxe: Add wrong/invalid subnet check Jiaxin Wu
2016-11-11 12:42   ` Laszlo Ersek [this message]
2016-11-14  6:51   ` Ye, Ting
2016-11-14  7:00     ` Wu, Jiaxin
2016-11-14  7:16       ` Ye, Ting
2016-11-11  5:18 ` [PATCH v2 2/2] MdeModulePkg/Ip4Dxe: Correct the return status Jiaxin Wu
2016-11-11 12:45   ` Laszlo Ersek

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=c665c82a-efaa-2e32-7f3d-9fb1b39d4719@redhat.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