Skip to content

eBPF-based security platform

image: default config images to 1 MiB

Daniel Borkmannba550c6ab2b3
diff --git a/Documentation/reference/cli/gen-tools.rst b/Documentation/reference/cli/gen-tools.rst
index c22fd6a8..2eaf75b8 100644
--- a/Documentation/reference/cli/gen-tools.rst
+++ b/Documentation/reference/cli/gen-tools.rst
@@ -82,8 +82,8 @@ raise --size``. Requires ``mkfs.ext4`` and ``veritysetup``.
- ``config``
- ``config`` or ``runtime``.
* - ``--size``
- - 64
- - File system size in MiB, 8 to 1048576.
+ - 1
+ - File system size in MiB, 1 to 1048576.
* - ``--builder``
- ``$SHIRUDO_BUILD``, else ``shirudo-build``
- The helper that signs the root hash.
@@ -149,7 +149,7 @@ trusted binaries. Requires ``readelf``, ``ldd`` and ``llvm-strip``.
- Operator keys directory that signs the image.
* - ``--size``
- 15
- - File system size in MiB, 8 to 1048576. The default holds the
+ - File system size in MiB, 1 to 1048576. The default holds the
stripped static target binary and its certificates. A dynamic
binary with its libraries or an ``--extra-binary`` may need more.
* - ``--builder``
diff --git a/testing/functional/image/t5001-config-image.sh b/testing/functional/image/t5001-config-image.sh
index a54b5358..623e4635 100755
--- a/testing/functional/image/t5001-config-image.sh
+++ b/testing/functional/image/t5001-config-image.sh
@@ -265,11 +265,19 @@ if command -v mkfs.ext4 >/dev/null 2>&1 && command -v debugfs >/dev/null 2>&1; t
mkdir -p "$W/config-root/etc/shirudo" &&
printf "eventlog.max_bytes = 12345\n" >"$W/config-root/etc/shirudo/shirudo.conf" &&
../tools/gen-image/shirudo-gen-image --source "$W/config-root" \
- --output "$W/generated-config" --keys-dir "$W/keys" --builder "$B" --size 8 &&
+ --output "$W/generated-config" --keys-dir "$W/keys" --builder "$B" &&
+ test "$(stat -c %s "$W/generated-config.img")" -eq 1048576 &&
verify "$W/generated-config" "$W/keys/cert.der" &&
debugfs -R "cat /etc/shirudo/shirudo.conf" "$W/generated-config.img" 2>/dev/null |
grep -qx "eventlog.max_bytes = 12345"
'
+ test_expect_success 'an image size below 1 MiB is refused' '
+ ! ../tools/gen-image/shirudo-gen-image --source "$W/config-root" \
+ --output "$W/zero" --keys-dir "$W/keys" --builder "$B" --size 0 \
+ 2>"$W/zero.err" &&
+ grep -q "between 1 and 1048576 MiB" "$W/zero.err" &&
+ ! test -e "$W/zero.img"
+ '
test_expect_success 'runtime generator includes interpreter, public keys and trusted probe' '
cp fixtures/image-runtime.conf "$W/bootstrap.conf" &&
diff --git a/testing/vm/image-fixtures.sh b/testing/vm/image-fixtures.sh
index 888c328a..c47ac478 100755
--- a/testing/vm/image-fixtures.sh
+++ b/testing/vm/image-fixtures.sh
@@ -130,7 +130,7 @@ for name in config-boot-keys config-live-new-key config-a config-b config-bad co
cp "$builtin_cert" "$output/public/builtin.der"
else
"$source_dir/tools/gen-image/shirudo-gen-image" --source "$root" \
- --output "$output/public/$name" --keys-dir "$keys_dir" --size 8 \
+ --output "$output/public/$name" --keys-dir "$keys_dir" \
--builder "$builder" >"$output/$name-build.log" 2>&1
fi
SHIRUDO_BUILD="$builder" "$operator" image verify "$output/public/$name" \
diff --git a/tools/gen-image/common.sh b/tools/gen-image/common.sh
index 5fcf8dc2..58a23d7a 100644
--- a/tools/gen-image/common.sh
+++ b/tools/gen-image/common.sh
@@ -27,8 +27,8 @@ check_image_options()
[ -n "$keys_dir" ] && [ -d "$keys_dir" ] ||
die '--keys-dir needs a directory'
case "$size" in ''|*[!0-9]*) die '--size must be an integer in MiB' ;; esac
- [ "${#size}" -le 7 ] && [ "$size" -ge 8 ] && [ "$size" -le 1048576 ] ||
- die '--size must be between 8 and 1048576 MiB'
+ [ "${#size}" -le 7 ] && [ "$size" -ge 1 ] && [ "$size" -le 1048576 ] ||
+ die '--size must be between 1 and 1048576 MiB'
for suffix in .img .verity .roothash .p7s; do
require_new_output "$output$suffix"
done
diff --git a/tools/gen-image/shirudo-gen-image b/tools/gen-image/shirudo-gen-image
index b22afa87..f0ab6374 100755
--- a/tools/gen-image/shirudo-gen-image
+++ b/tools/gen-image/shirudo-gen-image
@@ -100,6 +100,6 @@ source_dir=
output=
keys_dir=
kind=config
-size=64
+size=1
builder=${SHIRUDO_BUILD:-shirudo-build}
main "$@"