Patch "serial: protect uart_port_dtr_rts() in uart_shutdown() too" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    serial: protect uart_port_dtr_rts() in uart_shutdown() too

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     serial-protect-uart_port_dtr_rts-in-uart_shutdown-to.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit db71acf424c53d642c7f163ba18738efee9d3fbe
Author: Jiri Slaby (SUSE) <jirislaby@xxxxxxxxxx>
Date:   Fri Oct 25 11:05:48 2024 +0000

    serial: protect uart_port_dtr_rts() in uart_shutdown() too
    
    [ Upstream commit 602babaa84d627923713acaf5f7e9a4369e77473 ]
    
    Commit af224ca2df29 (serial: core: Prevent unsafe uart port access, part
    3) added few uport == NULL checks. It added one to uart_shutdown(), so
    the commit assumes, uport can be NULL in there. But right after that
    protection, there is an unprotected "uart_port_dtr_rts(uport, false);"
    call. That is invoked only if HUPCL is set, so I assume that is the
    reason why we do not see lots of these reports.
    
    Or it cannot be NULL at this point at all for some reason :P.
    
    Until the above is investigated, stay on the safe side and move this
    dereference to the if too.
    
    I got this inconsistency from Coverity under CID 1585130. Thanks.
    
    Signed-off-by: Jiri Slaby (SUSE) <jirislaby@xxxxxxxxxx>
    Cc: Peter Hurley <peter@xxxxxxxxxxxxxxxxxx>
    Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240805102046.307511-3-jirislaby@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    [Adapted over commit 5701cb8bf50e ("tty: Call ->dtr_rts() parameter
    active consistently") not in the tree]
    Signed-off-by: Tomas Krcka <krckatom@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 7cd12ea88c0b0..404354727d194 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -286,14 +286,16 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
 		/*
 		 * Turn off DTR and RTS early.
 		 */
-		if (uport && uart_console(uport) && tty) {
-			uport->cons->cflag = tty->termios.c_cflag;
-			uport->cons->ispeed = tty->termios.c_ispeed;
-			uport->cons->ospeed = tty->termios.c_ospeed;
-		}
+		if (uport) {
+			if (uart_console(uport) && tty) {
+				uport->cons->cflag = tty->termios.c_cflag;
+				uport->cons->ispeed = tty->termios.c_ispeed;
+				uport->cons->ospeed = tty->termios.c_ospeed;
+			}
 
-		if (!tty || C_HUPCL(tty))
-			uart_port_dtr_rts(uport, 0);
+			if (!tty || C_HUPCL(tty))
+				uart_port_dtr_rts(uport, 0);
+		}
 
 		uart_port_shutdown(port);
 	}




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux