Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19670327rwd; Wed, 28 Jun 2023 12:28:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4OetYsLHAGgfKfAbmCznBldFTOVxklb+kcTV+yreW+hSVXoSemj03BANQCBz+VCn0kQkdZ X-Received: by 2002:a17:90a:355:b0:261:113e:50d2 with SMTP id 21-20020a17090a035500b00261113e50d2mr19400310pjf.31.1687980532789; Wed, 28 Jun 2023 12:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687980532; cv=none; d=google.com; s=arc-20160816; b=RQ+YhtF5wGLAQDILzVo0o4VaE2CSjYezFZPFj4nFq5no0MC+yE0DAF2vZEEfti/F3P bzkL9ryup7+2h/lUgfMFiZFjuUypaeptYHilZUa+/6U6Cy96a2tNx5EtiPqtF5iCQ6wX 5l5s/nK71rKYD2IDr5HT9pfEcskbLHEac1Dh9p34XZDSMZmkB4mCNjjhuoiLd+xnGM+x ACTgh+iM7dkWoutKhSJ08c7twzO7PjnUpWWgXw5V6XUodc4RO79nMJSxPRyIGVd9VT1E Lim0eGMcFTAmYEgsxDVu73QvCfDdUuEMBSexlwThrKqwI0mIuGzEBuvx/75Xn2vh720u KvXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=B400Y8XQpX5Kj5os/HOHkhu+4T29AiPMC5/AIc/v82I=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=JNwv8XmrlB83lCcy9qGvJADwK6x+7oq1buE2yYZGz7BRoEdsF4MlmHdXo3h4yCwMb+ R/aLLoNZg4xY4IwA2St6YYRu5A9Xp4rG96qjJxTlTca/INmfb56bj/Ptz5wA4a3RNo6o hUwx6rHueS9MsGHeY8E/tjAo0/clbGBDRf5pK3/KtllNQ0F9j6LvnaIWWg+KRqsj0Yon hsBXJHeh92wpTPbQ5MYi92x8RJbHzRkBGn+IVqwd35vWnsKHxfksPshVpMaFb0LHfL1/ w7SWg0ejDtUf4qjReNASzJevPH040WOjDVZKDvNPsdUnO7IstPrXEosgfnvxbd2mUHFH B67w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=buZGVVpX; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nh4-20020a17090b364400b00262fe4585f3si5459475pjb.150.2023.06.28.12.28.37; Wed, 28 Jun 2023 12:28:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=buZGVVpX; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231614AbjF1TV2 (ORCPT + 99 others); Wed, 28 Jun 2023 15:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231848AbjF1TVV (ORCPT ); Wed, 28 Jun 2023 15:21:21 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C09EB1FF1 for ; Wed, 28 Jun 2023 12:21:19 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-666fb8b1bc8so90958b3a.1 for ; Wed, 28 Jun 2023 12:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687980078; x=1690572078; 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=B400Y8XQpX5Kj5os/HOHkhu+4T29AiPMC5/AIc/v82I=; b=buZGVVpXhnepTzMre+fu0irC2ApFIpl2+PPr4I60pc74BCP74QHOyKft8dVWtTvRb1 iIyJEYn08lH+gp058NWOTm9pkzhNgTfvX3MC/bBJVx4W24RLtjFwXxNCV1tbJhrDHN6n X9/Ez+46fVdmUsS12bOFeUPPfN/S2giSW6PYRNhBMl9nEK/x6XycusNnTkpHZBAoPjOT hD3lxajXsnTnmnB/w73s7mjmqfVsyIhvi+QfW+NIDSZot2rxtKJ5vJQcwz119sgFte4x VKSml+EnXegp1RyvulwLiFMNu2Exx/9ahVtyv36oISJEOp8P9w6t2S7GoJdcYuboyYD/ c9rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687980078; x=1690572078; 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=B400Y8XQpX5Kj5os/HOHkhu+4T29AiPMC5/AIc/v82I=; b=Vr2vOCiuL2riOHcVyp1MkdovQ825YgYJMfeNGFlxbmc2VJ7KFsV4JpR63iW1meSFxn /8FZSOCQxhUbBKLyn36GkL3pN1+KGkn8hmAS/rGvymNBZ0rDFxCIyN/zDR5D0SVO5IOi Q7y1g7J51hBIgjZ1aCcIhGiMt1TxNm+qrBAV595/aAsGF4DHP8Ha5KFF2woybnfyN+ch axI58RbLv/LGzn/K0MxLYIBE8CtGAP/TTVCYMbUg5MZN3gBbeYyGRw5ETiZ6DVvkwZsI WPkjQcBkUDucXP74kzJp0VJqDdpMvCmdNOYKDKz45rystz9ReeDwZl0AenIZIz/d4SQn QZng== X-Gm-Message-State: AC+VfDzHq69yQBI9SiW1meN+/kVYsjgZnIjKBb+7i5VzrpwRsiRpFlPh Hsgs6orcGeLuVqRUFZ9iLnIitNXfVn0= X-Received: by 2002:a17:902:bd86:b0:1b5:2fdf:5bd8 with SMTP id q6-20020a170902bd8600b001b52fdf5bd8mr14547163pls.8.1687980078193; Wed, 28 Jun 2023 12:21:18 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-236-201-58.hsd1.or.comcast.net. [71.236.201.58]) by smtp.gmail.com with ESMTPSA id a19-20020a170902b59300b001b04c2023e3sm7968004pls.218.2023.06.28.12.21.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 12:21:17 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 2/3] Bluetooth: hci_sync: Fix not handling ISO_LINK in hci_abort_conn_sync Date: Wed, 28 Jun 2023 12:21:13 -0700 Message-Id: <20230628192114.2773581-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230628192114.2773581-1-luiz.dentz@gmail.com> References: <20230628192114.2773581-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz ISO_LINK connections where not being handled properly on hci_abort_conn_sync which sometimes resulted in sending the wrong commands, or in case of having the reject command being sent by the socket code (iso.c) which is sort of a layer violation. Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_sync.c | 34 ++++++++++++++++++++++++++++++++++ net/bluetooth/iso.c | 14 -------------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index ef8297d04a8c..29bcfd576713 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5292,6 +5292,24 @@ static int hci_connect_cancel_sync(struct hci_dev *hdev, struct hci_conn *conn, if (conn->type == LE_LINK) return hci_le_connect_cancel_sync(hdev, conn, reason); + if (conn->type == ISO_LINK) { + /* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E + * page 1857: + * + * If this command is issued for a CIS on the Central and the + * CIS is successfully terminated before being established, + * then an HCI_LE_CIS_Established event shall also be sent for + * this CIS with the Status Operation Cancelled by Host (0x44). + */ + if (test_bit(HCI_CONN_CREATE_CIS, &conn->flags)) + return hci_disconnect_sync(hdev, conn, reason); + + /* There is no way to cancel a BIS without terminating the BIG + * which is done later on connection cleanup. + */ + return 0; + } + if (hdev->hci_ver < BLUETOOTH_VER_1_2) return 0; @@ -5318,11 +5336,27 @@ static int hci_reject_sco_sync(struct hci_dev *hdev, struct hci_conn *conn, sizeof(cp), &cp, HCI_CMD_TIMEOUT); } +static int hci_le_reject_cis_sync(struct hci_dev *hdev, struct hci_conn *conn, + u8 reason) +{ + struct hci_cp_le_reject_cis cp; + + memset(&cp, 0, sizeof(cp)); + cp.handle = cpu_to_le16(conn->handle); + cp.reason = reason; + + return __hci_cmd_sync_status(hdev, HCI_OP_LE_REJECT_CIS, + sizeof(cp), &cp, HCI_CMD_TIMEOUT); +} + static int hci_reject_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason) { struct hci_cp_reject_conn_req cp; + if (conn->type == ISO_LINK) + return hci_le_reject_cis_sync(hdev, conn, reason); + if (conn->type == SCO_LINK || conn->type == ESCO_LINK) return hci_reject_sco_sync(hdev, conn, reason); diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 84d238d0639a..9c41af55f2c7 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -614,18 +614,6 @@ static void iso_sock_kill(struct sock *sk) sock_put(sk); } -static void iso_conn_defer_reject(struct hci_conn *conn) -{ - struct hci_cp_le_reject_cis cp; - - BT_DBG("conn %p", conn); - - memset(&cp, 0, sizeof(cp)); - cp.handle = cpu_to_le16(conn->handle); - cp.reason = HCI_ERROR_REJ_BAD_ADDR; - hci_send_cmd(conn->hdev, HCI_OP_LE_REJECT_CIS, sizeof(cp), &cp); -} - static void __iso_sock_close(struct sock *sk) { BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket); @@ -650,8 +638,6 @@ static void __iso_sock_close(struct sock *sk) break; case BT_CONNECT2: - if (iso_pi(sk)->conn->hcon) - iso_conn_defer_reject(iso_pi(sk)->conn->hcon); iso_chan_del(sk, ECONNRESET); break; case BT_CONNECT: -- 2.40.1