public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/4] Access console drivers list under console_sem
@ 2019-04-26  5:32 Sergey Senozhatsky
  2019-04-26  5:32 ` [PATCHv2 1/4] printk: factor out __unregister_console() code Sergey Senozhatsky
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Sergey Senozhatsky @ 2019-04-26  5:32 UTC (permalink / raw)
  To: Petr Mladek, Steven Rostedt
  Cc: Andrew Morton, linux-kernel, Sergey Senozhatsky,
	Sergey Senozhatsky

Hello,

        Normally, we grab console_sem lock before we iterate consoles
list, which is necessary if we want to be race free. The only exception
to this rule is console_flush_on_panic(). However, it seems that we are
not fully race free - register_console() iterates console drivers list
in unsafe manner in several places. E.g. the following scenarion:

        CPU0                                    CPU1
        register_console()                      unregister_console()
                                                 console_lock()
          for_each_console()                      // modify console_drivers
            con->foo                                kfree(con)

I factored out register_console() and unregister_console() and now
the bulk of the work is done under console_sem. Both in register
and unregister paths we now have that oddly looking thing

	pr_info("console enabled/disabled");
	console_unlock();
	console_lock();

Which is not really odd, in fact. This is to make sure that we always
print messages on all the consoles.

v2:
- removed outdated comment (Petr)
- factor out register_console() and always run it under console_sem (Petr)
- added a patch which enusures that we always print "console disabled'
  on every console, before we unregister one of them

Sergey Senozhatsky (4):
  printk: factor out __unregister_console() code
  printk: remove invalid register_console() comment
  printk: factor out register_console() code
  printk: make sure we always print console disabled message

 kernel/printk/printk.c | 125 +++++++++++++++++++++++++----------------
 1 file changed, 76 insertions(+), 49 deletions(-)

-- 
2.21.0


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

end of thread, other threads:[~2019-05-27 12:45 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-26  5:32 [PATCHv2 0/4] Access console drivers list under console_sem Sergey Senozhatsky
2019-04-26  5:32 ` [PATCHv2 1/4] printk: factor out __unregister_console() code Sergey Senozhatsky
2019-05-15 13:34   ` Petr Mladek
2019-04-26  5:33 ` [PATCHv2 2/4] printk: remove invalid register_console() comment Sergey Senozhatsky
2019-05-15 13:38   ` Petr Mladek
2019-04-26  5:33 ` [PATCHv2 3/4] printk: factor out register_console() code Sergey Senozhatsky
2019-05-15 14:36   ` Petr Mladek
2019-05-23  6:51     ` Sergey Senozhatsky
2019-05-27 11:42       ` Petr Mladek
2019-04-26  5:33 ` [PATCHv2 4/4] printk: make sure we always print console disabled message Sergey Senozhatsky
2019-04-26  5:44   ` Sergey Senozhatsky
2019-05-15 14:47     ` Petr Mladek
2019-05-23  6:59       ` Sergey Senozhatsky
2019-05-27 12:45         ` Petr Mladek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox