Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp15032pxk; Wed, 16 Sep 2020 15:41:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK9agLiv+kkP2AC29dwzOYJXaxbrZ4nvE1wUroPfMLjay5GtQaLvOhndRIjxHlwexHLYoq X-Received: by 2002:a17:906:4107:: with SMTP id j7mr28915620ejk.533.1600296093031; Wed, 16 Sep 2020 15:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600296093; cv=none; d=google.com; s=arc-20160816; b=iHpuUHyvlZ9XsNbsaBE4w4+zynC2tpOSYDfjaHObOX1sCkUr4Oa4RZx+ZyDwZv1MHP W+pL5vhqeaV73/Wia1L1J2b/xjnmrk4krlwIVA81/+3TS5xYM5+FrHafzwttQ9vIU5Tf 3Pwr8Bj+WfN0TNUpllg1tukPxTMP7Fd46ppfqUXL9WXYCJN0oNoNlSa/o8hGo0fhIGV8 bmz6hM6PZ8NaEXVsQzQV0Taeen/sksy8i7cmLg72ZHy/v6jeOvOq/4JX40abKXHYbf1Z bUepT2rMj3wyMJ/Efp7llPexrq/zgxxpWHUpvW/Jqs+qPmp7fHoAR75s6dH8FAsbgSCn D6mA== 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=Gv5Ym7Y65u7UpAXs48lxQYYvj7ha6lG/xcFtbTRD8zI=; b=kEtwmil7MIbxdxlITJpH0I0ub7iCBUgK7ywD6jmehakhbUpmrrUPhv2tjD8hEDUKCj CMMvTrLSKyu27c3wLUNtSgUrRqTGJqET/Bgg+OVDV5wtYDkjDEWPy0VBQOfMDT6lEvPH xDjAqJmD9QtTE60R4U8wY4NQifleXD2bjv4W+QC6/X4Srdsxx9L0oYKfEFhEo6V1ASA7 Y+5zzaNtdZX/zqCo54pxG0d030mnVq3Txt89/sppcgmGYK1ntBEE80PcVH3u5XUXCsWG GBsZhFc+r7sqmHGb/JsqPRs0asLthq7IXCY/WTP5WFko0pkv6rsSywMIdwKHpBUslKzr fC4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=H3r6+T3l; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kt6si12661494ejb.276.2020.09.16.15.41.06; Wed, 16 Sep 2020 15:41:33 -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=@chromium.org header.s=google header.b=H3r6+T3l; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726397AbgIPWkO (ORCPT + 99 others); Wed, 16 Sep 2020 18:40:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgIPWkN (ORCPT ); Wed, 16 Sep 2020 18:40:13 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0096CC06174A for ; Wed, 16 Sep 2020 15:40:12 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id j2so200042eds.9 for ; Wed, 16 Sep 2020 15:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gv5Ym7Y65u7UpAXs48lxQYYvj7ha6lG/xcFtbTRD8zI=; b=H3r6+T3lprSi9LqwoZJK0zuMM9U8FaF/TNFQbuwOTd5OvetcZ6kPTEIbjnl8Ma7QVn st1OLTsPVcGlIsGPOGpCRbTpY/o5hH2XhNmjlNHwvP0kgs7zcZZV1be8+rerIjAmDXpx sO3M3DuF5/ps6BjVRJDuGOLGrsOGcdyafsM7A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Gv5Ym7Y65u7UpAXs48lxQYYvj7ha6lG/xcFtbTRD8zI=; b=bA1MUP7vbeKLN4vD3iYCBbT1AtRCUVaXR+vpWLOrz/Ms0CBKFHsrDsdKN0ge5T3LV8 IAFQHxHCYVlXqy3j7NUjCGLDQZFRV2e/KcY3RevfUNLErZ1q52SajbZYL6pe27ekge7Z wRu/ZZSFraI5Q36Fq6aJG7TTOf/Kl61rmHvBaTJRGdceEJWCoS+R77tD4d1NIBzV1LoC K4u1fhtq6xyv3r5ioOXKgE37IDJG6c/X9dP/fEXtBE/VKdXNlxH34Vyy9WRWGa2Ejb+A CT07pGHwntcVXdAY+3ZFTwoRf7HehpsESVEIUSAC8jFuJU3LGE8XLYBwy8qSpplzpyuh 3xvQ== X-Gm-Message-State: AOAM530aBUxoVkqQfOqk/UbgQYO/HZeREE7oBHvVJBCORrJ9XG3zxcR9 odS5BKBrzlCySx0wWKMEOrk0Wk/YqxBnQw== X-Received: by 2002:aa7:c054:: with SMTP id k20mr30373740edo.224.1600296011255; Wed, 16 Sep 2020 15:40:11 -0700 (PDT) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com. [209.85.128.47]) by smtp.gmail.com with ESMTPSA id cf7sm15036479edb.78.2020.09.16.15.40.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 15:40:10 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id e17so128647wme.0 for ; Wed, 16 Sep 2020 15:40:10 -0700 (PDT) X-Received: by 2002:a05:600c:2312:: with SMTP id 18mr601790wmo.141.1600296009905; Wed, 16 Sep 2020 15:40:09 -0700 (PDT) MIME-Version: 1.0 References: <20200814190909.361764-1-sonnysasaka@chromium.org> In-Reply-To: <20200814190909.361764-1-sonnysasaka@chromium.org> From: Sonny Sasaka Date: Wed, 16 Sep 2020 15:39:58 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] Bluetooth: Fix auto-creation of hci_conn at Conn Complete event To: BlueZ Cc: Abhishek Pandit-Subedi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Dear maintainers, Friendly ping to review this patch. Thanks! On Fri, Aug 14, 2020 at 12:09 PM Sonny Sasaka wrote: > > Currently the code auto-creates hci_conn only if the remote address has > been discovered before. This may not be the case. For example, the > remote device may trigger connection after reboot at already-paired > state so there is no inquiry result found, but it is still correct to > create the hci_conn when Connection Complete event is received. > > A better guard is to check against bredr allowlist. Devices in the > allowlist have been given permission to auto-connect. > > Fixes: 4f40afc6c764 ("Bluetooth: Handle BR/EDR devices during suspend") > Signed-off-by: Sonny Sasaka > Reviewed-by: Abhishek Pandit-Subedi > > --- > net/bluetooth/hci_event.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 33d8458fdd4a..6b83da1790ee 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -2566,7 +2566,6 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) > static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) > { > struct hci_ev_conn_complete *ev = (void *) skb->data; > - struct inquiry_entry *ie; > struct hci_conn *conn; > > BT_DBG("%s", hdev->name); > @@ -2575,13 +2574,19 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) > > conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); > if (!conn) { > - /* Connection may not exist if auto-connected. Check the inquiry > - * cache to see if we've already discovered this bdaddr before. > - * If found and link is an ACL type, create a connection class > + /* Connection may not exist if auto-connected. Check the bredr > + * allowlist to see if this device is allowed to auto connect. > + * If link is an ACL type, create a connection class > * automatically. > + * > + * Auto-connect will only occur if the event filter is > + * programmed with a given address. Right now, event filter is > + * only used during suspend. > */ > - ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr); > - if (ie && ev->link_type == ACL_LINK) { > + if (ev->link_type == ACL_LINK && > + hci_bdaddr_list_lookup_with_flags(&hdev->whitelist, > + &ev->bdaddr, > + BDADDR_BREDR)) { > conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, > HCI_ROLE_SLAVE); > if (!conn) { > -- > 2.26.2 >