Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp662200ybg; Wed, 3 Jun 2020 10:15:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUPPXTUF7iSlOyReTv7EBTQLirjPJ40RLfyvUbOfqxOSzGqUcpJRkJCOW3GeB5ylzuA3eg X-Received: by 2002:a17:906:f74a:: with SMTP id jp10mr290111ejb.43.1591204501985; Wed, 03 Jun 2020 10:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591204501; cv=none; d=google.com; s=arc-20160816; b=OR/8mCU6wgaUUqqQf82lu1wuJ2vO3nsKuBIrXvuaoju6l7NHAGzR4KmBQytAp45lyG J/DpMnKssuUEmJ0SMcO49I2Jfa3yUXz1BsAvT6oaK1LT3st927SqS+GNSRgnv4314Ft0 IPjmCUBMYeTEa14f7o0x2kCS4+HyDrniWukCRIIYzQxKXAbmqmFDgUgy4DplQYAyGwud vw4vpwLf1ddJKjAqe2LQW40NlcRPiR7cVA0DF+Xwz+n71U54TMzSbXa6zJ9wrJUvP/RH ScBkrTaqYBtf7OrgOzY5RFT4HfROBLPBKMQ4eH0hHEzKvtcn7DUD+AYugkUHiuWT1CS2 qHgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=KNTecTNnvShK+jbDcWYwGt/NrIa6D+tmpxROB3vM6M8=; b=nU5ens3fEdPGF5i+14WBK+4mFx8af2thLR5D3WiGid6OKbRYst48hBnUr6pfYSRH2F zXVDHSF3EvY/e59J4nSeg/uox7Ni0x2aDVpUzRrmDLYnyTi0NZaLdL+nrpBB4RU1hWCv rps/1ZrNC6y++9U4rEkibNIhqJuldxmToyj3l16EDu0BNhQmcsOStNVJsRd1LRJiVIAq Y01Tb9VR2segcHyG9cy1YCBJAimkVxy9+F//Rdac7X47423BRLdsNVyjUYLR30umRbW1 RTMBP0XjeHDelotZ7SJ3xDOpDetb/fkgEvB0PVlTs515uYXX8ymOUpyCi81A5mmRngK2 X2wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="at5OV/Ap"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si100020edy.210.2020.06.03.10.14.34; Wed, 03 Jun 2020 10:15:01 -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=@gmail.com header.s=20161025 header.b="at5OV/Ap"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726184AbgFCROW (ORCPT + 99 others); Wed, 3 Jun 2020 13:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725961AbgFCROV (ORCPT ); Wed, 3 Jun 2020 13:14:21 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2358C08C5C0 for ; Wed, 3 Jun 2020 10:14:21 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id p21so2146419pgm.13 for ; Wed, 03 Jun 2020 10:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KNTecTNnvShK+jbDcWYwGt/NrIa6D+tmpxROB3vM6M8=; b=at5OV/Aphg1X15SJ6Eudv7cdLkdv7OEmmo396zQMsxOfwC/sWeS+XPG4o1UD0SzG6f o6Ukg+ZtxUln86oN8/N40G6gnwv0xDqRSHAn+kRg2JHsiL5dDDBFuDiEDMV2XJGgsCfu mYGTvXQBbgLWAlqgS2rSH8rmvtKjWoLjGVh9Yj6uKQQmz/IyQFUtyFfLeMd1FRfFV3mc iWdhW7r3GSeVXcaKl8wpsavS8HjBmJj5jsrdfsPqUxf7SWZl3Kl2ruS9Cwv4ZHK8kcWa 7RnFZLGn0Hn7iorgCT8l4sPvH6YgTQjsjW73IE2j7iJF3X+nsx3b2A0Zf6VdDSqOZMu5 5E2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KNTecTNnvShK+jbDcWYwGt/NrIa6D+tmpxROB3vM6M8=; b=F2Y72uy7ZSbUHkELxCnWqJuO2yyJxr8T/alTwy8oQ+tJToYiVm/Vo9kc7EXdip6zli GNarDLAPIWy/XEJnFazTd4ckujrZosFodYbnl+QlK7j8C+1U1Qc8MiUQJNVqGVr3mYur nIqpDQ8CIgTVYIhQizdNbBfiCIb1+3/RrjcEXXlw2bXQdphokUcIqmkvpS71ThvV49PN 81tWIcP9RqyLobIlY/cJBb+in+LhUwThCbiT1vThu3/hsFQNGicXMck+DhTJhIDX6AP6 UwOGtFocAorZkAqnPt8m7pwdNJexdg0Skdbq0fDU+UeGZ5kss1AWOBcM5TFA4OKCrOYH 0TTg== X-Gm-Message-State: AOAM530YwzG1DRhytowvGEAL0ESroe2P+DS2nzXkOzvhuJtUOrCaYKJh 6Dpp/rKzC/Ypy38Siaq2cD0/0NKBhbA= X-Received: by 2002:a17:90a:aa83:: with SMTP id l3mr883420pjq.73.1591204460934; Wed, 03 Jun 2020 10:14:20 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.45]) by smtp.gmail.com with ESMTPSA id x190sm2016770pgb.79.2020.06.03.10.14.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:14:20 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v2 3/7] Bluetooth: Update resolving list when updating whitelist Date: Wed, 3 Jun 2020 22:47:09 +0530 Message-Id: <20200603171713.9882-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603171713.9882-1-sathish.narasimman@intel.com> References: <20200603171713.9882-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Marcel Holtmann 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 Signed-off-by: Sathish Narsimman --- net/bluetooth/hci_request.c | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 1d885ccd5419..bcd64dec9989 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,28 @@ 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); + + if (hci_dev_test_flag(hdev, HCI_PRIVACY)) + memcpy(cp.local_irk, hdev->irk, 16); + else + memset(cp.local_irk, 0, 16); + + hci_req_add(req, HCI_OP_LE_ADD_TO_RESOLV_LIST, + sizeof(cp), &cp); + } + } + return 0; } @@ -772,7 +809,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.17.1