Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3474489imu; Sun, 11 Nov 2018 15:57:07 -0800 (PST) X-Google-Smtp-Source: AJdET5ep+4XdDz5Is4YheR8E88ug7YfiiSXLIYUak+N8CbPvLwAo1tO5OXPTMdMq5wyEaE3lpD3y X-Received: by 2002:a17:902:bd0b:: with SMTP id p11-v6mr17722294pls.35.1541980627603; Sun, 11 Nov 2018 15:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980627; cv=none; d=google.com; s=arc-20160816; b=nPH3DyVciWT6JKK3OcDdE8RJIdBBW41ZrZ0vipc5IJjjLX2Oz1nIZc6Wvz/VB2lU1V /ae8Tk5EtlQ+4K4oobcHiDU2SJ7TC9m/L1D6wlcH96nyFYilDpg8sfQcPkdayDemX46R 6mI8BCDtZlOas6zZ01Ui3xTgSyBqGMV/ch8m3Lyb+cw7BZWEk/JXhZs/0DNB05dZ7KH6 MymSP4aBOHzw5S8BMjyEXfbnmChsdLTirYf2sbalBI1ZkWcA69i7mrwHkPL6dfn9IlEF mDWGdLe4BPjNUgQSrh7N17JGIVnOsWdC23xfx0vvtRvlRd+W9AAFPle5OlA3PmY2fY0h OL/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/4IcMHuKCytyRIK/Ar86iyB3JEOPW6rXrph9/n1TzkE=; b=Hg1JmAck0Fl8HMsvM3n58GQaNjO1cSoQLIb1CNoCksksaftjniWMEWeqT7zOGiHnmE 0G6LoGb5jVaUy8q7fg2I/Kq5qQOLBeKSUbAsES8YwtSN+151vEJ2a9oR61RqJbfd3q7R /5mIgf2+orJt0HN828ZoXwcv3c19dZIa9qzEnP+Ur/4S5cxtajjvauot2Erkjn3Mj8oD V7N8ZPG/9/hNDcY9+WkmTWT23K13UYvOmjMTBIoptq9Qh5h4x8+yKns929M6evqyx/nl Ofvm/7kuAHk15poSvlvmT3haGC4S+Z6rOSKOU4PqNT0NfmiCBFUyu3tEwnBTEA92QBL9 XkBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a3G6KNyT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d82-v6si17043735pfe.190.2018.11.11.15.56.52; Sun, 11 Nov 2018 15:57:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a3G6KNyT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732781AbeKLJqu (ORCPT + 99 others); Mon, 12 Nov 2018 04:46:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:35400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732475AbeKLISN (ORCPT ); Mon, 12 Nov 2018 03:18:13 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB2BA22353; Sun, 11 Nov 2018 22:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975298; bh=uYN9enrZD8/0zvjyzExjf821bQzK/PppLU+22pdh2BI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a3G6KNyThvKxtQbti9mB8FO9oWzT9QjJ70CLpjW/NufPu8Tux0w3IovEogfwr4Qpl zl3iYKHOSwlexMZBKkB/WKzxxGJ9FAnIs6rQcCu54pp91NJ7aehNwPAwd8LQMdw2Ty G/eJwhrYv3Jl4XfJ01tvNaPpn88anydjMAWGo85w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , "Shuah Khan (Samsung OSG)" Subject: [PATCH 4.19 208/361] usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten Date: Sun, 11 Nov 2018 14:19:15 -0800 Message-Id: <20181111221649.319974572@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shuah Khan (Samsung OSG) commit e28fd56ad5273be67d0fae5bedc7e1680e729952 upstream. 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 Signed-off-by: Shuah Khan (Samsung OSG) Cc: Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/vudc_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- 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);