Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp612912ybh; Wed, 15 Jul 2020 10:27:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxqD9jLtbWnBs9UDpG/t3cnA2IeCa9T/A10pCwsW6rio1LxLR6WZcxoIsaRHgmxQcyeUpK X-Received: by 2002:a17:906:ae56:: with SMTP id lf22mr25746ejb.59.1594834039554; Wed, 15 Jul 2020 10:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594834039; cv=none; d=google.com; s=arc-20160816; b=uOIBYWHoGWSHZSYI9Bv3hIOilU2eQ/M66/sNB3a7kjjTttvtgm9HekOkaa4eD2agNK Wvy8LUizhGSpdJNelQSEj+fAuEBDJiFP2vNfr1y/09YKxL9mT2EMPTH0VflpgdIV8Fnp 0mcVDlgv07BfV8/40kyKB/3nhF6ujW9L2Pd0lLnawwTA5962JZe7dRJ5BotfTaNRDwlZ 71ku7p49rTD7piNXebUcwcqh0UoO6PCQq2VXjmFOsf+cPssclK/f2imjBeJDLB5HHq71 zNhvLw9YF7U7q901TuoS1RHg3QSr6Krm6N2Mrgmbnwz3C6dhW/2dyH+Y0PBkhQP+OEPA j9Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=ZQI5LoCLf3kW9vPX1tZGQ/TqG6jhunp2LIK4dsOkaTA=; b=AjCdPRfV2pDXmxeLJCrMfIiarHZvVlG0hnMzZvg603UHbCmJ6iiYVLXFJgOnVR3k53 UjUyUXQgUqFmw/6im3y4T4M87JGivHt0nP8KRyOi6Xcl21I69/M6MFgCgZD+bBpcbl6c shprRptxxnF6OmPE/3pPk1MeueHbHJHfliqv96e6kzmPHWa/NcNUCfnKIBAnBiqavt1x Ee1US/SO4qPscOc96zkmxnzm5cEXle0Ujpi8iKNGhE2zSyukfS7C+5C3/pENdnmt0Iky 4RHuraMzRkJr8+gacTFJvciOSiH0legX3oFB+Kce8IuVXmqDVMae5QmSCpKrxWFrpmWE CC2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pks.im header.s=fm1 header.b=aCQb6+Sc; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=irZhqlqu; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bl25si1448378ejb.731.2020.07.15.10.26.33; Wed, 15 Jul 2020 10:27:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pks.im header.s=fm1 header.b=aCQb6+Sc; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=irZhqlqu; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbgGOR0D (ORCPT + 99 others); Wed, 15 Jul 2020 13:26:03 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:33947 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbgGOR0D (ORCPT ); Wed, 15 Jul 2020 13:26:03 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C528A5C00AB; Wed, 15 Jul 2020 13:25:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 15 Jul 2020 13:25:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=ZQI5LoCLf3kW9vPX1tZGQ/TqG6j hunp2LIK4dsOkaTA=; b=aCQb6+Sc6xn3Tje56M8sjEbcaIJSItsgz9PtvJ74z5P aXEFzYyYWQLol+xjzbP7lEriNFP/cyJLqvFvVSCD0xfSxgr9NHFErl7rCpERa1Dx SgR7aeeo+35X70HuHitLrAUuK2yHGqvUYGGNC59W8VhakospTKe5/rKn/yC6DuwZ Jdmbb2Tgp8Rs3LtzCKF8oSGVl1eTVaTVwohAzCk5CetQLUGPCacWCRYm6scPI9p3 IHF7s5dncZ2WRGfAxci8L07xqMc3gtbgtOM7SzrgWAEmJylTijhLBj8XZujMRT8c 8U3jtFgBLmpxoOZFtnghHYIxOwUkBFGZ3MLYn+N6/KQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=ZQI5Lo CLf3kW9vPX1tZGQ/TqG6jhunp2LIK4dsOkaTA=; b=irZhqlquZOHw0Di+KuJL0A BWHJuFc6Rvgtp7F+MqmzTPJ4Qj5TgbFnxwLzdyrwHKMyp1ruFXUTzUSJfMRiwZXX Fd2paJZFTnCj5tVS8/xxSfVUmGI8Njyh1lPEKKKFPrrCd78PAjefJspvrk82vPbX 7dVVJ95Ld/WmVZmFWxxrpmOnEcwv9Gj64vFNceAfuaCevGymPbxAYHXNnV0SOlO0 NGvMw3fG31sdQWMAJ/jqd+CA7Wx7ddqLWGyBUePOQG3kRDOBJ4PEB9QvNGL+Xcoe DvGLpsTYRxSKELRe7ShshmyGJHaT/Sf9CuEIFKE0giTVAYyM/uKqQ3CxaLSVpHTA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfedvgdduudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeehgefhtdefueffheekgfffudelffejtdfhvdejkedthfehvdelgfetgfdvtedthfen ucfkphepjeekrdehhedrgeekrdefudenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: from vm-mail.pks.im (x4e37301f.dyn.telefonica.de [78.55.48.31]) by mail.messagingengine.com (Postfix) with ESMTPA id 3C72B30600B1; Wed, 15 Jul 2020 13:25:58 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 77a62e29 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 15 Jul 2020 17:25:56 +0000 (UTC) Date: Wed, 15 Jul 2020 19:26:45 +0200 From: Patrick Steinhardt To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Subject: Re: [PATCH] Bluetooth: Fix updating connecton state in `hci_encrypt_cfm` Message-ID: <20200715172645.GA825@ncase> References: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline In-Reply-To: Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 15, 2020 at 08:40:05AM -0700, Luiz Augusto von Dentz wrote: > Hi Patrick, >=20 > On Wed, Jul 15, 2020 at 7:50 AM Patrick Steinhardt wrote: > > > > Starting with the upgrade to v5.8-rc3, I've noticed I wasn't able to > > connect to my Bluetooth headset properly anymore. While connecting to > > the device would eventually succeed, bluetoothd seemed to be confused > > about the current connection state where the state was flapping hence > > and forth. Bisecting this issue led to commit 3ca44c16b0dc ("Bluetooth: > > Consolidate encryption handling in hci_encrypt_cfm"), which refactored > > `hci_encrypt_cfm` to also handle updating the connection state. > > > > The commit in question changed the code to call `hci_connect_cfm` inside > > `hci_encrypt_cfm` and updating the connection state. But the conversion > > didn't keep old behaviour of when the connection state is updated, which > > now causes us to not properly update it anymore. > > > > Fix the issue by adding another parameter to the function that allows > > callers to specify whether the connection state should be updated, which > > allows us to restore previous behaviour. > > > > Fixes: 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci= _encrypt_cfm") > > Signed-off-by: Patrick Steinhardt > > --- > > include/net/bluetooth/hci_core.h | 4 ++-- > > net/bluetooth/hci_event.c | 6 +++--- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/h= ci_core.h > > index cdd4f1db8670..9abcc4a89abc 100644 > > --- a/include/net/bluetooth/hci_core.h > > +++ b/include/net/bluetooth/hci_core.h > > @@ -1381,13 +1381,13 @@ static inline void hci_auth_cfm(struct hci_conn= *conn, __u8 status) > > conn->security_cfm_cb(conn, status); > > } > > > > -static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) > > +static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,= __u8 update_state) > > { > > struct hci_cb *cb; > > __u8 encrypt; > > > > if (conn->state =3D=3D BT_CONFIG) { > > - if (status) > > + if (update_state) >=20 > The intent was actually to have if (!status) as it means the > encryption has succeeded the state can be considered connected, so I > wonder if we really need to introduce another parameter. Anyway as it > is broken we need to come up with a fix rather quickly. Yeah, I kind of figured that to be the case but wanted to go with the "safe" fix of restoring old behaviour first. I'll test whether `if (!status)` fixes the problem I'm seeing and will send a v2 in case it does. Patrick --1yeeQ81UyVL57Vl7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl8PPFQACgkQVbJhu7ck PpQrNQ//d7HU+xTNhXl70rUrLEgRtk3kZg6N6wJEb72WLk6GgHEvmBj/uyuzl4cR Yc/aB6HHShQArmsDOh044Duc3GlTiaDQbZfzzW+EDhU9fcpZEgan1rSPtYi6faKe 1YgY/CklRuOv2FAK0I64+Vt4CYGHsONzm/0I9b5qf89GA1qjMGTvQgRxMm0+vNu7 2AvTeRcBlCqEfVUz+mfada25AeiaPVbf8Rdr+tQ8K28LxM4KJoJrbpDZ/cDE9U4R OVr13r2q7wTOnPKuXYMVwefL+w8EXMWC0H4HZP3GklrTUMWTyV3asmr/pLzyrKKo tlLnB+eaW/E6YrRBPFXUoxBnG7if/Rt/Ez+C8PKbF3gyr+C2COknVkbswiMnHaZU 7blAUMsHzplaUJGsKKYPnclUvjVhgGii1NdGgG2F/D1spT8a+s6UfiZ0/tajvAE6 Vv8aBKgMd3GyOG2v04aYw4gcqfbeBW2Q27SHuhK2YRmAypfi/QhzkQlG6H0lk3BH yZ1ZWOILa/qNpsd6nz/Q7Pl7GJ1WC9t3R9Oqj2D2nwhCqHlOElUpBIJtFLEIACTA DkJ4CFlCPcarsFdEasAesw+Pq4T4O/o7VDYUJ4ViTuxXFjP+nLPan4oVBuC2ZieK 9qB31qLwjW/GNfMs6Qvsz5OtTa/hKLnCkNC8Pgb/DUqRDeIwVpE= =G0oM -----END PGP SIGNATURE----- --1yeeQ81UyVL57Vl7--