From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756199AbcIUPHQ (ORCPT ); Wed, 21 Sep 2016 11:07:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50138 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754413AbcIUPHN (ORCPT ); Wed, 21 Sep 2016 11:07:13 -0400 From: Jiri Olsa To: "Theodore Ts'o" Cc: "H. Peter Anvin" , Greg Price , lkml Subject: [PATCH] random: Fix early crash in credit_entropy_bits Date: Wed, 21 Sep 2016 17:07:11 +0200 Message-Id: <1474470431-27532-1-git-send-email-jolsa@kernel.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 21 Sep 2016 15:07:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa When printing out some early acpi messages I hit bug in work queue code. The system_wq is not initialized at the time acpi_early_init is called and causes irq storm that makes credit_entropy_bits call schedule_work and crash: BUG: unable to handle kernel NULL pointer dereference at 0000000000000102^M IP: [] __queue_work+0x32/0x450^M PGD 0 ^M Oops: 0000 [#1] SMP^M ... Call Trace:^M [ 286.521689] [] ? _raw_write_unlock_irqrestore+0x16/0x20^M [] ? add_interrupt_randomness+0x1c2/0x200^M [] queue_work_on+0x27/0x40^M [] credit_entropy_bits+0x219/0x280^M [] ? __mix_pool_bytes+0x36/0x90^M [] add_interrupt_randomness+0x1c2/0x200^M [] handle_irq_event_percpu+0x40/0x80^M [] handle_irq_event+0x2c/0x50^M [] handle_level_irq+0x83/0x100^M [] handle_irq+0x73/0x120^M [] ? _local_bh_enable+0x21/0x50^M [] do_IRQ+0x4b/0xd0^M [] common_interrupt+0x8c/0x8c^M [ 286.521717] [] ? native_restore_fl+0x6/0x10^M [] console_unlock+0x3ef/0x5d0^M [] ? update_sample+0x6e/0xe0^M [] vprintk_emit+0x2aa/0x520^M [] vprintk_default+0x1f/0x30^M [] printk+0x57/0x73^M [] acpi_os_vprintf+0x3f/0x41^M [] acpi_os_printf+0x52/0x6e^M ... [] acpi_load_tables+0x6c/0xf4^M [] acpi_early_init+0x7a/0xf0^M [] start_kernel+0x3be/0x472^M Preventing this by checking the system_wq has been initialized already. Signed-off-by: Jiri Olsa --- drivers/char/random.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 3efb3bf0ab83..f4dec86c2e25 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -725,7 +725,8 @@ retry: /* If the input pool is getting full, send some * entropy to the blocking pool until it is 75% full. */ - if (entropy_bits > random_write_wakeup_bits && + if (keventd_up() && + entropy_bits > random_write_wakeup_bits && r->initialized && r->entropy_total >= 2*random_read_wakeup_bits) { struct entropy_store *other = &blocking_pool; -- 2.7.4