xen/console: Don't treat NUL character as the end of the buffer
authorJulien Grall <julien.grall@arm.com>
Tue, 26 Feb 2019 21:39:58 +0000 (21:39 +0000)
committerJulien Grall <julien.grall@arm.com>
Fri, 16 Aug 2019 21:44:19 +0000 (22:44 +0100)
commitb5e6e1ee8da59fe93aa7e403bf1feaf76903e1d0
tree7270458fe2c83f27269a16335a088650d43bc0ea
parent854a49a7486a02edae5b3e53617bace526e9c1b1
xen/console: Don't treat NUL character as the end of the buffer

After upgrading Debian to Buster, I have began to notice console
mangling when using zsh in Dom0. This is happenning because output sent by
zsh to the console may contain NULs in the middle of the buffer.

The actual implementation of CONSOLEIO_write considers that a buffer
always terminate with a NUL and therefore will ignore anything after it.

In general, NULs are perfectly legitimate in terminal streams. For
instance, this could be used for padding slow terminals. See terminfo(5)
section `Delays and Padding`, or search for the pcre '\bpad'.

Other use cases includes using the console for dumping non-human
readable information (e.g debugger, file if no network...). With the
current behavior, the resulting stream will end up to be corrupted.

The documentation for CONSOLEIO_write is pretty limited (to not say
inexistent). From the declaration, the hypercall takes a buffer and size.
So this could lead to think the NUL character is allowed in the middle of
the buffer.

This patch updates the console API to pass the size along the buffer
down so we can remove the reliance on buffer terminating by a NUL
character.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
14 files changed:
xen/arch/arm/early_printk.c
xen/common/gdbstub.c
xen/drivers/char/console.c
xen/drivers/char/consoled.c
xen/drivers/char/serial.c
xen/drivers/char/xen_pv_console.c
xen/drivers/video/lfb.c
xen/drivers/video/lfb.h
xen/drivers/video/vga.c
xen/include/xen/console.h
xen/include/xen/early_printk.h
xen/include/xen/pv_console.h
xen/include/xen/serial.h
xen/include/xen/video.h