serial: 8250: null ptr deref in has_acpi_companion
PATCH 1/1 serial: 8250: null ptr deref in has_acpi_companion
uart->port.dev is set in serial8250_register_8250_port if the port number is under the initial CONFIG_SERIAL_8250_RUNTIME_UARTS. If unset, it will depend upon up->port.dev being set by the particular serial driver. A faulty driver might not set this value and this leads to null pointer dereferenced later in has_acpi_companion and later at uart_add_one_port call:
Oops: general protection fault, probably for non-canonical address KASAN: null-ptr-deref in range RIP: 0010:serial8250_register_8250_port+0xd34/0x2030
drivers/tty/serial/8250/8250_core.c
---
For a case of a low level driver not setting this, cf.
drivers/tty/serial/8250/8250_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_core.c +2 -0
@@ -756,6 +756,8 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)if (ret) goto err; } +if (!uart->port.dev) + goto err;if (up->port.flags &UPF_FIXED_TYPE ) uart->port.type = up->port.type;
Signature · 1 line
2.34.1
Jiri Slaby
maintainerHi,
1) the subject says:
[PATCH] serial: 8250: null ptr deref in has_acpi_companion
I read it as you are *adding* a null ptr dereference.
2) do not cut&paste literally the ./scripts/get_maintainer.pl output. I doubt Ingo and Thomas or others will help you with tty :P.
Quoted 27 lines · Filip Jensen
uart->port.devis set inserial8250_register_8250_portif the port number is under the initialCONFIG_SERIAL_8250_RUNTIME_UARTS. If unset, it will depend uponup->port.devbeing set by the particular serial driver. A faulty driver might not set this value and this leads to null pointer dereferenced later inhas_acpi_companionand later atuart_add_one_portcall:Oops: general protection fault, probably for non-canonical address KASAN: null-ptr-deref in range RIP: 0010:serial8250_register_8250_port+0xd34/0x2030
drivers/tty/serial/8250/8250_core.cSigned-off-by Filip Jensen <[email protected]>---
For a case of a low level driver not setting this, cf.
drivers/tty/serial/8250/8250_core.c | 2 ++ 1 file changed, 2 insertions(+)drivers/tty/serial/8250/8250_core.c +0
-0
drivers/tty/serial/8250/8250_core.c int serial8250_register_8250_port(const struct uart_8250_port *up) · line 760
Quoted 5 lines
drivers/tty/serial/8250/8250_core.c +2
-0@@ -756,6 +756,8 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)if (ret) goto err; } +if (!uart->port.dev) + goto err;
So ret actually can be unitialized, right?
thanks,
Signature · 2 lines
js suse labs