From: Oliver Neukum <oneukum@suse.com>
To: syzbot <syzbot+f0fae482604e6d9a87c9@syzkaller.appspotmail.com>,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, pavel.hofman@ivitera.com,
rob@robgreener.com, stern@rowland.harvard.edu,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] memory leak in usb_get_configuration
Date: Thu, 10 Mar 2022 10:51:42 +0100 [thread overview]
Message-ID: <b7bd6b82-03e3-eac8-21f5-1b05c97c98a3@suse.com> (raw)
In-Reply-To: <000000000000351b8605d9d1d1bf@google.com>
[-- Attachment #1: Type: text/plain, Size: 911 bytes --]
On 10.03.22 00:54, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 0014404f9c18 Merge branch 'akpm' (patches from Andrew)
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=15864216700000
> kernel config: https://syzkaller.appspot.com/x/.config?x=3f0a704147ec8e32
> dashboard link: https://syzkaller.appspot.com/bug?extid=f0fae482604e6d9a87c9
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13a63dbe700000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10e150a1700000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+f0fae482604e6d9a87c9@syzkaller.appspotmail.com
>
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0014404f9c18
[-- Attachment #2: 0001-USB-hub-fix-memory-leak-on-failure-of-usb_get_config.patch --]
[-- Type: text/x-patch, Size: 1394 bytes --]
From 785609ab0d95c753dc31267b3c4da585c16e0274 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Thu, 10 Mar 2022 10:40:36 +0100
Subject: [PATCH] USB: hub: fix memory leak on failure of usb_get_config
kfree()s on the error path need to be added.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/usb/core/config.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 48bc8a4814ac..548ce5ca6847 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -885,12 +885,16 @@ int usb_get_configuration(struct usb_device *dev)
length = ncfg * sizeof(char *);
dev->rawdescriptors = kzalloc(length, GFP_KERNEL);
- if (!dev->rawdescriptors)
- return -ENOMEM;
+ if (!dev->rawdescriptors) {
+ result = -ENOMEM;
+ goto err2;
+ }
desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
- if (!desc)
- return -ENOMEM;
+ if (!desc) {
+ result = -ENOMEM;
+ goto err2;
+ }
for (cfgno = 0; cfgno < ncfg; cfgno++) {
/* We grab just the first descriptor so we know how long
@@ -952,6 +956,11 @@ int usb_get_configuration(struct usb_device *dev)
err:
kfree(desc);
dev->descriptor.bNumConfigurations = cfgno;
+err2:
+ kfree(dev->rawdescriptors);
+ kfree(dev->config);
+ dev->rawdescriptors = NULL;
+ dev->config = NULL;
return result;
}
--
2.34.1
next prev parent reply other threads:[~2022-03-10 9:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-09 23:54 syzbot
2022-03-10 9:51 ` Oliver Neukum [this message]
2022-03-10 14:36 ` syzbot
2022-03-10 15:29 ` Alan Stern
2022-03-10 11:07 ` Oliver Neukum
2022-03-10 11:07 ` syzbot
2022-03-11 21:01 ` Alan Stern
2022-03-11 21:10 ` syzbot
2022-03-12 15:08 ` Pavel Skripkin
2022-03-12 15:25 ` Alan Stern
2022-03-12 15:45 ` Pavel Skripkin
2022-03-12 16:02 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7bd6b82-03e3-eac8-21f5-1b05c97c98a3@suse.com \
--to=oneukum@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pavel.hofman@ivitera.com \
--cc=rob@robgreener.com \
--cc=stern@rowland.harvard.edu \
--cc=syzbot+f0fae482604e6d9a87c9@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®