All of lore.kernel.org
 help / color / mirror / Atom feed
* memory leak in lapb_create_cb
@ 2015-12-30 21:00 Dmitry Vyukov
  2016-01-13 16:46 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Vyukov @ 2015-12-30 21:00 UTC (permalink / raw)
  To: David S. Miller, linux-x25, netdev, LKML, Peter Hurley,
	Greg Kroah-Hartman, Jiri Slaby
  Cc: syzkaller, Kostya Serebryany, Alexander Potapenko, Sasha Levin,
	Eric Dumazet

Hello,

The following program leads to a leak of struct lapb_cb:

// autogenerated by syzkaller (http://github.com/google/syzkaller)
#include <unistd.h>
#include <sys/syscall.h>
#include <string.h>
#include <stdint.h>

int main()
{
        syscall(SYS_mmap, 0x20000000ul, 0x10000ul, 0x3ul, 0x32ul,
0xfffffffffffffffful, 0x0ul);
        int fd = syscall(SYS_open, "/dev/ptmx", 0x103002ul, 0x0ul, 0, 0, 0);
        *(uint32_t*)0x20001000 = (uint32_t)0x6;
        syscall(SYS_ioctl, fd, 0x5423ul, 0x20001000ul, 0, 0, 0);
        *(uint32_t*)0x20006ff8 = (uint32_t)0x1;
        *(uint8_t*)0x20006ffc = (uint8_t)0x29c;
        *(uint8_t*)0x20006ffd = (uint8_t)0x3;
        *(uint8_t*)0x20006ffe = (uint8_t)0x4;
        *(uint8_t*)0x20006fff = (uint8_t)0x8;
        *(uint8_t*)0x20007000 = (uint8_t)0x3;
        *(uint8_t*)0x20007001 = (uint8_t)0x1;
        syscall(SYS_ioctl, fd, 0x400442c9ul, 0x20006ff8ul, 0, 0, 0);
        *(uint8_t*)0x20006f64 = (uint8_t)0xe7;
        *(uint8_t*)0x20006f65 = (uint8_t)0xfb49;
        *(uint16_t*)0x20006f66 = (uint16_t)0x3;
        syscall(SYS_ioctl, fd, 0x4b46ul, 0x20006f64ul, 0, 0, 0);
        *(uint16_t*)0x20003000 = (uint16_t)0x8;
        *(uint16_t*)0x20003002 = (uint16_t)0x5;
        *(uint16_t*)0x20003004 = (uint16_t)0x8;
        *(uint16_t*)0x20003006 = (uint16_t)0x3;
        *(uint8_t*)0x20003008 = (uint8_t)0x6;
        *(uint8_t*)0x20003009 = (uint8_t)0x4b8;
        *(uint8_t*)0x2000300a = (uint8_t)0x2;
        *(uint8_t*)0x2000300b = (uint8_t)0x1;
        *(uint32_t*)0x2000300c = (uint32_t)0x5;
        *(uint8_t*)0x20003010 = (uint8_t)0x802;
        syscall(SYS_ioctl, fd, 0x5404ul, 0x20003000ul, 0, 0, 0);
        return 0;
}


unreferenced object 0xffff8800633575d0 (size 512):
  comm "softirq", pid 0, jiffies 4299764624 (age 16.395s)
  hex dump (first 32 bytes):
    00 01 00 00 00 00 ad de 00 02 00 00 00 00 ad de  ................
    c0 a3 d4 34 00 88 ff ff 00 00 00 00 00 00 00 00  ...4............
  backtrace:
    [<ffffffff85c73a22>] kmemleak_alloc+0x72/0xc0 mm/kmemleak.c:915
    [<     inline     >] kmemleak_alloc_recursive include/linux/kmemleak.h:47
    [<     inline     >] slab_post_alloc_hook mm/slub.c:1335
    [<     inline     >] slab_alloc_node mm/slub.c:2594
    [<     inline     >] slab_alloc mm/slub.c:2602
    [<ffffffff816cc6f8>] kmem_cache_alloc_trace+0x138/0x2f0 mm/slub.c:2619
    [<     inline     >] kzalloc include/linux/slab.h:458
    [<     inline     >] lapb_create_cb net/lapb/lapb_iface.c:121
    [<ffffffff852ec5ea>] lapb_register+0xfa/0x590 net/lapb/lapb_iface.c:158
    [<     inline     >] x25_asy_open drivers/net/wan/x25_asy.c:485
    [<ffffffff83a69351>] x25_asy_open_tty+0x431/0x740
drivers/net/wan/x25_asy.c:573
    [<ffffffff82bacd58>] tty_ldisc_open.isra.2+0x78/0xd0
drivers/tty/tty_ldisc.c:447
    [<ffffffff82bad41a>] tty_set_ldisc+0x1ca/0xa30 drivers/tty/tty_ldisc.c:567
    [<     inline     >] tiocsetd drivers/tty/tty_io.c:2650
    [<ffffffff82b9481a>] tty_ioctl+0xb2a/0x2160 drivers/tty/tty_io.c:2883
    [<     inline     >] vfs_ioctl fs/ioctl.c:43
    [<ffffffff81750d41>] do_vfs_ioctl+0x681/0xe40 fs/ioctl.c:607
    [<     inline     >] SYSC_ioctl fs/ioctl.c:622
    [<ffffffff8175158f>] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:613
    [<ffffffff85c8eaf6>] entry_SYSCALL_64_fastpath+0x16/0x7a
arch/x86/entry/entry_64.S:185
    [<ffffffffffffffff>] 0xffffffffffffffff


On commit 8513342170278468bac126640a5d2d12ffbff106 (Dec 28).

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: memory leak in lapb_create_cb
  2015-12-30 21:00 memory leak in lapb_create_cb Dmitry Vyukov
@ 2016-01-13 16:46 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-01-13 16:46 UTC (permalink / raw)
  To: dvyukov
  Cc: linux-x25, netdev, linux-kernel, peter, gregkh, jslaby,
	syzkaller, kcc, glider, sasha.levin, edumazet

From: Dmitry Vyukov <dvyukov@google.com>
Date: Wed, 30 Dec 2015 22:00:44 +0100

> The following program leads to a leak of struct lapb_cb:

I looked into this report a bit, and although I couldn't figure out
how lapb_cb could be leaked, I definitely found an x25_asy object
leak in this driver.

====================
[PATCH] x25_asy: Free x25_asy on x25_asy_open() failure.

Based upon a report by Dmitry Vyukov.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/wan/x25_asy.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index cd39025..1bc5e93 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -571,8 +571,10 @@ static int x25_asy_open_tty(struct tty_struct *tty)
 
 	/* Perform the low-level X.25 async init */
 	err = x25_asy_open(sl->dev);
-	if (err)
+	if (err) {
+		x25_asy_free(sl);
 		return err;
+	}
 	/* Done.  We have linked the TTY line to a channel. */
 	return 0;
 }
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-13 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-30 21:00 memory leak in lapb_create_cb Dmitry Vyukov
2016-01-13 16:46 ` 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.