Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3198124iog; Mon, 20 Jun 2022 13:46:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uLal2pU9UW6jCzsSbO3r5p3itwSPmsfPQ8TiFeHol91o4TKaivYGF/j6cDBTPPgvwK14Jn X-Received: by 2002:a65:4501:0:b0:3fc:4895:283b with SMTP id n1-20020a654501000000b003fc4895283bmr23531098pgq.231.1655758000513; Mon, 20 Jun 2022 13:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655758000; cv=none; d=google.com; s=arc-20160816; b=nAGhSu4ajCjABY4GRU32Hq3uJCRc3AjBNIboHodAYojkAI79MQaGsMeJRXFDI4EARE +1ZVf9xv6mHlPKNmEi9G6eX6zyNNoQ/0hHtvGdL801DMTYF2NB/KRdaCf8XXjBr6xuvO TPpjXNXJOgahFVX1b9EOCEra5rTKHMN/XojeFnXRoD0544S7nCCqAKJ4V8K+CDLerhgU DxaXZTedRf6SRj1bQgdme4DecLMvFZEZGWJ8bXEaarVYs5ZZq1cnLIEI+LazQof7bZgI +sWaLPE7UeeB65SbH0kfAyGWL1S2RVh+r8U2Bq+884snZtrNhcv+O39AFKWViP8dSh+j yKHA== 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=NeN9XZYk4Nmmr2iNhCACELl+PcFCkbQTYUNEZaX26lg=; b=w/QNVQ+HAv2KO9Se4HfcDeOo7eQ+coroxFHCya3Q4yILpNOABgF3wm0QRBaFPXFZ49 eSfwlMcMf6ltZyLc2RhAGAmrt4t44rJe5J1GcFlNMtr2UsizKRMGadlK6W/1lxDw32Y4 GhauTwTgwlw/MyAzh7SuprOIYaxUHS1cs8+23flQx0ts+RCUFAyrAiB/9/4E4Q19djFD AQLK4u1qLcdF0+NNJVt0KLbwAL0vFXp3vGtbsbefGaSWuNA3t07yzZUAZEdcRbTFxSgN P+tSCoU31RLSCD/cf/BZ0bvOx9iA0DkIjjUETkWJJIw2vs5ec5cCuHN9hMvKIcr39/OO RvyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fDjhUAyW; 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 l3-20020a17090b078300b001eca8e0df15si4262667pjz.0.2022.06.20.13.46.08; Mon, 20 Jun 2022 13:46:40 -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=20210112 header.b=fDjhUAyW; 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 S237153AbiFTUSu (ORCPT + 99 others); Mon, 20 Jun 2022 16:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344444AbiFTUSa (ORCPT ); Mon, 20 Jun 2022 16:18:30 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 194A86277 for ; Mon, 20 Jun 2022 13:18:26 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id c30so13118334ljr.9 for ; Mon, 20 Jun 2022 13:18:26 -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=NeN9XZYk4Nmmr2iNhCACELl+PcFCkbQTYUNEZaX26lg=; b=fDjhUAyWQWvonO5KZeAmYvPzgnrF9vCpla7+i2tn4uj48UhkdgjBgwa8hDRhiMF9qP zGDzVtQLepDw57RKIiqnAC/ypeRcMGWwisZ+7Oa16l69V6Yp14kg65mwUxUSIrfzCqWZ 5zNXkGsUHty6k/Qc+sOS1CDrWDK+3C/iJPjtOIjD0cJy4KwlZxC7JabVfNq7kQdm1ufH Eij9f8vCwL6tRu7Jj015R4pAcUi/FZ1kcRm1DQ/6cSIeJmu7ek2A2GeVu65iVMsn8MlC Q/fdPYel43WkOrx3IJNS3+hVzVh9LFbH+D7vsUbaeVcPK6g4Z2aJMzwsjEHQUOy2ZLIH sTYA== 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=NeN9XZYk4Nmmr2iNhCACELl+PcFCkbQTYUNEZaX26lg=; b=dlbSUhEeb7fErqn0GiHtmG34rYS+7WNsimlfhcbNXd3vqw70SA54SauJ3BHf4b9iQC 321S1m1NRbC9joiRu74w4CFzpWJ+p6m8sdQYxH0R7NNMww2A38STstXfY5Ou6iGF6pcR 49EoTYTr6n39PtT6evZHOixDfp5f73++MQdgKqo+/jBcSxOLF9aXlAsZ0kGkZVu8wLMT D/OdNiXvL3fEcdV6EvYlrsVa18qdTL8rzDtInbvsuNceUaDNP9HhQgZIisYQikK1OHDl lRMc+UkKh5dPKbCsqBwTXitC+6n5QsDGxc8vSF+HfncM4p17HrBWXtTwGCLbY8EcBSrV BgWA== X-Gm-Message-State: AJIora/mOVxBb3vJcYp1648yIKBtuZMlCRc4XmDMFIpWKU1cNfiI286G gF/7waUosVIs+b0SqudU9U5IPt/YeUiK//ohojA= X-Received: by 2002:a2e:a16f:0:b0:25a:7527:95ce with SMTP id u15-20020a2ea16f000000b0025a752795cemr935288ljl.305.1655756304208; Mon, 20 Jun 2022 13:18:24 -0700 (PDT) MIME-Version: 1.0 References: <8d5c4724-d511-39b1-21d7-116c91cada45@pengutronix.de> In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 20 Jun 2022 13:18:12 -0700 Message-ID: Subject: Re: [BUG] BLE device unpairing triggers kernel panic To: Ahmad Fatoum Cc: "linux-bluetooth@vger.kernel.org" , Marcel Holtmann , "regressions@lists.linux.dev" , Pengutronix Kernel Team Content-Type: text/plain; charset="UTF-8" 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 Hi Ahmad, On Mon, Jun 20, 2022 at 3:06 AM Ahmad Fatoum wrote: > > Hi Luiz, > > On 17.06.22 22:48, Luiz Augusto von Dentz wrote: > > On Thu, Jun 16, 2022 at 3:38 AM Ahmad Fatoum wrote: > >> On 16.05.22 18:37, Ahmad Fatoum wrote: > >>>>>> - Commit a56a1138cbd8 ("Bluetooth: hci_sync: Fix not using conn_timeout") > >>>>>> fixes, despite the title, what event is waited on. First Pairing works now, > >>>>>> but the second pairing times out and crashes the kernel: > >>>>>> > >>>>>> [ 84.191684] Bluetooth: hci0: Opcode 0x200d failed: -110 > >>>>>> [ 84.230478] Bluetooth: hci0: request failed to create LE connection: err -110 > >>>>>> [ 84.237690] Unable to handle kernel read from unreadable memory at virtual address 0000000000000ca8 > >>>> > >>>> That said the error -110 mean -ETIMEDOUT > >>> > >>> Yes, this issue remains still. I feel better about my revert > >>> knowing that the crash is fixed, but I'd like this regression > >>> here fixed upstream as well. I'll try to collect some more > >>> information and report back. > >> > >> I've now found time to revisit this and sprinkle around some > >> extra logging. This is the initial pairing that works: > >> > >> Bluetooth: entered hci_le_create_conn_sync() > >> Bluetooth: hci0: opcode 0x200d plen 25 > >> Bluetooth: hci0: event 0x0f (sent = 0x0a) > >> Bluetooth: hci0: BT: opcode 0x200d (sent: 0x0a) > >> Bluetooth: hci0: event 0x3e (sent = 0x0a) > >> Bluetooth: hci0: BT: subevent 0x0a (sent 0x0a) > >> Bluetooth: entered hci_le_meta_evt(event=0x0a) completion clause > >> > >> I unpaired on device side and then retried pairing: > >> > >> Bluetooth: entered hci_le_create_conn_sync() > >> Bluetooth: hci0: opcode 0x200d plen 25 > >> Bluetooth: hci0: event 0x0f (sent = 0x0a) > >> Bluetooth: hci0: BT: opcode 0x200d (sent: 0x0a) > >> Bluetooth: entered hci_abort_conn() > >> Bluetooth: hci0: opcode hci_req_add_ev 0x200e > >> Bluetooth: hci0: event 0x0e (sent = 0x00) > >> Bluetooth: hci0: event 0x3e (sent = 0x00) > >> Bluetooth: hci0: BT: subevent 0x0a (sent 0x00) > >> Bluetooth: __hci_cmd_sync_sk pending (event = 0x0a status=1, err=-110) > >> Bluetooth: hci0: Opcode 0x200d failed: -110 > >> Bluetooth: hci0: opcode 0x2006 plen 15 > >> Bluetooth: hci0: event 0x0e (sent = 0x00) > >> Bluetooth: hci0: opcode 0x200a plen 1 > >> Bluetooth: hci0: event 0x0e (sent = 0x00) > >> Bluetooth: hci0: request failed to create LE connection: err -110 > >> > >> > >> But now it times out as reported. It looks like the > >> intermittent hci_abort_conn() is at fault here. My theory is > >> that replacing hci->sent_cmd is the problem here, as other > >> events can't be matched anymore. > > > > Yep, unpair command uses hci_abort_conn when it should really be using > > hci_abort_conn_sync, the problem is if we do that then it probably no > > longer work because it would have to wait for sync queue to complete > > so it would only be able to disconnect after the connect command > > completes, well perhaps that is acceptable > > Disconnect of connection #1 being processed after new connection #2 > concluded sounds wrong. Would I be able to reconnect > afterwards or would all connections, but the first, be directly > disconnected...? That depends on the order you have queued the commands, it will be processed in the exact order it is received, that why I said it is single queue design, and it is done like that to prevent messing up with states since we know the exact order the commands will be sent. > > otherwise we need a > > different queue to handle command that abort/cancel other already in > > the queue. > > Is the revert an acceptable interim solution or are there issues > I am missing? Afaik there were problem with concurrent connections request, so what would really help us here is to have some tests to emulate this scenario with our CI, in the meantime please check if the following fixes your problem: https://gist.github.com/Vudentz/b4fff292c7f4ad55ca3299fd5ab797ae > Cheers, > Ahmad > > > > >> We've been deploying the revert for a while now and I just posted > >> it to the mailing list[1]. There have been other reports > >> of this issue with different hardware too and fixing sent_cmd > >> would likely be too complicated/time intensive for me. > >> > >> I am happy to test future patches that fix this properly though. > >> > >> [1]: https://lore.kernel.org/linux-bluetooth/20220616092418.738877-1-a.fatoum@pengutronix.de/T/#t > >> > >> Cheers, > >> Ahmad > >> > >> > >> > >>> > >>> Cheers, > >>> Ahmad > >>> > >> > >> > >> -- > >> Pengutronix e.K. | | > >> Steuerwalder Str. 21 | http://www.pengutronix.de/ | > >> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > >> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | > > > > > > > > > -- > Pengutronix e.K. | | > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- Luiz Augusto von Dentz