random: fix possible sleeping allocation from irq context
authorTheodore Ts'o <tytso@mit.edu>
Mon, 23 Apr 2018 22:51:28 +0000 (18:51 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 24 Apr 2018 16:00:08 +0000 (12:00 -0400)
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 <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot+9de458f6a5e713ee8c1a@syzkaller.appspotmail.com
Fixes: 8ef35c866f8862df ("random: set up the NUMA crng instances...")
Cc: stable@vger.kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
drivers/char/random.c

index 3cd3aae24d6d31274018cf78798d009452d467b6..721dca8db9cfe823ff611c4e2a8445c4ff2b8f46 100644 (file)
@@ -789,7 +789,7 @@ static void crng_initialize(struct crng_state *crng)
 }
 
 #ifdef CONFIG_NUMA
-static void numa_crng_init(void)
+static void do_numa_crng_init(struct work_struct *work)
 {
        int i;
        struct crng_state *crng;
@@ -810,6 +810,13 @@ static void numa_crng_init(void)
                kfree(pool);
        }
 }
+
+static DECLARE_WORK(numa_crng_init_work, do_numa_crng_init);
+
+static void numa_crng_init(void)
+{
+       schedule_work(&numa_crng_init_work);
+}
 #else
 static void numa_crng_init(void) {}
 #endif