Tetsuo Handa
aafb5e38e6
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-14 09:44:23 +02:00
..
2021-04-14 08:24:11 +02:00
2021-03-04 10:26:24 +01:00
2020-10-29 09:57:44 +01:00
2019-05-21 10:50:46 +02:00
2019-05-21 11:28:46 +02:00
2021-05-11 14:04:15 +02:00
2019-05-21 10:50:46 +02:00
2019-08-28 08:28:39 -05:00
2018-06-05 11:24:55 -07:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-06-09 09:11:21 +02:00
2019-05-21 10:50:45 +02:00
2018-02-11 14:34:03 -08:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-06-05 17:37:13 +02:00
2020-02-24 08:36:59 +01:00
2019-09-16 15:32:01 -07:00
2019-12-13 08:42:17 +01:00
2019-08-16 11:33:56 -07:00
2020-07-29 10:18:43 +02:00
2019-05-24 18:00:41 +02:00
2019-08-16 11:33:56 -07:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2017-11-21 15:57:05 -08:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-12-17 19:56:41 +01:00
2019-05-30 11:26:38 -07:00
2021-03-04 10:26:11 +01:00
2019-05-21 10:50:45 +02:00
2019-05-30 11:26:32 -07:00
2019-05-21 10:50:45 +02:00
2019-05-24 17:36:45 +02:00
2019-05-30 11:26:35 -07:00
2020-10-01 13:17:56 +02:00
2019-09-04 13:42:43 +02:00
2021-05-14 09:44:23 +02:00
2020-11-18 19:20:29 +01:00