[SRU][Cosmic][Bionic][PATCH v1 0/1] Console got stuck using serial tty after logout

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[SRU][Cosmic][Bionic][PATCH v1 0/1] Console got stuck using serial tty after logout

woodrow.shen
From: Woodrow Shen <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1808097

[Impact]
The agetty stopped working using serial tty when user logged out, especially if there is a remained process. The agetty failed to open tty device due to serial port used by previous process was not released.

[Test Case]
1. Run background processes from serial console
$ while true; do sleep 10; done &

2. Log out
$ logout

3. Read journal log by journalctl | tail
Jan 28 16:07:01 ubuntu systemd[1]: Stopped Serial Getty on ttyAMA0.
Jan 28 16:07:01 ubuntu systemd[1]: Started Serial Getty on ttyAMA0.
Jan 28 16:07:02 ubuntu agetty[1643]: /dev/ttyAMA0: not a tty

[Fix]
The upstream has a fix since 4.20-rc6, which turns off TTY_IO_ERROR flag if port comes from console. The commit is cherry-picked by

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/tty/tty_port.c?h=v4.20-rc6&id=2a48602615e0a2f563549c7d5c8d507f904cf96e

[Regression Potential]
Should be none, and it's regression becoz 4.4 kernel didn't have this case.

Chanho Park (1):
  tty: do not set TTY_IO_ERROR flag if console port

 drivers/tty/tty_port.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[SRU][Cosmic][Bionic][PATCH v1 1/1] tty: do not set TTY_IO_ERROR flag if console port

woodrow.shen
From: Chanho Park <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1808097

Since Commit 761ed4a94582 ('tty: serial_core: convert uart_close to use
tty_port_close') and Commit 4dda864d7307 ('tty: serial_core: Fix serial
console crash on port shutdown), a serial port which is used as
console can be stuck when logging out if there is a remained process.
After logged out, agetty will try to grab the serial port but it will
be failed because the previous process did not release the port
correctly. To fix this, TTY_IO_ERROR bit should not be enabled of
tty_port_close if the port is console port.

Reproduce step:
- Run background processes from serial console
$ while true; do sleep 10; done &

- Log out
$ logout
-> Stuck

- Read journal log by journalctl | tail
Jan 28 16:07:01 ubuntu systemd[1]: Stopped Serial Getty on ttyAMA0.
Jan 28 16:07:01 ubuntu systemd[1]: Started Serial Getty on ttyAMA0.
Jan 28 16:07:02 ubuntu agetty[1643]: /dev/ttyAMA0: not a tty

Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
Cc: Geert Uytterhoeven <[hidden email]>
Cc: Rob Herring <[hidden email]>
Cc: Jiri Slaby <[hidden email]>
Signed-off-by: Chanho Park <[hidden email]>
Cc: stable <[hidden email]>
Signed-off-by: Greg Kroah-Hartman <[hidden email]>
(cherry picked from commit 2a48602615e0a2f563549c7d5c8d507f904cf96e)
Signed-off-by: Woodrow Shen <[hidden email]>
---
 drivers/tty/tty_port.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 25d7368..c699d41 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -640,7 +640,8 @@ void tty_port_close(struct tty_port *port, struct tty_struct *tty,
  if (tty_port_close_start(port, tty, filp) == 0)
  return;
  tty_port_shutdown(port, tty);
- set_bit(TTY_IO_ERROR, &tty->flags);
+ if (!port->console)
+ set_bit(TTY_IO_ERROR, &tty->flags);
  tty_port_close_end(port, tty);
  tty_port_tty_set(port, NULL);
 }
--
2.7.4


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU][Cosmic][Bionic][PATCH v1 0/1] Console got stuck using serial tty after logout

Po-Hsu Lin (Sam)
In reply to this post by woodrow.shen
Clean cherry-pick.
Acked-by: Po-Hsu Lin <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK/Cmnt: [SRU][Cosmic][Bionic][PATCH v1 0/1] Console got stuck using serial tty after logout

Wen-chien Jesse Sung
In reply to this post by woodrow.shen
This is already in v4.14.88 so likely it would get merged when Bionic kernel
pulls new stable changes in.

We can either take this one or just wait for the stable update merge.

Acked-By: Wen-chien Jesse Sung <[hidden email]>


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED: [SRU][Cosmic][Bionic][PATCH v1 0/1] Console got stuck using serial tty after logout

Kleber Souza
In reply to this post by woodrow.shen
On 12/12/18 3:13 PM, [hidden email] wrote:

> From: Woodrow Shen <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1808097
>
> [Impact]
> The agetty stopped working using serial tty when user logged out, especially if there is a remained process. The agetty failed to open tty device due to serial port used by previous process was not released.
>
> [Test Case]
> 1. Run background processes from serial console
> $ while true; do sleep 10; done &
>
> 2. Log out
> $ logout
>
> 3. Read journal log by journalctl | tail
> Jan 28 16:07:01 ubuntu systemd[1]: Stopped Serial Getty on ttyAMA0.
> Jan 28 16:07:01 ubuntu systemd[1]: Started Serial Getty on ttyAMA0.
> Jan 28 16:07:02 ubuntu agetty[1643]: /dev/ttyAMA0: not a tty
>
> [Fix]
> The upstream has a fix since 4.20-rc6, which turns off TTY_IO_ERROR flag if port comes from console. The commit is cherry-picked by
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/tty/tty_port.c?h=v4.20-rc6&id=2a48602615e0a2f563549c7d5c8d507f904cf96e
>
> [Regression Potential]
> Should be none, and it's regression becoz 4.4 kernel didn't have this case.
>
> Chanho Park (1):
>   tty: do not set TTY_IO_ERROR flag if console port
>
>  drivers/tty/tty_port.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
Applied to bionic/master-next and cosmic/master-next branches.

Thanks,
Kleber


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team