linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dvb: usb: fix use after free in dvb_usb_device_exit
@ 2019-04-30 13:07 Oliver Neukum
  2019-08-20 18:55 ` Ben Hutchings
  0 siblings, 1 reply; 7+ messages in thread
From: Oliver Neukum @ 2019-04-30 13:07 UTC (permalink / raw)
  To: mchehab, linux-media; +Cc: Oliver Neukum

dvb_usb_device_exit() frees and uses the device name in that order
Fix by storing the name in a buffer before freeing it

v2: fixed style issues
v3: strscpy used and variable names changed
v4: really use strscpy everywhere

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reported-by: syzbot+26ec41e9f788b3eba396@syzkaller.appspotmail.com
---
 drivers/media/usb/dvb-usb/dvb-usb-init.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c
index 99951e02a880..dd063a736df5 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c
@@ -287,12 +287,15 @@ EXPORT_SYMBOL(dvb_usb_device_init);
 void dvb_usb_device_exit(struct usb_interface *intf)
 {
 	struct dvb_usb_device *d = usb_get_intfdata(intf);
-	const char *name = "generic DVB-USB module";
+	const char *default_name = "generic DVB-USB module";
+	char name[40];
 
 	usb_set_intfdata(intf, NULL);
 	if (d != NULL && d->desc != NULL) {
-		name = d->desc->name;
+		strscpy(name, d->desc->name, sizeof(name));
 		dvb_usb_exit(d);
+	} else {
+		strscpy(name, default_name, sizeof(name));
 	}
 	info("%s successfully deinitialized and disconnected.", name);
 
-- 
2.16.4


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

end of thread, other threads:[~2020-04-14 10:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 13:07 [PATCH] dvb: usb: fix use after free in dvb_usb_device_exit Oliver Neukum
2019-08-20 18:55 ` Ben Hutchings
2019-08-21  8:18   ` Oliver Neukum
2019-08-21 12:47     ` Ben Hutchings
2019-08-22 10:41       ` [PATCH] media: dw2102: Fix use after free Anton Vasilyev
2019-08-29 16:56         ` Kees Cook
2020-04-14 10:10           ` Sean Young

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).