GenNCCfgData: add config XML hash check vs FW; gate MODCONFIG/DELVAR …#615
Open
kanechen66 wants to merge 1 commit into
Open
GenNCCfgData: add config XML hash check vs FW; gate MODCONFIG/DELVAR …#615kanechen66 wants to merge 1 commit into
kanechen66 wants to merge 1 commit into
Conversation
Contributor
|
Can you please verify that this works under linux? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
GenNCCfgData.pypreviously modified/deleted system UEFI configuration variables and generated config binaries without verifying that the config XML being used actually matches the schema the running firmware was built with. This can silently produce mismatched or invalid configuration cause unexpected behavior on the systmeThis change ports the config XML hash verification already used by
ConfigEditor.pyintoGenNCCfgData.py:Added a
compare_xml_hash_with_bios()method that computes the full XML hash viaCommonUtility.get_xml_full_hash()and compares it against the FW-claimed hash fromBoardMiscInfo.get_schema_xml_hash_from_bios()(theSCHEMA_XML_HASHUEFI variable). On mismatch it prints a warning with both hashes and returns non-zero.load_xml()now recordsself.config_xml_pathso the loaded XML can be re-hashed.Added an optional
--forceflag to all commands. When the hash mismatches:MODCONFIGandDELVARabort (return 1) and do not touch system variables, unless--forceis supplied.GENBIN/GENCSValso abort on mismatch unless--force.The hash check runs once up front in the argparse path so
MODCONFIGandDELVARshare a single check.Updated
usage()to document[--force].Impacts functionality?
Impacts security?
Breaking change?
Includes tests?
Includes documentation?
How This Was Tested
positive case
python .\GenNCCfgData.py GENBIN PlatformCfgData.xml test.vl
python GenNCCfgData.py MODCONFIG --xml_file PlatformCfgData.xml --var Frb2Enabled --val 1
python GenNCCfgData.py DELVAR --xml_file PlatformCfgData.xml
python GenNCCfgData.py GENCSV "PlatformCfgData.xml ;test.vl" out.csv
negative cases with different ver of xml
python .\GenNCCfgData.py GENBIN PlatformCfgData_bad.xml test.vl
python GenNCCfgData.py MODCONFIG --xml_file PlatformCfgData_bad.xml --var Frb2Enabled --val 1
python GenNCCfgData.py DELVAR --xml_file PlatformCfgData_bad.xml
python GenNCCfgData.py GENCSV "PlatformCfgData_bad.xml ;test.vl" out.csv
the above 4 cmds shows xml hash mismatch with running FW.
WARNING: Config xml file hash mismatches with system FW
FW ConfigXml Hash = 0c56b29ae8fee33fa6f9e8786bd6fa1d
PlatformCfgData_mod.xml Hash = ef516f6dd19b7624ac05100e7d2bf367
Aborting MODCONFIG: config XML hash mismatches with system FW. Use --force to override.
also, --force is working as expected to by pass the xml hash check
only warnning msg is shown
PS C:\test_mu\Tools> python GenNCCfgData.py GENCSV "PlatformCfgData_bad.xml ;data.vl" out.csv --force
WARNING: Config xml file hash mismatches with system FW
FW ConfigXml Hash = 0c56b29ae8fee33fa6f9e8786bd6fa1d
PlatformCfgData_mod.xml Hash = ef516f6dd19b7624ac05100e7d2bf367
Integration Instructions
None