lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1497358444-30736-4-git-send-email-pmladek@suse.com>
Date:   Tue, 13 Jun 2017 14:54:04 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Aleksey Makarov <aleksey.makarov@...aro.org>,
        Sabrina Dubroca <sd@...asysnail.net>,
        Sudeep Holla <sudeep.holla@....com>,
        linux-kernel@...r.kernel.org,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        Petr Mladek <pmladek@...e.com>
Subject: [PATCH 3/3] printk/console: Always have a preferred console

More consoles can be registered but one might be special. It is the one
with CON_CONSDEV flag set. It must be the first in the console_drivers
list. It is also sometimes called as a preferred one.

It is the console that is associated with /dev/console. It is shown
by "showconsole" binary. But if none of the consoles have CON_CONSDEV
flag set, the state is unclear and "showconsole" is unable to find it:

     showconsole: real console unknown: Success

Documentation/admin-guide/serial-console.rst says that the preferred
console is the last one on the command line. But there already exists
some fallbacks.

First, there is a fallback code that tries to enable any boot
console and one real console if no consoles are configured.
This code always sets CON_CONSDEV if console setup succeeded.

Second, console_unregister() sets the flag CON_CONSDEV for the next
console in the list when a console with this flag is being removed.

Now, the flag is not set if some consoles are configured and
the preferred one is never registered from some reason.

This patch modifies the code that enables the configured consoles.
It sets the CON_CONSDEV flag also when we register the first
console. It causes that one of the registered consoles will
always have CON_CONSDEV flag set.

It might have side effects. The first registered console will be
marked as preferred and kept first in the console_drivers list
until the really preferred one is registered. This might change
the order of consoles in console_drivers list. As a consequence,
another console might be selected when the really preferred one
is unregistered. But this should require some manual intervention.
The order was never guarantied. Therefore it does not look
worth the effort to keep the original order.

Signed-off-by: Petr Mladek <pmladek@...e.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 6e651f68bffd..76b1159f2004 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2483,7 +2483,7 @@ void register_console(struct console *newcon)
 		}
 
 		newcon->flags |= CON_ENABLED;
-		if (i == preferred_console)
+		if (i == preferred_console || !console_drivers)
 			newcon->flags |= CON_CONSDEV;
 		break;
 	}
-- 
1.8.5.6

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ