From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C090BC433DF for ; Tue, 7 Jul 2020 15:18:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9564F20663 for ; Tue, 7 Jul 2020 15:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135135; bh=jcT4x3sOkEfC37eVwUQ/OPxOH2St/0use41/zQWHQvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=oEtWHWt584G0pFEnc1ynhA9tWcKB7prgSPoJP1OrNJAhko3snUMi//wXh/dG9iymz YsriMUPabxW+ao1xhOfM8GLkUVM7nNmo8xgM1HnXOAyV/W5/XtgYoqsxYkpH21g11f 2COQ8A9QBCRkeAr4QQHEevTl5UhLfaHV4EM5H/60= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbgGGPSy (ORCPT ); Tue, 7 Jul 2020 11:18:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:58408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729274AbgGGPSx (ORCPT ); Tue, 7 Jul 2020 11:18:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 00C4220773; Tue, 7 Jul 2020 15:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135132; bh=jcT4x3sOkEfC37eVwUQ/OPxOH2St/0use41/zQWHQvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jamigCiKHc/xapXC8m9S4+wZvj+Vmy0sFSHC3feOETRHAePeuRuH1k3TnP3zFyjAN kqn01/c+BcFCpim0EWMQiVsRqDccfNP3RoKTqy1lYZbj4/1i5YBsrlxZ3V/d8ZBsG1 9AN3nnWIUHmqILZGJr3XrN1JsiGC/kA/Kj7SgN6A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+29dc7d4ae19b703ff947@syzkaller.appspotmail.com, Tuomas Tynkkynen , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 04/36] usbnet: smsc95xx: Fix use-after-free after removal Date: Tue, 7 Jul 2020 17:16:56 +0200 Message-Id: <20200707145749.348169173@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707145749.130272978@linuxfoundation.org> References: <20200707145749.130272978@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tuomas Tynkkynen [ Upstream commit b835a71ef64a61383c414d6bf2896d2c0161deca ] Syzbot reports an use-after-free in workqueue context: BUG: KASAN: use-after-free in mutex_unlock+0x19/0x40 kernel/locking/mutex.c:737 mutex_unlock+0x19/0x40 kernel/locking/mutex.c:737 __smsc95xx_mdio_read drivers/net/usb/smsc95xx.c:217 [inline] smsc95xx_mdio_read+0x583/0x870 drivers/net/usb/smsc95xx.c:278 check_carrier+0xd1/0x2e0 drivers/net/usb/smsc95xx.c:644 process_one_work+0x777/0xf90 kernel/workqueue.c:2274 worker_thread+0xa8f/0x1430 kernel/workqueue.c:2420 kthread+0x2df/0x300 kernel/kthread.c:255 It looks like that smsc95xx_unbind() is freeing the structures that are still in use by the concurrently running workqueue callback. Thus switch to using cancel_delayed_work_sync() to ensure the work callback really is no longer active. Reported-by: syzbot+29dc7d4ae19b703ff947@syzkaller.appspotmail.com Signed-off-by: Tuomas Tynkkynen Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/smsc95xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 6e971628bb50a..c3389bd87c654 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1338,7 +1338,7 @@ static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); if (pdata) { - cancel_delayed_work(&pdata->carrier_check); + cancel_delayed_work_sync(&pdata->carrier_check); netif_dbg(dev, ifdown, dev->net, "free pdata\n"); kfree(pdata); pdata = NULL; -- 2.25.1