PCILeechFWGenerator
PCILeechFWGenerator copied to clipboard
Harden MSI-X sidecar handling and unify subsystem-ID rules (review follow-ups)
These are low-severity follow-ups from the hardware-safety review of the offline-capture branch (PRs #675–#677). None of them blocks that merge.
-
Whitelist offline MSI-X fields.
src/device_clone/pcileech_generator.py(~line 1580) builds offline MSI-X info as{**info, ...}, so every sidecar key is passed through.validate_offline_snapshotdeliberately ignores extra keys.- This is harmless today:
table_entries/table_init_hexare only logged. - But if a writer for
msix_table_initis ever added, a hand-edited sidecar could inject MSI-X message addresses from the collecting host into the bitstream. - Pass through only the seven layout fields:
table_size,table_bir,table_offset,pba_bir,pba_offset,enabled,function_mask.
-
Check live MSI-X data against the config bytes.
src/build.py(MSIXManager.preload_data, ~line 293) andsrc/device_clone/msix.py(~line 70) use the sidecar'smsix_infoafterload_snapshot.load_snapshotchecks identity and the config SHA, but notmsix_infoagainst the config bytes.- So an edited sidecar with intact config bytes can drive
_inject_msixon live builds. - Validate it with the same
_msix_from_configcomparison the offline path uses.
-
Use one subsystem-ID rule.
- The offline/container device info (
pcileech_generator.py, ~line 511) keeps a raw0xFFFFsubsystem ID. - The live path's
_extract_subsystem_inforeplaces it with VID/DID. - So the same donor can end up with different subsystem IDs in the COE/IP depending on mode. Pick one rule; the raw value is arguably more faithful to the donor.
- The offline/container device info (