From: Shuah Khan <skhan@linuxfoundation.org>
To: Zheng Wang <zyytlz.wz@163.com>, valentina.manea.m@gmail.com
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, hackerzheng666@gmail.com,
1395428693sheep@gmail.com, alex000young@gmail.com,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v2] usbip: vudc: Fix use after free bug in vudc_remove due to race condition
Date: Thu, 16 Mar 2023 12:18:40 -0600 [thread overview]
Message-ID: <a83b2f5f-732c-6d71-3e0c-1dce76076817@linuxfoundation.org> (raw)
In-Reply-To: <20230316180940.1601515-1-zyytlz.wz@163.com>
On 3/16/23 12:09, Zheng Wang wrote:
> In vudc_probe, it calls init_vudc_hw, which bound &udc->timer with v_timer.
>
> When it calls usbip_sockfd_store, it will call v_start_timer to start the
> timer work.
>
> When we call vudc_remove to remove the driver, theremay be a sequence as
> follows:
>
> Fix it by shutdown the timer work before cleanup in vudc_remove.
>
> Note that removing a driver is a root-only operation, and should never
> happen.
>
> CPU0 CPU1
>
> |v_timer
> vudc_remove |
> kfree(udc); |
> //free shost |
> |udc->gadget
> |//use
>
> This bug was found by static analysis.
Tell me which static analysis tool did you use to find this and
the output from the tool.
>
> Fixes: b6a0ca111867 ("usbip: vudc: Add UDC specific ops")
> Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
> ---
> v2:
> - add more details about how the bug was found suggested by Shuah
> ---
> drivers/usb/usbip/vudc_dev.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
> index 2bc428f2e261..33d0991755bb 100644
> --- a/drivers/usb/usbip/vudc_dev.c
> +++ b/drivers/usb/usbip/vudc_dev.c
> @@ -633,6 +633,7 @@ int vudc_remove(struct platform_device *pdev)
> {
> struct vudc *udc = platform_get_drvdata(pdev);
>
> + timer_shutdown_sync(&udc->timer);
> usb_del_gadget_udc(&udc->gadget);
> cleanup_vudc_hw(udc);
> kfree(udc);
thanks,
-- Shuah
next prev parent reply other threads:[~2023-03-16 18:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 18:09 Zheng Wang
2023-03-16 18:18 ` Shuah Khan [this message]
[not found] ` <CAJedcCyb_XP=X=2XzjKJ-ay=mzPdEJEdRsAcU2KbeaQPjLaW3g@mail.gmail.com>
2023-03-16 19:09 ` gregkh
2023-03-17 3:59 ` Zheng Hacker
2023-03-16 23:08 ` kernel 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=a83b2f5f-732c-6d71-3e0c-1dce76076817@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=1395428693sheep@gmail.com \
--cc=alex000young@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hackerzheng666@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=valentina.manea.m@gmail.com \
--cc=zyytlz.wz@163.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®