Expand description
The exec trampoline: a static binary installed in the alias directory as
e, and the record files that tell it what to run.
Without ptrace every tracee has the alias directory as its kernel working
directory, so the two-byte path e names the trampoline from any
process, whatever length the original path string had. The supervisor
writes r<pid> next to it with the plan (see write_record), rewrites
the path string to e, lets the exec proceed, and the trampoline execs
the real target with the arguments rebuilt from the record and its own,
untouched, argv[1..]. A nested launch (see super::nested) takes
the trampoline in both modes, exec’d by its full path with ptrace, and
its record carries the process setup as well: a complete argument vector,
an environment, a directory to enter, session and death-signal flags,
seccomp programs, status descriptors, or a message to print and exit with.
In the guest-stub restricted mode every exec takes the trampoline, which
arms the guest stub and loads the program in place rather than exec’ing
it (see guest_stub); its record then also names the mailbox descriptor,
the AT_EXECFN path and the process name, see Trapped.
Outside the guest-stub mode a dynamically linked program of the host’s
machine is exec’d through a copy of the trampoline installed as l, the
loader, which maps the program where the kernel would and its interpreter
after it (see loader_path and ExecPlan).
The binaries under shim/bin/ are built by shim/build.sh from the
no_std crate in shim/ and embedded here; one per host architecture.
Structs§
- Record 🔒
- A record under construction.
- Trapped
- What a record carries in the guest-stub restricted mode.
Constants§
- SHIM 🔒
- SHIM32 🔒
- The 32-bit trampoline, which loads the compat ABI’s programs in the guest-stub mode: i386 on x86_64, 32-bit ARM on aarch64.
- SHIM_
NAME - Name of the trampoline inside the alias directory.
Statics§
- HAS_
32BIT 🔒 - Whether the i386 trampoline was installed and runs here.
- HAS_
LOADER 🔒 - Whether the loader was installed and runs here.
- INSTALLED 🔒
Functions§
- dir_
bytes - The alias directory as bytes, for building rewritten paths.
- has_
32bit - Whether the 32-bit trampoline is installed and runs here, which takes a kernel with ia32 emulation, or a CPU and kernel with AArch32.
- install
- Installs the trampoline and returns the directory holding it.
- install_
in 🔒 - Writes the trampoline into
dirand checks it runs there. - loader_
bytes 🔒 - The loader: a copy of the trampoline
shimwith the last byte of its role marker rewritten. - loader_
path - Path of the installed loader, when it runs here.
- path
- Path of the installed trampoline.
- record_
path - Path of the record file of process
tgid. - running
- Whether thread
tidis currently executing the trampoline. - write_
record - Writes the record the trampoline will read for process
tgid.