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

x86: Mark archrandom.h functions __must_check

We must not use the pointer output without validating the
success of the random read.

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20200110145422.49141-8-broonie@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Richard Henderson and committed by
Theodore Ts'o
1640a7b9 904caa64

+8 -8
+8 -8
arch/x86/include/asm/archrandom.h
··· 27 27 28 28 /* Unconditional execution of RDRAND and RDSEED */ 29 29 30 - static inline bool rdrand_long(unsigned long *v) 30 + static inline bool __must_check rdrand_long(unsigned long *v) 31 31 { 32 32 bool ok; 33 33 unsigned int retry = RDRAND_RETRY_LOOPS; ··· 41 41 return false; 42 42 } 43 43 44 - static inline bool rdrand_int(unsigned int *v) 44 + static inline bool __must_check rdrand_int(unsigned int *v) 45 45 { 46 46 bool ok; 47 47 unsigned int retry = RDRAND_RETRY_LOOPS; ··· 55 55 return false; 56 56 } 57 57 58 - static inline bool rdseed_long(unsigned long *v) 58 + static inline bool __must_check rdseed_long(unsigned long *v) 59 59 { 60 60 bool ok; 61 61 asm volatile(RDSEED_LONG ··· 64 64 return ok; 65 65 } 66 66 67 - static inline bool rdseed_int(unsigned int *v) 67 + static inline bool __must_check rdseed_int(unsigned int *v) 68 68 { 69 69 bool ok; 70 70 asm volatile(RDSEED_INT ··· 80 80 */ 81 81 #ifdef CONFIG_ARCH_RANDOM 82 82 83 - static inline bool arch_get_random_long(unsigned long *v) 83 + static inline bool __must_check arch_get_random_long(unsigned long *v) 84 84 { 85 85 return static_cpu_has(X86_FEATURE_RDRAND) ? rdrand_long(v) : false; 86 86 } 87 87 88 - static inline bool arch_get_random_int(unsigned int *v) 88 + static inline bool __must_check arch_get_random_int(unsigned int *v) 89 89 { 90 90 return static_cpu_has(X86_FEATURE_RDRAND) ? rdrand_int(v) : false; 91 91 } 92 92 93 - static inline bool arch_get_random_seed_long(unsigned long *v) 93 + static inline bool __must_check arch_get_random_seed_long(unsigned long *v) 94 94 { 95 95 return static_cpu_has(X86_FEATURE_RDSEED) ? rdseed_long(v) : false; 96 96 } 97 97 98 - static inline bool arch_get_random_seed_int(unsigned int *v) 98 + static inline bool __must_check arch_get_random_seed_int(unsigned int *v) 99 99 { 100 100 return static_cpu_has(X86_FEATURE_RDSEED) ? rdseed_int(v) : false; 101 101 }