Tetsuo Handa
c7e812a611
ttyprintk: Add TTY hangup callback.
...
[ Upstream commit c0070e1e60270f6a1e09442a9ab2335f3eaeaad2 ]
syzbot is reporting hung task due to flood of
tty_warn(tty, "%s: tty->count = 1 port count = %d\n", __func__,
port->count);
message [1], for ioctl(TIOCVHANGUP) prevents tty_port_close() from
decrementing port->count due to tty_hung_up_p() == true.
----------
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int i;
int fd[10];
for (i = 0; i < 10; i++)
fd[i] = open("/dev/ttyprintk", O_WRONLY);
ioctl(fd[0], TIOCVHANGUP);
for (i = 0; i < 10; i++)
close(fd[i]);
close(open("/dev/ttyprintk", O_WRONLY));
return 0;
}
----------
When TTY hangup happens, port->count needs to be reset via
"struct tty_operations"->hangup callback.
[1] https://syzkaller.appspot.com/bug?id=39ea6caa479af471183997376dc7e90bc7d64a6a
Reported-by: syzbot <syzbot+43e93968b964e369db0b@syzkaller.appspotmail.com>
Reported-by: syzbot <syzbot+3ed715090790806d8b18@syzkaller.appspotmail.com>
Tested-by: syzbot <syzbot+43e93968b964e369db0b@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: 24b4b67d17c308aa ("add ttyprintk driver")
Link: https://lore.kernel.org/r/17e0652d-89b7-c8c0-fb53-e7566ac9add4@i-love.sakura.ne.jp
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-22 10:40:25 +02:00
..
2021-04-16 11:59:07 +02:00
2020-01-04 13:39:15 +01:00
2020-04-24 07:59:00 +02:00
2019-01-31 08:12:34 +01:00
2017-06-07 12:07:48 +02:00
2020-10-01 20:40:09 +02:00
2016-08-31 14:47:54 +02:00
2019-03-13 14:04:54 -07:00
2016-08-31 14:12:35 +02:00
2016-07-14 16:21:53 +09:00
2019-08-04 09:33:43 +02:00
2019-04-17 08:36:44 +02:00
2017-05-25 15:44:30 +02:00
2016-08-05 09:48:22 -04:00
2019-10-05 12:30:35 +02:00
2016-06-29 17:33:46 +10:00
2019-12-21 10:42:07 +01:00
2021-03-03 17:44:32 +01:00
2016-08-31 14:47:54 +02:00
2016-09-27 21:06:22 -04:00
2016-10-05 18:36:18 -04:00
2016-08-30 14:45:50 +02:00
2020-10-01 20:40:12 +02:00
2021-05-22 10:40:25 +02:00
2020-07-22 09:10:53 +02:00