public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Hangyu Hua <hbh25y@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: balbi@kernel.org, gregkh@linuxfoundation.org, axboe@kernel.dk,
	dan.carpenter@oracle.com, jj251510319013@gmail.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: use after free in dev_config
Date: Thu, 30 Dec 2021 10:15:02 +0800	[thread overview]
Message-ID: <dc9d169f-deae-e0a1-4509-a105898f45c0@gmail.com> (raw)
In-Reply-To: <YczPGL/1Er/vh+X6@rowland.harvard.edu>

Thank for your suggesions. I will break this up into two separate 
patches later. And i think it's necessary to clear up dev->config and
dev->hs_config and dev->dev. For example, dev->hs_config is used in
ep0_read() which may lead a UAF.

Thanks.

On 2021/12/30 上午5:11, Alan Stern wrote:
> On Tue, Dec 28, 2021 at 05:21:26PM +0800, Hangyu Hua wrote:
>> There are two bugs:
> 
> You should break this up into two separate patches, one for each bug.
> 
>> dev->buf does not need to be released if it already exists before
>> executing dev_config.
> 
> That's right.  The call to dev_config should fail without changing any
> of the stored values.
> 
>> dev->config and dev->hs_config and dev->dev need to be cleaned if
>> dev_config fails to avoid UAF.
> 
> Do they really need to be cleared?  I think if dev_config fails then
> those pointers never get used, so it doesn't matter what they contain.
> 
> Of course, clearing them doesn't hurt, but it would be best to clear
> all of them in the "fail:" part of the routine.  And then you would
> want to change the pathway where usb_gadget_probe_driver fails, to make
> it go to "fail:" also.
> 
> Alan Stern
> 

      reply	other threads:[~2021-12-30  2:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28  9:21 [PATCH] usb: gadget: use after free in dev_config Hangyu Hua
2021-12-29 21:11 ` Alan Stern
2021-12-30  2:15   ` Hangyu Hua [this message]

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=dc9d169f-deae-e0a1-4509-a105898f45c0@gmail.com \
    --to=hbh25y@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=balbi@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jj251510319013@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --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