Skip to content

Re-pack support for UKIs - #724

Draft
arnaldo2792 wants to merge 1 commit into
bottlerocket-os:developfrom
arnaldo2792:repack-uki
Draft

Re-pack support for UKIs#724
arnaldo2792 wants to merge 1 commit into
bottlerocket-os:developfrom
arnaldo2792:repack-uki

Conversation

@arnaldo2792

Copy link
Copy Markdown
Contributor

Description of changes:

This PR complements: #701 and closes the gap to support re-pack workflows with UKIs.

A new binary (ukisys) is provided, to extract the stub from the compiled UKI. This is needed to offer the same experience like in other re-pack workflows: all the artifacts used to build the final image come from the cracked-open rootfs and UKIs.

Testing done:

  • Ran the re-pack workflow against a local build, using a custom certificate and new signing keys
  • Publish the AMIs with the re-packed artifacts
  • AMI booted, and cryptographic material matched that of the new keys

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@arnaldo2792
arnaldo2792 requested a review from jmt-lab August 13, 2026 01:07
@arnaldo2792
arnaldo2792 force-pushed the repack-uki branch 2 times, most recently from 1d1a57e to cb51387 Compare August 13, 2026 08:56
@arnaldo2792

Copy link
Copy Markdown
Contributor Author

(forced push includes a change to generate the correct HMAC, based on top off: #701)

Add re-pack support for UKIs. ukify provides support to extract sections
from an existing UKI. However, the stub is modified and signed, and
can't be re-used verbatim. Add ukisys, which should be our eventual
replacement of ukify. For the time being, it only supports extracting
the stub and re-setting it to its original state (flip a byte).

Signed-off-by: Arnaldo Garcia Rincon <agarrcia@amazon.com>
@arnaldo2792

Copy link
Copy Markdown
Contributor Author

(forced push to include the change in #701, which was needed due to the dependency on the new fat file extension).

Comment thread tools/ukisys/src/pe.rs

/// Writes a little-endian u16 into `buf` at `offset` in place.
fn write_u16(buf: &mut [u8], offset: usize, value: u16) {
buf[offset..offset + 2].copy_from_slice(&value.to_le_bytes());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need bounds checks on the writes?

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.

3 participants