From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969146AbdAELsP (ORCPT ); Thu, 5 Jan 2017 06:48:15 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38912 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092AbdAELsH (ORCPT ); Thu, 5 Jan 2017 06:48:07 -0500 Date: Thu, 5 Jan 2017 12:47:17 +0100 From: Greg KH To: xinwu.liu@intel.com Cc: arnd@arndb.de, tytso@mit.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] random: fix panic caused by system_wq is not initialization Message-ID: <20170105114717.GA9172@kroah.com> References: <1483606190-32584-1-git-send-email-xinwu.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1483606190-32584-1-git-send-email-xinwu.liu@intel.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 05, 2017 at 04:49:50PM +0800, xinwu.liu@intel.com wrote: > From: "Liu, Xinwu" > > While booting kernel on simulation environment(very slow), > kernel panicked: > > [ 310.837531] BUG: unable to handle kernel NULL pointer dereference at > 0000000000000102 > [ 310.909223] IP: [] __queue_work+0x2d/0x440 > [ 312.023898] Call Trace: > [ 312.046346] > [ 312.064346] [] queue_work_on+0x38/0x80 > [ 312.115177] [] credit_entropy_bits+0x1bf/0x280 > [ 312.168986] [] ?add_interrupt_randomness+0x1c2/0x200 > [ 312.228023] [] add_interrupt_randomness+0x1c2/0x200 > [ 312.285566] [] handle_irq_event_percpu+0x31/0x60 > [ 312.340869] [] handle_irq_event+0x39/0x60 > [ 312.390955] [] handle_edge_irq+0x90/0x150 > [ 312.441039] [] handle_irq+0xad/0x180 > [ 312.487388] [] ? debug_smp_processor_id+0x17/0x20 > [ 312.543433] [] do_IRQ+0x57/0xf0 > [ 312.586064] [] common_interrupt+0x89/0x89 > [ 312.636155] [] ? __do_softirq+0x5c/0x337 > [ 312.685485] [] ? __do_softirq+0xc1/0x337 > [ 312.734829] [] irq_exit+0xa5/0xb0 > [ 312.778935] [] do_IRQ+0x60/0xf0 > [ 312.821567] [] common_interrupt+0x89/0x89 > [ 312.871612] > [ 312.889628] [] ? delay_tsc+0x38/0xc0 > [ 312.938966] [] ? delay_tsc+0x70/0xc0 > [ 312.985320] [] __const_udelay+0x27/0x30 > [ 313.033907] [] timer_irq_works+0x36/0x8f > [ 313.083244] [] setup_IO_APIC+0x30e/0x7da > [ 313.132587] [] ? clear_IO_APIC+0x39/0x60 > [ 313.181929] [] apic_bsp_setup+0x86/0x94 > [ 313.230517] [] native_smp_prepare_cpus+0x26f/0x2e2 > [ 313.287320] [] kernel_init_freeable+0xda/0x227 > [ 313.341127] [] kernel_init+0xe/0x100 > [ 313.387481] [] ret_from_fork+0x1f/0x40 > [ 313.435322] [] ? rest_init+0x90/0x90 > [ 313.481649] Code: 44 00 00 55 48 89 e5 41 57 41 56 41 89 fe 41 55 49 > 89 d5 41 54 49 89 f4 53 48 83 ec 08 89 7d d4 9c 58 f6 c4 02 0f 85 c4 02 > 00 00 <41> f6 84 24 02 01 00 00 01 0f 85 df 02 00 00 41 83 fe 20 0f 84 > [ 313.743052] RIP [] __queue_work+0x2d/0x440 > [ 313.795369] RSP > [ 313.826768] CR2: 0000000000000102 > [ 313.856686] --[ end trace bb738d5d79381553 ]-- > [ 313.897788] Kernel panic - not syncing: Fatal exception in interrupt > > 1. Now, all interrupts will contribute to entropy pool. > 2. System_wq is initialized by early_initcall, but before that > clock event ready long time. > During this period, if entropy gathering by timer interrupt > cramming input pool, migration happends but system_wq isn't > ready, panic hit. > So, do basically check first to avoid this. > > Signed-off-by: Liu, Xinwu > --- > 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 d6876d5..621fcc9 100644 > --- a/drivers/char/random.c > +++ b/drivers/char/random.c > @@ -730,7 +730,8 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) > r->entropy_total >= 2*random_read_wakeup_bits) { > struct entropy_store *other = &blocking_pool; > > - if (other->entropy_count <= > + if (likely(keventd_up()) && > + other->entropy_count <= > 3 * other->poolinfo->poolfracbits / 4) { > schedule_work(&other->push_work); > r->entropy_total = 0; > -- > 1.9.1 Hasn't this patch been rejected multiple times already? Why send it again? greg k-h