Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2602938imi; Mon, 25 Jul 2022 03:14:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1towRr4askaad1TVew/T4RfteSyDYmt5zfdo0YF6kj247cxUTL31WKh8swouRhyeTOAGSOT X-Received: by 2002:a17:902:c203:b0:16d:47f3:976d with SMTP id 3-20020a170902c20300b0016d47f3976dmr12284879pll.131.1658744068622; Mon, 25 Jul 2022 03:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658744068; cv=none; d=google.com; s=arc-20160816; b=b/KIJ8iQzw7X1Pi/f8kF4f/FLlrN6pxTQPTS5vHcMjnEWsFtG1Fc0UsDsKz6ne3cbs 4g/oPK4jBArBo/Hf5N6eUYPKy4Ft/dPu9ucZkxOWpv9LpItxgIiweu85yHpdcCwRQi/o pXg9deKiAe97sKUA7oPxx83BFhIzXYP+thru8jN3B7++62YOZOTTSSiz4bg9U6+VCGe7 5n+z+TyMzacRdBqCGp3W4yWQwk42KSTdoyitdNk7ogG9PLtkdDyTNNhS4MC5Ue/8z3WK 9LRANTn8uTdLPxc7EdVgAfFjvXs78Kbe49vcJG6LezWAQ0n0jc3hDJeqfMxwoCvgTFxh VrRA== 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=sLw8Yfzm3c8kou871/a66dUzbZwPUL/eRicOlobjC40=; b=NPVbyotgIb2fX80tIF4KeuLWRgDNEVSKaaX+Fj0tYpxFjOjsgmB4JmHDY0JGLos9dg UjfMbXvu/I1HaQtI9Ji936fez9hfcOPFdFlg2ViU6yPb0fe4aY2g49/OBMbomMDAuLXO pDOGhf5mZTgFwefmsn3qwiTOlqhwrFoFBe3zCJ3gx3TImNEDhahecTb64sGIq5K1+Bcb 3m9NOz9s/vMqZrfiv3/BJR/CFd49P83yVSktgDOoEyLIa4rmjTIfAnDBfnJ8bHbFrMlQ oiBZkdts2/KKIc+bhfmBXlhg5rujAgMx4LJjN9qj5E7hFJXOdbYVT7L0gHIv9Ohz0nxn ZdAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rNPx12rA; 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=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 mq13-20020a17090b380d00b001efec8a14ecsi15343751pjb.99.2022.07.25.03.14.01; Mon, 25 Jul 2022 03:14:28 -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=@google.com header.s=20210112 header.b=rNPx12rA; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234132AbiGYKKY (ORCPT + 99 others); Mon, 25 Jul 2022 06:10:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234786AbiGYKKC (ORCPT ); Mon, 25 Jul 2022 06:10:02 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56C641836B for ; Mon, 25 Jul 2022 03:09:58 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id l23so19669122ejr.5 for ; Mon, 25 Jul 2022 03:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sLw8Yfzm3c8kou871/a66dUzbZwPUL/eRicOlobjC40=; b=rNPx12rA0JA1rhlipxU/3mPh+AskwJ44Bks9qWvCObOesppBf4cnHDrZ2h29VEONx7 MLC0UOa95uzVUTQu5eiflxrNjY7d4YVXKIvwT2IsnJo+6PrBHyak9XmDpC0Cvm/R/4o/ HCpIN5cvN+7uTri6ksW3XMcrgjLUmGFJjza/WPrMCSh8PTKJA8RotvW5rraIRFpUoDL2 +SKrKL1Hczv056hEIAgkBAB+BoCi9BnHvuxtecN8JAPYVzdnBdgKLEC3+rwPZnEMViMW 8qXn6rIkOTtiYzl1qUmIpX+wxAJCiwOjLwpfj1VlVFetFd/0dgA9oyFTiFm7HeAmlhM3 W76w== 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=sLw8Yfzm3c8kou871/a66dUzbZwPUL/eRicOlobjC40=; b=6FCJoyFEf1c8Qo71C0k/THy/MUf44P8yNFjvzbYZt/wl7Cs88CizlGZPnZ05WrFNn1 757Ldl0Izf5ust2N/9DAPJIAPdx9I1lRYHQs0q4Zsyvl7FoGsX58oFg5emYV8xWRJynD ja2F2YVLiCiSd2ueB8m81f4uPb4oeCPhbm7c55RC+yhOWzgH7bXGed2r7DLS9Cs+9E6I FiJOvteYbCflmUjHQMt1h/f8HQTVvfPK+INGA0XSI7RkdYVMXixoQKmjAeP/HJm9esuM xsSDPPHHjRevP/pLQoDk2GXaHFs0hhzmLIY+HwDCUyCINO61iY3TjxvuUD0+mc7dvlqY XoZw== X-Gm-Message-State: AJIora/30nK/v+iKSPMTf22+IA+oaITz+XBBVawrs4gZZ/eaDRI/R7KO j3l0lIQKZal7EJkfNaZxHR/VVQJjJevV/3JWBZSeCw== X-Received: by 2002:a17:907:9606:b0:72f:826d:21b4 with SMTP id gb6-20020a170907960600b0072f826d21b4mr9600818ejc.510.1658743796375; Mon, 25 Jul 2022 03:09:56 -0700 (PDT) MIME-Version: 1.0 References: <20220722182248.1.I20e96c839200bb75cd6af80384f16c8c01498f57@changeid> In-Reply-To: From: Archie Pusaka Date: Mon, 25 Jul 2022 18:09:44 +0800 Message-ID: Subject: Re: [PATCH] Bluetooth: hci_sync: Use safe loop when adding accept list To: Luiz Augusto von Dentz Cc: linux-bluetooth , Marcel Holtmann , CrosBT Upstreaming , Archie Pusaka , Zhengping Jiang , Michael Sun , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Paolo Abeni , Linux Kernel Mailing List , "open list:NETWORKING [GENERAL]" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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-bluetooth@vger.kernel.org Hi Eric and Luiz, > "the userspace can still remove devices" is a bit vague. I mean removing devices via MGMT command. > It seems that the issue at hand is that hci_le_add_accept_list_sync() can > move the current item from pend_le_conns / pend_le_reports lists ? The issue is, hci_le_add_accept_list_sync() is iterating the lists when the content is being removed elsewhere. > Hopefully these lists can not be changed by other threads while > hci_update_accept_list_sync() is running ? Probably. Looks like Luiz also thinks the same way. > Please add a Fixes: tag Unfortunately I don't know when this is introduced. > Hmm if this happens it means other threads are actually interfering > with cmd_sync queue which is something that is probably a bug since > the whole point of cmd_sync is to serialize the commands making it > easier to do more complex state updates (such accept+resolve list > updates) Thanks, I haven't fully grasped the intention of having hci_sync and how to properly use it. > we could perhaps still apply this change as a workaround but > ultimately I think it would be better to add a mgmt-tester reproducing > the issue and have a proper fix of the code updating the list from a > different thread. Agree. Having said that, I don't think currently I have the time to invest in writing a test and a proper fix, so my apologies on this. Best, Archie