moby / moby/buildkit

Refactor qemu emulator loading to use seccomp hook

Open
#2,873 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/qemu help wanted kind/enhancement
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

When emulators are needed for building multi-platform images they usually need to be installed in kernel. That is not ideal as we force the user to reconfigure their whole machine.

If kernel does not have emulators installed we use the embedded emulators built in https://github.com/tonistiigi/binfmt#buildkit-target . These have special patches that allow them to be invoked directly instead of loaded by the kernel. We pick the correct emulator, mount it inside container, and change the entrypoint to go through the emulator. Patches inside the emulator ensure that when emulated process calls exec() it is not invoked directly but by the same emulator.

This mostly works but has a limitation that all binaries inside container need to be for the same architecture, while when using kernel it allows mixing binaries.

Instead of changing the entrypoint we could use a different method. We could launch the container with a seccomp hook that gets called on every execve(2) invocation. Then we would see what emulator is needed for a specific binary and change call to go through the emulator(that we have mounted inside the container) instead.

This assumes that there will be no performance regression from handling these seccomp hooks. To be determined how practical it is in reality.

@AkihiroSuda @tiborvass

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the current embedded-emulator loading and entrypoint handling, then investigate the seccomp hook approach and its performance implications; done should support mixed-architecture binaries without requiring kernel-installed emulators.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
operating-systems, security
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.