From patchwork Thu Jan 2 22:06:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 234695 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,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 4C065C3276C for ; Thu, 2 Jan 2020 22:35:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FC4321835 for ; Thu, 2 Jan 2020 22:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004557; bh=5LC+NzYzKz3C/gfJpHSkuSDtvmu5Q5rwCuJpMuw3B+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PpLa4cCDrnqMIkd4dy25FQtmxlWGEzau7tcSLRC/2bwbydz7craru1bOiNjXAi1/Y yMynb27+4cw5Hq5k0RUMwCPpNl2SwWch9s3+4DLiQyFLLvwCNz3DFCJH3xfVYZ7/51 HSmY2DhmBlJJE+WhVabotDHuYTqY0jHx/PXWflNw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730058AbgABWf4 (ORCPT ); Thu, 2 Jan 2020 17:35:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:46024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730731AbgABWfw (ORCPT ); Thu, 2 Jan 2020 17:35:52 -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 D76DD222C3; Thu, 2 Jan 2020 22:35:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004552; bh=5LC+NzYzKz3C/gfJpHSkuSDtvmu5Q5rwCuJpMuw3B+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z3QS1l0kCz59RJvDldMvIpUfcJkHClkNY0KWON5+psNga98IcNoHwART8qS/lCv5F ySsR8d28rMbouP5OAWBEGK6tBbWwqRahJvYA1E1DILatNJleQTVTmbz61S8hMPB7Sx H6rl21HpuimaHqG6k7FEQeFivOntx7D+VU5TYJvI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mattijs Korpershoek , Marcel Holtmann , Sasha Levin Subject: [PATCH 4.4 029/137] Bluetooth: hci_core: fix init for HCI_USER_CHANNEL Date: Thu, 2 Jan 2020 23:06:42 +0100 Message-Id: <20200102220550.573959576@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mattijs Korpershoek [ Upstream commit eb8c101e28496888a0dcfe16ab86a1bee369e820 ] During the setup() stage, HCI device drivers expect the chip to acknowledge its setup() completion via vendor specific frames. If userspace opens() such HCI device in HCI_USER_CHANNEL [1] mode, the vendor specific frames are never tranmitted to the driver, as they are filtered in hci_rx_work(). Allow HCI devices which operate in HCI_USER_CHANNEL mode to receive frames if the HCI device is is HCI_INIT state. [1] https://www.spinics.net/lists/linux-bluetooth/msg37345.html Fixes: 23500189d7e0 ("Bluetooth: Introduce new HCI socket channel for user operation") Signed-off-by: Mattijs Korpershoek Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5d0b1358c754..4bce3ef2c392 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -4459,7 +4459,14 @@ static void hci_rx_work(struct work_struct *work) hci_send_to_sock(hdev, skb); } - if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { + /* If the device has been opened in HCI_USER_CHANNEL, + * the userspace has exclusive access to device. + * When device is HCI_INIT, we still need to process + * the data packets to the driver in order + * to complete its setup(). + */ + if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && + !test_bit(HCI_INIT, &hdev->flags)) { kfree_skb(skb); continue; }