Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/zbm-kcl: use proper offset when overwriting EFI KCL #512

Closed
wants to merge 1 commit into from

Conversation

ahesford
Copy link
Member

@ahesford ahesford commented Oct 25, 2023

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 with objdump, 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.

Copy link
Member

@zdykstra zdykstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads fairly clear to me. Testing it locally works as expected - success for a small KCL change, failure for a 5,000 byte addition.

The only thing that might be worth adding, in either comments or a commit message is a bit of detail specifically about the (normal) effective size of a KCL change that will be accepted, given the two EFI stubs we've encountered so far.

The overwrite will use the gap between the .cmdline section and the next
higher section as the maximum size for new KCLs. In practice, alignment
requirements in the stub loader mean that the maximum KCL size is likely
to be 4 kB.
@ahesford
Copy link
Member Author

Merged, with a comment in the script and the commit message about the expected gap size, to master and v2.2.x. The new zbm-kcl script has also been added to the release assets and the signify sigs updated. (The signatures for the other assets have not changed.)

@ahesford ahesford closed this Oct 25, 2023
@ahesford ahesford deleted the hexen branch October 25, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants