All of lore.kernel.org
 help / color / mirror / Atom feed
* memory leak in mcba_usb_probe
@ 2020-12-21  8:54 syzbot
  2021-01-10  8:54 ` Bui Quang Minh
  0 siblings, 1 reply; 4+ messages in thread
From: syzbot @ 2020-12-21  8:54 UTC (permalink / raw)
  To: a.darwish, bigeasy, gregkh, linux-kernel, linux-usb, stern,
	syzkaller-bugs, tglx

Hello,

syzbot found the following issue on:

HEAD commit:    467f8165 Merge tag 'close-range-cloexec-unshare-v5.11' of ..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15933e0f500000
kernel config:  https://syzkaller.appspot.com/x/.config?x=37c889fb8b2761af
dashboard link: https://syzkaller.appspot.com/bug?extid=57281c762a3922e14dfe
compiler:       gcc (GCC) 10.1.0-syz 20200507
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14fe2b9b500000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13bd2287500000

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

BUG: memory leak
unreferenced object 0xffff88811101c080 (size 64):
  comm "kworker/0:2", pid 56, jiffies 4294942309 (age 8.240s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<00000000e42b7c1c>] kmalloc include/linux/slab.h:557 [inline]
    [<00000000e42b7c1c>] hcd_buffer_alloc+0x149/0x190 drivers/usb/core/buffer.c:134
    [<0000000042899d1a>] usb_alloc_coherent+0x42/0x60 drivers/usb/core/usb.c:897
    [<00000000abbb04b6>] mcba_usb_start drivers/net/can/usb/mcba_usb.c:644 [inline]
    [<00000000abbb04b6>] mcba_usb_probe+0x27b/0x430 drivers/net/can/usb/mcba_usb.c:846
    [<00000000b5e48b67>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
    [<00000000a0416f71>] really_probe+0x159/0x480 drivers/base/dd.c:561
    [<00000000cce96f4d>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
    [<00000000b0116c0e>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
    [<00000000da4bf16e>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
    [<00000000e826f962>] __device_attach+0x122/0x250 drivers/base/dd.c:919
    [<00000000fb35d32b>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
    [<0000000083f168a1>] device_add+0x5be/0xc30 drivers/base/core.c:3091
    [<000000002b4245b1>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
    [<00000000fa502fa0>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
    [<000000004e1ab3a9>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
    [<00000000a0416f71>] really_probe+0x159/0x480 drivers/base/dd.c:561
    [<00000000cce96f4d>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745

BUG: memory leak
unreferenced object 0xffff88811101c0c0 (size 64):
  comm "kworker/0:2", pid 56, jiffies 4294942309 (age 8.240s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<00000000e42b7c1c>] kmalloc include/linux/slab.h:557 [inline]
    [<00000000e42b7c1c>] hcd_buffer_alloc+0x149/0x190 drivers/usb/core/buffer.c:134
    [<0000000042899d1a>] usb_alloc_coherent+0x42/0x60 drivers/usb/core/usb.c:897
    [<00000000abbb04b6>] mcba_usb_start drivers/net/can/usb/mcba_usb.c:644 [inline]
    [<00000000abbb04b6>] mcba_usb_probe+0x27b/0x430 drivers/net/can/usb/mcba_usb.c:846
    [<00000000b5e48b67>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
    [<00000000a0416f71>] really_probe+0x159/0x480 drivers/base/dd.c:561
    [<00000000cce96f4d>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
    [<00000000b0116c0e>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
    [<00000000da4bf16e>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
    [<00000000e826f962>] __device_attach+0x122/0x250 drivers/base/dd.c:919
    [<00000000fb35d32b>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
    [<0000000083f168a1>] device_add+0x5be/0xc30 drivers/base/core.c:3091
    [<000000002b4245b1>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
    [<00000000fa502fa0>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
    [<000000004e1ab3a9>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
    [<00000000a0416f71>] really_probe+0x159/0x480 drivers/base/dd.c:561
    [<00000000cce96f4d>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745

BUG: memory leak
unreferenced object 0xffff88811101c100 (size 64):
  comm "kworker/0:2", pid 56, jiffies 4294942309 (age 8.240s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<00000000e42b7c1c>] kmalloc include/linux/slab.h:557 [inline]
    [<00000000e42b7c1c>] hcd_buffer_alloc+0x149/0x190 drivers/usb/core/buffer.c:134
    [<0000000042899d1a>] usb_alloc_coherent+0x42/0x60 drivers/usb/core/usb.c:897
    [<00000000abbb04b6>] mcba_usb_start drivers/net/can/usb/mcba_usb.c:644 [inline]
    [<00000000abbb04b6>] mcba_usb_probe+0x27b/0x430 drivers/net/can/usb/mcba_usb.c:846
    [<00000000b5e48b67>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
    [<00000000a0416f71>] really_probe+0x159/0x480 drivers/base/dd.c:561
    [<00000000cce96f4d>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
    [<00000000b0116c0e>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
    [<00000000da4bf16e>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
    [<00000000e826f962>] __device_attach+0x122/0x250 drivers/base/dd.c:919
    [<00000000fb35d32b>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
    [<0000000083f168a1>] device_add+0x5be/0xc30 drivers/base/core.c:3091
    [<000000002b4245b1>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
    [<00000000fa502fa0>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
    [<000000004e1ab3a9>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
    [<00000000a0416f71>] really_probe+0x159/0x480 drivers/base/dd.c:561
    [<00000000cce96f4d>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745



---
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] 4+ messages in thread

* Re: memory leak in mcba_usb_probe
  2020-12-21  8:54 memory leak in mcba_usb_probe syzbot
@ 2021-01-10  8:54 ` Bui Quang Minh
  2021-01-10  8:54   ` [PATCH] can: mcba_usb: Fix memory leak when cancelling urb Bui Quang Minh
  2021-01-10  9:09   ` memory leak in mcba_usb_probe syzbot
  0 siblings, 2 replies; 4+ messages in thread
From: Bui Quang Minh @ 2021-01-10  8:54 UTC (permalink / raw)
  To: syzbot+57281c762a3922e14dfe
  Cc: a.darwish, bigeasy, gregkh, linux-kernel, linux-usb, stern,
	syzkaller-bugs, tglx, minhquangbui99

#syz test: https://github.com/minhbq-99/linux.git 080e743dff190ee8ebec63a13ac33fe8b7e4fc9e


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

* [PATCH] can: mcba_usb: Fix memory leak when cancelling urb
  2021-01-10  8:54 ` Bui Quang Minh
@ 2021-01-10  8:54   ` Bui Quang Minh
  2021-01-10  9:09   ` memory leak in mcba_usb_probe syzbot
  1 sibling, 0 replies; 4+ messages in thread
From: Bui Quang Minh @ 2021-01-10  8:54 UTC (permalink / raw)
  To: syzbot+57281c762a3922e14dfe
  Cc: a.darwish, bigeasy, gregkh, linux-kernel, linux-usb, stern,
	syzkaller-bugs, tglx, minhquangbui99

In mcba_usb_read_bulk_callback(), when we don't resubmit the urb, we
need to deallocate the transfer buffer that is allocated in
mcba_usb_start().

Reported-by: syzbot+57281c762a3922e14dfe@syzkaller.appspotmail.com
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
---
 drivers/net/can/usb/mcba_usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c
index df54eb7d4b36..7375c384cbd2 100644
--- a/drivers/net/can/usb/mcba_usb.c
+++ b/drivers/net/can/usb/mcba_usb.c
@@ -584,6 +584,8 @@ static void mcba_usb_read_bulk_callback(struct urb *urb)
 	case -EPIPE:
 	case -EPROTO:
 	case -ESHUTDOWN:
+		usb_free_coherent(urb->dev, urb->transfer_buffer_length,
+					urb->transfer_buffer, urb->transfer_dma);
 		return;
 
 	default:
-- 
2.17.1


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

* Re: memory leak in mcba_usb_probe
  2021-01-10  8:54 ` Bui Quang Minh
  2021-01-10  8:54   ` [PATCH] can: mcba_usb: Fix memory leak when cancelling urb Bui Quang Minh
@ 2021-01-10  9:09   ` syzbot
  1 sibling, 0 replies; 4+ messages in thread
From: syzbot @ 2021-01-10  9:09 UTC (permalink / raw)
  To: a.darwish, bigeasy, gregkh, linux-kernel, linux-usb,
	minhquangbui99, stern, syzkaller-bugs, tglx

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
memory leak in rxrpc_lookup_local

BUG: memory leak
unreferenced object 0xffff888118b2f300 (size 256):
  comm "syz-executor.5", pid 8860, jiffies 4294944050 (age 373.640s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 0a 00 00 00 00 80 c3 18 81 88 ff ff  ................
  backtrace:
    [<00000000799c996d>] kmalloc include/linux/slab.h:552 [inline]
    [<00000000799c996d>] kzalloc include/linux/slab.h:682 [inline]
    [<00000000799c996d>] rxrpc_alloc_local net/rxrpc/local_object.c:79 [inline]
    [<00000000799c996d>] rxrpc_lookup_local+0x1c1/0x760 net/rxrpc/local_object.c:244
    [<00000000a9547b72>] rxrpc_bind+0x174/0x240 net/rxrpc/af_rxrpc.c:149
    [<00000000c8d0f9b2>] afs_open_socket+0xdb/0x200 fs/afs/rxrpc.c:64
    [<0000000029791b25>] afs_net_init+0x2b4/0x340 fs/afs/main.c:126
    [<000000005937929d>] ops_init+0x4e/0x190 net/core/net_namespace.c:152
    [<0000000064e0e1db>] setup_net+0xde/0x2d0 net/core/net_namespace.c:342
    [<00000000ca4d5a61>] copy_net_ns+0x19f/0x3e0 net/core/net_namespace.c:483
    [<0000000029feabb4>] create_new_namespaces+0x199/0x4f0 kernel/nsproxy.c:110
    [<000000005ce44751>] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [<000000003c257699>] ksys_unshare+0x2fe/0x5c0 kernel/fork.c:2957
    [<000000001788a4be>] __do_sys_unshare kernel/fork.c:3025 [inline]
    [<000000001788a4be>] __se_sys_unshare kernel/fork.c:3023 [inline]
    [<000000001788a4be>] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3023
    [<00000000db77e81f>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    [<0000000052c5dd81>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff888118afb200 (size 256):
  comm "syz-executor.0", pid 8858, jiffies 4294944054 (age 373.600s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 0a 00 00 00 00 00 92 18 81 88 ff ff  ................
  backtrace:
    [<00000000799c996d>] kmalloc include/linux/slab.h:552 [inline]
    [<00000000799c996d>] kzalloc include/linux/slab.h:682 [inline]
    [<00000000799c996d>] rxrpc_alloc_local net/rxrpc/local_object.c:79 [inline]
    [<00000000799c996d>] rxrpc_lookup_local+0x1c1/0x760 net/rxrpc/local_object.c:244
    [<00000000a9547b72>] rxrpc_bind+0x174/0x240 net/rxrpc/af_rxrpc.c:149
    [<00000000c8d0f9b2>] afs_open_socket+0xdb/0x200 fs/afs/rxrpc.c:64
    [<0000000029791b25>] afs_net_init+0x2b4/0x340 fs/afs/main.c:126
    [<000000005937929d>] ops_init+0x4e/0x190 net/core/net_namespace.c:152
    [<0000000064e0e1db>] setup_net+0xde/0x2d0 net/core/net_namespace.c:342
    [<00000000ca4d5a61>] copy_net_ns+0x19f/0x3e0 net/core/net_namespace.c:483
    [<0000000029feabb4>] create_new_namespaces+0x199/0x4f0 kernel/nsproxy.c:110
    [<000000005ce44751>] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [<000000003c257699>] ksys_unshare+0x2fe/0x5c0 kernel/fork.c:2957
    [<000000001788a4be>] __do_sys_unshare kernel/fork.c:3025 [inline]
    [<000000001788a4be>] __se_sys_unshare kernel/fork.c:3023 [inline]
    [<000000001788a4be>] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3023
    [<00000000db77e81f>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    [<0000000052c5dd81>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff8881189f4800 (size 256):
  comm "syz-executor.6", pid 8856, jiffies 4294944054 (age 373.600s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 0a 00 00 00 00 c0 56 18 81 88 ff ff  ..........V.....
  backtrace:
    [<00000000799c996d>] kmalloc include/linux/slab.h:552 [inline]
    [<00000000799c996d>] kzalloc include/linux/slab.h:682 [inline]
    [<00000000799c996d>] rxrpc_alloc_local net/rxrpc/local_object.c:79 [inline]
    [<00000000799c996d>] rxrpc_lookup_local+0x1c1/0x760 net/rxrpc/local_object.c:244
    [<00000000a9547b72>] rxrpc_bind+0x174/0x240 net/rxrpc/af_rxrpc.c:149
    [<00000000c8d0f9b2>] afs_open_socket+0xdb/0x200 fs/afs/rxrpc.c:64
    [<0000000029791b25>] afs_net_init+0x2b4/0x340 fs/afs/main.c:126
    [<000000005937929d>] ops_init+0x4e/0x190 net/core/net_namespace.c:152
    [<0000000064e0e1db>] setup_net+0xde/0x2d0 net/core/net_namespace.c:342
    [<00000000ca4d5a61>] copy_net_ns+0x19f/0x3e0 net/core/net_namespace.c:483
    [<0000000029feabb4>] create_new_namespaces+0x199/0x4f0 kernel/nsproxy.c:110
    [<000000005ce44751>] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [<000000003c257699>] ksys_unshare+0x2fe/0x5c0 kernel/fork.c:2957
    [<000000001788a4be>] __do_sys_unshare kernel/fork.c:3025 [inline]
    [<000000001788a4be>] __se_sys_unshare kernel/fork.c:3023 [inline]
    [<000000001788a4be>] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3023
    [<00000000db77e81f>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    [<0000000052c5dd81>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff888118c34100 (size 256):
  comm "syz-executor.2", pid 8861, jiffies 4294944055 (age 373.590s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 0a 00 00 00 00 40 56 18 81 88 ff ff  .........@V.....
  backtrace:
    [<00000000799c996d>] kmalloc include/linux/slab.h:552 [inline]
    [<00000000799c996d>] kzalloc include/linux/slab.h:682 [inline]
    [<00000000799c996d>] rxrpc_alloc_local net/rxrpc/local_object.c:79 [inline]
    [<00000000799c996d>] rxrpc_lookup_local+0x1c1/0x760 net/rxrpc/local_object.c:244
    [<00000000a9547b72>] rxrpc_bind+0x174/0x240 net/rxrpc/af_rxrpc.c:149
    [<00000000c8d0f9b2>] afs_open_socket+0xdb/0x200 fs/afs/rxrpc.c:64
    [<0000000029791b25>] afs_net_init+0x2b4/0x340 fs/afs/main.c:126
    [<000000005937929d>] ops_init+0x4e/0x190 net/core/net_namespace.c:152
    [<0000000064e0e1db>] setup_net+0xde/0x2d0 net/core/net_namespace.c:342
    [<00000000ca4d5a61>] copy_net_ns+0x19f/0x3e0 net/core/net_namespace.c:483
    [<0000000029feabb4>] create_new_namespaces+0x199/0x4f0 kernel/nsproxy.c:110
    [<000000005ce44751>] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [<000000003c257699>] ksys_unshare+0x2fe/0x5c0 kernel/fork.c:2957
    [<000000001788a4be>] __do_sys_unshare kernel/fork.c:3025 [inline]
    [<000000001788a4be>] __se_sys_unshare kernel/fork.c:3023 [inline]
    [<000000001788a4be>] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3023
    [<00000000db77e81f>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    [<0000000052c5dd81>] entry_SYSCALL_64_after_hwframe+0x44/0xa9



Tested on:

commit:         080e743d can: mcba_usb: Fix memory leak when cancelling urb
git tree:       https://github.com/minhbq-99/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1322c7a8d00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=67a7baec24faba80
dashboard link: https://syzkaller.appspot.com/bug?extid=57281c762a3922e14dfe
compiler:       gcc (GCC) 10.1.0-syz 20200507


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

end of thread, other threads:[~2021-01-10  9:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21  8:54 memory leak in mcba_usb_probe syzbot
2021-01-10  8:54 ` Bui Quang Minh
2021-01-10  8:54   ` [PATCH] can: mcba_usb: Fix memory leak when cancelling urb Bui Quang Minh
2021-01-10  9:09   ` memory leak in mcba_usb_probe 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.