* [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). @ 2018-01-11 2:38 Wang Fan 2018-01-11 5:39 ` Wu, Hao A 2018-01-11 7:47 ` Wu, Jiaxin 0 siblings, 2 replies; 4+ messages in thread From: Wang Fan @ 2018-01-11 2:38 UTC (permalink / raw) To: edk2-devel; +Cc: Fu Siyuan, Jiaxin Wu, Hao Wu * The library API use array elements without any index range check, this patch is to fix this issue to avoid null pointer reference. Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan <fan.wang@intel.com> --- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index cbce28f..34e11a8 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -840,10 +840,14 @@ NetIp6IsNetEqual ( } if (Bit > 0) { Mask = (UINT8) (0xFF << (8 - Bit)); + ASSERT (Byte < 16); + if (Byte >= 16) { + return FALSE; + } if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) { return FALSE; } } -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). 2018-01-11 2:38 [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual() Wang Fan @ 2018-01-11 5:39 ` Wu, Hao A 2018-01-11 7:47 ` Wu, Jiaxin 1 sibling, 0 replies; 4+ messages in thread From: Wu, Hao A @ 2018-01-11 5:39 UTC (permalink / raw) To: Wang, Fan, edk2-devel@lists.01.org; +Cc: Fu, Siyuan, Wu, Jiaxin Reviewed-by: Hao Wu <hao.a.wu@intel.com> Best Regards, Hao Wu > -----Original Message----- > From: Wang, Fan > Sent: Thursday, January 11, 2018 10:39 AM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan; Wu, Jiaxin; Wu, Hao A > Subject: [Patch] MdeModulePkg/DxeNetLib: Add array range check in > NetIp6IsNetEqual(). > > * The library API use array elements without any index range check, this > patch is to fix this issue to avoid null pointer reference. > > Cc: Fu Siyuan <siyuan.fu@intel.com> > Cc: Jiaxin Wu <jiaxin.wu@intel.com> > Cc: Hao Wu <hao.a.wu@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wang Fan <fan.wang@intel.com> > --- > MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > index cbce28f..34e11a8 100644 > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > @@ -840,10 +840,14 @@ NetIp6IsNetEqual ( > } > > if (Bit > 0) { > Mask = (UINT8) (0xFF << (8 - Bit)); > > + ASSERT (Byte < 16); > + if (Byte >= 16) { > + return FALSE; > + } > if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) { > return FALSE; > } > } > > -- > 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). 2018-01-11 2:38 [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual() Wang Fan 2018-01-11 5:39 ` Wu, Hao A @ 2018-01-11 7:47 ` Wu, Jiaxin 2018-01-11 8:06 ` Wang, Fan 1 sibling, 1 reply; 4+ messages in thread From: Wu, Jiaxin @ 2018-01-11 7:47 UTC (permalink / raw) To: Wang, Fan, edk2-devel@lists.01.org; +Cc: Fu, Siyuan, Wu, Hao A Hi Fan, I think we need to update the below ASSERT if apply you patch: ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength <= IP6_PREFIX_MAX)); Update To: ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength < IP6_PREFIX_MAX)); If PrefixLength is IP6_PREFIX_MAX(128), then the Byte can be 16: Byte = (UINT8) (PrefixLength / 8); So, it will conflict with your patch ASSERT: ASSERT (Byte < 16); Thanks, Jiaxin > -----Original Message----- > From: Wang, Fan > Sent: Thursday, January 11, 2018 10:39 AM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Wu, > Hao A <hao.a.wu@intel.com> > Subject: [Patch] MdeModulePkg/DxeNetLib: Add array range check in > NetIp6IsNetEqual(). > > * The library API use array elements without any index range check, this > patch is to fix this issue to avoid null pointer reference. > > Cc: Fu Siyuan <siyuan.fu@intel.com> > Cc: Jiaxin Wu <jiaxin.wu@intel.com> > Cc: Hao Wu <hao.a.wu@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wang Fan <fan.wang@intel.com> > --- > MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > index cbce28f..34e11a8 100644 > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > @@ -840,10 +840,14 @@ NetIp6IsNetEqual ( > } > > if (Bit > 0) { > Mask = (UINT8) (0xFF << (8 - Bit)); > > + ASSERT (Byte < 16); > + if (Byte >= 16) { > + return FALSE; > + } > if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) { > return FALSE; > } > } > > -- > 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). 2018-01-11 7:47 ` Wu, Jiaxin @ 2018-01-11 8:06 ` Wang, Fan 0 siblings, 0 replies; 4+ messages in thread From: Wang, Fan @ 2018-01-11 8:06 UTC (permalink / raw) To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Fu, Siyuan, Wu, Hao A Thanks, Jiaxin, I will revise it. Best Regards Fan -----Original Message----- From: Wu, Jiaxin Sent: Thursday, January 11, 2018 3:48 PM To: Wang, Fan <fan.wang@intel.com>; edk2-devel@lists.01.org Cc: Fu, Siyuan <siyuan.fu@intel.com>; Wu, Hao A <hao.a.wu@intel.com> Subject: RE: [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual(). Hi Fan, I think we need to update the below ASSERT if apply you patch: ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength <= IP6_PREFIX_MAX)); Update To: ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength < IP6_PREFIX_MAX)); If PrefixLength is IP6_PREFIX_MAX(128), then the Byte can be 16: Byte = (UINT8) (PrefixLength / 8); So, it will conflict with your patch ASSERT: ASSERT (Byte < 16); Thanks, Jiaxin > -----Original Message----- > From: Wang, Fan > Sent: Thursday, January 11, 2018 10:39 AM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin > <jiaxin.wu@intel.com>; Wu, Hao A <hao.a.wu@intel.com> > Subject: [Patch] MdeModulePkg/DxeNetLib: Add array range check in > NetIp6IsNetEqual(). > > * The library API use array elements without any index range check, this > patch is to fix this issue to avoid null pointer reference. > > Cc: Fu Siyuan <siyuan.fu@intel.com> > Cc: Jiaxin Wu <jiaxin.wu@intel.com> > Cc: Hao Wu <hao.a.wu@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wang Fan <fan.wang@intel.com> > --- > MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > index cbce28f..34e11a8 100644 > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > @@ -840,10 +840,14 @@ NetIp6IsNetEqual ( > } > > if (Bit > 0) { > Mask = (UINT8) (0xFF << (8 - Bit)); > > + ASSERT (Byte < 16); > + if (Byte >= 16) { > + return FALSE; > + } > if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) { > return FALSE; > } > } > > -- > 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-11 8:01 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-01-11 2:38 [Patch] MdeModulePkg/DxeNetLib: Add array range check in NetIp6IsNetEqual() Wang Fan 2018-01-11 5:39 ` Wu, Hao A 2018-01-11 7:47 ` Wu, Jiaxin 2018-01-11 8:06 ` Wang, Fan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox