Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7078873ioo; Thu, 2 Jun 2022 22:11:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze3gyzp8GODVsBeBYzP8hHvMpQmEWjRkfXKnzupXAyF5mzNPV86MMx9L3aZ+bmujF0IWEK X-Received: by 2002:a17:902:d58a:b0:164:f5d1:82e9 with SMTP id k10-20020a170902d58a00b00164f5d182e9mr8541650plh.3.1654233096611; Thu, 02 Jun 2022 22:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654233096; cv=none; d=google.com; s=arc-20160816; b=Z66iJEFeaFWeEaKBvQ5Cm/5c1Z/q4Vq/DpcK6aSTA+GxIqCD4x1HWjRzHummyNR2of xS5TdsB7vUhG3utst31wVspyR7KR5TBeCIjyznuJR23yYszGF8DDqsC3uzsqus8+lR4a NcctBXoVj4qkEdpnaBkvffO2mScxPgMZsoFk6JtbdwB8VYpkbSuCByYCPqxAEAQQl5Bl Q1dszCWnV2T8+XLKiwKSTAGbj04PNCrfRXDy7LpEfhyHDIChqfN0anBoE8PuQT8YIkES f7Tqa7ttOlxnnjI+XgC+Mx0uzyzOZ4kqN1BpEeWQCaz9cSzLs7UG20oj5qkqJMkQCKNo L34Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=Wr2n5iI7XttDispKB41EO8G79l4qta1A1VBwdKgaGQg=; b=alb9PWtuq1q/Y029UHSfrsponbtu1ScwB0O+1zkStn6pkqoUdkOmHZhw1spj1DEwmE 7AAcrCYgwcL0wMQWjVDIrOIXc0vB9BVzk9lZjp6/o6ifjIiZnF/8cZPtGEPQfKCrxW+E sCL4WBXXYydDdDqUeGZLCGKXp+IDwFkZtGL1yPU+W+0PQ1YDmEiF/sEu3Yi1uSRehAhJ Vx40Gl2dh4mevgCY6R2AJ+2gTEAatObrXYgMuYxkCqTC5N2auuVre/si62LVlgLaObK3 YDgVjXySY0eBkS8wlYnpKZy5Ucs5CzQUSIssI7I09mxpytKP9HnbgaYN719ekbCDpOHe nROQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="K57/WdHT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg4-20020a1709028e8400b00163d2e834b4si7974954plb.127.2022.06.02.22.11.20; Thu, 02 Jun 2022 22:11:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20210112 header.b="K57/WdHT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236430AbiFBPPK (ORCPT + 99 others); Thu, 2 Jun 2022 11:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbiFBPPI (ORCPT ); Thu, 2 Jun 2022 11:15:08 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F611C2D5E for ; Thu, 2 Jun 2022 08:15:07 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id k73-20020a25244c000000b0065ca88b381aso4392638ybk.2 for ; Thu, 02 Jun 2022 08:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=Wr2n5iI7XttDispKB41EO8G79l4qta1A1VBwdKgaGQg=; b=K57/WdHT4u8VdENtYRT2HFl5kLPTLI0FcXt1D8IExcQ6jqRfEB78EOmbDeXhnMLAvx ShM+ROjLF8dh1S+MActgGL3MfFOJKHMiqUACX0uAFFTahYnUUPNZH0ivKYqGh46n9Qvv JIl1EH6b3KoMsm4FozPq3FZZ3qd1TbDzgBpA0TESnZwYKtoSt3FoG+zvJsUgDUuhG7Gq eywRkDVmJ+53j+cYerjmufgUCW6r4D/HTR543Pqm51dozKw/gfhXZY9wwekLD183o7C+ cxKKbP3EbNMGPVgSw88747UrRcyWeVckl8bkm/yMVsPAzekVnAjDzx4gQqY95FW0GKVn ZxKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Wr2n5iI7XttDispKB41EO8G79l4qta1A1VBwdKgaGQg=; b=g4br6agWxoak75OdqWwUrDptywzfJ7nHsWKCCsYjNGabfDzDVxTqx4tWnM9gU6iK+f LREkcYZXTxd3M3mm9+eE6Eo36rtUVK/N1YRDXbGGFq8d0wTXHY5iK13m1Jnxn4jXL+GB tofog5RUC3afz1bsZ8IhbMHQgr+EHlO0zXNSoguVNug3nRz5tLCg1pVXVZivU5qcwnon A3BKsCwc6j91SeyqWD0GaYNu0tjsmecQ0XmUgNDuJNUKoBnVhZkHFmmwP8o/UtGD1wuo iJ57OyeKvppHCPEuAhyWT4VdZJKmJM+IvbJ8qtmZRti2+aWP/z3VBxCgeMzfRuHea6mz pxpA== X-Gm-Message-State: AOAM531dJNV4wKp/xyf+Dpf2X1CWumWW5iIVdkdBAjAExmx48qPaX9ss SqRtbP8/MxadN0b3a+p7qs0ctOcwtzIlaio/AVE= X-Received: from alainmic.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:2890]) (user=alainmichaud job=sendgmr) by 2002:a25:8046:0:b0:65b:9fd2:53b0 with SMTP id a6-20020a258046000000b0065b9fd253b0mr5804468ybn.100.1654182907005; Thu, 02 Jun 2022 08:15:07 -0700 (PDT) Date: Thu, 2 Jun 2022 15:15:03 +0000 Message-Id: <20220602151456.v2.1.I9f2f4ef058af96a5ad610a90c6938ed17a7d103f@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog Subject: [PATCH v2] Bluetooth: clear the temporary linkkey in hci_conn_cleanup From: Alain Michaud To: linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Alain Michaud , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Luiz Augusto von Dentz , Marcel Holtmann , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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-kernel@vger.kernel.org From: Alain Michaud If a hardware error occurs and the connections are flushed without a disconnection_complete event being signaled, the temporary linkkeys are not flushed. This change ensures that any outstanding flushable linkkeys are flushed when the connection are flushed from the hash table. Signed-off-by: Alain Michaud --- Changes in v2: -Address Feedback from Luiz net/bluetooth/hci_conn.c | 3 +++ net/bluetooth/hci_event.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 352d7d612128..5911ca0c5239 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -118,6 +118,9 @@ static void hci_conn_cleanup(struct hci_conn *conn) if (test_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags)) hci_conn_params_del(conn->hdev, &conn->dst, conn->dst_type); + if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) + hci_remove_link_key(hdev, &conn->dst); + hci_chan_list_flush(conn); hci_conn_hash_del(hdev, conn); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6b83f9b0082c..b67fdd1ad8da 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2729,7 +2729,7 @@ static void hci_cs_disconnect(struct hci_dev *hdev, u8 status) mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags); if (conn->type == ACL_LINK) { - if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) + if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) hci_remove_link_key(hdev, &conn->dst); } @@ -3372,7 +3372,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, void *data, reason, mgmt_connected); if (conn->type == ACL_LINK) { - if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) + if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) hci_remove_link_key(hdev, &conn->dst); hci_req_update_scan(hdev); -- 2.36.1.255.ge46751e96f-goog