Add support for MAC address randomization in proximity detection (PD) requests. When enabled, the same randomized MAC address used for discovery and authentication phases will be used for the ranging measurements, maintaining privacy throughout the entire PD session workflow. The implementation adds a capability flag for devices to advertise PD MAC randomization support and validates that randomization is only requested when the device supports it. This ensures consistent MAC address usage across all phases of proximity detection while preventing invalid configurations where randomization is requested but not supported by hardware. Signed-off-by: Peddolla Harshavardhan Reddy --- include/net/cfg80211.h | 7 ++++++- include/uapi/linux/nl80211.h | 5 +++++ net/wireless/nl80211.c | 6 ++++++ net/wireless/pmsr.c | 10 ++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 00ef211f20f1..dd45dda7e619 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5734,6 +5734,10 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type); * multi-peer request this will indicate if the device can act * simultaneously as initiator and a responder. Only valid if @pd_support * is set. + * @pd_randomize_mac_addr: flag attribute in capability indicating that MAC + * address randomization is supported for PD request. if capable a mac + * address used for discovery, authentication will be used for ranging too. + * only valid if @pd_support is set * @pd_max_peer_ista_role: Maximum number of peers allowed for a device * operating in the ISTA role under proximity detection. Only valid if * @pd_support is set. Sum of both @pd_max_peer_ista_role and @@ -5795,7 +5799,8 @@ struct cfg80211_pmsr_capabilities { u8 report_ap_tsf:1, randomize_mac_addr:1, pd_support:1, - pd_concurrent_ista_rsta_support:1; + pd_concurrent_ista_rsta_support:1, + pd_randomize_mac_addr:1; u32 pd_max_peer_ista_role; u32 pd_max_peer_rsta_role; diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 85223b16eb84..c102a54ff335 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -7776,6 +7776,10 @@ enum nl80211_peer_measurement_peer_attrs { * NL80211_PMSR_ATTR_PD_MAX_PEER_ISTA_ROLE and * NL80211_PMSR_ATTR_PD_MAX_PEER_RSTA_ROLE is considered to enforce the * max peers supported in case the request is of peer-to-peer PD type + * @NL80211_PMSR_ATTR_PD_RANDOMIZE_MAC_ADDR: flag attribute in capability + * indicating that MAC address randomization is supported for PD request. + * if capable a mac address used for discovery, authentication will be + * used for ranging too. only valid if %NL80211_PMSR_ATTR_PD_SUPPORT is set * * @NUM_NL80211_PMSR_ATTR: internal * @NL80211_PMSR_ATTR_MAX: highest attribute number @@ -7792,6 +7796,7 @@ enum nl80211_peer_measurement_attrs { NL80211_PMSR_ATTR_PD_CONCURRENT_ISTA_RSTA_SUPPORT, NL80211_PMSR_ATTR_PD_MAX_PEER_ISTA_ROLE, NL80211_PMSR_ATTR_PD_MAX_PEER_RSTA_ROLE, + NL80211_PMSR_ATTR_PD_RANDOMIZE_MAC_ADDR, /* keep last */ NUM_NL80211_PMSR_ATTR, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 6d53eb3eb78c..2909520bb949 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -414,6 +414,7 @@ nl80211_pmsr_attr_policy[NL80211_PMSR_ATTR_MAX + 1] = { }, [NL80211_PMSR_ATTR_PD_MAX_PEER_ISTA_ROLE] = { .type = NLA_REJECT }, [NL80211_PMSR_ATTR_PD_MAX_PEER_RSTA_ROLE] = { .type = NLA_REJECT }, + [NL80211_PMSR_ATTR_PD_RANDOMIZE_MAC_ADDR] = { .type = NLA_REJECT }, }; static const struct nla_policy @@ -2441,6 +2442,11 @@ static int nl80211_send_pmsr_capa(struct cfg80211_registered_device *rdev, nla_put_u32(msg, NL80211_PMSR_ATTR_PD_MAX_PEER_RSTA_ROLE, cap->pd_max_peer_rsta_role)) return -ENOBUFS; + + if (cap->pd_randomize_mac_addr && + nla_put_flag(msg, + NL80211_PMSR_ATTR_PD_RANDOMIZE_MAC_ADDR)) + return -ENOBUFS; } caps = nla_nest_start_noflag(msg, NL80211_PMSR_ATTR_TYPE_CAPA); if (!caps) diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c index a55eb73e6938..fcd7af0c61ba 100644 --- a/net/wireless/pmsr.c +++ b/net/wireless/pmsr.c @@ -376,6 +376,7 @@ int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info) struct cfg80211_pmsr_request *req; struct nlattr *peers, *peer; int count, rem, err, idx, pd_count, max_pd_peers; + u8 use_random_mac = 0; capa = rdev->wiphy.pmsr_capa; @@ -422,6 +423,7 @@ int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info) req->mac_addr_mask); if (err) goto out_err; + use_random_mac = 1; } else { memcpy(req->mac_addr, wdev_address(wdev), ETH_ALEN); eth_broadcast_addr(req->mac_addr_mask); @@ -453,6 +455,14 @@ int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info) err = -EINVAL; goto out_err; } + + if (use_random_mac && + !capa->pd_randomize_mac_addr) { + NL_SET_ERR_MSG(info->extack, + "PD mac randomization not supported"); + err = -EINVAL; + goto out_err; + } } } } -- 2.34.1