From patchwork Sat Feb 25 00:20:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 656558 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B8A5C64ED8 for ; Sat, 25 Feb 2023 00:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbjBYAVE (ORCPT ); Fri, 24 Feb 2023 19:21:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjBYAVD (ORCPT ); Fri, 24 Feb 2023 19:21:03 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 678797038F for ; Fri, 24 Feb 2023 16:20:55 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id h17-20020a17090aea9100b0023739b10792so926789pjz.1 for ; Fri, 24 Feb 2023 16:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=QS+t43GmTGiabhyga4ShoD477QWkItKNnqQI5YOqHXA=; b=oFcQtVuqVpbXtC3tOkcr1BT57OV1LA9tt83ItBcmWxRTzsATlSUlArOvcmPa1LHPrp 6grqDuo+BQvgVySddfpKc9sISkYcdhXduu0lyoAIYDKomjgW6eB1KJ6kfaegQV87/hAQ nOBiAb5bYiQShpaNmNPXPXv490Ovgdpy93rHjUDStbexPqk6ipLfXP8kXHBfwLhe1w8c kE7Zgr0prFLZZRSOiGoxtKsh4uGVvecJwcXaSk9riMfi4V4nIW2JFiJKLcJIs9VYytrn xo8GWMIhYphZ5PdYeu3fhQxH1o3I4iqVMpqWNFq53wpjLnynW/rFjw0LApHvuP09fECb TNBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QS+t43GmTGiabhyga4ShoD477QWkItKNnqQI5YOqHXA=; b=0aodUbEQRP+ZGFFhyjtPJqLjBY9h1ATSTesvsy/LflJzE5R57ktWKR1tcnl3qnZVYo PFlddJfzbtynQ3o0Z1sY3cc51f1sTuyH4dkjwhhQ1LKbL26vOHQRsnRJN4nx7hUK5YNB EHsthszBfoa/Dbvia7y3ic6TY0Smp+OdaVVHq4OK8CqmOAsP17IuPTpPMtJVfU6bCV9N NO6MFyL/E6qHh6NWqCPZdBItCgr/ndrF1+ufMZqNSLQ5frbPXD3gcSnoa1I9U2yWfj/V xN/tLspJqRT0APlSTCUAmZK7YlBusK9ainsXSgVKkft1sKlYrdVjfjZzgo9SFusrAIMj Z5Mg== X-Gm-Message-State: AO0yUKXUifAnoqG6/LpEuGcQw9IcqEHPP/83NxrWWsoGYmZxNMqs+B4f Qm9ory5j5xKms1ygpVv5RCExVaau2tY= X-Google-Smtp-Source: AK7set8YYHcWUWh0aITg/R7yAz+fDWmoPqJY4nJycAnzsWhpYpAjJUi8i3qr0G0qV2weUNv88P0Isw== X-Received: by 2002:a17:902:d486:b0:19a:c009:8512 with SMTP id c6-20020a170902d48600b0019ac0098512mr1770180plg.6.1677284454195; Fri, 24 Feb 2023 16:20:54 -0800 (PST) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id ja17-20020a170902efd100b00196025a34b9sm75008plb.159.2023.02.24.16.20.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 16:20:53 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH 1/3] Bluetooth: hci_core: Make hci_conn_hash_add append to the list Date: Fri, 24 Feb 2023 16:20:50 -0800 Message-Id: <20230225002052.3866357-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes hci_conn_hash_add append to the tail of the conn_hash so it matches the order they are created, this is required if the controller attempts to match the order of ACL with CIS which uses append logic when programming the CIS ids on the CIG. The result of this change affects Create CIS: From: < HCI Command: LE Create Connected Isochronous Stream (0x08|0x0064) plen 9 Number of CIS: 2 CIS Handle: 2560 ACL Handle: 3586 CIS Handle: 2561 ACL Handle: 3585 To: < HCI Command: LE Create Connected Isochronous Stream (0x08|0x0064) plen 9 Number of CIS: 2 CIS Handle: 2560 ACL Handle: 3585 CIS Handle: 2561 ACL Handle: 3586 Signed-off-by: Luiz Augusto von Dentz --- include/net/bluetooth/hci_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7254edfba4c9..9488671c1219 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -978,7 +978,7 @@ static inline bool hci_conn_sc_enabled(struct hci_conn *conn) static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) { struct hci_conn_hash *h = &hdev->conn_hash; - list_add_rcu(&c->list, &h->list); + list_add_tail_rcu(&c->list, &h->list); switch (c->type) { case ACL_LINK: h->acl_num++; From patchwork Sat Feb 25 00:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 656649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53114C6FA8E for ; Sat, 25 Feb 2023 00:21:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjBYAVF (ORCPT ); Fri, 24 Feb 2023 19:21:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjBYAVE (ORCPT ); Fri, 24 Feb 2023 19:21:04 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF40E703B4 for ; Fri, 24 Feb 2023 16:20:56 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id c1so1190890plg.4 for ; Fri, 24 Feb 2023 16:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XklqBXUzE5TheuIzINkJARoV6rpuGdj5bkX5YZz0Fcs=; b=mVKgepDGOOHQ2i21ShdKa2VbzqNPtVnr6fyGjZKJNavTIwb4g/1rpU0DcpT3oozWTn E21dvq6xahdYwQJ87u1ZTfO5/l69c+qUG1WDbx0ggo8svtONaqYqUvJhz2y1K2G9bvhy MR1XRsPs22tE3sj8xu5JpzOUkDDoJ3YFoxGOv2M4yPxScosDwPB6z/v7gqh2lZ+xwr1i GDngrKKL+u7ktZXR0ZOs404ragYussfGV2Po5aL+zlU04ag8TWTG0BNv2FHACmsIFl7F 3tL0XBtXYqyzfK4rP59T7Jcul21AEA8FNscMD/C9bQ55m3tqC36BSTX04e7uyslbMNbR p1aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XklqBXUzE5TheuIzINkJARoV6rpuGdj5bkX5YZz0Fcs=; b=sqxZlyWdE/UQjPxEyH0QqqSScj2/SjTBnEnmHo+JmTNtrtSWnwxtDx+u8fXsw7/wGi ubQv1kQGVMIWHmubONtcApdlh1ooXi9PNTLw2a4DwbPxrgJnqsSXhrPkQ/0oy4/y4v8s MqMVhbDfjJ8KS0nF9KLiwRTJ13E8ZGvecFMSt33pmIeLHbrmyg2pE1qJ7Ua4Gp6ELgdd k5pSsFgVojU54MQtcKDdU1OaZ92teuVl6MIP5MzttkeC6A1n7I2wdYKB/baJ37Y87E2o 3Oh+NOqvTFy6Ue8OELzingzEOauLeSGWMmVa4nv1JJMGPBw9sCl8VJ1h0nK8+R7KL2M1 rj2w== X-Gm-Message-State: AO0yUKVJrl4u8QEBxXjbKm7jzSg2yc4DS+3P4dAKq/cc8sGqQJTUDa2K wy8u3N4McTu3Bo843F9LWfKegcEnJw0= X-Google-Smtp-Source: AK7set8PBse0S2WXHxodbniDP4ke6aGoG3NHNpEH6mRZdVRZ488yo5gUvIEgxg2RGxl2LYWrEhgl5A== X-Received: by 2002:a17:903:41c1:b0:19a:a6cd:35a8 with SMTP id u1-20020a17090341c100b0019aa6cd35a8mr1456248ple.25.1677284455618; Fri, 24 Feb 2023 16:20:55 -0800 (PST) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id ja17-20020a170902efd100b00196025a34b9sm75008plb.159.2023.02.24.16.20.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 16:20:54 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH 2/3] Bluetooth: hci_core: Detect if an ACL packet is in fact an ISO packet Date: Fri, 24 Feb 2023 16:20:51 -0800 Message-Id: <20230225002052.3866357-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230225002052.3866357-1-luiz.dentz@gmail.com> References: <20230225002052.3866357-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Because some transports don't have a dedicated type for ISO packets (see 14202eff214e1e941fefa0366d4c3bc4b1a0d500) they may use ACL type when in fact they are ISO packets. In the past this was left for the driver to detect such thing but it creates a problem when using the likes of btproxy when used by a VM as the host would not be aware of the connection the guest is doing it won't be able to detect such behavior, so this make bt_recv_frame detect when it happens as it is the common interface to all drivers including guest VMs. Fixes: 14202eff214e ("Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet") Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_core.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index b65c3aabcd53..334e308451f5 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2871,10 +2871,25 @@ int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb) return -ENXIO; } - if (hci_skb_pkt_type(skb) != HCI_EVENT_PKT && - hci_skb_pkt_type(skb) != HCI_ACLDATA_PKT && - hci_skb_pkt_type(skb) != HCI_SCODATA_PKT && - hci_skb_pkt_type(skb) != HCI_ISODATA_PKT) { + switch (hci_skb_pkt_type(skb)) { + case HCI_EVENT_PKT: + break; + case HCI_ACLDATA_PKT: + /* Detect if ISO packet has been sent as ACL */ + if (hci_conn_num(hdev, ISO_LINK)) { + __u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle); + __u8 type; + + type = hci_conn_lookup_type(hdev, hci_handle(handle)); + if (type == ISO_LINK) + hci_skb_pkt_type(skb) = HCI_ISODATA_PKT; + } + break; + case HCI_SCODATA_PKT: + break; + case HCI_ISODATA_PKT: + break; + default: kfree_skb(skb); return -EINVAL; } From patchwork Sat Feb 25 00:20:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 656557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEA8CC7EE2E for ; Sat, 25 Feb 2023 00:21:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229456AbjBYAVG (ORCPT ); Fri, 24 Feb 2023 19:21:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjBYAVF (ORCPT ); Fri, 24 Feb 2023 19:21:05 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7193F6F83A for ; Fri, 24 Feb 2023 16:20:58 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so915386pjp.2 for ; Fri, 24 Feb 2023 16:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=iEehvGyjyYp8SIKtPtm2hjz1jaUYESC95Csw9+5/Qh0=; b=E4mMaTw2G2wR1IuTAHzyp/gRW0sEApZRhJVJIEHDZ+00COJdi0ljz17D7nUkx7+Uo5 h7gjcHtAogI723UEp1go/NQlSOqTfosRdji0cWfURcB6HFWkOzjA426A5E92FmCu4gF2 ud+qtWOplYdzdTeM11wNH33swMWVm5V1rmkD4GeR2amdjVzAmzH8E+Ey3TUvF2FkTu1Y cnUpztnabwNcmzOSKbWfdXTIDxR1OcmZTyaTIBpYlhlRWgUweKjZbQTDQuMQNQ8uFYZ3 ODk+SMC4ZUJ15qQI2t2LpZ+MwHQJlpAWYbv2qGUE5ZlKvOHh0QHmIfo9hgdtT+Hv2L6A xnLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iEehvGyjyYp8SIKtPtm2hjz1jaUYESC95Csw9+5/Qh0=; b=pM+YXGvYahucde/F5ZfUEg/8trgiUQHU8ttwrcA9UIG0XGegLlX1ROaq9oF5zcPQLq 5sEPOHGHgTn6KdyUGMWj2OaWokFICZJuFWUbRDkjrThLbqsp4xdOZ5aT8OkUbG3soy6W 1fT9vnS2vHF0SrP9TSCDRnJKdruliEZBLnVagUAcIcfNbs2ENGb5fT38+grD9BiqVJz+ pMHM9AF265Vw5jHJm+Ly3I2HW96AwA+HvSTQ1FmnAblospdbmapuZy7LN/VAxWtQDI3r 8GqY1Nbqkar58yyn9KTmE1+1nxRAdw6/vKjvTz7LmwCpz6DCums38+xyxLpLsj79n1XL BWUA== X-Gm-Message-State: AO0yUKViHKlYws2SBc40oIdIBUnqWRG2QOty+8i/z4CAOPH6kUM0So80 xt0NOksVX2kt+7dSwhvChG62SsnQ1Fw= X-Google-Smtp-Source: AK7set+t3Gec/i5bemSePE00dOJ7WjRUIsCfzHPEU2G7S1ItuvIpJ8g0VhHoR9nT61cU9cYW9PfJhg== X-Received: by 2002:a17:902:d4c8:b0:199:30a6:376c with SMTP id o8-20020a170902d4c800b0019930a6376cmr18882926plg.68.1677284457413; Fri, 24 Feb 2023 16:20:57 -0800 (PST) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id ja17-20020a170902efd100b00196025a34b9sm75008plb.159.2023.02.24.16.20.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 16:20:56 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH 3/3] Bluetooth: btusb: Remove detection of ISO packets over bulk Date: Fri, 24 Feb 2023 16:20:52 -0800 Message-Id: <20230225002052.3866357-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230225002052.3866357-1-luiz.dentz@gmail.com> References: <20230225002052.3866357-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This removes the code introduced by 14202eff214e1e941fefa0366d4c3bc4b1a0d500 as hci_recv_frame is now able to detect ACL packets that are in fact ISO packets. Fixes: 14202eff214e ("Bluetooth: btusb: Detect if an ACL packet is in fact an ISO packet") Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/btusb.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 6273a93defd2..4ca91c033d2f 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1050,21 +1050,11 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count) hci_skb_expect(skb) -= len; if (skb->len == HCI_ACL_HDR_SIZE) { - __u16 handle = __le16_to_cpu(hci_acl_hdr(skb)->handle); __le16 dlen = hci_acl_hdr(skb)->dlen; - __u8 type; /* Complete ACL header */ hci_skb_expect(skb) = __le16_to_cpu(dlen); - /* Detect if ISO packet has been sent over bulk */ - if (hci_conn_num(data->hdev, ISO_LINK)) { - type = hci_conn_lookup_type(data->hdev, - hci_handle(handle)); - if (type == ISO_LINK) - hci_skb_pkt_type(skb) = HCI_ISODATA_PKT; - } - if (skb_tailroom(skb) < hci_skb_expect(skb)) { kfree_skb(skb); skb = NULL;