mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
fault-inject: fix boot failure with fault injection boot parameters
Since commite9bc360b10("fault-inject: use prandom where cryptographically secure randomness is not needed"), setup_fault_attr() calls prandom_init_once(), which calls kmalloc() and schedule_work(). But setup_fault_attr() can be called from __setup handlers before slab and workqueues are initialized, so any fault injection boot parameter leads to boot failure. So use DO_ONCE_LITE() instead. Link: https://lore.kernel.org/[email protected] Fixes:e9bc360b10("fault-inject: use prandom where cryptographically secure randomness is not needed") Signed-off-by: Sang-Heon Jeon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Akinobu Mita <[email protected]> Cc: <[email protected]> lib/fault-inject.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
This commit is contained in:
committed by
Andrew Morton
parent
fffc86cbe3
commit
27538caf7f
+7
-1
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/once_lite.h>
|
||||
#include <linux/prandom.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/sched.h>
|
||||
@@ -50,7 +51,12 @@ int setup_fault_attr(struct fault_attr *attr, char *str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
prandom_init_once(&fault_rnd_state);
|
||||
/*
|
||||
* __setup handlers run before slab and workqueues are initialized,
|
||||
* but prandom_init_once() calls kmalloc() and schedule_work(). So use
|
||||
* DO_ONCE_LITE() instead.
|
||||
*/
|
||||
DO_ONCE_LITE(prandom_seed_full_state, &fault_rnd_state);
|
||||
|
||||
attr->probability = probability;
|
||||
attr->interval = interval;
|
||||
|
||||
Reference in New Issue
Block a user