mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-12 16:16:27 +07:00
4cb760b024
We must not use the pointer output without validating the success of the random read. Reviewed-by: Harald Freudenberger <freude@linux.ibm.com> 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-11-broonie@kernel.org Signed-off-by: Theodore Ts'o <tytso@mit.edu>
52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Kernel interface for the s390 arch_random_* functions
|
|
*
|
|
* Copyright IBM Corp. 2017
|
|
*
|
|
* Author: Harald Freudenberger <freude@de.ibm.com>
|
|
*
|
|
*/
|
|
|
|
#ifndef _ASM_S390_ARCHRANDOM_H
|
|
#define _ASM_S390_ARCHRANDOM_H
|
|
|
|
#ifdef CONFIG_ARCH_RANDOM
|
|
|
|
#include <linux/static_key.h>
|
|
#include <linux/atomic.h>
|
|
|
|
DECLARE_STATIC_KEY_FALSE(s390_arch_random_available);
|
|
extern atomic64_t s390_arch_random_counter;
|
|
|
|
bool s390_arch_random_generate(u8 *buf, unsigned int nbytes);
|
|
|
|
static inline bool __must_check arch_get_random_long(unsigned long *v)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool __must_check arch_get_random_int(unsigned int *v)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
|
|
{
|
|
if (static_branch_likely(&s390_arch_random_available)) {
|
|
return s390_arch_random_generate((u8 *)v, sizeof(*v));
|
|
}
|
|
return false;
|
|
}
|
|
|
|
static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
|
|
{
|
|
if (static_branch_likely(&s390_arch_random_available)) {
|
|
return s390_arch_random_generate((u8 *)v, sizeof(*v));
|
|
}
|
|
return false;
|
|
}
|
|
|
|
#endif /* CONFIG_ARCH_RANDOM */
|
|
#endif /* _ASM_S390_ARCHRANDOM_H */
|