Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp366286rdb; Mon, 22 Jan 2024 06:46:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMxE+4xMkVxMSNehKYajDV/1VkiaMw9ZnYWIMtoPXhIAG+/oranOVHGRj0C1OAUrnj2nMI X-Received: by 2002:a05:6102:3a13:b0:469:8a40:897f with SMTP id b19-20020a0561023a1300b004698a40897fmr1840449vsu.29.1705934760628; Mon, 22 Jan 2024 06:46:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705934760; cv=pass; d=google.com; s=arc-20160816; b=F/41bfqJg2KfvUYV1pQEB78V+aZLzMdDCy6yGpYtd3K93AFz15nPDnpH+4SLci70Ib JweSCIx1ueRMoiOckI3qc+VMiidIrTRqe/vhFhwpH/5A9L5mam0sU+dUyhGITLCThdlE ows0ebIH5ngECrGiIgR6cuIUCIuU+fz+2jgEs3+olBBcS1l8fUb7YIrZidRqBCVgYloP yYG1utAYfiH6ppMxKTj7JsWwXgUJA4TxNAA6iBsAV/GqPwReT+RSaux2NyPL94o3qg6i L8srRzppFtxf3rkziG5dCufva216SP//X1diMNMP3PNhJnHzhjuKGBrTnyZCnnpem7G0 pIsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:from :dkim-signature; bh=EqXCKGHnXT0KXUzsFLxHmOxEpLgsFzriqXWJ5Er7ri4=; fh=v4Z3N2Htbr8NtGqMLkQjkIE/EbeUcf6lhEWEAm07n3g=; b=XZejpzsWnOKL3CdjSQKseHWKOm79i0H19bR2Am/EooPj+gVj9XxyCRHJ0WAV/elx80 SXuuIWFgcphvquQ/UleK809Wrf/ZyJL9P/qLhtBG4eCr9piCPmFEHHZwJZ64/+4ghBGM rRCcPwqOO5lg18FvyfYFRj+roKRphJl4zHaxypB+pk+pvy9Fc3HPvPe7k5nh7vKP0Qa9 xIR7K5pN6XxtzzYyRLagfrsNscH14wmRIVskw9yVK73zZTbdEj2PTygBOD0CVucUDJdE ZGlWZbFNF6PA6Er+PkpE4Mja5vMaO98xx+U8sOuPpeXzL39lcWb3bOl+Rpy9DsyGTSSw XaVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mobile-devices.fr header.s=google header.b="gcbuAl/v"; arc=pass (i=1 spf=pass spfdomain=mobile-devices.fr dkim=pass dkdomain=mobile-devices.fr); spf=pass (google.com: domain of linux-bluetooth+bounces-1221-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1221-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a16-20020a0cca90000000b0068170693ac3si5841184qvk.90.2024.01.22.06.46.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 06:46:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1221-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@mobile-devices.fr header.s=google header.b="gcbuAl/v"; arc=pass (i=1 spf=pass spfdomain=mobile-devices.fr dkim=pass dkdomain=mobile-devices.fr); spf=pass (google.com: domain of linux-bluetooth+bounces-1221-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1221-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 499A51C224E6 for ; Mon, 22 Jan 2024 14:46:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 985233D56A; Mon, 22 Jan 2024 14:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mobile-devices.fr header.i=@mobile-devices.fr header.b="gcbuAl/v" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2493620DF0 for ; Mon, 22 Jan 2024 14:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705934754; cv=none; b=YSADQzioXyVzIEQxI8O9zb7Z6NMjLLCao7hAYRHzMtMPLTQ/ci9eflfqNeSlVK/uOAj0div6c/Jjb170vBYprD69Wj5phNxxn31Ssg1ChfH1dJk4QmhvYB4UwOr7WS1wzhbAFXgEHfhhL4GcSkgCrkNRVvK4dp/3os4T9ABS2mo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705934754; c=relaxed/simple; bh=GogtZwYgHxZ/f05d4Wz2aHemGMxZcczpVrQmPLbn3gQ=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=H/ltGY/6/gQc+fU0jmvUdQBxDXruTNLPwbIgw0+TlMeTuZ1VHpN7G1DhaM3ukH4sReX31qSQd9Q8GIw0KkpaXizlk1jt/AThLOKcknXHWOKNnwYENzFv6MdXjgoQ5iEsegBPDOGvq9tHshgj3k1m5IcqwYRpLZq6VbsRI8acdAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mobile-devices.fr; spf=pass smtp.mailfrom=mobile-devices.fr; dkim=pass (1024-bit key) header.d=mobile-devices.fr header.i=@mobile-devices.fr header.b=gcbuAl/v; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mobile-devices.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mobile-devices.fr Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-40e490c2115so25911385e9.0 for ; Mon, 22 Jan 2024 06:45:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mobile-devices.fr; s=google; t=1705934749; x=1706539549; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=EqXCKGHnXT0KXUzsFLxHmOxEpLgsFzriqXWJ5Er7ri4=; b=gcbuAl/vI3XVLcKWWdhC/nuxDYZEe4MIeCS/Gt8gcnIh4+ETR/oS4Yi25UCqElh4yu qZq1scN2Zj6bBIm2xCgWf4LW/VzsavcPHzvH3Hp9QjcHRixl1k8ZnPRRB5irGMVDibDk Ota1sO1jNC5LV9c0MFoxmfuQT+l9sWbo0ZXXM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705934749; x=1706539549; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EqXCKGHnXT0KXUzsFLxHmOxEpLgsFzriqXWJ5Er7ri4=; b=M9I6AZiE6npSh7I0Ca8PDvEQG2BIU2oGmm8mzRWcxc+zGVQ4MCsnI4T8fxas/XdolI pZco1+3QEs99cWlo0PdQx5e/+8dTSKxr2FkJ/K4USrY3y9JrWX4IVorcig537nnuigC+ Z3O2sJH2GW/SY495CiA59BlHL8DcwdsUAXYTPlEsgXZ0Zea/NLVFAB/H+kioBZ9nqlnG MqYLRX9+w10SUHYkyMYmhxiMOAi1+uJxMUW6nY6ey9k4EFAhdCy01HFR1ddEZBkWo7Ls th3WWJvzl70PqP7tnCWFDT9IgZkKmAbuoMIn5aEtHtf8Abas+ns77unIGe3ocaB1xNlP hFyQ== X-Gm-Message-State: AOJu0YwP/oRuowZc6eOobubt5Y13nCygzQnWD8EubOXmaRyP0W+qGO+u nz0aRL/ajqFbEu1A24pzTmmAe13f2nQn543iW37btw2tyuDpjNtFuuZvi4RYT9jE99ZPXHjgZo+ m X-Received: by 2002:a05:600c:3109:b0:40e:8655:d48f with SMTP id g9-20020a05600c310900b0040e8655d48fmr2881890wmo.11.1705934749151; Mon, 22 Jan 2024 06:45:49 -0800 (PST) Received: from [10.42.100.11] (static-qvn-qvs-183113.business.bouyguestelecom.com. [89.87.183.113]) by smtp.gmail.com with ESMTPSA id jd21-20020a05622a719500b0042a41b27d3fsm740877qtb.90.2024.01.22.06.45.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jan 2024 06:45:48 -0800 (PST) From: Andrei Volkov X-Google-Original-From: Andrei Volkov Message-ID: <747030d8-a06f-4d7d-bf93-0e95f54b9bbf@munic.io> Date: Mon, 22 Jan 2024 15:45:46 +0100 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: regression in c7f59461f5a78: Bluetooth: Fix a refcnt underflow problem for hci_conn Content-Language: en-US, fr To: Luiz Augusto von Dentz Cc: linux-bluetooth@vger.kernel.org References: Organization: MUNIC In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Luiz, Wouldn't it be better to add a 'yet-another' flag as an addition to HCI_CONN_SSP_ENABLED, and clear it unconditionally at the top of 'hci_remote_ext_features_evt', before "        conn = hci_conn_hash_lookup_handle " check? In this case broken ext_features response (with ev->status != 0 or conn == NULL) will not indirectly enable the SSP feature. Regards Andrei VOLKOV Le 22/01/2024 à 15:02, Luiz Augusto von Dentz a écrit : > Hi Andrei, > > On Mon, Jan 22, 2024 at 7:18 AM Andrei Volkov > wrote: >> Hello, >> >> Lately we've bumped with regression introduced by commit: >> >> c7f59461f5a78 ("Bluetooth: Fix a refcnt underflow problem for >> hci_conn", 2023-10-04) >> >> The regression related with adding "hci_conn_ssp_enabled()" check in >> "hci_io_capa_request_evt()" handler, and broke pairing process initiated >> by the external device. >> >> Precisely, some ext. devices, like any phone equipped with Android ver < >> 14 (we have not latest one, so we didn't check), always send "IO >> Capability Request" before "Read Remote Extended Features" command, as >> consequence the flag "HCI_CONN_SSP_ENABLED" not yet activated at the >> time of "hci_io_capa_request_evt()" execution and >> "hci_conn_ssp_enabled()" always returns false in time of the pairing. >> >> As a result, pairing always fails. The quick and dirty fix is revert the >> ssp check introduced in the subj. commit, like below: >> >> --- a/net/bluetooth/hci_event.c >> +++ b/net/bluetooth/hci_event.c >> @@ -5329,7 +5329,7 @@ static void hci_io_capa_request_evt(struct hci_dev >> *hdev, void *data, >> hci_dev_lock(hdev); >> >> conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); >> - if (!conn || !hci_conn_ssp_enabled(conn)) >> + if (!conn) >> goto unlock; >> >> hci_conn_hold(conn); >> >> >> However, a more thorough and correct fix requires discussion and >> testing. Therefore, I would like to get any comments/suggestion from the >> community before doing this. > I think we need to do something like this, so we consider only the > local SSP flag when evaluating if we should proceed to respond or just > drop: > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 6130c969f361..a15924db83d9 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -5327,9 +5327,12 @@ static void hci_io_capa_request_evt(struct > hci_dev *hdev, void *data, > hci_dev_lock(hdev); > > conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); > - if (!conn || !hci_conn_ssp_enabled(conn)) > + if (!conn || !hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) > goto unlock; > > + /* Assume remote supports SSP since it has triggered this event */ > + set_bit(HCI_CONN_SSP_ENABLED, &conn->flags); > + > hci_conn_hold(conn); > > if (!hci_dev_test_flag(hdev, HCI_MGMT)) > > >> Regards >> Andrey VOLKOV >> >> >