* [PATCH] usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten
@ 2018-10-18 16:19 Shuah Khan (Samsung OSG)
2018-10-18 23:29 ` Randy Dunlap
0 siblings, 1 reply; 2+ messages in thread
From: Shuah Khan (Samsung OSG) @ 2018-10-18 16:19 UTC (permalink / raw)
To: shuah, valentina.manea.m, gregkh, rdunlap; +Cc: linux-usb, linux-kernel, stable
In rmmod path, usbip_vudc does platform_device_put() twice once from
platform_device_unregister() and then from put_vudc_device().
The second put results in:
BUG kmalloc-2048 (Not tainted): Poison overwritten error or
BUG: KASAN: use-after-free in kobject_put+0x1e/0x230 if KASAN is
enabled.
[ 169.042156] calling init+0x0/0x1000 [usbip_vudc] @ 1697
[ 169.042396] =============================================================================
[ 169.043678] probe of usbip-vudc.0 returned 1 after 350 usecs
[ 169.044508] BUG kmalloc-2048 (Not tainted): Poison overwritten
[ 169.044509] -----------------------------------------------------------------------------
...
[ 169.057849] INFO: Freed in device_release+0x2b/0x80 age=4223 cpu=3 pid=1693
[ 169.057852] kobject_put+0x86/0x1b0
[ 169.057853] 0xffffffffc0c30a96
[ 169.057855] __x64_sys_delete_module+0x157/0x240
Fix it to call platform_device_del() instead and let put_vudc_device() do
the platform_device_put().
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Cc: <stable@vger.kernel.org>
---
drivers/usb/usbip/vudc_main.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
index 3fc22037a82f..390733e6937e 100644
--- a/drivers/usb/usbip/vudc_main.c
+++ b/drivers/usb/usbip/vudc_main.c
@@ -73,6 +73,10 @@ static int __init init(void)
cleanup:
list_for_each_entry_safe(udc_dev, udc_dev2, &vudc_devices, dev_entry) {
list_del(&udc_dev->dev_entry);
+ /*
+ * Just do platform_device_del() here, put_vudc_device()
+ * calls the platform_device_put()
+ */
platform_device_del(udc_dev->pdev);
put_vudc_device(udc_dev);
}
@@ -89,7 +93,11 @@ static void __exit cleanup(void)
list_for_each_entry_safe(udc_dev, udc_dev2, &vudc_devices, dev_entry) {
list_del(&udc_dev->dev_entry);
- platform_device_unregister(udc_dev->pdev);
+ /*
+ * Just do platform_device_del() here, put_vudc_device()
+ * calls the platform_device_put()
+ */
+ platform_device_del(udc_dev->pdev);
put_vudc_device(udc_dev);
}
platform_driver_unregister(&vudc_driver);
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten
2018-10-18 16:19 [PATCH] usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten Shuah Khan (Samsung OSG)
@ 2018-10-18 23:29 ` Randy Dunlap
0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2018-10-18 23:29 UTC (permalink / raw)
To: Shuah Khan (Samsung OSG), valentina.manea.m, gregkh
Cc: linux-usb, linux-kernel, stable
On 10/18/18 9:19 AM, Shuah Khan (Samsung OSG) wrote:
> In rmmod path, usbip_vudc does platform_device_put() twice once from
> platform_device_unregister() and then from put_vudc_device().
>
> The second put results in:
>
> BUG kmalloc-2048 (Not tainted): Poison overwritten error or
> BUG: KASAN: use-after-free in kobject_put+0x1e/0x230 if KASAN is
> enabled.
>
> [ 169.042156] calling init+0x0/0x1000 [usbip_vudc] @ 1697
> [ 169.042396] =============================================================================
> [ 169.043678] probe of usbip-vudc.0 returned 1 after 350 usecs
> [ 169.044508] BUG kmalloc-2048 (Not tainted): Poison overwritten
> [ 169.044509] -----------------------------------------------------------------------------
> ...
> [ 169.057849] INFO: Freed in device_release+0x2b/0x80 age=4223 cpu=3 pid=1693
> [ 169.057852] kobject_put+0x86/0x1b0
> [ 169.057853] 0xffffffffc0c30a96
> [ 169.057855] __x64_sys_delete_module+0x157/0x240
>
> Fix it to call platform_device_del() instead and let put_vudc_device() do
> the platform_device_put().
>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
> Cc: <stable@vger.kernel.org>
and
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Thanks.
> ---
> drivers/usb/usbip/vudc_main.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
> index 3fc22037a82f..390733e6937e 100644
> --- a/drivers/usb/usbip/vudc_main.c
> +++ b/drivers/usb/usbip/vudc_main.c
> @@ -73,6 +73,10 @@ static int __init init(void)
> cleanup:
> list_for_each_entry_safe(udc_dev, udc_dev2, &vudc_devices, dev_entry) {
> list_del(&udc_dev->dev_entry);
> + /*
> + * Just do platform_device_del() here, put_vudc_device()
> + * calls the platform_device_put()
> + */
> platform_device_del(udc_dev->pdev);
> put_vudc_device(udc_dev);
> }
> @@ -89,7 +93,11 @@ static void __exit cleanup(void)
>
> list_for_each_entry_safe(udc_dev, udc_dev2, &vudc_devices, dev_entry) {
> list_del(&udc_dev->dev_entry);
> - platform_device_unregister(udc_dev->pdev);
> + /*
> + * Just do platform_device_del() here, put_vudc_device()
> + * calls the platform_device_put()
> + */
> + platform_device_del(udc_dev->pdev);
> put_vudc_device(udc_dev);
> }
> platform_driver_unregister(&vudc_driver);
>
--
~Randy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-19 7:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-18 16:19 [PATCH] usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten Shuah Khan (Samsung OSG)
2018-10-18 23:29 ` Randy Dunlap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox