* memory leak in lapb_register
@ 2019-05-21 13:43 syzbot
2019-06-16 15:54 ` [PATCH net] lapb: fixed leak of control-blocks Jeremy Sowden
0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2019-05-21 13:43 UTC (permalink / raw)
To: davem, linux-kernel, linux-x25, netdev, syzkaller-bugs
Hello,
syzbot found the following crash on:
HEAD commit: f49aa1de Merge tag 'for-5.2-rc1-tag' of git://git.kernel.o..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1042cd9ca00000
kernel config: https://syzkaller.appspot.com/x/.config?x=61dd9e15a761691d
dashboard link: https://syzkaller.appspot.com/bug?extid=afb980676c836b4a0afa
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11ea4654a00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=100f6f44a00000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+afb980676c836b4a0afa@syzkaller.appspotmail.com
g: Permanently added '10.128.0.195' (ECDSA) to the list of known hosts.
executing program
executing program
BUG: memory leak
unreferenced object 0xffff88810dadc400 (size 256):
comm "softirq", pid 0, jiffies 4294947366 (age 12.720s)
hex dump (first 32 bytes):
00 01 00 00 00 00 ad de 00 02 00 00 00 00 ad de ................
00 20 85 17 81 88 ff ff 00 00 00 00 00 00 00 00 . ..............
backtrace:
[<00000000fe4f5aaf>] kmemleak_alloc_recursive
include/linux/kmemleak.h:55 [inline]
[<00000000fe4f5aaf>] slab_post_alloc_hook mm/slab.h:439 [inline]
[<00000000fe4f5aaf>] slab_alloc mm/slab.c:3326 [inline]
[<00000000fe4f5aaf>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
[<0000000050cea448>] kmalloc include/linux/slab.h:547 [inline]
[<0000000050cea448>] kzalloc include/linux/slab.h:742 [inline]
[<0000000050cea448>] lapb_create_cb net/lapb/lapb_iface.c:121 [inline]
[<0000000050cea448>] lapb_register+0x90/0x1c0 net/lapb/lapb_iface.c:158
[<00000000c0d81e26>] x25_asy_open drivers/net/wan/x25_asy.c:482 [inline]
[<00000000c0d81e26>] x25_asy_open_tty+0x26b/0x2f6
drivers/net/wan/x25_asy.c:572
[<00000000bdec8ae5>] tty_ldisc_open.isra.0+0x40/0x70
drivers/tty/tty_ldisc.c:469
[<000000004f64cfca>] tty_set_ldisc+0x149/0x240
drivers/tty/tty_ldisc.c:596
[<00000000d8b98e91>] tiocsetd drivers/tty/tty_io.c:2332 [inline]
[<00000000d8b98e91>] tty_ioctl+0x366/0xa30 drivers/tty/tty_io.c:2592
[<00000000343f2123>] vfs_ioctl fs/ioctl.c:46 [inline]
[<00000000343f2123>] file_ioctl fs/ioctl.c:509 [inline]
[<00000000343f2123>] do_vfs_ioctl+0x62a/0x810 fs/ioctl.c:696
[<00000000b777b7e5>] ksys_ioctl+0x86/0xb0 fs/ioctl.c:713
[<0000000026d5db65>] __do_sys_ioctl fs/ioctl.c:720 [inline]
[<0000000026d5db65>] __se_sys_ioctl fs/ioctl.c:718 [inline]
[<0000000026d5db65>] __x64_sys_ioctl+0x1e/0x30 fs/ioctl.c:718
[<0000000006a4653e>] do_syscall_64+0x76/0x1a0
arch/x86/entry/common.c:301
[<00000000e706c40e>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
executing program
executing program
---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net] lapb: fixed leak of control-blocks.
2019-05-21 13:43 memory leak in lapb_register syzbot
@ 2019-06-16 15:54 ` Jeremy Sowden
2019-06-17 3:44 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Jeremy Sowden @ 2019-06-16 15:54 UTC (permalink / raw)
To: David S. Miller; +Cc: linux-x25, netdev, syzbot+afb980676c836b4a0afa
lapb_register calls lapb_create_cb, which initializes the control-
block's ref-count to one, and __lapb_insert_cb, which increments it when
adding the new block to the list of blocks.
lapb_unregister calls __lapb_remove_cb, which decrements the ref-count
when removing control-block from the list of blocks, and calls lapb_put
itself to decrement the ref-count before returning.
However, lapb_unregister also calls __lapb_devtostruct to look up the
right control-block for the given net_device, and __lapb_devtostruct
also bumps the ref-count, which means that when lapb_unregister returns
the ref-count is still 1 and the control-block is leaked.
Call lapb_put after __lapb_devtostruct to fix leak.
Reported-by: syzbot+afb980676c836b4a0afa@syzkaller.appspotmail.com
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
net/lapb/lapb_iface.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
index 600d754a1700..3c03f6512c5f 100644
--- a/net/lapb/lapb_iface.c
+++ b/net/lapb/lapb_iface.c
@@ -176,6 +176,7 @@ int lapb_unregister(struct net_device *dev)
lapb = __lapb_devtostruct(dev);
if (!lapb)
goto out;
+ lapb_put(lapb);
lapb_stop_t1timer(lapb);
lapb_stop_t2timer(lapb);
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] lapb: fixed leak of control-blocks.
2019-06-16 15:54 ` [PATCH net] lapb: fixed leak of control-blocks Jeremy Sowden
@ 2019-06-17 3:44 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2019-06-17 3:44 UTC (permalink / raw)
To: jeremy; +Cc: linux-x25, netdev, syzbot+afb980676c836b4a0afa
From: Jeremy Sowden <jeremy@azazel.net>
Date: Sun, 16 Jun 2019 16:54:37 +0100
> lapb_register calls lapb_create_cb, which initializes the control-
> block's ref-count to one, and __lapb_insert_cb, which increments it when
> adding the new block to the list of blocks.
>
> lapb_unregister calls __lapb_remove_cb, which decrements the ref-count
> when removing control-block from the list of blocks, and calls lapb_put
> itself to decrement the ref-count before returning.
>
> However, lapb_unregister also calls __lapb_devtostruct to look up the
> right control-block for the given net_device, and __lapb_devtostruct
> also bumps the ref-count, which means that when lapb_unregister returns
> the ref-count is still 1 and the control-block is leaked.
>
> Call lapb_put after __lapb_devtostruct to fix leak.
>
> Reported-by: syzbot+afb980676c836b4a0afa@syzkaller.appspotmail.com
> Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-17 3:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 13:43 memory leak in lapb_register syzbot
2019-06-16 15:54 ` [PATCH net] lapb: fixed leak of control-blocks Jeremy Sowden
2019-06-17 3:44 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.