All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Oliver Neukum <oneukum@suse.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCHv3] dvb: usb: fix use after free in dvb_usb_device_exit
Date: Tue, 30 Apr 2019 09:32:21 -0300	[thread overview]
Message-ID: <20190430093221.22c18c21@coco.lan> (raw)
In-Reply-To: <20190430121607.4279-1-oneukum@suse.com>

Em Tue, 30 Apr 2019 14:16:07 +0200
Oliver Neukum <oneukum@suse.com> escreveu:

> 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
> 
> 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..48d17736db5d 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 {
> +		memcpy(name, default_name, sizeof(name));

Please use strscpy() here too, as we're using it everywhere 
when a string requires copy inside media.

>  	}
>  	info("%s successfully deinitialized and disconnected.", name);
>  



Thanks,
Mauro

  reply	other threads:[~2019-04-30 12:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30 12:16 [PATCHv3] dvb: usb: fix use after free in dvb_usb_device_exit Oliver Neukum
2019-04-30 12:32 ` Mauro Carvalho Chehab [this message]
2019-05-03  5:10 ` kbuild test robot

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=20190430093221.22c18c21@coco.lan \
    --to=mchehab@kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=oneukum@suse.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 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.