From patchwork Wed Aug 22 12:04:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Godavarthi X-Patchwork-Id: 10572891 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83DB11390 for ; Wed, 22 Aug 2018 12:04:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7483C2B044 for ; Wed, 22 Aug 2018 12:04:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F0A22B047; Wed, 22 Aug 2018 12:04:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 019512B03D for ; Wed, 22 Aug 2018 12:04:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729074AbeHVP3I (ORCPT ); Wed, 22 Aug 2018 11:29:08 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:58844 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727754AbeHVP3I (ORCPT ); Wed, 22 Aug 2018 11:29:08 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 53EE760159; Wed, 22 Aug 2018 12:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534939470; bh=bV1NDFO4xCWocdUuS5Bas+c1kVDWmQA0BN2N0+p3qBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TIYQs+RRBxxbOwQnG6+3MErolTFYjH8zHyTZza6Z7mpn5cVBptxzni6H6NRj+WXWF 0igp3isi7MWnTEsPKLQrYKp0NjTtM/RiBgP8pT0QEd3N0dvYiebR+K9n3NYyk09kKJ 7s3wGnTL0Ss071d3wp56rtTjFsgK/BHuW+5rbC4U= Received: from bgodavar-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bgodavar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B777D6030D; Wed, 22 Aug 2018 12:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534939469; bh=bV1NDFO4xCWocdUuS5Bas+c1kVDWmQA0BN2N0+p3qBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPB+uX/M1JbYikvYfUIGsWat3qIsRc7s3I9qhlW/s6Z91LVuGayNvZivdi7+1PQdz E33nq/RPQuT9tBLOtL99JkiV+DPWNK89+GAkEu6WZ+I/Xf37b2QeqBl0XMoov2OLDQ oRkNAHkfAijOwGztfcZltxSIzbLwmVQS8howgmbQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B777D6030D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bgodavar@codeaurora.org From: Balakrishna Godavarthi To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, Balakrishna Godavarthi Subject: [PATCH v1 1/2] Bluetooth: hci_serdev: clear HCI_UART_PROTO_READY to avoid closing proto races Date: Wed, 22 Aug 2018 17:34:11 +0530 Message-Id: <20180822120412.20285-2-bgodavar@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822120412.20285-1-bgodavar@codeaurora.org> References: <20180822120412.20285-1-bgodavar@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clearing HCI_UART_PROTO_READY will avoid usage of proto function pointers before running the proto close function pointer. There is chance of kernel crash, due to usage of non proto close function pointers after proto close. Signed-off-by: Balakrishna Godavarthi --- drivers/bluetooth/hci_serdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index aa2543b3c286..46e20444ba19 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -368,6 +368,7 @@ void hci_uart_unregister_device(struct hci_uart *hu) { struct hci_dev *hdev = hu->hdev; + clear_bit(HCI_UART_PROTO_READY, &hu->flags); hci_unregister_dev(hdev); hci_free_dev(hdev); From patchwork Wed Aug 22 12:04:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Godavarthi X-Patchwork-Id: 10572889 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EC8C1390 for ; Wed, 22 Aug 2018 12:04:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BF0A2B03A for ; Wed, 22 Aug 2018 12:04:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4053C2B03D; Wed, 22 Aug 2018 12:04:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9A6F2B03A for ; Wed, 22 Aug 2018 12:04:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729109AbeHVP3M (ORCPT ); Wed, 22 Aug 2018 11:29:12 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:58940 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727754AbeHVP3M (ORCPT ); Wed, 22 Aug 2018 11:29:12 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B8EA86022B; Wed, 22 Aug 2018 12:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534939473; bh=un1c80IPdZ62Xf+AxsoPu3ZnIDAwPVXQEmbC4raqoY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C8fhAVHFCxvnecjIQq+s4jPSeMWody2iRrTWoJMPzOYE5UsHM0njJy/0519VAEewM XQey4TsYuBK5nhWmwuB7pYPSkrJuiU0hThcwhqwICJ7a0f7vxb6Pd3u8br0WFqgpfe yfhrPZzA40C/yfkWsX9hw29AEMhWxJ97CZObe2X4= Received: from bgodavar-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bgodavar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 310126049C; Wed, 22 Aug 2018 12:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534939473; bh=un1c80IPdZ62Xf+AxsoPu3ZnIDAwPVXQEmbC4raqoY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C8fhAVHFCxvnecjIQq+s4jPSeMWody2iRrTWoJMPzOYE5UsHM0njJy/0519VAEewM XQey4TsYuBK5nhWmwuB7pYPSkrJuiU0hThcwhqwICJ7a0f7vxb6Pd3u8br0WFqgpfe yfhrPZzA40C/yfkWsX9hw29AEMhWxJ97CZObe2X4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 310126049C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bgodavar@codeaurora.org From: Balakrishna Godavarthi To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: mka@chromium.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, Balakrishna Godavarthi Subject: [PATCH v1 2/2] Bluetooth: hci_serdev: Add protocol check in hci_uart_dequeue(). Date: Wed, 22 Aug 2018 17:34:12 +0530 Message-Id: <20180822120412.20285-3-bgodavar@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822120412.20285-1-bgodavar@codeaurora.org> References: <20180822120412.20285-1-bgodavar@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This will help to check the status of protocol while dequeuing an skb packet. In some instaces we will end up kernel crash, where proto close is called and we trying to dequeue an packet. [ 500.142902] [] do_raw_spin_lock+0x1c/0xe0 [ 500.148643] [] _raw_spin_lock_irqsave+0x38/0x48 [ 500.154917] [] skb_dequeue+0x28/0x84 [ 500.160209] [] 0xffffff8000ad6f48 [ 500.165230] [] 0xffffff8000ad6610 [ 500.170257] [] process_one_work+0x238/0x3e4 [ 500.176174] [] worker_thread+0x2bc/0x3d4 [ 500.181821] [] kthread+0x138/0x140 [ 500.186945] [] ret_from_fork+0x10/0x18 Signed-off-by: Balakrishna Godavarthi --- drivers/bluetooth/hci_serdev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 46e20444ba19..a541e6ee085e 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -57,9 +57,10 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) { struct sk_buff *skb = hu->tx_skb; - if (!skb) - skb = hu->proto->dequeue(hu); - else + if (!skb) { + if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) + skb = hu->proto->dequeue(hu); + } else hu->tx_skb = NULL; return skb;