* memory leak in read_adv_mon_features
@ 2020-08-15 17:19 syzbot
2020-09-08 20:06 ` [Linux-kernel-mentees] [PATCH] Bluetooth: Fix memory leak in read_adv_mon_features() Peilin Ye
0 siblings, 1 reply; 4+ messages in thread
From: syzbot @ 2020-08-15 17:19 UTC (permalink / raw)
To: davem, johan.hedberg, kuba, linux-bluetooth, linux-kernel, marcel,
netdev, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 7fca4dee Merge tag 'powerpc-5.9-2' of git://git.kernel.org..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15ea92a1900000
kernel config: https://syzkaller.appspot.com/x/.config?x=e320bbff976a5cdc
dashboard link: https://syzkaller.appspot.com/bug?extid=f7f6e564f4202d8601c6
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1286db9a900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1143ddf6900000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com
BUG: memory leak
unreferenced object 0xffff88812b18e6e0 (size 32):
comm "syz-executor286", pid 6490, jiffies 4294993450 (age 13.120s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 20 00 10 00 00 00 00 00 ........ .......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000f286b99c>] kmalloc include/linux/slab.h:559 [inline]
[<00000000f286b99c>] read_adv_mon_features+0xa1/0x150 net/bluetooth/mgmt.c:4180
[<00000000f0f16504>] hci_mgmt_cmd net/bluetooth/hci_sock.c:1603 [inline]
[<00000000f0f16504>] hci_sock_sendmsg+0xb01/0xc60 net/bluetooth/hci_sock.c:1738
[<000000001560da71>] sock_sendmsg_nosec net/socket.c:651 [inline]
[<000000001560da71>] sock_sendmsg+0x4c/0x60 net/socket.c:671
[<000000007d7be9f6>] sock_write_iter+0xc5/0x140 net/socket.c:998
[<00000000e3633d41>] call_write_iter include/linux/fs.h:1882 [inline]
[<00000000e3633d41>] new_sync_write+0x173/0x210 fs/read_write.c:503
[<0000000021a87df2>] vfs_write+0x21d/0x280 fs/read_write.c:578
[<0000000003f07ff6>] ksys_write+0xd8/0x120 fs/read_write.c:631
[<0000000003a7df09>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
[<000000005ecd28f6>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
BUG: memory leak
unreferenced object 0xffff88812b18e660 (size 32):
comm "syz-executor286", pid 6495, jiffies 4294993998 (age 7.640s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 20 00 10 00 00 00 00 00 ........ .......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000f286b99c>] kmalloc include/linux/slab.h:559 [inline]
[<00000000f286b99c>] read_adv_mon_features+0xa1/0x150 net/bluetooth/mgmt.c:4180
[<00000000f0f16504>] hci_mgmt_cmd net/bluetooth/hci_sock.c:1603 [inline]
[<00000000f0f16504>] hci_sock_sendmsg+0xb01/0xc60 net/bluetooth/hci_sock.c:1738
[<000000001560da71>] sock_sendmsg_nosec net/socket.c:651 [inline]
[<000000001560da71>] sock_sendmsg+0x4c/0x60 net/socket.c:671
[<000000007d7be9f6>] sock_write_iter+0xc5/0x140 net/socket.c:998
[<00000000e3633d41>] call_write_iter include/linux/fs.h:1882 [inline]
[<00000000e3633d41>] new_sync_write+0x173/0x210 fs/read_write.c:503
[<0000000021a87df2>] vfs_write+0x21d/0x280 fs/read_write.c:578
[<0000000003f07ff6>] ksys_write+0xd8/0x120 fs/read_write.c:631
[<0000000003a7df09>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
[<000000005ecd28f6>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
---
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* [Linux-kernel-mentees] [PATCH] Bluetooth: Fix memory leak in read_adv_mon_features() 2020-08-15 17:19 memory leak in read_adv_mon_features syzbot @ 2020-09-08 20:06 ` Peilin Ye 2020-09-09 7:25 ` [Linux-kernel-mentees] [PATCH v2] " Peilin Ye 0 siblings, 1 reply; 4+ messages in thread From: Peilin Ye @ 2020-09-08 20:06 UTC (permalink / raw) To: Marcel Holtmann, Johan Hedberg Cc: Peilin Ye, Miao-chen Chou, David S. Miller, Jakub Kicinski, Greg Kroah-Hartman, linux-bluetooth, linux-kernel, linux-kernel-mentees, syzkaller-bugs read_adv_mon_features() is leaking memory. Free `rp` before returning. Fixes: e5e1e7fd470c ("Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES") Reported-and-tested-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> --- net/bluetooth/mgmt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5bbe71002fb9..f96251f818fc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4157,7 +4157,7 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, { struct adv_monitor *monitor = NULL; struct mgmt_rp_read_adv_monitor_features *rp = NULL; - int handle; + int handle, err; size_t rp_size = 0; __u32 supported = 0; __u16 num_handles = 0; @@ -4192,9 +4192,13 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, if (num_handles) memcpy(&rp->handles, &handles, (num_handles * sizeof(u16))); - return mgmt_cmd_complete(sk, hdev->id, - MGMT_OP_READ_ADV_MONITOR_FEATURES, - MGMT_STATUS_SUCCESS, rp, rp_size); + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_READ_ADV_MONITOR_FEATURES, + MGMT_STATUS_SUCCESS, rp, rp_size); + + kfree(rp); + + return err; } static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev, -- 2.25.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Linux-kernel-mentees] [PATCH v2] Bluetooth: Fix memory leak in read_adv_mon_features() 2020-09-08 20:06 ` [Linux-kernel-mentees] [PATCH] Bluetooth: Fix memory leak in read_adv_mon_features() Peilin Ye @ 2020-09-09 7:25 ` Peilin Ye 2020-09-11 7:01 ` Marcel Holtmann 0 siblings, 1 reply; 4+ messages in thread From: Peilin Ye @ 2020-09-09 7:25 UTC (permalink / raw) To: Marcel Holtmann, Johan Hedberg Cc: Peilin Ye, Miao-chen Chou, David S. Miller, Jakub Kicinski, Greg Kroah-Hartman, linux-bluetooth, linux-kernel, linux-kernel-mentees, syzkaller-bugs read_adv_mon_features() is leaking memory. Free `rp` before returning. Fixes: e5e1e7fd470c ("Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES") Reported-and-tested-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=f7f6e564f4202d8601c6 Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> --- I forgot the "Link:" tag yesterday. Sorry about that. Change in v2: - add a proper "Link:" tag. net/bluetooth/mgmt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5bbe71002fb9..f96251f818fc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4157,7 +4157,7 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, { struct adv_monitor *monitor = NULL; struct mgmt_rp_read_adv_monitor_features *rp = NULL; - int handle; + int handle, err; size_t rp_size = 0; __u32 supported = 0; __u16 num_handles = 0; @@ -4192,9 +4192,13 @@ static int read_adv_mon_features(struct sock *sk, struct hci_dev *hdev, if (num_handles) memcpy(&rp->handles, &handles, (num_handles * sizeof(u16))); - return mgmt_cmd_complete(sk, hdev->id, - MGMT_OP_READ_ADV_MONITOR_FEATURES, - MGMT_STATUS_SUCCESS, rp, rp_size); + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_READ_ADV_MONITOR_FEATURES, + MGMT_STATUS_SUCCESS, rp, rp_size); + + kfree(rp); + + return err; } static int add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev, -- 2.25.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH v2] Bluetooth: Fix memory leak in read_adv_mon_features() 2020-09-09 7:25 ` [Linux-kernel-mentees] [PATCH v2] " Peilin Ye @ 2020-09-11 7:01 ` Marcel Holtmann 0 siblings, 0 replies; 4+ messages in thread From: Marcel Holtmann @ 2020-09-11 7:01 UTC (permalink / raw) To: Peilin Ye Cc: Johan Hedberg, Miao-chen Chou, David S. Miller, Jakub Kicinski, Greg Kroah-Hartman, linux-bluetooth, open list, linux-kernel-mentees, syzkaller-bugs Hi Peilin, > read_adv_mon_features() is leaking memory. Free `rp` before returning. > > Fixes: e5e1e7fd470c ("Bluetooth: Add handler of MGMT_OP_READ_ADV_MONITOR_FEATURES") > Reported-and-tested-by: syzbot+f7f6e564f4202d8601c6@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?extid=f7f6e564f4202d8601c6 > Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> > --- > I forgot the "Link:" tag yesterday. Sorry about that. > > Change in v2: > - add a proper "Link:" tag. > > net/bluetooth/mgmt.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-11 7:02 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-08-15 17:19 memory leak in read_adv_mon_features syzbot 2020-09-08 20:06 ` [Linux-kernel-mentees] [PATCH] Bluetooth: Fix memory leak in read_adv_mon_features() Peilin Ye 2020-09-09 7:25 ` [Linux-kernel-mentees] [PATCH v2] " Peilin Ye 2020-09-11 7:01 ` Marcel Holtmann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).