From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751830AbdG0JaC (ORCPT ); Thu, 27 Jul 2017 05:30:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:59251 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751789AbdG0JaA (ORCPT ); Thu, 27 Jul 2017 05:30:00 -0400 Date: Thu, 27 Jul 2017 11:29:57 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: Sergey Senozhatsky , Steven Rostedt , Andrew Morton , Peter Zijlstra , Matt Redfearn , Greg Kroah-Hartman , Jiri Slaby , "David S. Miller" , Alan Cox , "Fabio M. Di Nitto" , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] printk/console: Enhance the check for consoles using init memory Message-ID: <20170727092957.GD3799@pathway.suse.cz> References: <1500036673-7122-1-git-send-email-pmladek@suse.com> <1500036673-7122-3-git-send-email-pmladek@suse.com> <20170726130804.GB2173@jagdpanzerIV.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170726130804.GB2173@jagdpanzerIV.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2017-07-26 22:08:04, Sergey Senozhatsky wrote: > On (07/14/17 14:51), Petr Mladek wrote: > > printk_late_init() is responsible for disabling boot consoles that > > use init memory. It checks the address of struct console for this. > > > > But this is not enough. For example, there are several early > > consoles that have write() method in the init section and > > struct console in the normal section. They are not disabled > > and could cause fancy and hard to debug system states. > > > > It is even more complicated by the macros EARLYCON_DECLARE() and > > OF_EARLYCON_DECLARE() where various struct members are set at > > runtime by the provided setup() function. > > > > I have tried to reproduce this problem and forced the classic uart > > early console to stay using keep_bootcon parameter. In particular > > I used earlycon=uart,io,0x3f8 keep_bootcon console=ttyS0,115200. > > The system did not boot: > > > > [ 1.570496] PM: Image not found (code -22) > > [ 1.570496] PM: Image not found (code -22) > > [ 1.571886] PM: Hibernation image not present or could not be loaded. > > [ 1.571886] PM: Hibernation image not present or could not be loaded. > > [ 1.576407] Freeing unused kernel memory: 2528K > > [ 1.577244] kernel tried to execute NX-protected page - exploit attempt? (uid: 0) > > > > The double lines are caused by having both early uart console and > > ttyS0 console enabled at the same time. The early console stopped > > working when the init memory was freed. Fortunately, the invalid > > call was caught by the NX-protexted page check and did not cause > > any silent fancy problems. > > > > This patch adds a check for many other addresses stored in > > struct console. It omits setup() and match() that are used > > only when the console is registered. Therefore they have > > already been used at this point and there is no reason > > to use them again. > > > > Signed-off-by: Petr Mladek > > Reviewed-by: Sergey Senozhatsky Thanks for the review. I am going to push the two patches into for-4.14 branch so that we could get some testing via linux-next. Best Regards, Petr