public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>,
	syzbot+29dc7d4ae19b703ff947@syzkaller.appspotmail.com,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 13/27] usbnet: smsc95xx: Fix use-after-free after removal
Date: Wed,  1 Jul 2020 21:26:01 -0400	[thread overview]
Message-ID: <20200702012615.2701532-13-sashal@kernel.org> (raw)
In-Reply-To: <20200702012615.2701532-1-sashal@kernel.org>

From: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>

[ 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 <tuomas.tynkkynen@iki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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


  parent reply	other threads:[~2020-07-02  1:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02  1:25 [PATCH AUTOSEL 4.19 01/27] regmap: fix alignment issue Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 02/27] ARM: dts: omap4-droid4: Fix spi configuration and increase rate Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 03/27] drm/tegra: hub: Do not enable orphaned window group Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 04/27] gpu: host1x: Detach driver on unregister Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 05/27] btrfs: use kfree() in btrfs_ioctl_get_subvol_info() Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 06/27] net: usb: ax88179_178a: fix packet alignment padding Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 07/27] usb: usbtest: fix missing kfree(dev->buf) in usbtest_disconnect Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 08/27] spi: spidev: fix a race between spidev_release and spidev_remove Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 09/27] spi: spidev: fix a potential use-after-free in spidev_release() Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 10/27] tg3: driver sleeps indefinitely when EEH errors exceed eeh_max_freezes Sasha Levin
2020-07-02  1:25 ` [PATCH AUTOSEL 4.19 11/27] ixgbe: protect ring accesses with READ- and WRITE_ONCE Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 12/27] i40e: " Sasha Levin
2020-07-02  1:26 ` Sasha Levin [this message]
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 14/27] drm: panel-orientation-quirks: Add quirk for Asus T101HA panel Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 15/27] drm: panel-orientation-quirks: Use generic orientation-data for Acer S1003 Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 16/27] s390/kasan: fix early pgm check handler execution Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 17/27] s390/debug: avoid kernel warning on too large number of pages Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 18/27] cifs: Fix double add page to memcg when cifs_readpages Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 19/27] drm/sun4i: mixer: Call of_dma_configure if there's an IOMMU Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 20/27] cifs: update ctime and mtime during truncate Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 21/27] ARM: imx6: add missing put_device() call in imx6q_suspend_init() Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 22/27] scsi: mptscsih: Fix read sense data size Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 23/27] usb: dwc3: pci: Fix reference count leak in dwc3_pci_resume_work Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 24/27] block: release bip in a right way in error path Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 25/27] nvme-rdma: assign completion vector correctly Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 26/27] x86/entry: Increase entry_stack size to a full page Sasha Levin
2020-07-02  1:26 ` [PATCH AUTOSEL 4.19 27/27] kgdb: Avoid suspicious RCU usage warning Sasha Levin

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=20200702012615.2701532-13-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+29dc7d4ae19b703ff947@syzkaller.appspotmail.com \
    --cc=tuomas.tynkkynen@iki.fi \
    /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