Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3487745imu; Sun, 11 Nov 2018 16:13:09 -0800 (PST) X-Google-Smtp-Source: AJdET5fTh6lV+GWUV4oE5w9K+0WT8XH99XaiPC6FyIxeoBF4vAFqBZ2igVjWXKxevwtR/yOfzVPz X-Received: by 2002:a17:902:a81:: with SMTP id 1-v6mr3155867plp.20.1541981589462; Sun, 11 Nov 2018 16:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981589; cv=none; d=google.com; s=arc-20160816; b=lHaXXvBRhg+lgn2xSYyCQu9VS2GQlLuZfdSdvFlTelNFQDX53NOw8Vlmm6LPVsfmZv ZPAMadlkDKMFxn2iDVcTtKXWuuLcJpV0u+h3jDE6/uh4sLRDaO3fIaRAwyL8Jc4vPFcQ O6ubOrJr1q6dOLlUhlNQpqywufcwYT4VMmVsjoGXM9u6JBEVBjTbhsxh0GHTAAukHwBm FbVo2XiOa4niSSSslTEf1RZCwETmvnl6BnrfuzECta4Uq2wWV5jiLTXbzf2Eu+jy8Pyy CFG5dtkKpMG5II8FDhJvPovSu8s74SVdCgiAVfFouMKtBeyG6xic2WVWO1L5RrL/Pmmb LrYQ== 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=X4Fgi9yAM1Fd8HBoT+2XYoayVnk2qdCje8IydrpFNzY=; b=IBV3/J79RYRvNGJynsLQqA0n00Ol+z4qpoPVvBwiloSiQwkkNm+FWy7KVHRZMvw5py LXFl2MkglzUdDiDbi0tNi7i1L6MvRpA4VMC+YKPUFeRdZhIqUyD29sWyEJ3ZKZmqmrBD qewLeJ7g0qv/eTSjLKK9CG1yAT7fO0hUGwEXotih/OQmB3RHyDBRjW/UvD1g/PSaF7ZH amFYQvhtDBnmpEZftJUVNYm/Xo4qY7SZlDbLTbCovO4vv7cJjvdhrBHwAqKWOcW7uHxY LovZv3Dm1UG5vUUsrPZ/2Cgr9gVo+ZppFm6j6m6540ZZhimRIi58I4pue41hdHYj1ykv gCxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NkWoaA8y; 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 133si13803959pge.246.2018.11.11.16.12.54; Sun, 11 Nov 2018 16:13:09 -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=NkWoaA8y; 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 S1731423AbeKLKCl (ORCPT + 99 others); Mon, 12 Nov 2018 05:02:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:60196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730598AbeKLIRT (ORCPT ); Mon, 12 Nov 2018 03:17:19 -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 9E32221722; Sun, 11 Nov 2018 22:27:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975243; bh=mLokdsEVT/NaxJxslSeSnBN/TRCuPQcHAV4S4czoBvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NkWoaA8yY4p2KtEH56a+JRXjceqoAsV9WTbA/hE+0N0sKFC3r4gzwV56v1XZD/W8H Jzy/BM4CMv8h0cAh6zDky69J3ibiHg+iY6bs7Les0ueRX6NRB+HemS7CQOUihx1Im1 HD1oBvC2iluUfByC6xmFAsGXALVqnzP+vb3UqF7U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Balakrishna Godavarthi , Marcel Holtmann , Sasha Levin Subject: [PATCH 4.19 092/361] Bluetooth: hci_qca: Remove hdev dereference in qca_close(). Date: Sun, 11 Nov 2018 14:17:19 -0800 Message-Id: <20181111221632.633226379@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: Balakrishna Godavarthi [ Upstream commit c2d7827338618a9e73a3f892ca63d9082bb7a94d ] When flag KASAN is set, we are seeing an following crash while removing hci_uart module. [ 50.589909] Unable to handle kernel paging request at virtual address 6b6b6b6b6b6b73 [ 50.597902] Mem abort info: [ 50.600846] Exception class = DABT (current EL), IL = 32 bits [ 50.606959] SET = 0, FnV = 0 [ 50.610142] EA = 0, S1PTW = 0 [ 50.613396] Data abort info: [ 50.616401] ISV = 0, ISS = 0x00000004 [ 50.620373] CM = 0, WnR = 0 [ 50.623466] [006b6b6b6b6b6b73] address between user and kernel address ranges [ 50.630818] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 50.671670] PC is at qca_power_shutdown+0x28/0x100 [hci_uart] [ 50.677593] LR is at qca_close+0x74/0xb0 [hci_uart] [ 50.775689] Process rmmod (pid: 2144, stack limit = 0xffffff801ba90000) [ 50.782493] Call trace: [ 50.872150] [] qca_power_shutdown+0x28/0x100 [hci_uart] [ 50.879138] [] qca_close+0x74/0xb0 [hci_uart] [ 50.885238] [] hci_uart_unregister_device+0x44/0x50 [hci_uart] [ 50.892846] [] qca_serdev_remove+0x50/0x5c [hci_uart] [ 50.899654] [] serdev_drv_remove+0x28/0x38 [ 50.905489] [] device_release_driver_internal+0x140/0x1e4 [ 50.912653] [] driver_detach+0x78/0x84 [ 50.918121] [] bus_remove_driver+0x80/0xa8 [ 50.923942] [] driver_unregister+0x4c/0x58 [ 50.929768] [] qca_deinit+0x24/0x598 [hci_uart] [ 50.936045] [] hci_uart_exit+0x10/0x48 [hci_uart] [ 50.942495] [] SyS_delete_module+0x17c/0x224 This crash is due to dereference of hdev, after freeing it. Signed-off-by: Balakrishna Godavarthi Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/bluetooth/hci_qca.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -167,7 +167,7 @@ struct qca_serdev { }; static int qca_power_setup(struct hci_uart *hu, bool on); -static void qca_power_shutdown(struct hci_dev *hdev); +static void qca_power_shutdown(struct hci_uart *hu); static void __serial_clock_on(struct tty_struct *tty) { @@ -609,7 +609,7 @@ static int qca_close(struct hci_uart *hu if (hu->serdev) { qcadev = serdev_device_get_drvdata(hu->serdev); if (qcadev->btsoc_type == QCA_WCN3990) - qca_power_shutdown(hu->hdev); + qca_power_shutdown(hu); else gpiod_set_value_cansleep(qcadev->bt_en, 0); @@ -1232,12 +1232,15 @@ static const struct qca_vreg_data qca_so .num_vregs = 4, }; -static void qca_power_shutdown(struct hci_dev *hdev) +static void qca_power_shutdown(struct hci_uart *hu) { - struct hci_uart *hu = hci_get_drvdata(hdev); + struct serdev_device *serdev = hu->serdev; + unsigned char cmd = QCA_WCN3990_POWEROFF_PULSE; host_set_baudrate(hu, 2400); - qca_send_power_pulse(hdev, QCA_WCN3990_POWEROFF_PULSE); + hci_uart_set_flow_control(hu, true); + serdev_device_write_buf(serdev, &cmd, sizeof(cmd)); + hci_uart_set_flow_control(hu, false); qca_power_setup(hu, false); } @@ -1413,7 +1416,7 @@ static void qca_serdev_remove(struct ser struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev); if (qcadev->btsoc_type == QCA_WCN3990) - qca_power_shutdown(qcadev->serdev_hu.hdev); + qca_power_shutdown(&qcadev->serdev_hu); else clk_disable_unprepare(qcadev->susclk);