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: add __arch_get_k_vdso_rng_data() helper for data page access

_vdso_data is specific to x86 and __arch_get_k_vdso_data() is provided
so that all architectures can provide the requested pointer.

Do the same with _vdso_rng_data, provide __arch_get_k_vdso_rng_data()
and don't use x86 _vdso_rng_data directly.

Until now vdso/vsyscall.h was only included by time/vsyscall.c but now
it will also be included in char/random.c, leading to a duplicate
declaration of _vdso_data and _vdso_rng_data.

To fix this issue, move the declaration in a C file. vma.c looks like
the most appropriate candidate. We don't need to replace the definitions
in vsyscall.h by declarations as declarations are already in asm/vvar.h.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

authored by

Christophe Leroy and committed by
Jason A. Donenfeld
b757959f 81c68960

+13 -5
+3
arch/x86/entry/vdso/vma.c
··· 38 38 } 39 39 #undef EMIT_VVAR 40 40 41 + DEFINE_VVAR(struct vdso_data, _vdso_data); 42 + DEFINE_VVAR_SINGLE(struct vdso_rng_data, _vdso_rng_data); 43 + 41 44 unsigned int vclocks_used __read_mostly; 42 45 43 46 #if defined(CONFIG_X86_64)
+7 -3
arch/x86/include/asm/vdso/vsyscall.h
··· 9 9 #include <asm/vgtod.h> 10 10 #include <asm/vvar.h> 11 11 12 - DEFINE_VVAR(struct vdso_data, _vdso_data); 13 - DEFINE_VVAR_SINGLE(struct vdso_rng_data, _vdso_rng_data); 14 - 15 12 /* 16 13 * Update the vDSO data page to keep in sync with kernel timekeeping. 17 14 */ ··· 18 21 return _vdso_data; 19 22 } 20 23 #define __arch_get_k_vdso_data __x86_get_k_vdso_data 24 + 25 + static __always_inline 26 + struct vdso_rng_data *__x86_get_k_vdso_rng_data(void) 27 + { 28 + return &_vdso_rng_data; 29 + } 30 + #define __arch_get_k_vdso_rng_data __x86_get_k_vdso_rng_data 21 31 22 32 /* The asm-generic header needs to be included after the definitions above */ 23 33 #include <asm-generic/vdso/vsyscall.h>
+3 -2
drivers/char/random.c
··· 59 59 #ifdef CONFIG_VDSO_GETRANDOM 60 60 #include <vdso/getrandom.h> 61 61 #include <vdso/datapage.h> 62 + #include <vdso/vsyscall.h> 62 63 #endif 63 64 #include <asm/archrandom.h> 64 65 #include <asm/processor.h> ··· 290 289 * because the vDSO side only checks whether the value changed, without 291 290 * actually using or interpreting the value. 292 291 */ 293 - smp_store_release((unsigned long *)&_vdso_rng_data.generation, next_gen + 1); 292 + smp_store_release((unsigned long *)&__arch_get_k_vdso_rng_data()->generation, next_gen + 1); 294 293 #endif 295 294 if (!static_branch_likely(&crng_is_ready)) 296 295 crng_init = CRNG_READY; ··· 743 742 queue_work(system_unbound_wq, &set_ready); 744 743 atomic_notifier_call_chain(&random_ready_notifier, 0, NULL); 745 744 #ifdef CONFIG_VDSO_GETRANDOM 746 - WRITE_ONCE(_vdso_rng_data.is_ready, true); 745 + WRITE_ONCE(__arch_get_k_vdso_rng_data()->is_ready, true); 747 746 #endif 748 747 wake_up_interruptible(&crng_init_wait); 749 748 kill_fasync(&fasync, SIGIO, POLL_IN);