Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752743AbdGGErH (ORCPT ); Fri, 7 Jul 2017 00:47:07 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33632 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbdGGErG (ORCPT ); Fri, 7 Jul 2017 00:47:06 -0400 Date: Fri, 7 Jul 2017 13:47:12 +0900 From: Sergey Senozhatsky To: Matt Redfearn Cc: Petr Mladek , Sergey Senozhatsky , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] serial: earlycon: Make early_con as __initdata Message-ID: <20170707044712.GC7478@jagdpanzerIV.localdomain> References: <1499337481-19397-1-git-send-email-matt.redfearn@imgtec.com> <1499337481-19397-2-git-send-email-matt.redfearn@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1499337481-19397-2-git-send-email-matt.redfearn@imgtec.com> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2088 Lines: 55 On (07/06/17 11:38), Matt Redfearn wrote: > All early console drivers that may be registered as the earlycon are > marked __init to be placed in the init section. The drivers' code and > data are freed during free_initmem_default() but the early console is > not unregistered in printk_late_init() as the init_section_intersects() > test fails. This leads to the earlycon still being active, potentially > with dangling pointers into the freed init section, which may have been > poisoned by the slab debugger. Attempting to use the boot console after > this will likely lead to weird behaviour and kernel crashes. people want to use early-con as a panic() console fallback. -ss > Fix this by marking the early_con struct __initdata so that the > init_section_intersects() test succeeds and the console is unregistered > in printk_late_init() before the init section is freed. > > The 8250 earlycon, on which the generic earlycon was based, had these > attributes on it's console struct. The switch to the generic > implementation in commit d2fd6810a823 ("tty/serial: convert 8250 to > generic earlycon") appears to have broken unregistraton of the boot > console when its code and data are in __init. > > Fixes: d2fd6810a823 ("tty/serial: convert 8250 to generic earlycon") > Signed-off-by: Matt Redfearn > > --- > > drivers/tty/serial/earlycon.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c > index c3651540e1ba..388aaafcca2b 100644 > --- a/drivers/tty/serial/earlycon.c > +++ b/drivers/tty/serial/earlycon.c > @@ -29,13 +29,13 @@ > > #include > > -static struct console early_con = { > +static struct console early_con __initdata = { > .name = "uart", /* fixed up at earlycon registration */ > .flags = CON_PRINTBUFFER | CON_BOOT, > .index = 0, > }; > > -static struct earlycon_device early_console_dev = { > +static struct earlycon_device early_console_dev __initdata = { > .con = &early_con, > }; > > -- > 2.7.4 >