From patchwork Thu Mar 12 10:07:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 197290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1ACDC10DCE for ; Thu, 12 Mar 2020 10:06:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DCD1206FA for ; Thu, 12 Mar 2020 10:06:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jdQTkCBG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbgCLKGv (ORCPT ); Thu, 12 Mar 2020 06:06:51 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43596 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbgCLKGv (ORCPT ); Thu, 12 Mar 2020 06:06:51 -0400 Received: by mail-pg1-f194.google.com with SMTP id u12so2825019pgb.10 for ; Thu, 12 Mar 2020 03:06:50 -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=3YDtsZFvd+LPTd0Sd0anKk1uRn89slB36yxlIFn11go=; b=jdQTkCBGhoVnBa+vbD/hrrTmZNBq1rDe3VTL/ZHKxOrp7gykKpuEvh6XGyY7e4gS6L Umj0OHpaCI6rN7RkOMoe1Boi9I7cTesnDsN7R7OS8orNIvh5dbGo262/4q2U1t46qOJM gLkHyNnu+u4ZoTVN1PVCpJPzMPTrmRFNxC20wEXdpLtELx6JPhe+g/83qgvAH+XzVqM+ nNhGCGKxDoqb81CFWqQpR+dwtTFNc8AU5AVN9AQaCyN6SdwrCVozDSf0RRcboggcZTkM YpDM30x8hMR0CtzRPiEq1cHFuQ0D4vhiVqoMP9Hu/8omS/38GXTPCHmbgyBNzUp0CsI4 0fUw== 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=3YDtsZFvd+LPTd0Sd0anKk1uRn89slB36yxlIFn11go=; b=huHvNJLUAxwPPijEVEfmzvAUyFiR2foQ1EcnQVw37c5lPiJ/8prFn9ioBm3+D/uioN u4PZv8Pghsa0siPo54nrIcBPHuBYojCi0ueyCFgdFZqPn8mnPPiIPTTCe/KWeTTXP9sj IuyR2Yl3fd1aYYIEEAy0rtjwzvg67DrG6ieTVCzML6kODmdQUv7AEzA0hZN5+d9Hwc2T 2SEeTHyq8X8GjRe51Y055DlNGsmroFbBua8ONJ6/JhBmeAQPTe2kgsdxgAGvaP7TT9xX xYLkEICV1bHbrw1TQwcfUAlf71rvaFQK5w5ynE+O9VMfRbdBokP1geAvZzenD2ueVrqt 3eEw== X-Gm-Message-State: ANhLgQ1vT9qQXPilZEGsElMHtxIZpYY4C+wJu76WsvZdZVX3mtVSt44f 0B1JIrFgVoQXbJkRyh/4vFPSfcOuLu8= X-Google-Smtp-Source: ADFU+vvmKGDrp+ae0vMf7DCodYgnQUqJG/NrbYg5fiJZ1d91al3ZYbg1eTuvL04mZVaRmGTSYIr1iw== X-Received: by 2002:a63:4912:: with SMTP id w18mr6865770pga.122.1584007609629; Thu, 12 Mar 2020 03:06:49 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.45]) by smtp.gmail.com with ESMTPSA id e9sm10578295pfl.179.2020.03.12.03.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 03:06:48 -0700 (PDT) From: Sathish Narsimman X-Google-Original-From: Sathish Narsimman To: linux-bluetooth@vger.kernel.org, nsathish41@gmail.com Cc: chethan.tumkur.narayan@intel.com, Sathish Narsimman Subject: [PATCH 1/7] Bluetooth: LL Privacy Delete Store Resolving list Date: Thu, 12 Mar 2020 15:37:48 +0530 Message-Id: <20200312100754.3445-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200312100754.3445-1-sathish.narasimman@intel.com> References: <20200312100754.3445-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch help to delte the resolving list stored in the BT Controller w.r.t BD_ADDR. Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_request.c | 33 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 5f60e135aeb6..352bc43940ff 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -457,6 +457,7 @@ enum { #define HCI_LE_DATA_LEN_EXT 0x20 #define HCI_LE_PHY_2M 0x01 #define HCI_LE_PHY_CODED 0x08 +#define HCI_LE_LL_PRIVACY 0x40 #define HCI_LE_EXT_ADV 0x10 #define HCI_LE_EXT_SCAN_POLICY 0x80 #define HCI_LE_PHY_2M 0x01 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index d4e28773d378..5f04ef88da35 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1657,6 +1657,8 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __le64 rand, void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *bdaddr_type); +void hci_req_del_from_resolving_list(struct hci_dev *hdev, u8 addr_type, + bdaddr_t *bdaddr); #define SCO_AIRMODE_MASK 0x0003 #define SCO_AIRMODE_CVSD 0x0000 diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index bf83179ab9d1..f4bbd3b79210 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -885,6 +885,39 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +void hci_req_del_from_resolving_list(struct hci_dev *hdev, u8 addr_type, bdaddr_t *bdaddr) +{ + struct hci_cp_le_del_from_resolv_list cp; + struct hci_request req; + struct bdaddr_list_with_irk *irk; + + BT_DBG(""); + + /* Nothing to be done if LL privacy is not supported */ + if ( !(hdev->le_features[0] & HCI_LE_LL_PRIVACY) ) + return; + + if ( !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && + ( hci_dev_test_flag(hdev, HCI_LE_ADV) || + hci_dev_test_flag(hdev, HCI_LE_SCAN) || + hci_lookup_le_connect(hdev) ) ) + return; + + /* If the device is not present in resolving list + * no need to send HCI command. + */ + irk = hci_bdaddr_list_lookup_with_irk(&hdev->le_resolv_list, bdaddr, addr_type); + if (!irk) + return; + + hci_req_init(&req, hdev); + cp.bdaddr_type = addr_type; + bacpy(&cp.bdaddr, bdaddr); + + hci_req_add(&req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, sizeof(cp), &cp); + hci_req_run(&req, NULL); +} + void hci_req_add_le_passive_scan(struct hci_request *req) { struct hci_dev *hdev = req->hdev; From patchwork Thu Mar 12 10:07:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 197289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92857C1975A for ; Thu, 12 Mar 2020 10:07:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 72F89206FA for ; Thu, 12 Mar 2020 10:07:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rm0JKmK3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbgCLKHC (ORCPT ); Thu, 12 Mar 2020 06:07:02 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37957 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgCLKHC (ORCPT ); Thu, 12 Mar 2020 06:07:02 -0400 Received: by mail-pf1-f194.google.com with SMTP id z5so3029445pfn.5 for ; Thu, 12 Mar 2020 03:07:01 -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=y8MluMm6f37XTe3y61evZ3K/RFwbeZ1K+tfhSmXkmKU=; b=rm0JKmK3M9l2ShN5Rm8hIF7crWT2uzhqAbDpxufwiAgbh1CYUcivvSY/Nceab+uNgK qGWeDnK4GF2/aySFt4k+uJz3BeNhcC9kaMaL4XHUWGlrxwSZc9oF4lk0oPPBD+OMfMeO iFZbZJGPnosn7TiUdSNzabAt9sdCAAME/8NtzlxIiyZJXImW6nap7omgnQWlob0A9XTC qIiPxIr2kImMYbc5OSed3ldtMMiJWiU31DVNGR0canN9M8WiiuFBGbPA/LfVRjaHT0Rm VNIMOTDtNG7692PFC544J4JZpUO++CpYf8MPha7zkt9nuezRYUEbYrPYUp/xOcQUDKiu AJvw== 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=y8MluMm6f37XTe3y61evZ3K/RFwbeZ1K+tfhSmXkmKU=; b=buBzRKicmAYpUz+HE78frQXN9HxxK8houDbSRCv+x8s1A9xK+luW+sMdx/PG3wNNY1 cRSDrW1uRE3OiiiPUq2o/6/SQneYzgURPYZizD2RpHoa4ew1i8VgXxbOukF5O2E0vxna F2aAYp0MfMa36/tNyRo2PUF2ycd6ug48rYi/k7W6iy5+S16NzwjGFhP6+USGW6lAmzne TKXJeRSJXZzkrz/o6v6BgFAH/3q+xwExTdER6UlmFv1Q352F+o58xZJG6xPaobHcfv2G QQfj7m/xKsEswr076apW8v825R800Qj+UOZd5QS7i7z7D6D8lbreC1NWFChikFnxctII dRRg== X-Gm-Message-State: ANhLgQ2UNCTPT0gR5vWSQ9wW9lzx0uQdkwUg6pmLEhHTUhz9ndStKTFX GUVCwuJPyKavgXeUI3Eg/yWDiNi3gDpupQ== X-Google-Smtp-Source: ADFU+vv2v0eV3wXPQmxJO73n9PC05yAbeZKT7Voy9YiXlRwLN+iRvj9kNi0SJjTDuzpepSMsrM2jAw== X-Received: by 2002:aa7:9888:: with SMTP id r8mr5294374pfl.293.1584007620683; Thu, 12 Mar 2020 03:07:00 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.45]) by smtp.gmail.com with ESMTPSA id e9sm10578295pfl.179.2020.03.12.03.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 03:07:00 -0700 (PDT) From: Sathish Narsimman X-Google-Original-From: Sathish Narsimman To: linux-bluetooth@vger.kernel.org, nsathish41@gmail.com Cc: chethan.tumkur.narayan@intel.com, Sathish Narsimman , Joy Shermin Subject: [PATCH 3/7] Bluetooth: Update the Resolving list when Local IRK changed Date: Thu, 12 Mar 2020 15:37:50 +0530 Message-Id: <20200312100754.3445-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200312100754.3445-1-sathish.narasimman@intel.com> References: <20200312100754.3445-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Whenever the Local IRK changes. i.e privacy mode is toggled this patch helps to change the IRK list in the bluetooth controller Signed-off-by: Sathish Narsimman Signed-off-by: Joy Shermin --- include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_request.c | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index e5e09d530ce7..43d31a9339a6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1659,6 +1659,8 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *bdaddr_type); int hci_req_update_resolving_list(struct hci_dev *hdev, u8 addr_type, bdaddr_t *bdaddr, u8 irk[16]); +void hci_req_update_resolving_list_local_irk(struct hci_dev *hdev); + void hci_req_del_from_resolving_list(struct hci_dev *hdev, u8 addr_type, bdaddr_t *bdaddr); diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 88225a9ca1f8..9ffb62178d24 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -965,6 +965,56 @@ int hci_req_update_resolving_list(struct hci_dev *hdev, u8 type, bdaddr_t *bdadd return 0; } +void hci_req_update_resolving_list_local_irk(struct hci_dev *hdev) +{ + struct bdaddr_list_with_irk *irk; + struct hci_request req; + + BT_DBG(""); + + /* Nothing to be done if LL privacy is not supported. */ + if (!(hdev->le_features[0] & HCI_LE_LL_PRIVACY)) + return; + + /* If resolving list is empty, nothing is to be done.*/ + if (list_empty(&hdev->le_resolv_list)) + return; + + /* Resolving List cannot be updated if address resolution + * in the controller is enabled and advertisement or scanning + * or create connection command is ongoing. + */ + if ( !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && + ( hci_dev_test_flag(hdev, HCI_LE_ADV) || + hci_dev_test_flag(hdev, HCI_LE_SCAN) || + hci_lookup_le_connect(hdev) ) ) + return; + + /* If resolving list is not empty, then clear the resolving list + * and add back each entry with updated local IRK. + */ + hci_req_init(&req, hdev); + + list_for_each_entry(irk, &hdev->le_resolv_list, list) { + struct hci_cp_le_add_to_resolv_list cp; + struct hci_cp_le_del_from_resolv_list cp1; + + cp1.bdaddr_type = irk->bdaddr_type; + bacpy(&cp1.bdaddr, &irk->bdaddr); + hci_req_add(&req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, + sizeof(cp1), &cp1); + + cp.bdaddr_type = irk->bdaddr_type; + bacpy(&cp.bdaddr, &irk->bdaddr); + memcpy(cp.peer_irk, irk->peer_irk, 16); + memcpy(cp.local_irk, hdev->irk, 16); + hci_req_add(&req, HCI_OP_LE_ADD_TO_RESOLV_LIST, + sizeof(cp), &cp); + } + + hci_req_run(&req, NULL); +} + void hci_req_del_from_resolving_list(struct hci_dev *hdev, u8 addr_type, bdaddr_t *bdaddr) { struct hci_cp_le_del_from_resolv_list cp; From patchwork Thu Mar 12 10:07:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 197288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 565D4C10DCE for ; Thu, 12 Mar 2020 10:07:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3488A20724 for ; Thu, 12 Mar 2020 10:07:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lGCg1l8E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726785AbgCLKHJ (ORCPT ); Thu, 12 Mar 2020 06:07:09 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42112 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgCLKHJ (ORCPT ); Thu, 12 Mar 2020 06:07:09 -0400 Received: by mail-pf1-f193.google.com with SMTP id x2so2658266pfn.9 for ; Thu, 12 Mar 2020 03:07:09 -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=/zcprjgIRbmIdLFXtpyP+sMyaGODDY39obss3o04Ujs=; b=lGCg1l8EBg3FnK7janYyZR33tAcvBofsxkcmuXPnjXxDAr7eOpaeUavXH42YKF2t7b hyW5q+So302Sr+cM8urfVaBRpey++QaQkNL3J9TmxACHU9g1iYf+CUMUHnWxpIHXkxeS tU39tLklJ3WLBN7y1wxpBSF3Lq70zb1ygBtXOXaGhSXZ72KVixCpErdY5H4MHjoGTCNh pEUA87bSvBILBWdjUvnNQsulNWwBBP42Zxr5YqLsgw2nW7wd3sAGDBP/Ky5AiDwYnyW9 gZ67XmGXQZgg42W8Laq03A/FZMFvwfmetnl7WnnryWqMQ7g6lE1MTVxisWLZcyoIcpn4 x1Ew== 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=/zcprjgIRbmIdLFXtpyP+sMyaGODDY39obss3o04Ujs=; b=iKmuMvo3XypP+rzDtHpLlSH9G2utb9by2KPLdhIhIxq1ppa9tQ9Ebtvaxouag0WGWn GzXhA11JUfPxjkcts+ryNBQ1LAEU4Tvque7+ZA1dGmUn7KOj7zhYuLg6qqtwp7u0NK5c CXzkiROg8q0+U8/rO0IhEQ73uisu6OaLbtUbrCJxk8Xnc3qFGwsajdrYHc1kSBWjqtB6 iF0q/NDF6bHEh3KLuXu/TVyaa1ERmTvSU0YyCh3tzqY1ENASZmukEvFlyrRuky4raKKm O88ZCzcOfI6z1ftQ8blv++wttpunlDTG7OacoUN7WEt/QtOlIlqwiQ6Ot6UuFMdIbDHk DcUw== X-Gm-Message-State: ANhLgQ0TSyu7iX0cA98++v8Pz7mpePwmMKPSof5pf8HW4uWAtGyONOcL +CaaArvNF03bYhHgyxBd+57JuJUgLCjQFw== X-Google-Smtp-Source: ADFU+vvDFfeNTPobROmpH0Buk1XHlAlsGdrlK7bkMhEeZRIiTn1pwGXeJGDk/x/dI1H+3YTM1IHelg== X-Received: by 2002:a63:2cc3:: with SMTP id s186mr6866953pgs.71.1584007628485; Thu, 12 Mar 2020 03:07:08 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.45]) by smtp.gmail.com with ESMTPSA id e9sm10578295pfl.179.2020.03.12.03.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 03:07:08 -0700 (PDT) From: Sathish Narsimman X-Google-Original-From: Sathish Narsimman To: linux-bluetooth@vger.kernel.org, nsathish41@gmail.com Cc: chethan.tumkur.narayan@intel.com, Sathish Narsimman , Joy Shermin Subject: [PATCH 5/7] Bluetooth: LL Privacy Check and Update the Resolving List Date: Thu, 12 Mar 2020 15:37:52 +0530 Message-Id: <20200312100754.3445-6-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200312100754.3445-1-sathish.narasimman@intel.com> References: <20200312100754.3445-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch is an helper function which will be usefull to check the Local Resolving list and update the controller Resolving list during le_create_conn , le_directed_adv. Signed-off-by: Sathish Narsimman Signed-off-by: Joy Shermin --- net/bluetooth/hci_request.c | 21 +++++++++++++++++++++ net/bluetooth/hci_request.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index e17db3103a3d..6b685cdc7de5 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1015,6 +1015,27 @@ void hci_req_update_resolving_list_local_irk(struct hci_dev *hdev) hci_req_run(&req, NULL); } +void hci_req_check_and_update_resolving_list(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr) +{ + struct smp_irk *irk; + + BT_DBG(""); + + /* Nothing to be done if LL privacy is not supported */ + if ( !(hdev->le_features[0] & HCI_LE_LL_PRIVACY) ) + return; + + if ( !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && + ( hci_dev_test_flag(hdev, HCI_LE_ADV) || + hci_dev_test_flag(hdev, HCI_LE_SCAN) || + hci_lookup_le_connect(hdev) ) ) + return; + + irk = hci_find_irk_by_addr(hdev, bdaddr, type); + if (irk) + hci_req_update_resolving_list(hdev, irk->addr_type, &irk->bdaddr, irk->val); +} + void hci_load_resolving_list (struct hci_dev *hdev) { struct smp_irk *irk; diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 0e81614d235e..92a71f35543b 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -90,6 +90,8 @@ void __hci_req_clear_ext_adv_sets(struct hci_request *req); int hci_get_random_address(struct hci_dev *hdev, bool require_privacy, bool use_rpa, struct adv_info *adv_instance, u8 *own_addr_type, bdaddr_t *rand_addr); +void hci_req_check_and_update_resolving_list(struct hci_dev *hdev, u8 addr_type, + bdaddr_t *bdaddr); void __hci_req_update_class(struct hci_request *req); From patchwork Thu Mar 12 10:07:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 197287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E645C2BB1D for ; Thu, 12 Mar 2020 10:07:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E9C4206FA for ; Thu, 12 Mar 2020 10:07:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qpoWLV81" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbgCLKHS (ORCPT ); Thu, 12 Mar 2020 06:07:18 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41737 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgCLKHS (ORCPT ); Thu, 12 Mar 2020 06:07:18 -0400 Received: by mail-pf1-f194.google.com with SMTP id z65so3023146pfz.8 for ; Thu, 12 Mar 2020 03:07:17 -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=WEssHPdmc+CHUX/J9svOx4jP0pCE2+tppJ8olfTleQM=; b=qpoWLV81qW2rMTAtb/JdQk5gDvpAAFkaURhKCNhCgEhSq6rDaf/0BYz5U9PB4XG9Rc TKITRI8R0Yj4w3td0YabE7JrZMSLdyE2S+Sh3dpKTmSWXNuv7IEVkyZeAVY4Qi6cAVKY tStB8dvV5sz2vtdX7QNcPLdnZH7aBrtA/I+nAX91jedSkxv1CWu4M5m1XUpkkDtbNKac K0XsU6zBsDd6MBT7MUiZ2vnCOASH+XLUE87DfFvV6444cZOjMrrYhK1qgEs8ElX4B5hm N5NgEOxBJ++iY1Jdbnq/5mnvMuj97EN/Un+NtPPcS6wJkesJkt4tgzxDgNST/LJnraHR ooXQ== 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=WEssHPdmc+CHUX/J9svOx4jP0pCE2+tppJ8olfTleQM=; b=Nd+ucwx+v4eyD+l7GYV1pGINZKmvEXrgVsohSohluqFDfFfcssXfX8ixa0KQ3G/umS pYeVxC5VNrI3g749p+3Iw0VSlOhHBgDDETQKGN6YOorDAUQfPl7+xT1rDQuG9wZVQmkD W2NHu6fp7ej1Bwn9evkT8XYftzjypjqA7H9lPAWkuANE+rashwsrVBRaxACO6HcgoYyj FDOG3qEOZe3w174LZ53VxB7osI9eEJkA7Q1QyIk3vK4HkTDQg77IEwrU+bGytA0P5HEV 0SbPKXBmV1Lr+F0tWJG7k8BkaelfkL/E++CUnwMywu7rMuHl9AnPNLetJNjO4HGuKXM0 n58g== X-Gm-Message-State: ANhLgQ26foEnmROzn3Y2fSE/Kyaa15vRgmF4pGWxaZYdR/V6Gu671BjW VLgbgComD1AP8gUGv38e3z15oHXu1vL1ZA== X-Google-Smtp-Source: ADFU+vsFeH6BJ/hJhMrE2LaFWr11OZIO66iMMHFEWjUiE9MHIaZ8tqxui9+WBuGrFCLwr1iMaiGPqQ== X-Received: by 2002:a63:e007:: with SMTP id e7mr6982851pgh.414.1584007636397; Thu, 12 Mar 2020 03:07:16 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.45]) by smtp.gmail.com with ESMTPSA id e9sm10578295pfl.179.2020.03.12.03.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 03:07:15 -0700 (PDT) From: Sathish Narsimman X-Google-Original-From: Sathish Narsimman To: linux-bluetooth@vger.kernel.org, nsathish41@gmail.com Cc: chethan.tumkur.narayan@intel.com, Sathish Narsimman Subject: [PATCH 7/7] Bluetooth LL Privacy update White list Date: Thu, 12 Mar 2020 15:37:54 +0530 Message-Id: <20200312100754.3445-8-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200312100754.3445-1-sathish.narasimman@intel.com> References: <20200312100754.3445-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Update white list filter policy of if LL Privacy is enabled When Address Resolution is enabled and device is already in the white list then follow the filter policy Signed-off-by: Sathish Narsimman --- net/bluetooth/hci_request.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 12868caf50ea..47cb2602713a 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -711,7 +711,16 @@ static int add_to_white_list(struct hci_request *req, /* White list can not be used with RPAs */ if (!allow_rpa && hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type)) { - return -1; + /* White list can not be used with RPAs if address + * resolution is disabled in the controller + */ + if (!hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return -1; + + /* if the peer device is not present in the resolving list */ + if (!hci_bdaddr_list_lookup_with_irk(&hdev->le_resolv_list, &b->bdaddr, + b->bdaddr_type)) + return -1; } /* During suspend, only wakeable devices can be in whitelist */ @@ -768,7 +777,16 @@ static u8 update_white_list(struct hci_request *req) /* White list can not be used with RPAs */ if (!allow_rpa && hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) { - return 0x00; + /* White list can not be used with RPAs if address + * resolution is disabled in the controller + */ + if (!hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return 0x00; + + /* if the peer device is not present in the resolving list */ + if (!hci_bdaddr_list_lookup_with_irk(&hdev->le_resolv_list, &b->bdaddr, + b->bdaddr_type)) + return 0x00; } num_entries++;