Skip to content

Commit 1640a7b

Browse files
rth7680tytso
authored andcommitted
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 <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 904caa6 commit 1640a7b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

arch/x86/include/asm/archrandom.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
/* Unconditional execution of RDRAND and RDSEED */
2929

30-
static inline bool rdrand_long(unsigned long *v)
30+
static inline bool __must_check rdrand_long(unsigned long *v)
3131
{
3232
bool ok;
3333
unsigned int retry = RDRAND_RETRY_LOOPS;
@@ -41,7 +41,7 @@ static inline bool rdrand_long(unsigned long *v)
4141
return false;
4242
}
4343

44-
static inline bool rdrand_int(unsigned int *v)
44+
static inline bool __must_check rdrand_int(unsigned int *v)
4545
{
4646
bool ok;
4747
unsigned int retry = RDRAND_RETRY_LOOPS;
@@ -55,7 +55,7 @@ static inline bool rdrand_int(unsigned int *v)
5555
return false;
5656
}
5757

58-
static inline bool rdseed_long(unsigned long *v)
58+
static inline bool __must_check rdseed_long(unsigned long *v)
5959
{
6060
bool ok;
6161
asm volatile(RDSEED_LONG
@@ -64,7 +64,7 @@ static inline bool rdseed_long(unsigned long *v)
6464
return ok;
6565
}
6666

67-
static inline bool rdseed_int(unsigned int *v)
67+
static inline bool __must_check rdseed_int(unsigned int *v)
6868
{
6969
bool ok;
7070
asm volatile(RDSEED_INT
@@ -80,22 +80,22 @@ static inline bool rdseed_int(unsigned int *v)
8080
*/
8181
#ifdef CONFIG_ARCH_RANDOM
8282

83-
static inline bool arch_get_random_long(unsigned long *v)
83+
static inline bool __must_check arch_get_random_long(unsigned long *v)
8484
{
8585
return static_cpu_has(X86_FEATURE_RDRAND) ? rdrand_long(v) : false;
8686
}
8787

88-
static inline bool arch_get_random_int(unsigned int *v)
88+
static inline bool __must_check arch_get_random_int(unsigned int *v)
8989
{
9090
return static_cpu_has(X86_FEATURE_RDRAND) ? rdrand_int(v) : false;
9191
}
9292

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)
9494
{
9595
return static_cpu_has(X86_FEATURE_RDSEED) ? rdseed_long(v) : false;
9696
}
9797

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)
9999
{
100100
return static_cpu_has(X86_FEATURE_RDSEED) ? rdseed_int(v) : false;
101101
}

0 commit comments

Comments
 (0)