Skip to content

Allow custom kernel boot args via --kernel-arg#1744

Open
arirubinstein wants to merge 1 commit into
apple:mainfrom
arirubinstein:kernel-arg-boot-args
Open

Allow custom kernel boot args via --kernel-arg#1744
arirubinstein wants to merge 1 commit into
apple:mainfrom
arirubinstein:kernel-arg-boot-args

Conversation

@arirubinstein

@arirubinstein arirubinstein commented Jun 17, 2026

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

What

Adds a repeatable --kernel-arg flag to container run/container create for appending arbitrary boot arguments to the kernel command line.

container run --kernel /path/to/custom-bzImage \
  --kernel-arg lsm=lockdown,capability,landlock,yama,apparmor,bpf \
  ...

Why

The runtime hardcodes lsm=lockdown,capability,landlock,yama,apparmor (and oops=panic) onto every kernel command line in RuntimeService.bootstrap. With a custom kernel there is no way to adjust this — e.g. to enable BPF LSM you need lsm=...,bpf, which is currently impossible. More generally there is no escape hatch for any boot-time kernel argument.

How

  • New --kernel-arg <arg> option (repeatable) on Flags.Management.
  • Utility.getKernel appends the user args onto kernel.commandLine.kernelArgs, which is persisted into the container bundle.
  • RuntimeService.bootstrap now applies its built-in defaults per-key, skipping any default whose key the user already supplied. Defaults are expressed as a small keyed table, so this also lets oops= be overridden and makes future defaults easy to add.

Default behavior is unchanged for anyone who does not pass --kernel-arg — the same oops=panic and lsm=... args are applied.

Testing

  • swift build clean.
  • container run --help renders the new flag.

Add a repeatable --kernel-arg flag to plumb arbitrary boot arguments
onto the kernel command line. User-supplied args are persisted on the
kernel in the bundle, and the runtime's built-in defaults (oops=panic,
lsm=...) are now applied per-key only when the user has not already
supplied that key. This lets custom kernels override the LSM stack,
e.g. to enable BPF LSM with:

  --kernel-arg lsm=lockdown,capability,landlock,yama,apparmor,bpf
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.

1 participant