Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4756371ybb; Tue, 7 Apr 2020 13:56:34 -0700 (PDT) X-Google-Smtp-Source: APiQypKL9dWHPjPYB1q/IDq2y7WvsqznMSRefy9TrYE+uXR6wID8BtbJfZVDlNtyd8GrmL7OSAb6 X-Received: by 2002:a05:6830:1495:: with SMTP id s21mr3388268otq.35.1586292994038; Tue, 07 Apr 2020 13:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586292994; cv=none; d=google.com; s=arc-20160816; b=IVbcxNMSqFts1QZdjcVe7C7LWN92kSmJLf2XBMeuqkxSlUqBpigJOYqehx25Jd8kQU n65bBZuCEHm/7z4tUSF1755WfwOxbiUrJs+zLi4d4/gFrdZjKv9Is+0wTNTJ4TvjMfjC lzre2R2LTB5s26//pzzOcLMxys2E/N/2G2B4aFdjq1tA+DlP7IwVhKGceBxsp7xJ5jVs TMW1uQyxlOr52UZxiH/7bzzDNTWdQqVQGLhqVAfQlVefyQQENxOY54oxDf8dTuveLaRT JbCCXegbgfQikji9uI5G2X2u8b3d4YQPeH3U+fETjWVny9cT/DYZQaMYHFrQvPNTJoO6 BgFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=4rZeFjxln59jzQgtehPBm9ebFZRre7c9SHZe6+35qu0=; b=eWsWshjMLwUW09R5QibCcg+aVVLpmCumzEE29rqLlMmq4CHIP5b5WUoSNyHLznYJDF ja1f7cMoGJ/OA6/dHQ/Wt0mGNdDZUBQUV6LfPpHL3EIA4AojoqAAuXngagJEB9na+9uC /mWBkkbkBeGg350xTYR1Krxjy11BwIwV+CrBIb6ZJ3DW3lpV6i2db7YmDuH6cCvC4Afp Se1Jpc5L48UWIOT7ZZBOAUpxO2EgV2J7lbK529/TlcKcBHHlkrIi/zVLZOp3n7ZX2iEM 0Ad4UADx83Q8t9dkXCiC8uDvU+1bSQs+IceuG+iB7K1VZMd9fWnOg1tYOswdn+s378xy ra8A== 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 t1si1705950otj.216.2020.04.07.13.56.19; Tue, 07 Apr 2020 13:56:34 -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 S1726395AbgDGU4S (ORCPT + 99 others); Tue, 7 Apr 2020 16:56:18 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:39852 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726386AbgDGU4S (ORCPT ); Tue, 7 Apr 2020 16:56:18 -0400 Received: from localhost.localdomain (p4FEFC5A7.dip0.t-ipconnect.de [79.239.197.167]) by mail.holtmann.org (Postfix) with ESMTPSA id 76AEDCECDB for ; Tue, 7 Apr 2020 23:05:50 +0200 (CEST) From: Marcel Holtmann To: linux-bluetooth@vger.kernel.org Subject: [PATCH] Bluetooth: Update resolving list when updating whitelist Date: Tue, 7 Apr 2020 22:56:11 +0200 Message-Id: <20200407205611.1002903-1-marcel@holtmann.org> X-Mailer: git-send-email 2.25.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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); + } + } + return 0; } @@ -772,7 +805,7 @@ static u8 update_white_list(struct hci_request *req) } /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) { return 0x00; } -- 2.25.2