* @entropy buffer of seed data to be checked
*
* return:
- * 0 on success
- * -EAGAIN on when the CTRNG is not yet primed
- * < 0 on error
+ * %true on success
+ * %false when the CTRNG is not yet primed
*/
-static int drbg_fips_continuous_test(struct drbg_state *drbg,
- const unsigned char *entropy)
+static bool drbg_fips_continuous_test(struct drbg_state *drbg,
+ const unsigned char *entropy)
+ __must_hold(&drbg->drbg_mutex)
{
unsigned short entropylen = drbg_sec_strength(drbg->core->flags);
- int ret = 0;
if (!IS_ENABLED(CONFIG_CRYPTO_FIPS))
- return 0;
+ return true;
/* skip test if we test the overall system */
if (list_empty(&drbg->test_data.list))
return ret;
}
-static inline int drbg_get_random_bytes(struct drbg_state *drbg,
- unsigned char *entropy,
- unsigned int entropylen)
+static inline void drbg_get_random_bytes(struct drbg_state *drbg,
+ unsigned char *entropy,
+ unsigned int entropylen)
+ __must_hold(&drbg->drbg_mutex)
{
- int ret;
-
- do {
+ do
get_random_bytes(entropy, entropylen);
- ret = drbg_fips_continuous_test(drbg, entropy);
- if (ret && ret != -EAGAIN)
- return ret;
- } while (ret);
-
- return 0;
+ while (!drbg_fips_continuous_test(drbg, entropy));
}
static int drbg_seed_from_random(struct drbg_state *drbg)
BinderReturnWriter, DArc, DLArc, DTRWrap, DeliverCode, DeliverToRead,
};
- use core::{
- mem::size_of,
- sync::atomic::{AtomicU32, Ordering},
- };
+ use core::mem::size_of;
+fn is_aligned(value: usize, to: usize) -> bool {
+ value % to == 0
+}
+
/// Stores the layout of the scatter-gather entries. This is used during the `translate_objects`
/// call and is discarded when it returns.
struct ScatterGatherState {
* which partial initialization succeeded.
*/
static unsigned long kfence_init_pool(void)
+ __context_unsafe(/* constructor */)
{
unsigned long addr, start_pfn;
- int i;
+ int i, rand;
if (!arch_kfence_init_pool())
return (unsigned long)__kfence_pool;