Skip to content

Commit 34c1572

Browse files
committed
Merge: CVE-2024-50058: serial: protect uart_port_dtr_rts() in uart_shutdown() too
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5543 JIRA: https://issues.redhat.com/browse/RHEL-63838 CVE: CVE-2024-50058 ``` serial: protect uart_port_dtr_rts() in uart_shutdown() too Commit af224ca (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@kernel.org> Cc: Peter Hurley <peter@hurleysoftware.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20240805102046.307511-3-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 602baba) ``` Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2024-10-22 12:44 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://gitlab.com/cki-project/kernel-workflow/-/issues/new?issue%5Btitle%5D=backporter%20webhook%20issue)</small> Approved-by: John W. Linville <linville@redhat.com> Approved-by: Chris von Recklinghausen <crecklin@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents bd185ba + dfd4779 commit 34c1572

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/tty/serial/serial_core.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,16 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
374374
/*
375375
* Turn off DTR and RTS early.
376376
*/
377-
if (uport && uart_console(uport) && tty) {
378-
uport->cons->cflag = tty->termios.c_cflag;
379-
uport->cons->ispeed = tty->termios.c_ispeed;
380-
uport->cons->ospeed = tty->termios.c_ospeed;
381-
}
377+
if (uport) {
378+
if (uart_console(uport) && tty) {
379+
uport->cons->cflag = tty->termios.c_cflag;
380+
uport->cons->ispeed = tty->termios.c_ispeed;
381+
uport->cons->ospeed = tty->termios.c_ospeed;
382+
}
382383

383-
if (!tty || C_HUPCL(tty))
384-
uart_port_dtr_rts(uport, false);
384+
if (!tty || C_HUPCL(tty))
385+
uart_port_dtr_rts(uport, false);
386+
}
385387

386388
uart_port_shutdown(port);
387389
}

0 commit comments

Comments
 (0)