mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] i8042: Add debug_kbd option
@ 2015-06-25 19:25 cpaul
  2015-06-25 20:00 ` Joe Perches
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: cpaul @ 2015-06-25 19:25 UTC (permalink / raw)
  To: Benjamin Tissoires, linux-kernel, linux-input, Dmitry Torokhov,
	Hans de Goede

From: Stephen Chandler Paul <cpaul@redhat.com>

A big problem with the current i8042 debugging option is that it outputs
data going to and from the keyboard by default. As a result, many dmesg
logs uploaded by users will unintentionally contain sensitive information
such as their password, as such it's probably a good idea not to output
data coming from the keyboard unless specifically enabled by the user.

Signed-off-by: Stephen Chandler Paul <cpaul@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 Documentation/kernel-parameters.txt |  7 +++++++
 drivers/input/serio/i8042.c         | 25 +++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index ae44749..9e00234 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1304,6 +1304,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			     <bus_id>,<clkrate>
 
 	i8042.debug	[HW] Toggle i8042 debug mode
+	i8042.debug_kbd [HW] Enable printing of interrupt data from the KBD port
+			     As a side effect, this option will mask some of the
+			     interrupts sent back from the keyboard during the
+			     initialization of the KBD port on the i8042, if you
+			     need to see this, you will need to enable this
+			     option.
+			     (disabled by default)
 	i8042.direct	[HW] Put keyboard port into non-translated mode
 	i8042.dumbkbd	[HW] Pretend that controller can only read data from
 			     keyboard and cannot control its state
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index cb5ece7..084fc05 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -88,6 +88,23 @@ MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
 static bool i8042_debug;
 module_param_named(debug, i8042_debug, bool, 0600);
 MODULE_PARM_DESC(debug, "Turn i8042 debugging mode on and off");
+
+static bool i8042_debug_kbd;
+module_param_named(debug_kbd, i8042_debug_kbd, bool, 0600);
+MODULE_PARM_DESC(i8042_kbd, "Turn i8042 kbd debugging output on or off");
+
+#define str_dbg(str, data, format, args...)			\
+	do {							\
+		if (!i8042_debug)				\
+			break;					\
+								\
+		if (str & I8042_STR_AUXDATA || i8042_debug_kbd)	\
+			dbg("%02x " format, data, ##args);	\
+		else						\
+			dbg("** " format, ##args);		\
+	} while (0)
+#else
+#define str_dbg(str, data, format, args...) do { } while (0)
 #endif
 
 static bool i8042_bypass_aux_irq_test;
@@ -528,10 +545,10 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id)
 	port = &i8042_ports[port_no];
 	serio = port->exists ? port->serio : NULL;
 
-	dbg("%02x <- i8042 (interrupt, %d, %d%s%s)\n",
-	    data, port_no, irq,
-	    dfl & SERIO_PARITY ? ", bad parity" : "",
-	    dfl & SERIO_TIMEOUT ? ", timeout" : "");
+	str_dbg(str, data, "<- i8042 (interrupt, %d, %d%s%s)\n",
+		port_no, irq,
+		dfl & SERIO_PARITY ? ", bad parity" : "",
+		dfl & SERIO_TIMEOUT ? ", timeout" : "");
 
 	filtered = i8042_filter(data, str, serio);
 
-- 
2.4.3


^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [PATCH v4] i8042: Add debug_kbd option
@ 2015-06-27 20:35 Andreas Mohr
  0 siblings, 0 replies; 13+ messages in thread
From: Andreas Mohr @ 2015-06-27 20:35 UTC (permalink / raw)
  To: Stephen Chandler Paul
  Cc: Benjamin Tissoires, linux-kernel, linux-input, Hans de Goede,
	Dmitry Torokhov

Hi,

[no In-Reply-To header - lkml.org "headers" is broken ATM]

> +
> +static bool i8042_debug_kbd;
> +module_param_named(debug_kbd, i8042_debug_kbd, bool, 0600);
> +MODULE_PARM_DESC(i8042_kbd, "Turn i8042 kbd debugging output on or off
> (requires i8042.debug=1)");

seems inconsistent:
i8042_debug_kbd != debug_kbd != i8042_kbd
While the first two seem perfectly fine,
"i8042_kbd" sounds like a build error or similar to me, on the severity front.

(grepping kernel tree drivers/ on quick glance
does not seem to show any naming deviations in the MODULE_PARM_DESC area)


> "Turn i8042 kbd debugging output on or off (requires i8042.debug=1)"
should be improved to
  "Turn i8042 kbd debugging output on (requires i8042.debug=1)"
(it *is* default-off)
The point is that it
(at least now that it reached current implementation version?)
merely *enables* additional output,
it does *not* actively *disable* (veto)
something which may have been default-enabled elsewhere.


Also, since this is about "special" situations only
(many standard situations already have this output enabled),
it should be worded to somehow include this "special" enabling.

Also, I'd prefer to also see the *reason*
for it being default-disabled in modinfo output.

Also, "i8042" is useless (since completely scope-superfluous) information
(this *is* i8042 driver)

So perhaps wording in total could be something like
"Turn kbd debugging output unconditionally on (may reveal sensitive data)"
or possibly best
"Unconditional enable (may reveal sensitive data) of normally sanitize-filtered kbd data traffic log"

and in combination:
"[DESCRIPTION] (pre-condition: i8042.debug=1 enabled)"

"kbd debugging output"
could be shortened to
"kbd debug log"

So, a final suggestion might be:
"Unconditional enable (may reveal sensitive data) of normally sanitize-filtered kbd data traffic debug log [pre-condition: i8042.debug=1 enabled]"


And given that this description is now completely different,
one might choose to rename debug_kbd variable
to something more specific, too
("debug_full" / "debug_data" / "debug_traffic"?).


> +	i8042.debug_kbd [HW] Enable printing of interrupt data from the
> KBD port
> +			     (disabled by default, requires that
> i8042.debug=1
> +			     be enabled)
is not correct - code implementation definitely conveys
that it needs to be "*and* requires"
(especially since current wording strongly suggests that
*while it's default-disabled*,
i8042.debug_kbd will be implicitly enabled once i8042.debug=1 is available,
which is wrong).

Perhaps write it as something like
"and as pre-condition requires i8042.debug=1 to be enabled too".



Definitely very good to see this (quote) "big problem" corrected!

Thanks,

Andreas Mohr

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

end of thread, other threads:[~2015-06-27 20:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25 19:25 [PATCH] i8042: Add debug_kbd option cpaul
2015-06-25 20:00 ` Joe Perches
2015-06-25 20:32 ` Dmitry Torokhov
2015-06-25 21:31   ` Stephen Chandler Paul
2015-06-25 21:35     ` Dmitry Torokhov
2015-06-25 22:12       ` Stephen Chandler Paul
2015-06-26 19:28 ` [PATCH v2] " cpaul
2015-06-26 22:28 ` [PATCH v3] " cpaul
2015-06-26 23:05   ` Dmitry Torokhov
2015-06-26 23:21     ` Stephen Chandler Paul
2015-06-26 23:24       ` Dmitry Torokhov
2015-06-27  0:24     ` [PATCH v4] " cpaul
2015-06-27 20:35 Andreas Mohr

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

all inboxes | Powered by JetHome®