Reporting Issues
Bug 3310 - VarCheckPolicyLibMmiHandler() passes uninitialized TempSize to DumpVariablePolicy()
Summary: VarCheckPolicyLibMmiHandler() passes uninitialized TempSize to DumpVariablePo...
Status: RESOLVED FIXED
Alias: None
Product: EDK2
Classification: Unclassified
Component: Code (show other bugs)
Version: Current
Hardware: All All
: Lowest normal
Assignee: Bret Barkelew
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-08 17:01 UTC by Allen_Wynn@Dell.com
Modified: 2021-04-12 21:40 UTC (History)
3 users (show)

See Also:
EDK II Code First industry standard specifications: ---
Branch URL:
Release(s) the issue is observed: EDK II Master
The OS the target platform is running: ---
Package: MdeModulePkg
Release(s) the issues must be fixed: EDK II Master
Tianocore documents:


Attachments
Mailing List Patch (1.37 KB, application/octet-stream)
2021-04-09 14:23 UTC, Bret Barkelew
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Allen_Wynn@Dell.com 2021-04-08 17:01:04 UTC
In file MdeModulePkg\Library\VariablePolicyLib\VariablePolicyLib.c procedure DumpVariablePolicy() function header says  the "call can be made with a 0 size and it will return the size of the buffer required to hold the table."

In file MdeModulePkg\Library\VarCheckPolicyLib\VarCheckPolicyLib.c procedure VarCheckPolicyLibMmiHandler() around line 219 calls DumpVariablePolicy(NULL, &TempSize).  It is attempting to get the required size of the policy buffer, and is passing in NULL as the Policy pointer.
However, TempSize is uninitialized.

In file MdeModulePkg\Library\VariablePolicyLib\VariablePolicyLib.c procedure DumpVariablePolicy() and receives &Tempsize as *Size.  The code checks the parameters, and checks to see if the size passed in is greater than zero.
  // Check the parameters.
  if (Size == NULL || (*Size > 0 && Policy == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
Since TempSize has never been set, the variable could contain anything.

I believe VarCheckPolicyLibMmiHandler() needs to set TempSize to zero before calling DumpVariablePolicy(NULL, &TempSize).
Comment 1 Bret Barkelew 2021-04-09 13:35:38 UTC
Good catch, Allen! I expect nothing less.
Comment 2 Bret Barkelew 2021-04-09 14:23:26 UTC
Created attachment 690 [details]
Mailing List Patch
Comment 3 Bret Barkelew 2021-04-12 21:40:11 UTC
Will be fixed in PR:
https://github.com/tianocore/edk2/pull/1557