Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5891507ioo; Wed, 1 Jun 2022 15:10:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8f59AGV3H4q73AdG7mqPfC7QFKY35zQFozLXWJbNuShe/kQE+OBv9bXVu9oI2p94dZm/r X-Received: by 2002:a17:903:22d0:b0:164:ec0:178c with SMTP id y16-20020a17090322d000b001640ec0178cmr1556987plg.127.1654121401327; Wed, 01 Jun 2022 15:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654121401; cv=none; d=google.com; s=arc-20160816; b=bHVSZ8Hsckk+wRVNeBQOve8oUZ7yHNeTYTo6TiGiTV/Fq+43NQbnVIccPYZGAvvy7K gsS/jQbEIe86RgApMfg8LwUF+k6+ujc19g2MPZgH3Wf2zsJOwf2QvdFG/HQvzMRd7TQy HQehZl965HwZZN14GV7epDcnbNQD7QkQ2ROk+SQQsfLca6vorggYa8KK3oF+kbwJwY2Q E5VGHd0erGlaCRf7hjoiMeRo8YD4nkJ2WVw/d8bFTJv2jQspOWLIhyybq8dFX/L/9Hj9 EDT2jdUGhGkiRLBWCCsEqrnFLAK65G3SFWai5wNn9d4OzBOxmlbzm4Rl2ssb3DcaePsc L66A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fZXF7GPcAcaOPScOAplIm+VORKBsYKZ17YpBBud/XGc=; b=EpMESlRxYzV2915oBJ+yvXlhNx0djeXGvZyYbn2tzhUn5xywvjrZWOe61USfGTzAg2 HdyhhrXLGIJkzgYQ6go2oX44YZEovD9pPwS7zyR16juKY+bvUyyM3IC25GwG5PCNvX7K EY++V1hc++1thW/F7DoElHV1ni3L+cG8X7rcR5vO5IFLUSKOLicW4Jd10BK63F4LIPgO nuT5ejtN05P0GpZe9j4e/q7/Ax9cQa97TrzW9oGVvhqh5DaLOA4Zw11+XuDIKNAgpYPu j4Iklxvzsy6UjVBieeTkCVGzQND2JdILqElL+mlFKrblNMp9OvzIiu1uMCBgSr351LwE pbjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cglP+0SL; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j71-20020a63804a000000b003fc8c5109adsi1912079pgd.315.2022.06.01.15.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 15:10:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cglP+0SL; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1D2E5813F7; Wed, 1 Jun 2022 14:45:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231738AbiFAVpW (ORCPT + 99 others); Wed, 1 Jun 2022 17:45:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231779AbiFAVpV (ORCPT ); Wed, 1 Jun 2022 17:45:21 -0400 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 C2E067A455; Wed, 1 Jun 2022 14:45:20 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id s14so2914058plk.8; Wed, 01 Jun 2022 14:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fZXF7GPcAcaOPScOAplIm+VORKBsYKZ17YpBBud/XGc=; b=cglP+0SLTIabqtnre/RPxQwVASYfan1tRkC3a/xHKvzzcQ4zJkgkk/DO+wTxzyHp2w sS8j3NL7AinwOMUiJylKl1FX+vx1p6YiNM8/2Z1XMI2ceczdnhrQX07a+yMJ11N3mCb4 byUjIzK6oRruE52OOjVpRmgqQtM8d45cBEj6hBXRJuHMKyGi+c6dHd8F4lXmBOumWkMc vaGXS1rowJTmumxKI0Ev9ngKWPSDrHqkAr5TrM8INGMzFYhd511sUTyzpXnDhLQkA9fS uJ7U1cewiMaSc2YTtgG6VKDAxX8oRa2M1iOIKMIEeFB4QZeBqFaDYWqrXoSV12cFhiTe GX8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fZXF7GPcAcaOPScOAplIm+VORKBsYKZ17YpBBud/XGc=; b=KSMMtDWu89gBdPOO/OHHM44Q7XFj7HRXig/k9P4eYME80U8AWz3ihaKUYd0ktoZIyS V3zQT8tzb2D/zL2Yp69qz+R0RdIvjnbukXj528yCexVeB/rlAHE+jcejJsk0k/dt4EUV Ogb9lLPVZycsKpptwhPwFcraBFQXBDDnVElkE7iU6Z7a5FX6DrtMrq64QWjIbzyFu8sD 3kXzOr22sUhHvjob4gzozk9x29/8EdLpQ1TPhI58Wdk2V883gaeUui+WImebLhm0jPwf yb3ITIgGT468RW82vWXr7ZwgZQM1WBV0xo1Okvp4Y91OeBu9VUpm2M2pcc+hOBFW4JCL xBlg== X-Gm-Message-State: AOAM532lyrc+LzyRbAex6/tulxnXAeJIMUa8N0lmjVksrHmnPLqjBqeP kJwcREWRWkFgcOxtmu0gs7WZzJnmmY8h9eBJmhw= X-Received: by 2002:a17:903:244f:b0:162:4daf:f8bb with SMTP id l15-20020a170903244f00b001624daff8bbmr1525626pls.20.1654119919850; Wed, 01 Jun 2022 14:45:19 -0700 (PDT) MIME-Version: 1.0 References: <20220601151115.1.Ia503b15be0f366563b4e7c9f93cbec5e756bb0ae@changeid> In-Reply-To: <20220601151115.1.Ia503b15be0f366563b4e7c9f93cbec5e756bb0ae@changeid> From: Luiz Augusto von Dentz Date: Wed, 1 Jun 2022 14:45:08 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: clear the temporary linkkey in hci_conn_cleanup To: Alain Michaud Cc: "linux-bluetooth@vger.kernel.org" , ChromeOS Bluetooth Upstreaming , Alain Michaud , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Marcel Holtmann , Paolo Abeni , Linux Kernel Mailing List , "open list:NETWORKING [GENERAL]" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Alain, On Wed, Jun 1, 2022 at 8:12 AM Alain Michaud wrote: > > 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 > > --- > > net/bluetooth/hci_conn.c | 3 +++ > net/bluetooth/hci_event.c | 4 +++- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c > index 352d7d612128..85dc1af90fcb 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_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..09f4ff71e747 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -3372,8 +3372,10 @@ 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_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) { > hci_remove_link_key(hdev, &conn->dst); > + clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags); > + } Could we use test_and_clean_bit instead? In theory there could be other threads trying to clean up so I guess it would be safer to reduce the risk of having concurrency problems although hci_dev_lock would prevent that, better to be safe than sorry. > hci_req_update_scan(hdev); > } > -- > 2.36.1.255.ge46751e96f-goog > -- Luiz Augusto von Dentz