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: <1592835984-28613-2-git-send-email-sumit.garg@linaro.org>
Date:   Mon, 22 Jun 2020 19:56:18 +0530
From:   Sumit Garg <sumit.garg@...aro.org>
To:     kgdb-bugreport@...ts.sourceforge.net, linux-serial@...r.kernel.org
Cc:     gregkh@...uxfoundation.org, daniel.thompson@...aro.org,
        jason.wessel@...driver.com, dianders@...omium.org, jslaby@...e.com,
        linux@...linux.org.uk, linux-kernel@...r.kernel.org,
        Sumit Garg <sumit.garg@...aro.org>
Subject: [PATCH 1/7] serial: kgdb_nmi: Allow NMI console to replace kgdb IO console

Traditionally, kgdb NMI console relied on cmdline option "console=" to
enable/disable consoles. But it didn't took into account DT/ACPI modes
which can also provide default preferred console that can be enabled
prior to kgdb NMI console. And if that default preferred console is
used for debug IO operations as well then it will lead to duplicate
consoles representing same physical serial device which in turn leads
to duplicate printk messages.

In order to avoid this duplication, we need to disable/unregister debug
IO console in case the NMI console is enabled successfully. Also, we
wouldn't like to see beginning boot messages twice, so we need to
remove flag: CON_PRINTBUFFER prior to NMI console registration.

Signed-off-by: Sumit Garg <sumit.garg@...aro.org>
---
 drivers/tty/serial/kgdb_nmi.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 6004c0c..b32c6b1 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -40,6 +40,7 @@ module_param_named(magic, kgdb_nmi_magic, charp, 0600);
 MODULE_PARM_DESC(magic, "magic sequence to enter NMI debugger (default $3#33)");
 
 static atomic_t kgdb_nmi_num_readers = ATOMIC_INIT(0);
+static struct console *orig_dbg_cons;
 
 static int kgdb_nmi_console_setup(struct console *co, char *options)
 {
@@ -352,8 +353,22 @@ int kgdb_register_nmi_console(void)
 		goto err_drv_reg;
 	}
 
+	/*
+	 * If we already have an active debug IO console, and are switching
+	 * to a NMI console, don't print everything out again, since debug IO
+	 * console, and the NMI console are the same physical device, it's
+	 * annoying to see the beginning boot messages twice.
+	 */
+	if (dbg_io_ops->cons && (dbg_io_ops->cons->flags & CON_ENABLED)) {
+		orig_dbg_cons = dbg_io_ops->cons;
+		kgdb_nmi_console.flags &= ~CON_PRINTBUFFER;
+	}
+
 	register_console(&kgdb_nmi_console);
 
+	if (orig_dbg_cons && (kgdb_nmi_console.flags & CON_ENABLED))
+		unregister_console(orig_dbg_cons);
+
 	return 0;
 err_drv_reg:
 	put_tty_driver(kgdb_nmi_tty_driver);
@@ -373,6 +388,9 @@ int kgdb_unregister_nmi_console(void)
 	if (ret)
 		return ret;
 
+	if (orig_dbg_cons)
+		register_console(orig_dbg_cons);
+
 	ret = tty_unregister_driver(kgdb_nmi_tty_driver);
 	if (ret)
 		return ret;
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ