Skip to content

Commit

Permalink
zfs: Overallocate nvpair buffers on all CHERI platforms
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markjdb authored and bsdjhb committed Aug 2, 2024
1 parent f891ac4 commit e354261
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion module/nvpair/nvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e354261

Please sign in to comment.