mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-07 19:45:07 +02:00
MdeModulePkg/NonDiscoverable: fix memory override bug
For PciIoPciRead interface, memory prior to Buffer would be written with zeros if Offset was larger than sizeof (Dev->ConfigSpace), which would cause serious system exception. So we add a pre-check branch to avoid memory override. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Heyi Guo <heyi.guo@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
parent
400a59737f
commit
710d9e69fa
@ -465,6 +465,11 @@ PciIoPciRead (
|
||||
Address = (UINT8 *)&Dev->ConfigSpace + Offset;
|
||||
Length = Count << ((UINTN)Width & 0x3);
|
||||
|
||||
if (Offset >= sizeof (Dev->ConfigSpace)) {
|
||||
ZeroMem (Buffer, Length);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (Offset + Length > sizeof (Dev->ConfigSpace)) {
|
||||
//
|
||||
// Read all zeroes for config space accesses beyond the first
|
||||
|
Loading…
x
Reference in New Issue
Block a user