From b464251fcf0fbb16f2ff7728da89995e51404fa5 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 31 Jul 2024 15:27:52 +0000 Subject: [PATCH] zfs: Overallocate nvpair buffers on all CHERI platforms Otherwise the size != NV_ALIGN(size2) check in i_validate_nvpair() can fail for nvlists created by a purecap userspace when consumed by a hybrid kernel. This arises for me with nextboot, which uses zfsbootcfg under the hood to invoke ZFS_IOC_{GET,SET}_BOOTENV. For a freshly created pool, the boot environment type will be VB_RAW, and gets converted to a VB_NVLIST upon the first write. After that, it is re-read from the pool by the kernel and allocated without the extra space allocated by the NVPAIR_OVER_ALLOCATE_DECODE option. When zfsbootcfg subsequently modifies and sets the boot environment again, the nvlist contains pad bytes inserted by nvpair_nominal_decode_size(), and the above-mentioned check in i_validate_nvpair() fails. --- module/nvpair/nvpair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 47fd1b0fd6f2..a054a6376ca9 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -55,7 +55,7 @@ #define skip_whitespace(p) while ((*(p) == ' ') || (*(p) == '\t')) (p)++ -#ifdef __CHERI_PURE_CAPABILITY__ +#if __has_feature(capabilities) #define NVPAIR_OVER_ALLOCATE_DECODE #endif