linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] printk: Unconditionally unregister boot consoles if in init section
@ 2017-07-06 10:38 Matt Redfearn
  2017-07-06 10:38 ` [PATCH 2/2] serial: earlycon: Make early_con as __initdata Matt Redfearn
  2017-07-07  4:45 ` [PATCH 1/2] printk: Unconditionally unregister boot consoles if in init section Sergey Senozhatsky
  0 siblings, 2 replies; 11+ messages in thread
From: Matt Redfearn @ 2017-07-06 10:38 UTC (permalink / raw)
  To: Petr Mladek, Sergey Senozhatsky, Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Matt Redfearn, Steven Rostedt, linux-kernel

Commit 4c30c6f566c0 ("kernel/printk: do not turn off bootconsole in
printk_late_init() if keep_bootcon") added a check on keep_bootcon to
ensure that boot consoles were kept around until the real console is
registered.
This can lead to problems if the boot console data and code are in the
init section, since it can be freed before the boot console is
deregistered. This was fixed by commit 81cc26f2bd11 ("printk: only
unregister boot consoles when necessary").
The keep_bootcon flag prevents the unregistration of a boot console,
even if it's data and code reside in the init section and are about to
be freed. This can lead to crashes and weird panics when the bootconsole
is accessed after free, especially if page poisoning is in use and the
code / data have been overwritten with a poison value.
To prevent this, always free the boot console if it is within the init
section.

Fixes 81cc26f2bd11 ("printk: only unregister boot consoles when necessary").
Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>

---

 kernel/printk/printk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index a1db38abac5b..b5411f44eed4 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2660,7 +2660,7 @@ static int __init printk_late_init(void)
 	int ret;
 
 	for_each_console(con) {
-		if (!keep_bootcon && con->flags & CON_BOOT) {
+		if (con->flags & CON_BOOT) {
 			/*
 			 * Make sure to unregister boot consoles whose data
 			 * resides in the init section before the init section
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-07-14 21:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-06 10:38 [PATCH 1/2] printk: Unconditionally unregister boot consoles if in init section Matt Redfearn
2017-07-06 10:38 ` [PATCH 2/2] serial: earlycon: Make early_con as __initdata Matt Redfearn
2017-07-07  4:47   ` Sergey Senozhatsky
2017-07-07  4:45 ` [PATCH 1/2] printk: Unconditionally unregister boot consoles if in init section Sergey Senozhatsky
2017-07-07  7:58   ` Matt Redfearn
2017-07-11 12:43     ` Petr Mladek
2017-07-11 14:41       ` Matt Redfearn
2017-07-12 11:11         ` Petr Mladek
2017-07-14 12:40           ` Petr Mladek
2017-07-14 13:58             ` Matt Redfearn
2017-07-14 21:54       ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).