Re: [syzbot] memory leak in pty_common_install

From: syzbot
Date: Thu Jun 30 2022 - 02:09:28 EST


syzbot has found a reproducer for the following issue on:

HEAD commit: d9b2ba67917c Merge tag 'platform-drivers-x86-v5.19-3' of g..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1795f0f0080000
kernel config: https://syzkaller.appspot.com/x/.config?x=b6c1840347c4c391
dashboard link: https://syzkaller.appspot.com/bug?extid=bdebcbf44250d75bdd82
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13d01f90080000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=126f34f0080000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+bdebcbf44250d75bdd82@xxxxxxxxxxxxxxxxxxxxxxxxx

Warning: Permanently added '10.128.1.122' (ECDSA) to the list of known hosts.
executing program
executing program
executing program
BUG: memory leak
unreferenced object 0xffff88810222e600 (size 512):
comm "syz-executor149", pid 3615, jiffies 4294954919 (age 12.620s)
hex dump (first 32 bytes):
50 e6 22 02 81 88 ff ff e0 ff ff ff 0f 00 00 00 P.".............
10 e6 22 02 81 88 ff ff 10 e6 22 02 81 88 ff ff ..".......".....
backtrace:
[<ffffffff8262ce09>] kmalloc include/linux/slab.h:600 [inline]
[<ffffffff8262ce09>] pty_common_install+0x59/0x3d0 drivers/tty/pty.c:381
[<ffffffff8261decb>] tty_driver_install_tty drivers/tty/tty_io.c:1307 [inline]
[<ffffffff8261decb>] tty_init_dev.part.0+0x5b/0x2f0 drivers/tty/tty_io.c:1419
[<ffffffff8261e1a0>] tty_init_dev+0x40/0x60 drivers/tty/tty_io.c:1409
[<ffffffff8262cc29>] ptmx_open drivers/tty/pty.c:834 [inline]
[<ffffffff8262cc29>] ptmx_open+0xd9/0x210 drivers/tty/pty.c:800
[<ffffffff815dd68d>] chrdev_open+0x10d/0x340 fs/char_dev.c:414
[<ffffffff815cbf96>] do_dentry_open+0x1e6/0x660 fs/open.c:848
[<ffffffff815f26c1>] do_open fs/namei.c:3520 [inline]
[<ffffffff815f26c1>] path_openat+0x18a1/0x1e70 fs/namei.c:3653
[<ffffffff815f5391>] do_filp_open+0xc1/0x1b0 fs/namei.c:3680
[<ffffffff815cf88d>] do_sys_openat2+0xed/0x260 fs/open.c:1278
[<ffffffff815d02df>] do_sys_open fs/open.c:1294 [inline]
[<ffffffff815d02df>] __do_sys_openat fs/open.c:1310 [inline]
[<ffffffff815d02df>] __se_sys_openat fs/open.c:1305 [inline]
[<ffffffff815d02df>] __x64_sys_openat+0x7f/0xe0 fs/open.c:1305
[<ffffffff845ac915>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff845ac915>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
[<ffffffff8460006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0

BUG: memory leak
unreferenced object 0xffff88810213d400 (size 1024):
comm "syz-executor149", pid 3615, jiffies 4294954919 (age 12.620s)
hex dump (first 32 bytes):
01 54 00 00 01 00 00 00 00 00 00 00 00 00 00 00 .T..............
40 be ca 41 81 88 ff ff 60 65 c5 84 ff ff ff ff @..A....`e......
backtrace:
[<ffffffff8261dbbc>] kmalloc include/linux/slab.h:600 [inline]
[<ffffffff8261dbbc>] kzalloc include/linux/slab.h:733 [inline]
[<ffffffff8261dbbc>] alloc_tty_struct+0x3c/0x2f0 drivers/tty/tty_io.c:3091
[<ffffffff8262ce72>] pty_common_install+0xc2/0x3d0 drivers/tty/pty.c:389
[<ffffffff8261decb>] tty_driver_install_tty drivers/tty/tty_io.c:1307 [inline]
[<ffffffff8261decb>] tty_init_dev.part.0+0x5b/0x2f0 drivers/tty/tty_io.c:1419
[<ffffffff8261e1a0>] tty_init_dev+0x40/0x60 drivers/tty/tty_io.c:1409
[<ffffffff8262cc29>] ptmx_open drivers/tty/pty.c:834 [inline]
[<ffffffff8262cc29>] ptmx_open+0xd9/0x210 drivers/tty/pty.c:800
[<ffffffff815dd68d>] chrdev_open+0x10d/0x340 fs/char_dev.c:414
[<ffffffff815cbf96>] do_dentry_open+0x1e6/0x660 fs/open.c:848
[<ffffffff815f26c1>] do_open fs/namei.c:3520 [inline]
[<ffffffff815f26c1>] path_openat+0x18a1/0x1e70 fs/namei.c:3653
[<ffffffff815f5391>] do_filp_open+0xc1/0x1b0 fs/namei.c:3680
[<ffffffff815cf88d>] do_sys_openat2+0xed/0x260 fs/open.c:1278
[<ffffffff815d02df>] do_sys_open fs/open.c:1294 [inline]
[<ffffffff815d02df>] __do_sys_openat fs/open.c:1310 [inline]
[<ffffffff815d02df>] __se_sys_openat fs/open.c:1305 [inline]
[<ffffffff815d02df>] __x64_sys_openat+0x7f/0xe0 fs/open.c:1305
[<ffffffff845ac915>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff845ac915>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
[<ffffffff8460006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0