bin/zbm-kcl: use proper offset when overwriting EFI KCL #512
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.
Now that we write UEFI bundles with intelligent offsets,
zbm-kcl
needs to honor that offset when overwriting the built-in KCL. We could split out all sections and recreate the logic to write them with proper offsets and alignment, but the simpler approach adopted here is to scan the existing UEFI bundle withobjdump
, compute the gap between.cmdline
and the next higher section, and use that as an upper bound on the permissible size of any new KCL written to the file.In practice, this limit should never be encountered; the alignment requirements seem to mean that the minimum gap is 0x1000 (4k) bytes, and I can't imagine somebody is writing 4000 characters to the command line. Anybody pushing this limit should probably just write a custom image anyway.
Regardless, the overarching goal here is to be extremely cautious, so anything that seems out of whack will just cause the overwrite to fail rather than corrupt the image.