From: Alexey Dobriyan Date: Thu, 5 Oct 2023 16:34:21 +0000 (+0300) Subject: serial: initialize retinfo in uart_get_info() X-Git-Tag: v6.7-rc1~75^2~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfb5e0cece70b36bacbe8f888c096e6370a9c6ba;p=thirdparty%2Flinux.git serial: initialize retinfo in uart_get_info() If this check ever triggers static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) { uport = uart_port_check(state); if (!uport) goto out; then all those sysfs users will print stack contents to userspace. Signed-off-by: Alexey Dobriyan Link: https://lore.kernel.org/r/967b9ef1-fb36-48bf-9e6a-1b99af24c052@p183 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 70bf2bec875c5..be74d30cfa9e7 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -775,6 +775,9 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) struct uart_port *uport; int ret = -ENODEV; + /* Initialize structure in case we error out later to prevent any stack info leakage. */ + *retinfo = (struct serial_struct){}; + /* * Ensure the state we copy is consistent and no hardware changes * occur as we go