Skip to content

Commit 32988e2

Browse files
tytsogregkh
authored andcommitted
random: fix possible sleeping allocation from irq context
commit 6c1e851c4edc13a43adb3ea4044e3fc8f43ccf7d upstream. We can do a sleeping allocation from an irq context when CONFIG_NUMA is enabled. Fix this by initializing the NUMA crng instances in a workqueue. Reported-by: Tetsuo Handa <[email protected]> Reported-by: [email protected] Fixes: 8ef35c866f8862df ("random: set up the NUMA crng instances...") Cc: [email protected] Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 13eec12 commit 32988e2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/char/random.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ static void crng_initialize(struct crng_state *crng)
800800
}
801801

802802
#ifdef CONFIG_NUMA
803-
static void numa_crng_init(void)
803+
static void do_numa_crng_init(struct work_struct *work)
804804
{
805805
int i;
806806
struct crng_state *crng;
@@ -821,6 +821,13 @@ static void numa_crng_init(void)
821821
kfree(pool);
822822
}
823823
}
824+
825+
static DECLARE_WORK(numa_crng_init_work, do_numa_crng_init);
826+
827+
static void numa_crng_init(void)
828+
{
829+
schedule_work(&numa_crng_init_work);
830+
}
824831
#else
825832
static void numa_crng_init(void) {}
826833
#endif

0 commit comments

Comments
 (0)