audk/MdeModulePkg
Laszlo Ersek e7bd0dd26d MdeModulePkg/LzmaCustomDecompressLib: catch 4GB+ uncompressed buffer sizes
The LzmaUefiDecompressGetInfo() function
[MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c] currently
silently truncates the UINT64 "DecodedSize" property of the compressed
blob to the UINT32 "DestinationSize" output parameter.

If "DecodedSize" is 0x1_0000_0100, for example, then the subsequent memory
allocation (for decompression) will likely succeed (allocating 0x100 bytes
only), but then the LzmaUefiDecompress() function (which re-fetches the
uncompressed buffer size from the same LZMA header into a "SizeT"
variable) will overwrite the buffer.

Catch (DecodedSize > MAX_UINT32) in LzmaUefiDecompressGetInfo() at once.
This should not be a practical limitation. (The issue cannot be fixed for
32-bit systems without spec modifications anyway, given that the
"OutputSize" output parameter of
EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL.ExtractSection() has type UINTN,
not UINT64.)

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1816
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20201119115034.12897-2-lersek@redhat.com>
2020-11-21 02:04:40 +00:00
..
Application MdeModulePkg/CapsuleApp: Fix spelling mistake 2020-08-07 18:53:01 +00:00
Bus MdeModulePkg/AtaAtapiPassThru: Trace ATA packets 2020-11-11 02:27:59 +00:00
Core MdeModulePkg/Core/Dxe: limit FwVol encapsulation section recursion 2020-11-21 01:40:53 +00:00
Include MdeModulePkg: Define the VarCheckPolicyLib and SMM interface 2020-11-17 01:03:43 +00:00
Library MdeModulePkg/LzmaCustomDecompressLib: catch 4GB+ uncompressed buffer sizes 2020-11-21 02:04:40 +00:00
Logo MdeModulePkg/Logo:Add RISCV64 architecture 2020-05-07 03:17:15 +00:00
Test MdeModulePkg: Add DxeResetSystemLib unit test 2020-02-07 19:18:53 +00:00
Universal MdeModulePkg: Drop VarLock from RuntimeDxe variable driver 2020-11-17 01:03:43 +00:00
MdeModulePkg.ci.yaml MdeModulePkg: Define the VariablePolicyLib 2020-11-17 01:03:43 +00:00
MdeModulePkg.dec MdeModulePkg/Core/Dxe: limit FwVol encapsulation section recursion 2020-11-21 01:40:53 +00:00
MdeModulePkg.dsc MdeModulePkg: Define the VarCheckPolicyLib and SMM interface 2020-11-17 01:03:43 +00:00
MdeModulePkg.uni MdeModulePkg/Core/Dxe: limit FwVol encapsulation section recursion 2020-11-21 01:40:53 +00:00
MdeModulePkgExtra.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00