All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] memory leak in smsc75xx_bind
@ 2021-05-24  9:12 syzbot
  2021-05-24 19:44 ` Pavel Skripkin
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2021-05-24  9:12 UTC (permalink / raw)
  To: davem, kuba, linux-kernel, linux-usb, netdev, steve.glendinning,
	syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    6ebb6814 Merge tag 'perf-urgent-2021-05-23' of git://git.k..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1334afc7d00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ae7b129a135ab06b
dashboard link: https://syzkaller.appspot.com/bug?extid=b558506ba8165425fee2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11ca4a35d00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b558506ba8165425fee2@syzkaller.appspotmail.com

BUG: memory leak
unreferenced object 0xffff888118ddde40 (size 192):
  comm "kworker/1:2", pid 1931, jiffies 4295045866 (age 18.790s)
  hex dump (first 32 bytes):
    40 39 e7 18 81 88 ff ff 00 00 00 00 00 00 00 00  @9..............
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff84245b62>] kmalloc include/linux/slab.h:556 [inline]
    [<ffffffff84245b62>] kzalloc include/linux/slab.h:686 [inline]
    [<ffffffff84245b62>] smsc75xx_bind+0x7a/0x334 drivers/net/usb/smsc75xx.c:1460
    [<ffffffff82b5b2e6>] usbnet_probe+0x3b6/0xc30 drivers/net/usb/usbnet.c:1728
    [<ffffffff82be65e7>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
    [<ffffffff82624159>] really_probe+0x159/0x500 drivers/base/dd.c:576
    [<ffffffff8262458b>] driver_probe_device+0x8b/0x100 drivers/base/dd.c:763
    [<ffffffff82624cb6>] __device_attach_driver+0xf6/0x120 drivers/base/dd.c:870
    [<ffffffff82621047>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
    [<ffffffff82624832>] __device_attach+0x122/0x260 drivers/base/dd.c:938
    [<ffffffff82622ce6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
    [<ffffffff8261f105>] device_add+0x5d5/0xd70 drivers/base/core.c:3320
    [<ffffffff82be3b89>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
    [<ffffffff82bf3f0c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
    [<ffffffff82be5d4c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
    [<ffffffff82624159>] really_probe+0x159/0x500 drivers/base/dd.c:576
    [<ffffffff8262458b>] driver_probe_device+0x8b/0x100 drivers/base/dd.c:763
    [<ffffffff82624cb6>] __device_attach_driver+0xf6/0x120 drivers/base/dd.c:870

BUG: memory leak
unreferenced object 0xffff888113abcf00 (size 192):
  comm "kworker/1:1", pid 8586, jiffies 4295046670 (age 10.750s)
  hex dump (first 32 bytes):
    40 69 0c 13 81 88 ff ff 00 00 00 00 00 00 00 00  @i..............
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff84245b62>] kmalloc include/linux/slab.h:556 [inline]
    [<ffffffff84245b62>] kzalloc include/linux/slab.h:686 [inline]
    [<ffffffff84245b62>] smsc75xx_bind+0x7a/0x334 drivers/net/usb/smsc75xx.c:1460
    [<ffffffff82b5b2e6>] usbnet_probe+0x3b6/0xc30 drivers/net/usb/usbnet.c:1728
    [<ffffffff82be65e7>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
    [<ffffffff82624159>] really_probe+0x159/0x500 drivers/base/dd.c:576
    [<ffffffff8262458b>] driver_probe_device+0x8b/0x100 drivers/base/dd.c:763
    [<ffffffff82624cb6>] __device_attach_driver+0xf6/0x120 drivers/base/dd.c:870
    [<ffffffff82621047>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
    [<ffffffff82624832>] __device_attach+0x122/0x260 drivers/base/dd.c:938
    [<ffffffff82622ce6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
    [<ffffffff8261f105>] device_add+0x5d5/0xd70 drivers/base/core.c:3320
    [<ffffffff82be3b89>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
    [<ffffffff82bf3f0c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
    [<ffffffff82be5d4c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
    [<ffffffff82624159>] really_probe+0x159/0x500 drivers/base/dd.c:576
    [<ffffffff8262458b>] driver_probe_device+0x8b/0x100 drivers/base/dd.c:763
    [<ffffffff82624cb6>] __device_attach_driver+0xf6/0x120 drivers/base/dd.c:870

BUG: memory leak
unreferenced object 0xffff888118ee1900 (size 192):
  comm "kworker/0:0", pid 8419, jiffies 4295046919 (age 8.260s)
  hex dump (first 32 bytes):
    40 49 0a 19 81 88 ff ff 00 00 00 00 00 00 00 00  @I..............
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff84245b62>] kmalloc include/linux/slab.h:556 [inline]
    [<ffffffff84245b62>] kzalloc include/linux/slab.h:686 [inline]
    [<ffffffff84245b62>] smsc75xx_bind+0x7a/0x334 drivers/net/usb/smsc75xx.c:1460
    [<ffffffff82b5b2e6>] usbnet_probe+0x3b6/0xc30 drivers/net/usb/usbnet.c:1728
    [<ffffffff82be65e7>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
    [<ffffffff82624159>] really_probe+0x159/0x500 drivers/base/dd.c:576
    [<ffffffff8262458b>] driver_probe_device+0x8b/0x100 drivers/base/dd.c:763
    [<ffffffff82624cb6>] __device_attach_driver+0xf6/0x120 drivers/base/dd.c:870
    [<ffffffff82621047>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
    [<ffffffff82624832>] __device_attach+0x122/0x260 drivers/base/dd.c:938
    [<ffffffff82622ce6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
    [<ffffffff8261f105>] device_add+0x5d5/0xd70 drivers/base/core.c:3320
    [<ffffffff82be3b89>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
    [<ffffffff82bf3f0c>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
    [<ffffffff82be5d4c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
    [<ffffffff82624159>] really_probe+0x159/0x500 drivers/base/dd.c:576
    [<ffffffff8262458b>] driver_probe_device+0x8b/0x100 drivers/base/dd.c:763
    [<ffffffff82624cb6>] __device_attach_driver+0xf6/0x120 drivers/base/dd.c:870



---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

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

* Re: [syzbot] memory leak in smsc75xx_bind
  2021-05-24  9:12 [syzbot] memory leak in smsc75xx_bind syzbot
@ 2021-05-24 19:44 ` Pavel Skripkin
  2021-05-24 20:00   ` syzbot
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Skripkin @ 2021-05-24 19:44 UTC (permalink / raw)
  To: syzbot
  Cc: davem, kuba, linux-kernel, linux-usb, netdev, steve.glendinning,
	syzkaller-bugs

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]

On Mon, 24 May 2021 02:12:26 -0700
syzbot <syzbot+b558506ba8165425fee2@syzkaller.appspotmail.com> wrote:

> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    6ebb6814 Merge tag 'perf-urgent-2021-05-23' of
> git://git.k.. git tree:       upstream
> console output:
> https://syzkaller.appspot.com/x/log.txt?x=1334afc7d00000 kernel
> config:  https://syzkaller.appspot.com/x/.config?x=ae7b129a135ab06b
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=b558506ba8165425fee2 syz
> repro:      https://syzkaller.appspot.com/x/repro.syz?x=11ca4a35d00000
> 
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit: Reported-by:
> syzbot+b558506ba8165425fee2@syzkaller.appspotmail.com
> 

#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master



[-- Attachment #2: 0001-net-usb-fix-memory-leak-in-smsc75xx_bind.patch --]
[-- Type: text/x-patch, Size: 1943 bytes --]

From a93ac5c6364b739f96448613d1bc196c11adf61e Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <paskripkin@gmail.com>
Date: Mon, 24 May 2021 22:36:42 +0300
Subject: [PATCH] net: usb: fix memory leak in smsc75xx_bind

Syzbot reported memory leak in smsc75xx_bind().
The problem was is non-freed memory in case of
errors after memory allocation.

backtrace:
  [<ffffffff84245b62>] kmalloc include/linux/slab.h:556 [inline]
  [<ffffffff84245b62>] kzalloc include/linux/slab.h:686 [inline]
  [<ffffffff84245b62>] smsc75xx_bind+0x7a/0x334 drivers/net/usb/smsc75xx.c:1460
  [<ffffffff82b5b2e6>] usbnet_probe+0x3b6/0xc30 drivers/net/usb/usbnet.c:1728

Reported-by: syzbot+b558506ba8165425fee2@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 drivers/net/usb/smsc75xx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index f8cdabb9ef5a..b286993da67c 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -1483,7 +1483,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	ret = smsc75xx_wait_ready(dev, 0);
 	if (ret < 0) {
 		netdev_warn(dev->net, "device not ready in smsc75xx_bind\n");
-		return ret;
+		goto err;
 	}
 
 	smsc75xx_init_mac_address(dev);
@@ -1492,7 +1492,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	ret = smsc75xx_reset(dev);
 	if (ret < 0) {
 		netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret);
-		return ret;
+		goto err;
 	}
 
 	dev->net->netdev_ops = &smsc75xx_netdev_ops;
@@ -1502,6 +1502,10 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 	dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
 	dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE;
 	return 0;
+
+err:
+	kfree(pdata);
+	return ret;
 }
 
 static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
-- 
2.31.1


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

* Re: [syzbot] memory leak in smsc75xx_bind
  2021-05-24 19:44 ` Pavel Skripkin
@ 2021-05-24 20:00   ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2021-05-24 20:00 UTC (permalink / raw)
  To: davem, kuba, linux-kernel, linux-usb, netdev, paskripkin,
	steve.glendinning, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+b558506ba8165425fee2@syzkaller.appspotmail.com

Tested on:

commit:         1434a312 Merge branch 'for-5.13-fixes' of git://git.kernel..
git tree:       upstream
kernel config:  https://syzkaller.appspot.com/x/.config?x=eb6cff3094efa258
dashboard link: https://syzkaller.appspot.com/bug?extid=b558506ba8165425fee2
compiler:       
patch:          https://syzkaller.appspot.com/x/patch.diff?x=15dfdf1dd00000

Note: testing is done by a robot and is best-effort only.

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

end of thread, other threads:[~2021-05-24 20:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24  9:12 [syzbot] memory leak in smsc75xx_bind syzbot
2021-05-24 19:44 ` Pavel Skripkin
2021-05-24 20:00   ` syzbot

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.