* [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity issue
@ 2023-01-04 4:34 Ranbir Singh
2023-01-04 4:38 ` [edk2-devel] " Michael D Kinney
2023-01-04 4:39 ` Ranbir Singh
0 siblings, 2 replies; 3+ messages in thread
From: Ranbir Singh @ 2023-01-04 4:34 UTC (permalink / raw)
To: devel
[-- Attachment #1.1: Type: text/plain, Size: 162 bytes --]
Attached patch fixes the *OVERRUN* Coverity issue in the file *IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c*
Please consider it for review and merge.
[-- Attachment #1.2: Type: text/html, Size: 200 bytes --]
[-- Attachment #2: 0001-IntelFsp2Pkg-Library-BaseFspCommonLib-Fix-OVERRUN-Co.patch --]
[-- Type: text/plain, Size: 2222 bytes --]
From e0df5b0a34f1b96aa9610c5eef9161cbbca717d2 Mon Sep 17 00:00:00 2001
From: Ranbir Singh <Ranbir.Singh3@Dell.com>
Date: Thu, 22 Dec 2022 10:57:21 +0530
Subject: [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity
issue
FspData->PerfIdx is getting increased for every call unconditionally
in the function SetFspMeasurePoint and hence memory access can happen
for out of bound FspData->PerfData[] array entries also.
Example -
FspData->PerfData is an array of 32 UINT64 entries. Assume a call
is made to SetFspMeasurePoint function when the FspData->PerfIdx
last value is 31. It gets incremented to 32 at line 400.
Any subsequent call to SetFspMeasurePoint functions leads to
FspData->PerfData[32] getting accessed which is out of the PerfData
array as well as the FSP_GLOBAL_DATA structure boundary.
Hence keep array access and index increment inside if block only and
return invalid performance timestamp when PerfIdx is invalid.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4200
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
index a22b0e7825..cda2a7b247 100644
--- a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
@@ -377,7 +377,8 @@ GetFspSiliconInitUpdDataPointer (
@param[in] Id Measurement point ID.
- @return performance timestamp.
+ @return performance timestamp if current PerfIdx is valid,
+ else return 0 as invalid performance timestamp
**/
UINT64
EFIAPI
@@ -395,9 +396,10 @@ SetFspMeasurePoint (
if (FspData->PerfIdx < sizeof (FspData->PerfData) / sizeof (FspData->PerfData[0])) {
FspData->PerfData[FspData->PerfIdx] = AsmReadTsc ();
((UINT8 *)(&FspData->PerfData[FspData->PerfIdx]))[7] = Id;
+ return FspData->PerfData[(FspData->PerfIdx)++];
}
- return FspData->PerfData[(FspData->PerfIdx)++];
+ return (UINT64)0x0000000000000000;
}
/**
--
2.36.1.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity issue
2023-01-04 4:34 [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity issue Ranbir Singh
@ 2023-01-04 4:38 ` Michael D Kinney
2023-01-04 4:39 ` Ranbir Singh
1 sibling, 0 replies; 3+ messages in thread
From: Michael D Kinney @ 2023-01-04 4:38 UTC (permalink / raw)
To: devel@edk2.groups.io, Ranbir.Singh3@Dell.com; +Cc: Kinney, Michael D
[-- Attachment #1: Type: text/plain, Size: 594 bytes --]
We expect patches be part of the email. No attachments.
Please see:
https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Development-Process
Thanks,
Mike
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ranbir Singh via groups.io
Sent: Tuesday, January 3, 2023 8:35 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity issue
Attached patch fixes the OVERRUN Coverity issue in the file IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
Please consider it for review and merge.
[-- Attachment #2: Type: text/html, Size: 40564 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity issue
2023-01-04 4:34 [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity issue Ranbir Singh
2023-01-04 4:38 ` [edk2-devel] " Michael D Kinney
@ 2023-01-04 4:39 ` Ranbir Singh
1 sibling, 0 replies; 3+ messages in thread
From: Ranbir Singh @ 2023-01-04 4:39 UTC (permalink / raw)
To: Ranbir Singh, devel
[-- Attachment #1: Type: text/plain, Size: 2291 bytes --]
Copying patch contents directly in the message below ...
>From e0df5b0a34f1b96aa9610c5eef9161cbbca717d2 Mon Sep 17 00:00:00 2001
From: Ranbir Singh <Ranbir.Singh3@Dell.com>
Date: Thu, 22 Dec 2022 10:57:21 +0530
Subject: [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity
issue
FspData->PerfIdx is getting increased for every call unconditionally
in the function SetFspMeasurePoint and hence memory access can happen
for out of bound FspData->PerfData[] array entries also.
Example -
FspData->PerfData is an array of 32 UINT64 entries. Assume a call
is made to SetFspMeasurePoint function when the FspData->PerfIdx
last value is 31. It gets incremented to 32 at line 400.
Any subsequent call to SetFspMeasurePoint functions leads to
FspData->PerfData[32] getting accessed which is out of the PerfData
array as well as the FSP_GLOBAL_DATA structure boundary.
Hence keep array access and index increment inside if block only and
return invalid performance timestamp when PerfIdx is invalid.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4200
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
index a22b0e7825..cda2a7b247 100644
--- a/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/FspCommonLib.c
@@ -377,7 +377,8 @@ GetFspSiliconInitUpdDataPointer (
@param[in] Id Measurement point ID.
- @return performance timestamp.
+ @return performance timestamp if current PerfIdx is valid,
+ else return 0 as invalid performance timestamp
**/
UINT64
EFIAPI
@@ -395,9 +396,10 @@ SetFspMeasurePoint (
if (FspData->PerfIdx < sizeof (FspData->PerfData) / sizeof (FspData->PerfData[0])) {
FspData->PerfData[FspData->PerfIdx] = AsmReadTsc ();
((UINT8 *)(&FspData->PerfData[FspData->PerfIdx]))[7] = Id;
+ return FspData->PerfData[(FspData->PerfIdx)++];
}
- return FspData->PerfData[(FspData->PerfIdx)++];
+ return (UINT64)0x0000000000000000;
}
/**
--
2.36.1.windows.1
[-- Attachment #2: Type: text/html, Size: 3376 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-04 4:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 4:34 [PATCH] IntelFsp2Pkg/Library/BaseFspCommonLib: Fix OVERRUN Coverity issue Ranbir Singh
2023-01-04 4:38 ` [edk2-devel] " Michael D Kinney
2023-01-04 4:39 ` Ranbir Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox