Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
run: go tool task patched-build-deps

# Before the tracer starts: what is built here is not extracted, and the analysis reads only
# what the step under it compiles (the kernel's bzImage, built here when a touched file is one
# what the step under it compiles (the kernel's vmlinux, built here when a touched file is one
# only it builds, would be the whole kernel).
- name: Build what compiling the touched files needs, untraced
if: ${{ matrix.build-mode == 'manual' }}
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/parts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,9 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Ends in verifying it (spin-machine-dev verify kernel), which reads the bzImage's setup header (a relocatable
# bzImage, or KASLR is off) and checks vmlinux's Xen PVH notes survived the strip.
# Without either, the failure is a VM that does not start or a kernel at a fixed
# address, in whichever lane boots one next.
# Ends in verifying it (spin-machine-dev verify kernel), which checks vmlinux's Xen PVH notes
# survived the strip and its relocation table is filled. Without either, the failure is a
# VM that does not start or a kernel at a fixed address, in whichever lane boots one next.
#
# And what it produced, by sha256, on the run's summary: a pull request that changes the
# config, or bumps the Debian toolchain the kernel is compiled with, changes every guest's
Expand All @@ -234,7 +233,6 @@ jobs:
with:
name: vmlinux-${{ github.sha }}
path: |
_output/kernel/bzImage
_output/kernel/vmlinux
_output/kernel/kernel-config
retention-days: 30
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ One tarball, laid out as `spin-machine-dev build` lays out `_output/`:
| `bin/mkfs.ext4`, `bin/debugfs`, `bin/e2fsck`, `bin/dumpe2fs`, `e2fsprogs/mke2fs.conf` | static e2fsprogs, and the defaults an ext4 for this kernel is made with |
| `qemu/qboot.bin` and the other ROMs | qboot.bin is the BIOS a machine boots with |
| `qemu/patches/`, `qemu/qboot-*.patch`, `qemu/qboot-COPYING` | the changes this tree makes to QEMU and qboot, shipped with the binaries built from them |
| `kernel/bzImage`, `kernel/vmlinux`, `kernel/kernel-config` | the kernel a machine boots, and the same kernel as an ELF |
| `kernel/vmlinux`, `kernel/kernel-config` | the kernel a machine boots, through PVH, and its configuration. No `kernel/bzImage` since #660 |
| `kernel/sources` | every source and header the kernel compiled, which `spin-machine-dev cves` judges CVEs against |
| `kernel/patches/` | the changes this tree makes to the kernel |
| `image/rootfs.qcow2` | the base image, read-only (0444) |
Expand Down
2 changes: 1 addition & 1 deletion boot/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ tasks:
- |
set -euo pipefail
kernel=()
if [ -f {{.OUTPUT_ABS}}/kernel/bzImage ]; then kernel=(--kernel {{.OUTPUT_ABS}}/kernel/bzImage); fi
if [ -f {{.OUTPUT_ABS}}/kernel/vmlinux ]; then kernel=(--kernel {{.OUTPUT_ABS}}/kernel/vmlinux); fi
here=$(go run ./cmd/spin-machine-dev lab tree here --qemu {{.QEMU | default .OUTPUT_ABS}} "${kernel[@]}" --spin-machine here)
echo "SPIN_MACHINE_OUTPUT=$here" >> "${GITHUB_ENV:-/dev/stdout}"

Expand Down
2 changes: 1 addition & 1 deletion cmd/spin-machine-dev/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func verifyCmd() *cobra.Command {
the machine type every checkpoint is saved on (a newer one is said, not failed), and
the TCG binary's query-qmp-schema has every QMP command and event the module
defines, as the module defines it
kernel a vmlinux with both Xen notes and a filled .data.reloc, and a relocatable bzImage
kernel a vmlinux with both Xen notes and a filled .data.reloc
e2fsprogs the four tools and mke2fs.conf, and mkfs.ext4 answers the pinned version
systemd the packages the image installs
openssh the packages the image installs
Expand Down
9 changes: 2 additions & 7 deletions cmd/spin-machine-dev/edges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ import (
"github.com/spin-stack/machine/machine"
)

// kernelFixture is a relocatable bzImage and a vmlinux that randomizes itself, as kernel/Dockerfile
// leaves them.
// kernelFixture is a vmlinux that randomizes itself, as kernel/Dockerfile leaves it.
func kernelFixture(t *testing.T, out string) {
t.Helper()
bz := make([]byte, 0x300)
copy(bz[0x202:], "HdrS")
bz[0x234] = 1
put(t, filepath.Join(out, "kernel/bzImage"), string(bz), 0o644)
put(t, filepath.Join(out, "kernel/vmlinux"), string(vmlinuxFixture()), 0o644)
for _, f := range []string{"kernel/kernel-config", "kernel/sources", "kernel/patches/0001-k.patch"} {
put(t, filepath.Join(out, f), f, 0o644)
Expand Down Expand Up @@ -243,7 +238,7 @@ func TestAnOSVScanThatFailsIsNotAFinding(t *testing.T) {
func TestAShellIsSystemdIn2GiBAndTwoCPUsByDefault(t *testing.T) {
dir := checkout(t)
out := filepath.Join(dir, "_output")
for _, f := range []string{"bin/qemu-system-x86_64", "kernel/bzImage", "image/rootfs.qcow2"} {
for _, f := range []string{"bin/qemu-system-x86_64", "kernel/vmlinux", "image/rootfs.qcow2"} {
put(t, filepath.Join(out, f), "x", 0o644)
}
put(t, filepath.Join(out, "bin/spin-machine"), "#!/bin/sh\necho \"$*\" > "+filepath.Join(dir, "boot")+"\n", 0o755)
Expand Down
2 changes: 1 addition & 1 deletion cmd/spin-machine-dev/lab.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ resume.`,
_, _ = fmt.Fprintln(c.OutOrStdout(), table)
summarise(table)
for _, r := range rows {
if !r.Resumed && !r.Moved && !r.NoBzImage {
if !r.Resumed && !r.Moved && !r.Unbootable {
return exitError{code: 1}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/spin-machine-dev/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ slower. Leave with 'poweroff -f', or Ctrl-A then X.`,
return err
}
base := filepath.Join(w.out, "image", "rootfs.qcow2")
for _, f := range []string{"bin/spin-machine", "bin/qemu-system-x86_64", "kernel/bzImage", "image/rootfs.qcow2"} {
for _, f := range []string{"bin/spin-machine", "bin/qemu-system-x86_64", "kernel/vmlinux", "image/rootfs.qcow2"} {
if _, err := os.Stat(filepath.Join(w.out, f)); err != nil {
return couldNot(fmt.Errorf("missing %s: spin-machine-dev build makes it", filepath.Join(w.out, f)))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/spin-machine-dev/patched.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ in <out>/patched/<part>. Parts: ` + strings.Join(patched.Names(), ", ") + `.`,
Use: "prepare <part>",
Short: "Build what compiling a part's touched C files needs, before an analysis traces the compiler",
Long: `Build in <out>/patched/<part>/src, which tree made, what compile needs, so that only the touched
files are compiled under CodeQL's tracer: the kernel configured from kernel/, with its bzImage when
a touched file is one only the bzImage builds. codeql.yml runs it before the tracer starts.`,
files are compiled under CodeQL's tracer: the kernel configured from kernel/, with vmlinux when
a touched file is a host tool only vmlinux's build compiles. codeql.yml runs it before the tracer starts.`,
Args: cobra.ExactArgs(1),
RunE: func(c *cobra.Command, args []string) error {
w, p, dir, err := patchedPart(args[0])
Expand Down
12 changes: 5 additions & 7 deletions cmd/spin-machine-dev/verbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,13 @@ mkdir -p "$dest/bin" "$dest/e2fsprogs"; : > "$dest/e2fsprogs/mke2fs.conf"
for b in mkfs.ext4 e2fsck dumpe2fs debugfs; do printf '#!/bin/sh\necho mke2fs ` + version + `\n' > "$dest/bin/$b"; chmod +x "$dest/bin/$b"; done`
}

// kernelDocker is a docker whose kernel build writes a bzImage and vmlinux that verify, and the
// kernelDocker is a docker whose kernel build writes a vmlinux that verifies, and the
// config they were built with: lockdown as KERNEL_LOCKDOWN asks, and extra in the one built with
// none.
func kernelDocker(extra string) string {
return `dest=""; lockdown=""; for a; do case "$a" in type=local,dest=*) dest=${a#type=local,dest=};; KERNEL_LOCKDOWN=*) lockdown=${a#KERNEL_LOCKDOWN=};; esac; done
[ -n "$dest" ] || exit 0
mkdir -p "$dest/kernel"; head -c 1024 /dev/zero > "$dest/kernel/bzImage"
printf HdrS | dd of="$dest/kernel/bzImage" bs=1 seek=514 conv=notrunc 2>/dev/null
printf '\001' | dd of="$dest/kernel/bzImage" bs=1 seek=564 conv=notrunc 2>/dev/null
mkdir -p "$dest/kernel"
printf '` + printfEscaped(vmlinuxFixture()) + `' > "$dest/kernel/vmlinux"
if [ "$lockdown" = none ]; then
printf '# CONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY is not set\nCONFIG_LOCK_DOWN_KERNEL_FORCE_NONE=y\nCONFIG_BPF_LSM=y\n` + extra + `' > "$dest/kernel/kernel-config"
Expand Down Expand Up @@ -417,7 +415,7 @@ func TestPublishIsWhatFetchPulls(t *testing.T) {
func TestVerifySaysWhatIsMissingAndAsksQEMUForTheArguments(t *testing.T) {
dir := checkout(t)
_, stderr, status := verb(t, "verify", "qemu", "kernel")
if status != 1 || !strings.Contains(stderr, "qemu: missing") || !strings.Contains(stderr, "kernel: no kernel") {
if status != 1 || !strings.Contains(stderr, "qemu: missing") || !strings.Contains(stderr, "kernel: reading "+filepath.Join(dir, "_output/kernel/vmlinux")) {
t.Errorf("verify of nothing built: exit %d, %q", status, stderr)
}
if _, stderr, status := verb(t, "verify"); status != 1 || !strings.Contains(stderr, "image: missing") {
Expand Down Expand Up @@ -560,7 +558,7 @@ func packed(t *testing.T, dir string) string {
for _, f := range build.Firmware {
put(t, filepath.Join(out, "qemu", f), f, 0o644)
}
for _, f := range []string{"e2fsprogs/mke2fs.conf", "kernel/bzImage", "kernel/vmlinux", "kernel/kernel-config", "kernel/sources",
for _, f := range []string{"e2fsprogs/mke2fs.conf", "kernel/vmlinux", "kernel/kernel-config", "kernel/sources",
"kernel/patches/0001-k.patch", "image/rootfs.qcow2", "licenses.txt"} {
put(t, filepath.Join(out, f), f, 0o644)
}
Expand Down Expand Up @@ -1103,7 +1101,7 @@ func TestShellBootsTheBaseAndChecksItAfter(t *testing.T) {
if _, stderr, status := verb(t, "shell"); status != 2 || !strings.Contains(stderr, "missing") {
t.Errorf("nothing built: exit %d, %q", status, stderr)
}
for _, f := range []string{"bin/qemu-system-x86_64", "kernel/bzImage", "image/rootfs.qcow2"} {
for _, f := range []string{"bin/qemu-system-x86_64", "kernel/vmlinux", "image/rootfs.qcow2"} {
put(t, filepath.Join(out, f), "x", 0o644)
}
log := filepath.Join(dir, "boot")
Expand Down
Loading
Loading