Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2099231ybl; Thu, 30 Jan 2020 11:20:22 -0800 (PST) X-Google-Smtp-Source: APXvYqw+87TaC4ZpgZMi4qoKXPxNdCkgQJ15aLeV/825z+E7DEHKL8PAebFioS7O6X8TXxOZ7czh X-Received: by 2002:aca:5844:: with SMTP id m65mr3982056oib.136.1580412022484; Thu, 30 Jan 2020 11:20:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580412022; cv=none; d=google.com; s=arc-20160816; b=N3415KmguaVpPrNfz1Rndd+2TBCgSLaUw3K7yML/NBTxsBRcVu2hh27znGWvEaJWyl /aJbxql1McLbpDn+X0aTu5SwcZXYpYfBhvhwhxJEQUcMVWHhIi/lDXMW4f7hbDgCMeep qD/GEFEJRnravGabFv9FU3Pa4p/43QanIG0IZKY/k2qQjgDlLivUbtYB5OVk5rGDtFph +SF6Cc8lKkNLWw9fznjjg2BQ/e4zBIrxrG9iIfYKQwB3qkVGZUYmRMeeH1W2FZ0dE7oc ak2qgSjEaKnZajXulesdg6F+YRENDhTeCxbcS/dLwe/7lkpKu7CQzoVHlBXiwt4/6Z0z UbNA== 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=slwWXycwE4CLO06BTlPWxyrs0eM8w3RSCQDs7jbm0Ec=; b=ArVKeDVNHKpC632ImPF1bQsQ1/SabApIfkWJijM8CZNDeC2t9RRQXEL67b1d4bTTt6 KK4Dy0xLgclIOaYsWmMgA4eCm3lb30Cakb+qUAvKv+TDvz/f5a+gD+Y7iH6suBGQvqDM feF60FdBOr8DbThM7P15m9EgXDyqo2HFYSB9i2Vl7fXmrOoZ91pkF0Uaal5GIUvTCBoM xj4ARBODS7BayhOwM5jNdvRHaN6sjpJ8eo5eNT+VOTAdq/zm1f5p55xvw9VPq9IFR0BV 4ggaTcDLiHZoVKVWh2UWYPkjc+k3rktpam7cinIRttOJqZ00l03Dk+oTW9YNjUwmzEmX GpkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xUuBl+yC; 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 i78si3175173oib.1.2020.01.30.11.20.10; Thu, 30 Jan 2020 11:20:22 -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=xUuBl+yC; 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 S1731234AbgA3Sql (ORCPT + 99 others); Thu, 30 Jan 2020 13:46:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:56716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731205AbgA3Sqg (ORCPT ); Thu, 30 Jan 2020 13:46:36 -0500 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 9011C20674; Thu, 30 Jan 2020 18:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409996; bh=yNI5ogw+07m/kN6nHUW3rK8XJmN2BvbV3VxJy40X4EQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xUuBl+yCR0kB4VIFKLIBgztmevTO8yEhg89biglq8Tdmp1//pe1n4tqPiv0ojJY0I 7w6PBa0JpUakjMJOysuLutdkBXxQgeyJ/8luLziFdmKSJPJKgeB+ZLLLlVodTJWvYS VJKQIKvCnTId5HFEIQqLhiNj6PQ3Ni2a/KX4laWY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+b563b7f8dbe8223a51e8@syzkaller.appspotmail.com, Siva Rebbagondla , Prameela Rani Garnepudi , Amitkumar Karwar , Fariya Fatima , Johan Hovold , Kalle Valo Subject: [PATCH 5.4 100/110] rsi: fix use-after-free on failed probe and unbind Date: Thu, 30 Jan 2020 19:39:16 +0100 Message-Id: <20200130183625.571091732@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Johan Hovold commit e93cd35101b61e4c79149be2cfc927c4b28dc60c upstream. Make sure to stop both URBs before returning after failed probe as well as on disconnect to avoid use-after-free in the completion handler. Reported-by: syzbot+b563b7f8dbe8223a51e8@syzkaller.appspotmail.com Fixes: a4302bff28e2 ("rsi: add bluetooth rx endpoint") Fixes: dad0d04fa7ba ("rsi: Add RS9113 wireless driver") Cc: stable # 3.15 Cc: Siva Rebbagondla Cc: Prameela Rani Garnepudi Cc: Amitkumar Karwar Cc: Fariya Fatima Signed-off-by: Johan Hovold Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/rsi/rsi_91x_usb.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -292,6 +292,15 @@ out: dev_kfree_skb(rx_cb->rx_skb); } +static void rsi_rx_urb_kill(struct rsi_hw *adapter, u8 ep_num) +{ + struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev; + struct rx_usb_ctrl_block *rx_cb = &dev->rx_cb[ep_num - 1]; + struct urb *urb = rx_cb->rx_urb; + + usb_kill_urb(urb); +} + /** * rsi_rx_urb_submit() - This function submits the given URB to the USB stack. * @adapter: Pointer to the adapter structure. @@ -823,10 +832,13 @@ static int rsi_probe(struct usb_interfac if (adapter->priv->coex_mode > 1) { status = rsi_rx_urb_submit(adapter, BT_EP); if (status) - goto err1; + goto err_kill_wlan_urb; } return 0; + +err_kill_wlan_urb: + rsi_rx_urb_kill(adapter, WLAN_EP); err1: rsi_deinit_usb_interface(adapter); err: @@ -857,6 +869,10 @@ static void rsi_disconnect(struct usb_in adapter->priv->bt_adapter = NULL; } + if (adapter->priv->coex_mode > 1) + rsi_rx_urb_kill(adapter, BT_EP); + rsi_rx_urb_kill(adapter, WLAN_EP); + rsi_reset_card(adapter); rsi_deinit_usb_interface(adapter); rsi_91x_deinit(adapter);