Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp801899iog; Fri, 17 Jun 2022 14:06:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1trl6jeWN0u3nZ1dBZ3kmjuHrHqZtd6wOhjpH5HQCiwqCHtgPIeFRbJNNq+lQAjnP4eH3Xl X-Received: by 2002:a17:906:d9d9:b0:710:f2ae:b455 with SMTP id qk25-20020a170906d9d900b00710f2aeb455mr11197434ejb.77.1655500015196; Fri, 17 Jun 2022 14:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655500015; cv=none; d=google.com; s=arc-20160816; b=fDAWZITif/OoI3IvrLWRC/5CRB6SyLSgb+FIjY1jbo3paFvcZ1SP/7STzmuEsHJ/7r UiPVTCVrxHGUKwuaH8qfbX/EEX0Z8rIRo5ibuR5rcaunRk4crYRT6XAmzuIuhDb38gSu PxKnVV0Co/8302BBNrhooLBGd0hTSWdWHqbstdirr7SjeViKhAGL+lRQCsVnfgApOQdr q8AKZpGVT1Xcmw5ThZk3Ku/yhumz5v6kYiVM5r0UDfifMQm7JxNDasA2bA38J2FQLA8j +wsaAe1YIBWKHt1Ot/fBfMrMHuUFOq6my9YbRgis08nkUv/DjSMADTTDOMcNQO5Qj2al FdJQ== 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=ZvlmhjX5WrHl156XHjI+XlN+ZCT9UnRn+tpViHipDk4=; b=f27rAWp9SaqF1jVuDRCkKzsjl/nNyTU1iQrNBBQH+pIfThy7yE3dsHH4g3YYj5xwso gQURtivKIiallNU8OjRkiKnVGtFKhT3BXdOAWRFYhPveSvx/sIi5qiGJQBullIOD9cup rSWv7xN3WsLMQ8qrXeMcaF6PbpBbRF+eEwVma5jjrftopej+H7eU0cYRaZt2ka80SSko GMeeQqTaqOr8276tKba4mFWLW8Q7ogai7PyLRcsmL+9qPdqiKJlqiIgKc7l6A3/Lj6p9 Prh/LNvkXP6noSQ1QG9LUzUGfiys2QxROwMLPszDrPVXO25/qaAq81h55gLNVzAYYPBK Tfzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AQvbQNqj; 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 dr22-20020a170907721600b006ff78d48b00si5941391ejc.534.2022.06.17.14.06.14; Fri, 17 Jun 2022 14:06:55 -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=AQvbQNqj; 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 S1383337AbiFQUs5 (ORCPT + 99 others); Fri, 17 Jun 2022 16:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381762AbiFQUsz (ORCPT ); Fri, 17 Jun 2022 16:48:55 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E97045DBCE for ; Fri, 17 Jun 2022 13:48:50 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id m25so5883683lji.11 for ; Fri, 17 Jun 2022 13:48:50 -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=ZvlmhjX5WrHl156XHjI+XlN+ZCT9UnRn+tpViHipDk4=; b=AQvbQNqjOh+vs7nV5O4ZkPwpwVG3IY/XB6qUsKlo+u+PXBU59U7UGX2SeOkfGtUFhe OGLyR7EAaHiOA5PfWmMV9H4KzkryFkxzdJuYgfRXa/59tlGXShywPbvDJszBRZ4Y4PmJ 5Uh1/5YSEVpF9HtIFUpQl5jVL1LgshkzaXE8mTSaMAsJsVDYf1dznDACdEtMyavCHglw zLEBZkjGuJ3sck9feEMZr/8ui88ly3fhgPHM0P0etLAyf1Jnm423P+biHDflkD+4PGjq KuUI5Noeudu3KiO6beAYGEY0aG5QvAcdsLv9JT0D4EKsoIkZmf0WqC0GffegxYkKqatF kUYw== 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=ZvlmhjX5WrHl156XHjI+XlN+ZCT9UnRn+tpViHipDk4=; b=vj66VqMNjELHBStc//BysPKpCae7/lI1wzeuoWPB9jCf306n10Pl5Wh/L+h8ZZSfXv MECmpmcwPnOD7UBtP/JSmLQ2VD2yAVlOAL+QwvS6JiIVgKDt7Co4g5rA7HJR4YglMqOa F3U6Mmvk/oHJS7qfvQ7/7Q8ZtqwBxnuSoR/61wfJTL2auXQpQo+HCKVQXN02tTk/DaV8 6sZIYGwnu8i4itCe1tooj5wnO19CHH/3vaeGTbTktzkLAokqCQkjzhCAETw871FWFuyx JaX1/cWSdrCbNhcbriwDl9e+Y6lfMruRb+NgblpagXA2dJxtWkhKlL4OenVMdBN0m00C f5JQ== X-Gm-Message-State: AJIora8nohoe6cH77eudA+F5lroK21cnW6yhaHo1L++8xQ1fBtqQoOqn hX79ZzS1DqCcPjZeYn2T0Tl6UqG0uhSk1F/X1NqJ6z+d X-Received: by 2002:a05:651c:549:b0:255:bbd2:fb8 with SMTP id q9-20020a05651c054900b00255bbd20fb8mr5859838ljp.305.1655498928997; Fri, 17 Jun 2022 13:48:48 -0700 (PDT) MIME-Version: 1.0 References: <8d5c4724-d511-39b1-21d7-116c91cada45@pengutronix.de> In-Reply-To: From: Luiz Augusto von Dentz Date: Fri, 17 Jun 2022 13:48:37 -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 Thu, Jun 16, 2022 at 3:38 AM Ahmad Fatoum wrote: > > Hello Luiz, > > 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 otherwise we need a different queue to handle command that abort/cancel other already in the queue. > 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 | -- Luiz Augusto von Dentz