console: fix out-of-bounds read in dputc(/dev/*, ...)
Trying to output a single character via
	echo -a /dev/serial0-1
currently results in garbage output after the newline, because console.c's
fops_write discards the buffer length and passes the buffer to
(struct cdev)::puts which only handles NUL-terminated strings.

Fix this by amending (struct cdev)::puts with a new nbytes parameter,
which is correctly propagated. All this functions now return at most the
nbytes parameter they were passed in. This fixes __console_puts, which
used to count new lines twice in its return value.

Fixes: b4f55fcf35 ("console: expose consoles in devfs")
Cc: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent d421771 commit 75a74b5c107b3bc30f9c3836208f4c17f9309eed
@Ahmad Fatoum Ahmad Fatoum authored on 23 Aug 2019
Sascha Hauer committed on 2 Sep 2019
Showing 6 changed files
View
common/console.c
View
common/ratp/ratp.c
View
drivers/serial/efi-stdio.c
View
drivers/serial/serial_efi.c
View
fs/pstore/platform.c
View
include/console.h