eBPF-based security platform
bpm: use .bee names for package definitions
John Fastabend18f76f0949ee
diff --git a/Documentation/getting-started.rst b/Documentation/getting-started.rstindex 07d600b3..e0c473db 100644--- a/Documentation/getting-started.rst+++ b/Documentation/getting-started.rst@@ -194,11 +194,17 @@ and extends nothing.6) Packages and registries---------------------------A package is a directory with a ``Beefile`` next to the BPF sources::+A package is a directory with a ``<name>.bee`` Beefile next to the BPF sources::++ example-shield/+ ├── example-shield.bee+ └── shield.bpf.c++Example ``example-shield.bee``::[package]- name = "kernel-obs"- description = "shirudo kernel observability"+ name = "example-shield"+ description = "Example BPF shield"license = "GPL-2.0 OR BSD-2-Clause"authors = ["Example Org"]@@ -206,16 +212,17 @@ A package is a directory with a ``Beefile`` next to the BPF sources::source = "decoders/exec.lua"[[upatches]]- source = "kernel-obs.bpf.c"+ source = "shield.bpf.c"``[[files]]`` entries are copied into the package (headers, decoders,reproducers); each ``[[upatches]]`` entry is built and signed, with itsunload directive, through ``shirudo-build``. On the operator::- shirudo bpm build ./pkg --version 1.0.0 --keys-dir /var/lib/shirudo/keys- shirudo bpm info ./kernel-obs-1.0.0.bee- shirudo bpm push ./kernel-obs-1.0.0.bee \- oci://quay.io/example/kernel-obs --keys-dir /var/lib/shirudo/keys+ shirudo bpm build ./pkg --version 1.0.0 \+ -f ./pkg/example-shield.bee --keys-dir /var/lib/shirudo/keys+ shirudo bpm info ./example-shield-1.0.0.bee+ shirudo bpm push ./example-shield-1.0.0.bee \+ oci://quay.io/example/example-shield --keys-dir /var/lib/shirudo/keys``push`` uploads the package and its certificate and, given the signingmaterial, adds the version to the registry's signed index atdiff --git a/Documentation/index.rst b/Documentation/index.rstindex 985354d9..e149c979 100644--- a/Documentation/index.rst+++ b/Documentation/index.rst@@ -127,7 +127,7 @@ Contributinglicence. Vendored files keep their upstream SPDX identifiers.``upatches/``- The packages shirudo ships, each with its ``Beefile``.+ The packages shirudo ships, each with a named ``.bee`` package definition.``vendor/libbpf/``Vendored libbpf and BPF UAPI headers with shirudo's BSD shims fordiff --git a/Documentation/upatch.rst b/Documentation/upatch.rstindex d6027b9b..6faa1317 100644--- a/Documentation/upatch.rst+++ b/Documentation/upatch.rst@@ -252,7 +252,19 @@ for tests and ``init``'s own boot-restore, not for operation.5) Packaging-------------A package is a directory with a ``Beefile`` next to the sources::+A package is a directory with a ``<name>.bee`` Beefile next to the sources::++ example-shields/+ ├── example-shields.bee+ └── shield.bpf.c++The ``.bee`` suffix names the package definition. ``bpm build`` writes+the versioned package archive as ``<name>-<version>.bee`` and stores the+definition inside that archive under the member name ``Beefile``. Pass+the local definition with ``-f``; the legacy default filename+``Beefile`` remains accepted when ``-f`` is omitted.++Example ``example-shields.bee``::[package]name = "example-shields"@@ -312,11 +324,13 @@ A package is a directory with a ``Beefile`` next to the sources::when it satisfies every key given. An entry without a selectorapplies everywhere.-``upatches/kernel-cve/Beefile`` in the tree is a worked example with-one entry per CVE shield, and ``upatches/kernel-obs/Beefile`` one with+``upatches/kernel-cve/kernel-cve.bee`` in the tree is a worked example+with one entry per CVE shield, and+``upatches/kernel-obs/kernel-obs.bee`` one withdecoders and shared headers. Build and inspect::shirudo bpm build ./example-shields --version 1.0.0 \+ -f ./example-shields/example-shields.bee \--keys-dir /var/lib/shirudo/keysshirudo bpm info ./example-shields-1.0.0.bee@@ -327,7 +341,7 @@ provides the helper. From a checkout, set ``SHIRUDO_BUILD`` tocheckout root on ``PATH``. If ``shirudo bpm --help`` shows only targetcommands, the helper was not found.-``bpm build [context] --version <v> [-f <Beefile>] [--keys-dir <dir>]``+``bpm build [context] --version <v> [-f <name>.bee] [--keys-dir <dir>]``builds and signs every entry through ``shirudo-build`` and writes``<name>-<version>.bee``: a gzip tarball with the ``Beefile``, the``upatches/*.upatch`` and ``*.unload.upatch`` artifacts, thediff --git a/completion/shirudo.bash b/completion/shirudo.bashindex 029bd1c8..2b3d7990 100644--- a/completion/shirudo.bash+++ b/completion/shirudo.bash@@ -91,7 +91,8 @@ _shirudo()elif [[ $sub == repo && cword -eq 3 ]]; thenCOMPREPLY=( $(compgen -W "update" -- "$cur") )elif [[ $sub == build && ${COMP_WORDS[COMP_CWORD-1]} == -f ]]; then- COMPREPLY=( $(compgen -f -- "$cur") )+ COMPREPLY=( $(compgen -f -X '!*.bee' -- "$cur") \+ $(compgen -d -- "$cur") )elif [[ $sub == build && ${COMP_WORDS[COMP_CWORD-1]} == --keys-dir ]]; thenCOMPREPLY=( $(compgen -d -- "$cur") )elif [[ $sub == build && $cur == -* ]]; thendiff --git a/testing/Makefile b/testing/Makefileindex 96bfb92b..74542728 100644--- a/testing/Makefile+++ b/testing/Makefile@@ -128,7 +128,7 @@ TEST_VM_BUNDLE_SOURCES := $(sort $(wildcard \$(ROOT)/testing/fixtures/decoders/* \$(ROOT)/testing/signing/*.sh \$(ROOT)/upatches/kernel-obs/*.c $(ROOT)/upatches/kernel-obs/*.h $(ROOT)/upatches/kernel-obs/*.list \- $(ROOT)/upatches/kernel-obs/*.py $(ROOT)/upatches/kernel-obs/Beefile \+ $(ROOT)/upatches/kernel-obs/*.py $(ROOT)/upatches/kernel-obs/kernel-obs.bee \$(ROOT)/upatches/kernel-obs/decoders/*))# The kernel build replaces versioned package files; depend on its stable stamp.TEST_VM_BUNDLE_ARTIFACTS := $(VM_KERNEL_STAMP)diff --git a/tools/shirudo-build/README.md b/tools/shirudo-build/README.mdindex 2e6a7878..fdc1b73e 100644--- a/tools/shirudo-build/README.md+++ b/tools/shirudo-build/README.md@@ -14,7 +14,7 @@ dispatch to this separate helper with `execv`; when compiling `.bpf.c`input, the helper forks and execs `clang -target bpf`. The helper shipsonly in the operator package, so no target-side code path can reach thecompiler or the operator signing code. It hosts the operator-only BPM-commands: `shirudo bpm build` (Beefile to signed `.bee`), `shirudo bpm+commands: `shirudo bpm build` (package definition to signed `.bee` archive), `shirudo bpmpush` (package and certificate referrer, with an optional signed index), and`shirudo bpm tree append` (signed upatch tree). The CMS signer and thesecommand implementations are linked only into `shirudo-build`.@@ -43,7 +43,7 @@ target boundary) and `AGENTS.md` (the no-subprocess invariant).| `<file.bpf.o>` | gen_loader → sign → package (skip compile) || `--unload <name>` | emit signed UNLOAD directive `.upatch` || `keys vouch <cert.der>` | sign a vouch for another certificate |-| `bpm build [context] --version <v>` | compile, sign and package every Beefile upatch into a `.bee` |+| `bpm build [context] --version <v> [-f <name>.bee]` | compile, sign and package every Beefile upatch into a `.bee` || `bpm push <pkg.bee> oci://...` | publish the package and certificate referrer; with signing material, also update the signed index || `bpm tree append <pkg.bee> oci://...` | publish the next generation of a signed upatch tree |@@ -86,11 +86,14 @@ Example layout:```textexample-shield/-├── Beefile+├── example-shield.bee└── shield.bpf.c```-Example `Beefile`:+The local package definition uses the package name with a `.bee` suffix.+`bpm build` stores it inside the package archive as `Beefile`.++Example `example-shield.bee`:```toml[package]@@ -114,6 +117,7 @@ Build and inspect the package, then publish its tree entry:```shshirudo bpm build ./example-shield --version 1.0.0 \+ -f ./example-shield/example-shield.bee \--keys-dir /var/lib/shirudo/keysshirudo bpm info ./example-shield-1.0.0.beeshirudo bpm tree append ./example-shield-1.0.0.bee \diff --git a/tools/shirudo-build/bpm-build.c b/tools/shirudo-build/bpm-build.cindex d224e9e0..ae846d42 100644--- a/tools/shirudo-build/bpm-build.c+++ b/tools/shirudo-build/bpm-build.c@@ -1109,7 +1109,7 @@ static void build_usage(void){fprintf(stderr,"usage: shirudo bpm build [context] --version <version>\n"- " shirudo bpm build [context] -f <Beefile> --version <version>\n"+ " shirudo bpm build [context] -f <name>.bee --version <version>\n"" [--keys-dir <dir>]\n\n""Builds a signed .bee package from a Beefile. The build command\n""is available only in shirudo-operator and requires signing keys.\n");@@ -1246,7 +1246,7 @@ usage:static void bpm_usage(FILE *fp){fprintf(fp,- "usage: shirudo bpm build [context] --version <version> [-f <Beefile>]\n"+ "usage: shirudo bpm build [context] --version <version> [-f <name>.bee]\n"" [--keys-dir <dir>]\n"" shirudo bpm push <package-file> <repository> [--keys-dir <dir> |\n"" --index-cert <cert.der> --index-key <key.pem>]\n"diff --git a/upatches/kernel-cve/REBUILD.md b/upatches/kernel-cve/REBUILD.mdindex 513ccb12..66f14051 100644--- a/upatches/kernel-cve/REBUILD.md+++ b/upatches/kernel-cve/REBUILD.md@@ -1,6 +1,6 @@# Rebuilding exported kernel-CVE upatches-This bundle contains the generated Beefile, combined manifest, the shared `vmlinux.h`, BPF C sources, and (for entries that have them) signed payloads, object files, logs, certificates, and per-record JSON metadata.+This bundle contains the generated `kernel-cve.bee` package definition, combined manifest, the shared `vmlinux.h`, BPF C sources, and (for entries that have them) signed payloads, object files, logs, certificates, and per-record JSON metadata.From a compatible Shirudo checkout, copy this directory beneath `upatches/` and run the normal Jbrust shield builder for `kernel-cve` with the destination project's signer. Replace the package signer with the destination project's signer when rebuilding the signed entry.diff --git a/upatches/kernel-cve/Beefile b/upatches/kernel-cve/kernel-cve.beesimilarity index 100%rename from upatches/kernel-cve/Beefilerename to upatches/kernel-cve/kernel-cve.beediff --git a/upatches/kernel-cve/manifest.json b/upatches/kernel-cve/manifest.jsonindex eda9836c..08f7a7c6 100644--- a/upatches/kernel-cve/manifest.json+++ b/upatches/kernel-cve/manifest.json@@ -6,7 +6,7 @@"upatches_included": false},"collateral": {- "beefile": "kernel-cve/Beefile",+ "beefile": "kernel-cve/kernel-cve.bee","manifest": "kernel-cve/manifest.json","per_entry_source_dirs": "kernel-cve/sources/","rebuild_notes": "kernel-cve/REBUILD.md"diff --git a/upatches/kernel-obs/Beefile b/upatches/kernel-obs/kernel-obs.beesimilarity index 100%rename from upatches/kernel-obs/Beefilerename to upatches/kernel-obs/kernel-obs.bee