[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 1/4] xen/console: Don't treat NUL character as the end of the buffer
Hi Stefano, On 10/2/19 2:25 AM, Stefano Stabellini wrote: On Mon, 5 Aug 2019, Julien Grall wrote: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.Hi, 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@xxxxxxx> --- This patch was originally sent standalone [1]. But the series grows to include another bug found in the console code and documentation. Cnhanges in v2: - Switch from unsigned int to size_t. So truncation is avoided. We can decide whether we want explicit truncation later on. - Remove unecessary leading NUL added in dump_console_ring_key - Remove unecessary decoration in sercon_puts - Fix loop in lfb_scroll_puts - use while() rather than do {} while() Change since the standalone version: - Fix early printk on Arm - Fix gdbstub - Remove unecessary leading NUL character added by Xen - Handle DomU console - Rework the commit message Below a small C program to repro the bug on Xen: int main(void) { write(1, "\r\33[0m\0\0\0\0\0\0\0\0\33[27m\33[24m\33[j\33[32mjulien\33[31m@\33[00m\33[36mjuno2-julieng:~\33[37m>", 75); write(1, "\33[K\33[32C\33[01;33m--juno2-julieng-13:44--\33[00m\33[37m\33[55D", 54); write(1, "\33[?2004h", 8); return 0; } Without this patch, the only --juno2-julieng-13:44-- will be printed in yellow. This patch was tested on Arm using serial console. I am not entirely sure whether the video and PV console is correct. I would appreciate help for testing here. [1] https://lists.xenproject.org/archives/html/xen-devel/2019-02/msg01932.htmlAcked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> Thank you for the acked-by. Although, this was already merged 2 months ago. Cheers, -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |