mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-27 11:29:36 +03:00
d0aa9dbccf
C99 6.7.8.17 says that when an undesignated initialiser is used, only the first element of a union is initialised. If the first element is not the largest within the union, how the remaining space is initialised is up to the compiler. GCC extends the initialiser to the entire union, while Clang treats the remainder as padding, and so initialises according to whatever automatic/implicit initialisation rules are currently active. When Linux is compiled with CONFIG_INIT_STACK_ALL_PATTERN, -ftrivial-auto-var-init=pattern is added to the kernel CFLAGS. This flag sets the policy for automatic/implicit initialisation of variables on the stack. Taken together, this means that when compiling under CONFIG_INIT_STACK_ALL_PATTERN on Clang, the "zero" initialiser will only zero the first element in a union, and the rest will be filled with a pattern. This is significant for aes_ctx_t, which in aes_encrypt_atomic() and aes_decrypt_atomic() is initialised to zero, but then used as a gcm_ctx_t, which is the fifth element in the union, and thus gets pattern initialisation. Later, it's assumed to be zero, resulting in a hang. As confusing and undiscoverable as it is, by the spec, we are at fault when we initialise a structure containing a union with the zero initializer. As such, this commit replaces these uses with an explicit memset(0). Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Closes #16135 Closes #16206 |
||
---|---|---|
.. | ||
checksum | ||
file | ||
linux_dos_attributes | ||
.gitignore | ||
badsend.c | ||
btree_test.c | ||
chg_usr_exec.c | ||
clone_mmap_cached.c | ||
clone_mmap_write.c | ||
clonefile.c | ||
cp_files.c | ||
ctime.c | ||
devname2devid.c | ||
dir_rd_update.c | ||
dosmode_readonly_write.c | ||
draid.c | ||
ereports.c | ||
get_diff.c | ||
getversion.c | ||
idmap_util.c | ||
libzfs_input_check.c | ||
Makefile.am | ||
mkbusy.c | ||
mkfile.c | ||
mkfiles.c | ||
mktree.c | ||
mmap_exec.c | ||
mmap_libaio.c | ||
mmap_seek.c | ||
mmap_sync.c | ||
mmapwrite.c | ||
nvlist_to_lua.c | ||
readmmap.c | ||
rename_dir.c | ||
renameat2.c | ||
rm_lnkcnt_zero_file.c | ||
send_doall.c | ||
stride_dd.c | ||
suid_write_to_file.c | ||
threadsappend.c | ||
truncate_test.c | ||
user_ns_exec.c | ||
xattrtest.c | ||
zed_fd_spill-zedlet.c | ||
zfs_diff-socket.c |