Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

random: vDSO: avoid call to out of line memset()

With the current implementation, __cvdso_getrandom_data() calls
memset() on certain architectures, which is unexpected in the VDSO.

Rather than providing a memset(), simply rewrite opaque data
initialization to avoid memset().

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

authored by

Christophe Leroy and committed by
Jason A. Donenfeld
b7bad082 81723e3a

+7 -5
+7 -5
lib/vdso/getrandom.c
··· 3 3 * Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. 4 4 */ 5 5 6 + #include <linux/array_size.h> 6 7 #include <linux/cache.h> 7 8 #include <linux/kernel.h> 8 9 #include <linux/time64.h> ··· 74 73 u32 counter[2] = { 0 }; 75 74 76 75 if (unlikely(opaque_len == ~0UL && !buffer && !len && !flags)) { 77 - *(struct vgetrandom_opaque_params *)opaque_state = (struct vgetrandom_opaque_params) { 78 - .size_of_opaque_state = sizeof(*state), 79 - .mmap_prot = PROT_READ | PROT_WRITE, 80 - .mmap_flags = MAP_DROPPABLE | MAP_ANONYMOUS 81 - }; 76 + struct vgetrandom_opaque_params *params = opaque_state; 77 + params->size_of_opaque_state = sizeof(*state); 78 + params->mmap_prot = PROT_READ | PROT_WRITE; 79 + params->mmap_flags = MAP_DROPPABLE | MAP_ANONYMOUS; 80 + for (size_t i = 0; i < ARRAY_SIZE(params->reserved); ++i) 81 + params->reserved[i] = 0; 82 82 return 0; 83 83 } 84 84