PCILeechFWGenerator icon indicating copy to clipboard operation
PCILeechFWGenerator copied to clipboard

Harden MSI-X sidecar handling and unify subsystem-ID rules (review follow-ups)

Open ramseymcgrath opened this issue 1 month ago • 0 comments

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.

  1. 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_snapshot deliberately ignores extra keys.
    • This is harmless today: table_entries/table_init_hex are only logged.
    • But if a writer for msix_table_init is 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.
  2. Check live MSI-X data against the config bytes.

    • src/build.py (MSIXManager.preload_data, ~line 293) and src/device_clone/msix.py (~line 70) use the sidecar's msix_info after load_snapshot.
    • load_snapshot checks identity and the config SHA, but not msix_info against the config bytes.
    • So an edited sidecar with intact config bytes can drive _inject_msix on live builds.
    • Validate it with the same _msix_from_config comparison the offline path uses.
  3. Use one subsystem-ID rule.

    • The offline/container device info (pcileech_generator.py, ~line 511) keeps a raw 0xFFFF subsystem ID.
    • The live path's _extract_subsystem_info replaces 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.

ramseymcgrath avatar Nov 01 '26 19:11 ramseymcgrath