mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Vasilyev <vasilyev@ispras.ru>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jussi Kivilinna <jussi.kivilinna@haltian.com>,
	Peter Senna Tschudin <peter.senna@collabora.com>,
	Raz Manor <Raz.Manor@valens.com>,
	Romain Perier <romain.perier@collabora.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org
Subject: Re: [PATCH] udc: Memory leak on error path and use after free
Date: Wed, 16 Aug 2017 19:00:05 +0300	[thread overview]
Message-ID: <682044ba-e4c2-a1b9-3652-a01e81a40ac2@ispras.ru> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1708161125520.3053-100000@iolanthe.rowland.org>



On 16.08.2017 18:29, Alan Stern wrote:
> On Wed, 16 Aug 2017, Anton Vasilyev wrote:
> 
>> gadget_release() is responsible for cleanup dev memory.
>> But if net2280_probe() fails after dev allocation, then
>> gadget_release() become unregistered and dev memory leaks.
> 
> This isn't needed if usb_add_gadget_udc_release() is fixed, right?
> 

No, this situation could appear before call
usb_add_gadget_udc_release().

>> Also net2280_remove() calls usb_del_gadget_udc() which
>> perform schedule_delayed_work() with gadget_release(), so
>> it is possible that dev will be deallocated exactly after
>> this call and leads to use after free.
> 
> Where is there a possible use after free?
> 

net2280_remove() continue work with struct net2280 *dev after call
usb_del_gadget_udc(&dev->gadget), but this net2280 *dev could be
deallocated by gadget_release()

>> The patch moves deallocation from gadget_release() to
>> net2280_remove().
> 
> Alan Stern
> 

-- 
Anton Vasilyev
Linux Verification Center, ISPRAS
web: http://linuxtesting.org
e-mail: vasilyev@ispras.ru

  reply	other threads:[~2017-08-16 16:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16 13:47 Anton Vasilyev
2017-08-16 15:29 ` Alan Stern
2017-08-16 16:00   ` Anton Vasilyev [this message]
2017-08-16 16:35     ` Alan Stern
2017-08-22 15:45       ` Anton Vasilyev
2017-08-22 18:37         ` 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=682044ba-e4c2-a1b9-3652-a01e81a40ac2@ispras.ru \
    --to=vasilyev@ispras.ru \
    --cc=Raz.Manor@valens.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jussi.kivilinna@haltian.com \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.senna@collabora.com \
    --cc=romain.perier@collabora.com \
    --cc=stern@rowland.harvard.edu \
    /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®