* [PATCH EDK2 v1 0/1] EmulatorPkg/host: fix overflow in Mult
@ 2020-09-01 10:58 wenyi,xie
2020-09-01 10:58 ` [PATCH EDK2 v1 1/1] " wenyi,xie
0 siblings, 1 reply; 6+ messages in thread
From: wenyi,xie @ 2020-09-01 10:58 UTC (permalink / raw)
To: devel, jordan.l.justen, afish, ray.ni; +Cc: songdongkuang, xiewenyi2
Main Changes :
convert int to uint64 to avoid overflow when Multiply two int.
Wenyi Xie (1):
EmulatorPkg/host: fix overflow in Mult
EmulatorPkg/Win/Host/WinHost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.20.1.windows.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow in Mult
2020-09-01 10:58 [PATCH EDK2 v1 0/1] EmulatorPkg/host: fix overflow in Mult wenyi,xie
@ 2020-09-01 10:58 ` wenyi,xie
2020-09-02 6:54 ` [edk2-devel] " Laszlo Ersek
2020-09-22 3:42 ` wenyi,xie
0 siblings, 2 replies; 6+ messages in thread
From: wenyi,xie @ 2020-09-01 10:58 UTC (permalink / raw)
To: devel, jordan.l.justen, afish, ray.ni; +Cc: songdongkuang, xiewenyi2
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2947
When calculating memory regions and store the information in the
gSystemMemory in file WinHost.c, the code below will cause overflow,
because _wtoi (MemorySizeStr) return an int value and SIZE_1MB is
also an int value, if MemorySizeStr is lager for example 2048, then
result of multiplication will overflow.
for (Index = 0, Done = FALSE; !Done; Index++) {
//
// Save the size of the memory and make a Unicode filename SystemMemory00
//
gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
---
EmulatorPkg/Win/Host/WinHost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 0838c56ddea8..876cb8d4be8b 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -577,7 +577,7 @@ Returns:
//
// Save the size of the memory and make a Unicode filename SystemMemory00, ...
//
- gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
+ gSystemMemory[Index].Size = ((UINT64)_wtoi (MemorySizeStr)) * ((UINT64)SIZE_1MB);
//
// Find the next region
--
2.20.1.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow in Mult
2020-09-01 10:58 ` [PATCH EDK2 v1 1/1] " wenyi,xie
@ 2020-09-02 6:54 ` Laszlo Ersek
2020-09-22 3:42 ` wenyi,xie
1 sibling, 0 replies; 6+ messages in thread
From: Laszlo Ersek @ 2020-09-02 6:54 UTC (permalink / raw)
To: ray.ni; +Cc: devel, xiewenyi2, jordan.l.justen, afish, songdongkuang
Ray,
On 09/01/20 12:58, wenyi,xie via groups.io wrote:
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2947
>
> When calculating memory regions and store the information in the
> gSystemMemory in file WinHost.c, the code below will cause overflow,
> because _wtoi (MemorySizeStr) return an int value and SIZE_1MB is
> also an int value, if MemorySizeStr is lager for example 2048, then
> result of multiplication will overflow.
>
> for (Index = 0, Done = FALSE; !Done; Index++) {
> //
> // Save the size of the memory and make a Unicode filename SystemMemory00
> //
> gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
> ---
> EmulatorPkg/Win/Host/WinHost.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
> index 0838c56ddea8..876cb8d4be8b 100644
> --- a/EmulatorPkg/Win/Host/WinHost.c
> +++ b/EmulatorPkg/Win/Host/WinHost.c
> @@ -577,7 +577,7 @@ Returns:
> //
> // Save the size of the memory and make a Unicode filename SystemMemory00, ...
> //
> - gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
> + gSystemMemory[Index].Size = ((UINT64)_wtoi (MemorySizeStr)) * ((UINT64)SIZE_1MB);
>
> //
> // Find the next region
>
if you'd like this fix to be in edk2-stable202008, then please approve
the patch as soon as you can.
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow in Mult
2020-09-01 10:58 ` [PATCH EDK2 v1 1/1] " wenyi,xie
2020-09-02 6:54 ` [edk2-devel] " Laszlo Ersek
@ 2020-09-22 3:42 ` wenyi,xie
2020-09-23 2:48 ` [edk2-devel] " Ni, Ray
1 sibling, 1 reply; 6+ messages in thread
From: wenyi,xie @ 2020-09-22 3:42 UTC (permalink / raw)
To: devel, jordan.l.justen, afish, ray.ni; +Cc: songdongkuang
Hi all,
Please review this patch when you're free, thanks.
Regards
Wenyi
On 2020/9/1 18:58, Wenyi Xie wrote:
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2947
>
> When calculating memory regions and store the information in the
> gSystemMemory in file WinHost.c, the code below will cause overflow,
> because _wtoi (MemorySizeStr) return an int value and SIZE_1MB is
> also an int value, if MemorySizeStr is lager for example 2048, then
> result of multiplication will overflow.
>
> for (Index = 0, Done = FALSE; !Done; Index++) {
> //
> // Save the size of the memory and make a Unicode filename SystemMemory00
> //
> gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
> ---
> EmulatorPkg/Win/Host/WinHost.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
> index 0838c56ddea8..876cb8d4be8b 100644
> --- a/EmulatorPkg/Win/Host/WinHost.c
> +++ b/EmulatorPkg/Win/Host/WinHost.c
> @@ -577,7 +577,7 @@ Returns:
> //
> // Save the size of the memory and make a Unicode filename SystemMemory00, ...
> //
> - gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
> + gSystemMemory[Index].Size = ((UINT64)_wtoi (MemorySizeStr)) * ((UINT64)SIZE_1MB);
>
> //
> // Find the next region
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow in Mult
2020-09-22 3:42 ` wenyi,xie
@ 2020-09-23 2:48 ` Ni, Ray
2020-09-23 2:58 ` wenyi,xie
0 siblings, 1 reply; 6+ messages in thread
From: Ni, Ray @ 2020-09-23 2:48 UTC (permalink / raw)
To: devel@edk2.groups.io, xiewenyi2@huawei.com, Justen, Jordan L,
afish@apple.com
Cc: songdongkuang@huawei.com
Reviewed-by: Ray Ni <ray.ni@intel.com>
Pull request was created: https://github.com/tianocore/edk2/pull/951
If you see any failures, please send updated patch to fix.
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of wenyi,xie
> via groups.io
> Sent: Tuesday, September 22, 2020 11:43 AM
> To: devel@edk2.groups.io; Justen, Jordan L <jordan.l.justen@intel.com>;
> afish@apple.com; Ni, Ray <ray.ni@intel.com>
> Cc: songdongkuang@huawei.com
> Subject: Re: [edk2-devel] [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow
> in Mult
>
> Hi all,
>
> Please review this patch when you're free, thanks.
>
> Regards
> Wenyi
>
> On 2020/9/1 18:58, Wenyi Xie wrote:
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2947
> >
> > When calculating memory regions and store the information in the
> > gSystemMemory in file WinHost.c, the code below will cause overflow,
> > because _wtoi (MemorySizeStr) return an int value and SIZE_1MB is
> > also an int value, if MemorySizeStr is lager for example 2048, then
> > result of multiplication will overflow.
> >
> > for (Index = 0, Done = FALSE; !Done; Index++) {
> > //
> > // Save the size of the memory and make a Unicode filename
> SystemMemory00
> > //
> > gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
> >
> > Cc: Jordan Justen <jordan.l.justen@intel.com>
> > Cc: Andrew Fish <afish@apple.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
> > ---
> > EmulatorPkg/Win/Host/WinHost.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/EmulatorPkg/Win/Host/WinHost.c
> b/EmulatorPkg/Win/Host/WinHost.c
> > index 0838c56ddea8..876cb8d4be8b 100644
> > --- a/EmulatorPkg/Win/Host/WinHost.c
> > +++ b/EmulatorPkg/Win/Host/WinHost.c
> > @@ -577,7 +577,7 @@ Returns:
> > //
> > // Save the size of the memory and make a Unicode filename
> SystemMemory00, ...
> > //
> > - gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
> > + gSystemMemory[Index].Size = ((UINT64)_wtoi (MemorySizeStr)) *
> ((UINT64)SIZE_1MB);
> >
> > //
> > // Find the next region
> >
>
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow in Mult
2020-09-23 2:48 ` [edk2-devel] " Ni, Ray
@ 2020-09-23 2:58 ` wenyi,xie
0 siblings, 0 replies; 6+ messages in thread
From: wenyi,xie @ 2020-09-23 2:58 UTC (permalink / raw)
To: Ni, Ray, devel@edk2.groups.io, Justen, Jordan L, afish@apple.com
Cc: songdongkuang@huawei.com
OK, Thanks.
Regards
Wenyi
On 2020/9/23 10:48, Ni, Ray wrote:
> Reviewed-by: Ray Ni <ray.ni@intel.com>
>
> Pull request was created: https://github.com/tianocore/edk2/pull/951
>
> If you see any failures, please send updated patch to fix.
>
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of wenyi,xie
>> via groups.io
>> Sent: Tuesday, September 22, 2020 11:43 AM
>> To: devel@edk2.groups.io; Justen, Jordan L <jordan.l.justen@intel.com>;
>> afish@apple.com; Ni, Ray <ray.ni@intel.com>
>> Cc: songdongkuang@huawei.com
>> Subject: Re: [edk2-devel] [PATCH EDK2 v1 1/1] EmulatorPkg/host: fix overflow
>> in Mult
>>
>> Hi all,
>>
>> Please review this patch when you're free, thanks.
>>
>> Regards
>> Wenyi
>>
>> On 2020/9/1 18:58, Wenyi Xie wrote:
>>> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2947
>>>
>>> When calculating memory regions and store the information in the
>>> gSystemMemory in file WinHost.c, the code below will cause overflow,
>>> because _wtoi (MemorySizeStr) return an int value and SIZE_1MB is
>>> also an int value, if MemorySizeStr is lager for example 2048, then
>>> result of multiplication will overflow.
>>>
>>> for (Index = 0, Done = FALSE; !Done; Index++) {
>>> //
>>> // Save the size of the memory and make a Unicode filename
>> SystemMemory00
>>> //
>>> gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
>>>
>>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>>> Cc: Andrew Fish <afish@apple.com>
>>> Cc: Ray Ni <ray.ni@intel.com>
>>> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
>>> ---
>>> EmulatorPkg/Win/Host/WinHost.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/EmulatorPkg/Win/Host/WinHost.c
>> b/EmulatorPkg/Win/Host/WinHost.c
>>> index 0838c56ddea8..876cb8d4be8b 100644
>>> --- a/EmulatorPkg/Win/Host/WinHost.c
>>> +++ b/EmulatorPkg/Win/Host/WinHost.c
>>> @@ -577,7 +577,7 @@ Returns:
>>> //
>>> // Save the size of the memory and make a Unicode filename
>> SystemMemory00, ...
>>> //
>>> - gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * SIZE_1MB;
>>> + gSystemMemory[Index].Size = ((UINT64)_wtoi (MemorySizeStr)) *
>> ((UINT64)SIZE_1MB);
>>>
>>> //
>>> // Find the next region
>>>
>>
>>
>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-09-23 2:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-01 10:58 [PATCH EDK2 v1 0/1] EmulatorPkg/host: fix overflow in Mult wenyi,xie
2020-09-01 10:58 ` [PATCH EDK2 v1 1/1] " wenyi,xie
2020-09-02 6:54 ` [edk2-devel] " Laszlo Ersek
2020-09-22 3:42 ` wenyi,xie
2020-09-23 2:48 ` [edk2-devel] " Ni, Ray
2020-09-23 2:58 ` wenyi,xie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox