From patchwork Thu Jan 12 01:24:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Veerendranath Jakkam X-Patchwork-Id: 13097356 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9302FC5479D for ; Thu, 12 Jan 2023 01:24:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235346AbjALBYw (ORCPT ); Wed, 11 Jan 2023 20:24:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbjALBYt (ORCPT ); Wed, 11 Jan 2023 20:24:49 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB7D40856 for ; Wed, 11 Jan 2023 17:24:49 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30BNvAaj029436; Thu, 12 Jan 2023 01:24:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=4d0NK3mY13n3Tp6eoJiARZmZ7pTGxfPaaYeId66oSY0=; b=O4XBzZxrqB/B2tGjLxpIYFj3KCxMdmglUTzJmDopdIbl1coIkC/Bu0oBe4dps1U3sbRZ /b8vsGDupf6gD19OBl3k2/lFaOp4EYn9xvvxdLixBWBSkmClu2Mm2apjE/hK6MYkF3O5 ZQZOqe0MAhkN7zlcUON7JP4L+DdQto/G91vt/xn9KcJjQ+WLI2hjtvQ1CtZtDx1QQPZy WQ0C0k+1OJ8o9hJaEAINwWR58lwM0TS1Un2qNoCoCpLoVyB+ZRRTPcebMyxHTIwUgJzG HJ1VFtZXxD5A9tuCijbwv8cjY0rsn3+PvBb4dqusUCiE1DGRW/UQnkow9yA9Ip3aN3/T TQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n1km2jk3s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 01:24:44 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30C1OiCH001196 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 01:24:44 GMT Received: from cnss-mw-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 11 Jan 2023 17:24:42 -0800 From: Veerendranath Jakkam To: CC: , Subject: [PATCH v3 1/3] wifi: nl80211: Add support for randomizing TA of auth and deauth frames Date: Thu, 12 Jan 2023 06:54:13 +0530 Message-ID: <20230112012415.167556-2-quic_vjakkam@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112012415.167556-1-quic_vjakkam@quicinc.com> References: <20230112012415.167556-1-quic_vjakkam@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 1n_hKUqkcV1J_iUXS6q03BNzpi13678f X-Proofpoint-GUID: 1n_hKUqkcV1J_iUXS6q03BNzpi13678f X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120007 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add support to use a random local address in authentication and deauthentication frames sent to unassociated peer when the driver supports. The driver needs to configure receive behavior to accept frames with random transmit address specified in TX path authentication frames during the time of the frame exchange is pending and such frames need to be acknowledged similarly to frames sent to the local permanent address when this random address functionality is used. This capability allows use of randomized transmit address for PASN authentication frames to improve privacy of WLAN clients. Signed-off-by: Veerendranath Jakkam --- v2: - Move random address allowed checks to separate function. --- include/uapi/linux/nl80211.h | 5 ++++ net/wireless/mlme.c | 55 +++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index c14a91bbca7c..6bfcc3d2ec06 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -6294,6 +6294,10 @@ enum nl80211_feature_flags { * might apply, e.g. no scans in progress, no offchannel operations * in progress, and no active connections. * + * @NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA: Device supports randomized TA + * in authentication and deauthentication frames sent to unassociated peer + * using @NL80211_CMD_FRAME. + * * @NUM_NL80211_EXT_FEATURES: number of extended features. * @MAX_NL80211_EXT_FEATURES: highest extended feature index. */ @@ -6362,6 +6366,7 @@ enum nl80211_ext_feature_index { NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD, NL80211_EXT_FEATURE_RADAR_BACKGROUND, NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE, + NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA, /* add new features before the definition below */ NUM_NL80211_EXT_FEATURES, diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 58e1fb18f85a..cfacda5bd80b 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -673,6 +673,39 @@ static bool cfg80211_allowed_address(struct wireless_dev *wdev, const u8 *addr) return ether_addr_equal(addr, wdev_address(wdev)); } +static bool cfg80211_allowed_random_address(struct wireless_dev *wdev, + const struct ieee80211_mgmt *mgmt) +{ + if (ieee80211_is_auth(mgmt->frame_control) || + ieee80211_is_deauth(mgmt->frame_control)) { + /* Allow random TA to be used with authentication and + * deauthentication frames if the driver has indicated support. + */ + if (wiphy_ext_feature_isset( + wdev->wiphy, + NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA)) + return true; + } else if (ieee80211_is_action(mgmt->frame_control) && + mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) { + /* Allow random TA to be used with Public Action frames if the + * driver has indicated support. + */ + if (!wdev->connected && + wiphy_ext_feature_isset( + wdev->wiphy, + NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA)) + return true; + + if (wdev->connected && + wiphy_ext_feature_isset( + wdev->wiphy, + NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED)) + return true; + } + + return false; +} + int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, struct wireless_dev *wdev, struct cfg80211_mgmt_tx_params *params, u64 *cookie) @@ -771,25 +804,9 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, return err; } - if (!cfg80211_allowed_address(wdev, mgmt->sa)) { - /* Allow random TA to be used with Public Action frames if the - * driver has indicated support for this. Otherwise, only allow - * the local address to be used. - */ - if (!ieee80211_is_action(mgmt->frame_control) || - mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) - return -EINVAL; - if (!wdev->connected && - !wiphy_ext_feature_isset( - &rdev->wiphy, - NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA)) - return -EINVAL; - if (wdev->connected && - !wiphy_ext_feature_isset( - &rdev->wiphy, - NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED)) - return -EINVAL; - } + if (!cfg80211_allowed_address(wdev, mgmt->sa) && + !cfg80211_allowed_random_address(wdev, mgmt)) + return -EINVAL; /* Transmit the management frame as requested by user space */ return rdev_mgmt_tx(rdev, wdev, params, cookie); From patchwork Thu Jan 12 01:24:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Veerendranath Jakkam X-Patchwork-Id: 13097357 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E8A7C54EBC for ; Thu, 12 Jan 2023 01:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235308AbjALBYy (ORCPT ); Wed, 11 Jan 2023 20:24:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbjALBYw (ORCPT ); Wed, 11 Jan 2023 20:24:52 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C1140850 for ; Wed, 11 Jan 2023 17:24:51 -0800 (PST) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30BNv75W005899; Thu, 12 Jan 2023 01:24:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=uVztuqDWIKbMZqamyBCdGiGm8jAW3lJd/CD2iK1lQMU=; b=P1l3A89YOz8n5BEz7hoTbD3PzhF4rlU/UMVXGkCg6RZxxeDVxNRIlzFY2bpcUZ7barbM bJg/ZEzhbngNDlqtxF/mnFpTFzLLMNod6USzAKBit3cMBM2NwEhc/tU1vLgeui39Kidw fvi1T0QBCd0KDIuNbax31Y1KpaBwhmaY9kHVPLZxBZ5H+Yfly/dpFrn3N2D1oJsxFBT6 wvkywa3QCEywPVv/AA97Chszr4aLVDbzuCOzFzcGEd4HLA9CDptaj/Mjr4QjL/hg2u/9 KfdnxZrlgSLx5hQYeHvztX5MljMDeaUwGInwfvQjTHqy0PLgy9/+oxGX9FkHtGDInAnh YA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n1m6p2gxs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 01:24:46 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30C1OjCD024738 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 01:24:45 GMT Received: from cnss-mw-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 11 Jan 2023 17:24:44 -0800 From: Veerendranath Jakkam To: CC: , Subject: [PATCH v3 2/3] wifi: mac80211: Add support to randomize TA of auth and deauth frames Date: Thu, 12 Jan 2023 06:54:14 +0530 Message-ID: <20230112012415.167556-3-quic_vjakkam@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112012415.167556-1-quic_vjakkam@quicinc.com> References: <20230112012415.167556-1-quic_vjakkam@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 4jkx7jvHBiiNZz1PekPFJj982c6EkaRa X-Proofpoint-GUID: 4jkx7jvHBiiNZz1PekPFJj982c6EkaRa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=790 clxscore=1015 spamscore=0 phishscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120007 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Cache the TA of the authentication and deauthentication frames temporarily till the response waiting time offchannel period complete and indicate the temporary address to driver when driver supports randomizing TA of auth and deauth frames. Driver should allow TX and RX of the frames when the temporary address is TA and RA respectively. Allow the authentication and deauthentication frames with cached address as RA in RX path. Reported-by: kernel test robot Signed-off-by: Veerendranath Jakkam --- v2: - Modify the implementation to allow the authentication and deauthentication frames with the random address till the response waiting time off-channel period complete. - Use BSS changed flag to indicate change in allowed random address to driver. v3: - Fix warning reported by kernel test robot --- include/net/mac80211.h | 12 ++++++++++++ net/mac80211/main.c | 3 ++- net/mac80211/offchannel.c | 38 ++++++++++++++++++++++++++++++++++++++ net/mac80211/rx.c | 18 ++++++++++++++---- net/mac80211/util.c | 7 ++++++- 5 files changed, 72 insertions(+), 6 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 689da327ce2e..a6f0987f88a1 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -340,6 +340,8 @@ struct ieee80211_vif_chanctx_switch { * @BSS_CHANGED_FILS_DISCOVERY: FILS discovery status changed. * @BSS_CHANGED_UNSOL_BCAST_PROBE_RESP: Unsolicited broadcast probe response * status changed. + * @BSS_CHANGED_TEMP_ADDR: Temporary self address allowed for authentication and + * deauthentication frames is changed. * */ enum ieee80211_bss_change { @@ -375,6 +377,7 @@ enum ieee80211_bss_change { BSS_CHANGED_HE_BSS_COLOR = 1<<29, BSS_CHANGED_FILS_DISCOVERY = 1<<30, BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = 1<<31, + BSS_CHANGED_TEMP_ADDR = 1ULL<<32, /* when adding here, make sure to change ieee80211_reconfig */ }; @@ -1771,6 +1774,14 @@ enum ieee80211_offload_flags { * your driver/device needs to do. * @ap_addr: AP MLD address, or BSSID for non-MLO connections * (station mode only) + * @temp_addr: Temporary self address allowed for the authentication and + * deauthentication frames till the response waiting time offchannel period + * complete. Driver should allow TX and RX of the frames with the temporary + * address as TA and RA respectively when it is non zero. This will be set + * to zero address when there is no temporary self address is active. + * Change in the value of this will be indicated with + * @BSS_CHANGED_TEMP_ADDR. This will be indicated only when driver supports + * %NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA. */ struct ieee80211_vif_cfg { /* association related data */ @@ -1786,6 +1797,7 @@ struct ieee80211_vif_cfg { bool s1g; bool idle; u8 ap_addr[ETH_ALEN] __aligned(2); + u8 temp_addr[ETH_ALEN] __aligned(2); }; /** diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 846528850612..238cbf05d08d 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -205,7 +205,8 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) BSS_CHANGED_PS |\ BSS_CHANGED_IBSS |\ BSS_CHANGED_ARP_FILTER |\ - BSS_CHANGED_SSID) + BSS_CHANGED_SSID |\ + BSS_CHANGED_TEMP_ADDR) void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, u64 changed) diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c index d78c82d6b696..54233be31e9b 100644 --- a/net/mac80211/offchannel.c +++ b/net/mac80211/offchannel.c @@ -187,6 +187,12 @@ static void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc) roc->mgmt_tx_cookie, roc->chan, GFP_KERNEL); + if (!is_zero_ether_addr(roc->sdata->vif.cfg.temp_addr)) { + eth_zero_addr(roc->sdata->vif.cfg.temp_addr); + ieee80211_vif_cfg_change_notify(roc->sdata, + BSS_CHANGED_TEMP_ADDR); + } + list_del(&roc->list); kfree(roc); } @@ -234,6 +240,36 @@ static bool ieee80211_recalc_sw_work(struct ieee80211_local *local, return true; } +static void ieee80211_config_temp_addr(struct ieee80211_sub_if_data *sdata, + const struct ieee80211_hdr *hdr) +{ + unsigned int link; + + if (!wiphy_ext_feature_isset(sdata->local->hw.wiphy, + NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA)) + return; + + if (memcmp(sdata->vif.addr, hdr->addr2, ETH_ALEN) == 0 || + memcmp(sdata->vif.cfg.temp_addr, hdr->addr2, ETH_ALEN) == 0) { + return; + } else if (sdata->vif.valid_links) { + rcu_read_lock(); + for (link = 0; link < ARRAY_SIZE(sdata->vif.link_conf); link++) { + struct ieee80211_bss_conf *link_conf; + + link_conf = rcu_dereference(sdata->vif.link_conf[link]); + if (!link_conf) + continue; + if (memcmp(link_conf->addr, hdr->addr2, ETH_ALEN) == 0) + return; + } + rcu_read_unlock(); + } + + memcpy(sdata->vif.cfg.temp_addr, hdr->addr2, ETH_ALEN); + ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_TEMP_ADDR); +} + static void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc, unsigned long start_time) { @@ -245,6 +281,8 @@ static void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc, if (roc->mgmt_tx_cookie) { if (!WARN_ON(!roc->frame)) { + ieee80211_config_temp_addr(roc->sdata, + (void *) roc->frame->data); ieee80211_tx_skb_tid_band(roc->sdata, roc->frame, 7, roc->chan->band); roc->frame = NULL; diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 7e3ab6e1b28f..a611697cecd0 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -4192,6 +4192,12 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) u8 *bssid = ieee80211_get_bssid(hdr, skb->len, sdata->vif.type); bool multicast = is_multicast_ether_addr(hdr->addr1) || ieee80211_is_s1g_beacon(hdr->frame_control); + bool skip_addr1_check = false; + + if ((ieee80211_is_auth(hdr->frame_control) || + ieee80211_is_deauth(hdr->frame_control)) && + ether_addr_equal(sdata->vif.cfg.temp_addr, hdr->addr1)) + skip_addr1_check = true; switch (sdata->vif.type) { case NL80211_IFTYPE_STATION: @@ -4201,6 +4207,8 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) return false; if (multicast) return true; + if (skip_addr1_check) + return true; return ieee80211_is_our_addr(sdata, hdr->addr1, &rx->link_id); case NL80211_IFTYPE_ADHOC: if (!bssid) @@ -4213,7 +4221,7 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) return true; if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) return false; - if (!multicast && + if (!multicast && !skip_addr1_check && !ether_addr_equal(sdata->vif.addr, hdr->addr1)) return false; if (!rx->sta) { @@ -4233,7 +4241,7 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) return false; if (!is_broadcast_ether_addr(bssid)) return false; - if (!multicast && + if (!multicast && !skip_addr1_check && !ether_addr_equal(sdata->dev->dev_addr, hdr->addr1)) return false; if (!rx->sta) { @@ -4251,10 +4259,12 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) return false; if (multicast) return true; + if (skip_addr1_check) + return true; return ether_addr_equal(sdata->vif.addr, hdr->addr1); case NL80211_IFTYPE_AP_VLAN: case NL80211_IFTYPE_AP: - if (!bssid) + if (!bssid && !skip_addr1_check) return ieee80211_is_our_addr(sdata, hdr->addr1, &rx->link_id); @@ -4266,7 +4276,7 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) * and location updates. Note that mac80211 * itself never looks at these frames. */ - if (!multicast && + if (!multicast && !skip_addr1_check && !ieee80211_is_our_addr(sdata, hdr->addr1, &rx->link_id)) return false; diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 6f5407038459..fd7e77938023 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -2663,7 +2663,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) /* Finally also reconfigure all the BSS information */ list_for_each_entry(sdata, &local->interfaces, list) { unsigned int link_id; - u32 changed; + u64 changed; if (!ieee80211_sdata_running(sdata)) continue; @@ -2712,6 +2712,11 @@ int ieee80211_reconfig(struct ieee80211_local *local) BSS_CHANGED_TXPOWER | BSS_CHANGED_MCAST_RATE; + if (!is_zero_ether_addr(sdata->vif.cfg.temp_addr)) { + eth_zero_addr(sdata->vif.cfg.temp_addr); + changed |= BSS_CHANGED_TEMP_ADDR; + } + if (sdata->vif.bss_conf.mu_mimo_owner) changed |= BSS_CHANGED_MU_GROUPS; From patchwork Thu Jan 12 01:24:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Veerendranath Jakkam X-Patchwork-Id: 13097358 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49A3AC46467 for ; Thu, 12 Jan 2023 01:24:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235573AbjALBY4 (ORCPT ); Wed, 11 Jan 2023 20:24:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbjALBYz (ORCPT ); Wed, 11 Jan 2023 20:24:55 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12D004086C for ; Wed, 11 Jan 2023 17:24:54 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30BNxRqt030913; Thu, 12 Jan 2023 01:24:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=UO96Uw4BEMBBuMbf/pDEd3SPzLFgwpGvtMFqid7G4uw=; b=p5IpwQ4oqSOwJtcM2iOGIyk6kH4XTxLud+hDSmQnPA913oZgf2DRBlAYMSrvtltuLXLu ETUD3+Kf4cKXS0REAiiD5bg9vasOJYn81zvyuxJ2BYZFRNcu+STkKz3zaMSn7lDidEQf aYM7PfZ6o23DVQxeYcGqkN3fQkLutv74qkqw6x/ixLbHliwsTZ+FHQY2bYdUs1AeZFzE 9eq/TVRgnxwstSPrDxx+dQyui16uG0GcDCCF4yHzc/t/tIMB/46542CVOupmsqUx/TCs rMR3F7GVbuLOPd8yEqJzCsWPsJV5m6F23yM7T2uaS8zk+fQxPSgbevuAMRzLy4avUEMs yg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n1k5k2ksb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 01:24:48 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30C1OlKH001659 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 01:24:47 GMT Received: from cnss-mw-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 11 Jan 2023 17:24:45 -0800 From: Veerendranath Jakkam To: CC: , Subject: [PATCH v3 3/3] wifi: mac80211_hwsim: Add support for randomizing auth and deauth frames TA Date: Thu, 12 Jan 2023 06:54:15 +0530 Message-ID: <20230112012415.167556-4-quic_vjakkam@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112012415.167556-1-quic_vjakkam@quicinc.com> References: <20230112012415.167556-1-quic_vjakkam@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: KMFtHWMwSgqz0dfk85NJ9V0WE-3shAE7 X-Proofpoint-GUID: KMFtHWMwSgqz0dfk85NJ9V0WE-3shAE7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 suspectscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120007 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add changes to support randomizing TA of the authentication and deauthentication frames and indicate the support to upper layers. Signed-off-by: Veerendranath Jakkam --- drivers/net/wireless/mac80211_hwsim.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index c57c8903b7c0..40469d2723e5 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -720,6 +720,9 @@ struct mac80211_hwsim_data { int rx_rssi; struct mac80211_hwsim_link_data link_data[IEEE80211_MLD_MAX_NUM_LINKS]; + + /* Ack the frames with RA as configured temporary address */ + u8 temp_addr[ETH_ALEN]; }; static const struct rhashtable_params hwsim_rht_params = { @@ -1237,6 +1240,10 @@ static bool mac80211_hwsim_addr_match(struct mac80211_hwsim_data *data, if (data->scanning && memcmp(addr, data->scan_addr, ETH_ALEN) == 0) return true; + if (!is_zero_ether_addr(data->temp_addr) && + ether_addr_equal(addr, data->temp_addr)) + return true; + memcpy(md.addr, addr, ETH_ALEN); ieee80211_iterate_active_interfaces_atomic(data->hw, @@ -2285,6 +2292,7 @@ static void mac80211_hwsim_vif_info_changed(struct ieee80211_hw *hw, u64 changed) { struct hwsim_vif_priv *vp = (void *)vif->drv_priv; + struct mac80211_hwsim_data *hwsim = hw->priv; hwsim_check_magic(vif); @@ -2297,6 +2305,22 @@ static void mac80211_hwsim_vif_info_changed(struct ieee80211_hw *hw, vp->assoc = vif->cfg.assoc; vp->aid = vif->cfg.aid; } + + if (changed & BSS_CHANGED_TEMP_ADDR) { + wiphy_dbg(hw->wiphy, " TMP_ADDR: vif->cfg.temp_addr=%pM\n", + vif->cfg.temp_addr); + + if (!is_zero_ether_addr(hwsim->temp_addr)) + mac80211_hwsim_config_mac_nl(hw, hwsim->temp_addr, + false); + if (!is_zero_ether_addr(vif->cfg.temp_addr)) { + ether_addr_copy(hwsim->temp_addr, vif->cfg.temp_addr); + mac80211_hwsim_config_mac_nl(hw, hwsim->temp_addr, + true); + } else { + eth_zero_addr(hwsim->temp_addr); + } + } } static void mac80211_hwsim_link_info_changed(struct ieee80211_hw *hw, @@ -4445,6 +4469,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info, NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS); wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_BEACON_RATE_LEGACY); + wiphy_ext_feature_set(hw->wiphy, + NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA); hw->wiphy->interface_modes = param->iftypes;