public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Stop printk printing non-printable chars
@ 2004-06-18 20:53 matthew-lkml
  2004-06-18 21:08 ` Linus Torvalds
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: matthew-lkml @ 2004-06-18 20:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: torvalds

Hi,

I have had problems recently with the output from dmesg. Somewhere in
the depths of ACPI (drivers/acpi/tables.c:104) the
header->asl_compiler_id contained non-printable characters, and it made
xterm stop displaying any more output. dmesg|less had to be used as less
filters out the duff chars.

The main problem seems to be in ACPI, but I don't see any reason for
printk to even consider printing _any_ non-printable characters at all.
It makes all characters out of the range 32..126 (except for newline)
print as a '?'.

Patch is for 2.6.7.

Matthew


--- linux-2.6.7/kernel/printk.c.orig	2004-06-18 20:44:28.000000000 +0100
+++ linux-2.6.7/kernel/printk.c	2004-06-18 20:53:36.000000000 +0100
@@ -14,6 +14,8 @@
  *     manfreds@colorfullife.com
  * Rewrote bits to get rid of console_lock
  *	01Mar01 Andrew Morton <andrewm@uow.edu.au>
+ * Stop emit_log_char from emitting non-ASCII chars.
+ *  Matthew Newton, 18 June 2004 <matthew-lkml@newtoncomputing.co.uk>
  */
 
 #include <linux/kernel.h>
@@ -538,7 +540,11 @@
 			}
 			log_level_unknown = 0;
 		}
-		emit_log_char(*p);
+		if (p[0] != '\n' && (p[0] < 32 || p[0] > 126)) {
+			emit_log_char('?');
+		} else {
+			emit_log_char(*p);
+		}
 		if (*p == '\n')
 			log_level_unknown = 1;
 	}



^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: [PATCH] Stop printk printing non-printable chars
@ 2004-06-19 20:12 Albert Cahalan
  2004-06-19 22:56 ` Jan-Benedict Glaw
  0 siblings, 1 reply; 25+ messages in thread
From: Albert Cahalan @ 2004-06-19 20:12 UTC (permalink / raw)
  To: linux-kernel mailing list; +Cc: dwmw2

David Woodhouse writes:

> Please don't do that -- it makes printing UTF-8 impossible.
> While I'd not argue that now is the time to start outputting
> UTF-8 all over the place, I wouldn't accept that it's a good
> time to _prevent_ it either, as your patch would do.
>
> If you want to post-process printk output, don't do it in the kernel. 

It is dangerous to let the 0x9b character go out
to a serial console. It means the same as ESC [ does
when you have a normal 8-bit terminal.

Non-cannonical UTF-8 encoding for ESC and other
troublesome characters may also cause problems.



^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: [PATCH] Stop printk printing non-printable chars
@ 2004-06-20  4:02 Albert Cahalan
  2004-06-20  8:38 ` David Woodhouse
  2004-06-20  8:49 ` Jan-Benedict Glaw
  0 siblings, 2 replies; 25+ messages in thread
From: Albert Cahalan @ 2004-06-20  4:02 UTC (permalink / raw)
  To: linux-kernel mailing list
  Cc: jbglaw, dwmw2, arjanv, Linus Torvalds, jbglaw, matthew-lkml

>> It is dangerous to let the 0x9b character go out
>> to a serial console. It means the same as ESC [ does
>> when you have a normal 8-bit terminal.
>
> Get real: either you *want* to get those codes
> interpreted (think about full-blown ncurses apps
> being run over serial link), or you *don't* (think
> about simply recording serial console's output).
> You just have to choose the correct application
> for your task.

If there are full-blown ncurses apps being routed
through printk -- that is, the KERNEL log -- then
we have far bigger issues.

The 0x9b character must be blocked, at least when
a serial console is in use. (apps on such a console
may of course use 0x9b as desired -- just not printk)





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

end of thread, other threads:[~2004-06-21 13:09 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-18 20:53 [PATCH] Stop printk printing non-printable chars matthew-lkml
2004-06-18 21:08 ` Linus Torvalds
2004-06-18 22:44   ` Jesper Juhl
2004-06-18 23:52     ` matthew-lkml
2004-06-19  4:18       ` Willy Tarreau
2004-06-19 10:27         ` Matthias Urlichs
2004-06-19 23:00       ` Dave Jones
2004-06-19  1:23     ` Matthias Urlichs
2004-06-19  1:43       ` Jesper Juhl
2004-06-19 10:20         ` Matthias Urlichs
2004-06-18 21:32 ` Jan-Benedict Glaw
2004-06-18 21:58   ` Pekka Pietikainen
2004-06-19  0:03   ` matthew-lkml
2004-06-19  8:31     ` Jan-Benedict Glaw
2004-06-19 11:18 ` David Woodhouse
2004-06-19 15:49   ` matthew-lkml
2004-06-19 16:09     ` Arjan van de Ven
2004-06-20  2:19     ` Horst von Brand
2004-06-20 14:17     ` David Woodhouse
2004-06-20 20:06       ` Jeff Woods
  -- strict thread matches above, loose matches on Subject: below --
2004-06-19 20:12 Albert Cahalan
2004-06-19 22:56 ` Jan-Benedict Glaw
2004-06-20  4:02 Albert Cahalan
2004-06-20  8:38 ` David Woodhouse
2004-06-20  8:49 ` Jan-Benedict Glaw

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