Skip to content

Commit 46fc3cf

Browse files
committed
fix(os): drop init_on_free hardening that breaks GCP TDX boot
1 parent 3729683 commit 46fc3cf

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

os/yocto/layers/meta-dstack/recipes-kernel/linux/files/dstack.cfg

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,18 @@ CONFIG_CRYPTO_SHA256=y
4949
CONFIG_CRYPTO_SHA512=y
5050

5151
# Production kernel self-protection baseline.
52+
#
53+
# CONFIG_INIT_ON_FREE_DEFAULT_ON is deliberately NOT set: with init_on_free=1
54+
# a GCP TDX guest is silently killed by the host during mem_encrypt_init()
55+
# (the 1 GiB SWIOTLB private->shared conversion) and reboot-loops before
56+
# reaching /init. Confirmed on c3-standard-4 by booting the same image with
57+
# init_on_alloc=0/init_on_free=0 cmdline overrides: only init_on_free=1
58+
# reproduces the reset; init_on_alloc=1 alone boots fine (and is kept below).
59+
# The same kernel with init_on_free=1 boots fine on AWS EC2 and QEMU TDX,
60+
# so this is a GCP host-side interaction, not a generic kernel bug.
5261
CONFIG_SECURITY_DMESG_RESTRICT=y
5362
CONFIG_IO_STRICT_DEVMEM=y
5463
CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
55-
CONFIG_INIT_ON_FREE_DEFAULT_ON=y
5664
CONFIG_SLAB_FREELIST_RANDOM=y
5765
CONFIG_SLAB_FREELIST_HARDENED=y
5866
CONFIG_HARDENED_USERCOPY=y

os/yocto/tools/aws/audit-aws-ec2-image-hardening.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ echo "== Kernel hardening recommendations =="
150150
recommend_config CONFIG_SECURITY_DMESG_RESTRICT y
151151
recommend_config CONFIG_IO_STRICT_DEVMEM y
152152
recommend_config CONFIG_INIT_ON_ALLOC_DEFAULT_ON y
153-
recommend_config CONFIG_INIT_ON_FREE_DEFAULT_ON y
153+
# CONFIG_INIT_ON_FREE_DEFAULT_ON is intentionally not recommended: the unified
154+
# image also boots on GCP TDX, where init_on_free=1 makes the host kill the
155+
# guest during the SWIOTLB private->shared conversion (see dstack.cfg).
154156
recommend_config CONFIG_SLAB_FREELIST_RANDOM y
155157
recommend_config CONFIG_SLAB_FREELIST_HARDENED y
156158
recommend_config CONFIG_HARDENED_USERCOPY y

0 commit comments

Comments
 (0)