Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp42217ybb; Tue, 7 Apr 2020 16:23:44 -0700 (PDT) X-Google-Smtp-Source: APiQypLfUSSm6qG19Ut8g1GhOBzZL9WO1/tZPl47/IS8kyQRH4/6Fys5yiYobbc/Q7dRBVWgx+9J X-Received: by 2002:a05:6830:146:: with SMTP id j6mr3557623otp.352.1586301824833; Tue, 07 Apr 2020 16:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586301824; cv=none; d=google.com; s=arc-20160816; b=ztvF9Gzl9pQSOWk9Mm4REz7+hjK9wLtgUKsFKcwJ74pzRqdA5Uvc55nI9V5NbnWNyd nDCnuLBPMaba3P5xjJ2mkN9AzoiO0mWAxtK9HqeyV8QZme8jj95jgQPLziKWidW/bJtX u+Ex5HbAbGc6xBDPaX2Zt0GnREFbTBBL4TN5hmiCFe5nMbR9xs56ZJB7H6vrMBICPRuB yH/c2WzDVsTiKJYxILr5XmBft5pd/LCvvp+KgmhJQuih+tx81yjRl0eM2dAPpZDGbIka D8cm5x59vZ+GfDNIKvCtiVUY7zOwIxAd+HAFNiLau84Ilhx9AWUldQs85NNOyaFBlJ+r ILhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=g84Ke+L0BGNedOtYPla7yPU331UpQ9V7HfUVaq6oFWg=; b=dpC2fOkDuf98UcScABy5i01X0l5Evo+Z1Vr5PTmS2vEiWaoBB9v/OaqRBblkeY0AAs dIGnSQvCjJxpoKUqpidX0UmsfpbYxRZuBBrjmdbPZN3PDZk+pRRatKDiLxBZ83+S+xac H+mOdveyxwXIOv0boHZRkCmIKj/JFcNVJG3nGlS4rVkloj246J/YW7jteNJoZbGaGQm1 xl7L3fiWRXETMV0uyLEgdut7NS0TFzQPsWeUBuOi8JZvlZ9NGwQtgfcx8f+1jvr///BS QhNU4CL5+hNYgpepl/A7svOZAZStG/ZgZQsOxaFKbH0ng68qKJtuVT7mcexycYHEe/nY s7Rg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si1974064otf.299.2020.04.07.16.23.28; Tue, 07 Apr 2020 16:23:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726417AbgDGXXX convert rfc822-to-8bit (ORCPT + 99 others); Tue, 7 Apr 2020 19:23:23 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:56955 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726386AbgDGXXX (ORCPT ); Tue, 7 Apr 2020 19:23:23 -0400 Received: from marcel-macbook.fritz.box (p4FEFC5A7.dip0.t-ipconnect.de [79.239.197.167]) by mail.holtmann.org (Postfix) with ESMTPSA id 5FFC6CECDD; Wed, 8 Apr 2020 01:32:56 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Bluetooth: Update resolving list when updating whitelist From: Marcel Holtmann In-Reply-To: Date: Wed, 8 Apr 2020 01:23:21 +0200 Cc: "linux-bluetooth@vger.kernel.org" Content-Transfer-Encoding: 8BIT Message-Id: <8FE77D49-9522-42C0-BE0C-C282281389E9@holtmann.org> References: <20200407205611.1002903-1-marcel@holtmann.org> To: Luiz Augusto von Dentz X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, >> When the whitelist is updated, then also update the entries of the >> resolving list for devices where IRKs are available. >> >> Signed-off-by: Marcel Holtmann >> --- >> net/bluetooth/hci_request.c | 37 +++++++++++++++++++++++++++++++++++-- >> 1 file changed, 35 insertions(+), 2 deletions(-) >> >> diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c >> index efec2a0bb824..45fbda5323af 100644 >> --- a/net/bluetooth/hci_request.c >> +++ b/net/bluetooth/hci_request.c >> @@ -695,6 +695,21 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, >> bt_dev_dbg(req->hdev, "Remove %pMR (0x%x) from whitelist", &cp.bdaddr, >> cp.bdaddr_type); >> hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); >> + >> + if (use_ll_privacy(req->hdev)) { >> + struct smp_irk *irk; >> + >> + irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); >> + if (irk) { >> + struct hci_cp_le_del_from_resolv_list cp; >> + >> + cp.bdaddr_type = bdaddr_type; >> + bacpy(&cp.bdaddr, bdaddr); >> + >> + hci_req_add(req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, >> + sizeof(cp), &cp); >> + } >> + } >> } >> >> /* Adds connection to white list if needed. On error, returns -1. */ >> @@ -715,7 +730,7 @@ static int add_to_white_list(struct hci_request *req, >> return -1; >> >> /* White list can not be used with RPAs */ >> - if (!allow_rpa && >> + if (!allow_rpa && !use_ll_privacy(hdev) && >> hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type)) { >> return -1; >> } >> @@ -732,6 +747,24 @@ static int add_to_white_list(struct hci_request *req, >> cp.bdaddr_type); >> hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp); >> >> + if (use_ll_privacy(hdev)) { >> + struct smp_irk *irk; >> + >> + irk = hci_find_irk_by_addr(hdev, ¶ms->addr, >> + params->addr_type); >> + if (irk) { >> + struct hci_cp_le_add_to_resolv_list cp; >> + >> + cp.bdaddr_type = params->addr_type; >> + bacpy(&cp.bdaddr, ¶ms->addr); >> + memcpy(cp.peer_irk, irk->val, 16); >> + memset(cp.local_irk, 0, 16); >> + >> + hci_req_add(req, HCI_OP_LE_ADD_TO_RESOLV_LIST, >> + sizeof(cp), &cp); > > Shouldn't we be checking if there is any space left in the list before > trying to send the command? I wonder what would happen if there is too > many IRKs, I guess that means we would still have to resolve them in > the host. the resolving list size is just a guesstimate and no guarantee that space is available. However my assumption is that if you have x entries for whitespace, then you also get x entries for the resolving list. If we are not putting the device in the whitelist, then it also makes no sense to add it to the resolving list. Regards Marcel