From: Vinay Gannevaram A NAN service advertises in its Cipher Suite Info attribute whether it supports group keys (GTK and IGTK, optionally BIGTK) and whether IGTK and BIGTK use NCS-BIP-GMAC-256 instead of NCS-BIP-CMAC-128. With an offloaded Discovery Engine and NDP setup, the device builds this attribute for the Service Discovery Frames of the function and for the NDP setup frames, and it distributes and installs the group keys during NDP setup. So far, NDP offload only covers the GTK, which is requested per NDP. Add NL80211_NAN_FUNC_GROUP_KEYS and NL80211_NAN_FUNC_BIP_GMAC_256 to configure the group-key support of a function. The device also uses it for NDPs of the service and establishes the group keys that both peers support; the per-NDP GTK requirement and GTK cipher are unchanged. Use typed attributes rather than the raw capability field, whose other bits, such as the number of replay counters, are properties of the device. Signed-off-by: Vinay Gannevaram Signed-off-by: Shivani Baranwal --- include/net/cfg80211.h | 37 +++++++++++++++++++++++++++--------- include/uapi/linux/nl80211.h | 34 ++++++++++++++++++++++++++++++--- net/wireless/nl80211.c | 18 ++++++++++++++++++ 3 files changed, 77 insertions(+), 12 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 0964301473e1..9aae48c2b95d 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4404,7 +4404,8 @@ struct cfg80211_nan_peer_sched { * @pmk_len: length of @pmk in bytes * @pmkid: PMKID (16 octets) to include in the NDP Request, or NULL if absent * @gtk_required: if true, GTK protection is required for group-addressed data - * frames + * frames. IGTK and BIGTK follow the service group-key support, see + * &struct cfg80211_nan_func.group_keys. * @gtk_cipher: GTK cipher suite ID, valid when @gtk_required is true * @ipv6_intf_id: IPv6 link-local interface identifier, or NULL if absent * @ndp_id: output NDP ID assigned by the driver on success (1-255) @@ -4459,7 +4460,8 @@ struct cfg80211_nan_ndp_initiate { * @cipher_suite and %NL80211_EXT_FEATURE_SECURE_NAN. * @pmk_len: length of @pmk in bytes * @gtk_required: if true, GTK protection is required for group-addressed data - * frames + * frames. IGTK and BIGTK follow the service group-key support, see + * &struct cfg80211_nan_func.group_keys. * @gtk_cipher: GTK cipher suite ID, valid when @gtk_required is true * @ipv6_intf_id: IPv6 link-local interface identifier, or NULL if absent * @transport_info: if true, convey @transport_port and @transport_protocol to @@ -4523,7 +4525,9 @@ struct cfg80211_nan_ndp_terminate { * @ssi_len: length of @ssi * @cipher_suite: initiator's cipher suite ID * @pmkid: PMKID from the peer's SCIA attribute (16 bytes), or NULL if absent - * @gtk_required: if true, initiator requires GTK protection + * @gtk_required: if true, the initiator requires GTK protection. IGTK and + * BIGTK follow the service group-key support, see + * &struct cfg80211_nan_func.group_keys. * @gtk_cipher: GTK cipher suite ID, included when @gtk_required is true * @ipv6_intf_id: initiator's IPv6 link-local interface identifier, or NULL * if absent @@ -4668,7 +4672,20 @@ struct cfg80211_nan_func_filter { * @security_required: if true, the SDEA Security Required bit is set. Requires * @data_path_required and %NL80211_EXT_FEATURE_SECURE_NAN. * @gtk_required: if true, the SDEA GTK Required bit is set for GTK protection - * of group-addressed data frames. Requires %NL80211_EXT_FEATURE_SECURE_NAN. + * of group-addressed data frames. This is independent of @group_keys, which + * advertises service group-key support. Requires + * %NL80211_EXT_FEATURE_SECURE_NAN. + * @group_keys: group-key support of the service, advertised in the Cipher + * Suite Info attribute of the Service Discovery Frames of this function, as + * defined by &enum nl80211_nan_group_keys. With + * %WIPHY_NAN_FLAGS_OFFLOAD_NDP the device also uses it for NDPs of the + * service: it advertises it in NDP setup frames (an NDP initiator uses its + * subscribe function) and establishes the group keys that both peers + * support. If zero, no group-key support is advertised. Requires + * %NL80211_EXT_FEATURE_SECURE_NAN. + * @bip_gmac_256: if true, IGTK and BIGTK use NCS-BIP-GMAC-256 instead of + * NCS-BIP-CMAC-128. Requires @group_keys and + * %NL80211_EXT_FEATURE_SECURE_NAN. * @pairing_bootstrap_methods: bitmap of supported NAN pairing * bootstrapping methods per the Wi-Fi Aware Specification Table 9-321. * @csids: array of u32 NAN Cipher Suite ID (CSID) selectors supported by @@ -4727,6 +4744,8 @@ struct cfg80211_nan_func { bool data_path_required; bool security_required; bool gtk_required; + u8 group_keys; + bool bip_gmac_256; u16 pairing_bootstrap_methods; u32 *csids; u8 num_csids; @@ -6781,15 +6800,15 @@ struct wiphy_radio { * %NL80211_CMD_NAN_SET_NON_EVAC_CHANNELS. The device learns and manages peer * NAN schedules; userspace must not set them with * %NL80211_CMD_NAN_SET_PEER_SCHED. The device assigns NDP IDs for locally - * initiated NDPs, derives, installs, and removes PTKs and, when requested, - * GTKs. The device creates and removes NDI peer stations for offloaded NDPs. - * Userspace must not add those NDI peer stations or their + * initiated NDPs, derives, installs, and removes PTKs and, when negotiated, + * GTKs, IGTKs, and BIGTKs (see &struct cfg80211_nan_func.group_keys). The + * device creates and removes NDI peer stations for offloaded NDPs. Userspace + * must not add those NDI peer stations or their * keys. NDP offload is supported on all bands in * &struct wiphy.nan_supported_bands. The device supplies the band-specific * capabilities, such as the HE 6 GHz band and EHT capabilities, and the * regulatory information in the frames it builds. The driver implements - * @nan_ndp_initiate, - * @nan_ndp_respond, and + * @nan_ndp_initiate, @nan_ndp_respond, and * @nan_ndp_terminate callbacks. It supports * %NL80211_CMD_NAN_NDP_INITIATE, %NL80211_CMD_NAN_NDP_RESPOND, and * %NL80211_CMD_NAN_NDP_TERMINATE, and diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 2581b7328867..8976154fdfcd 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -7888,6 +7888,17 @@ enum nl80211_nan_publish_type { NL80211_NAN_UNSOLICITED_PUBLISH = 1 << 1, }; +/** + * enum nl80211_nan_group_keys - NAN group key support + * @NL80211_NAN_GROUP_KEYS_GTK_IGTK: the service supports GTK and IGTK. + * @NL80211_NAN_GROUP_KEYS_GTK_IGTK_BIGTK: the service supports GTK, IGTK, + * and BIGTK. + */ +enum nl80211_nan_group_keys { + NL80211_NAN_GROUP_KEYS_GTK_IGTK = 1, + NL80211_NAN_GROUP_KEYS_GTK_IGTK_BIGTK = 2, +}; + /** * enum nl80211_nan_func_term_reason - NAN functions termination reason * @@ -7953,7 +7964,9 @@ enum nl80211_nan_func_term_reason { * %NL80211_EXT_FEATURE_SECURE_NAN. * @NL80211_NAN_FUNC_GTK_REQUIRED: flag attribute. Sets the SDEA "GTK * Required" bit for GTK protection of group-addressed data frames. - * Requires %NL80211_EXT_FEATURE_SECURE_NAN. + * This is separate from @NL80211_NAN_FUNC_GROUP_KEYS, which advertises the + * service's group-key support in its Cipher Suite Info attribute. Requires + * %NL80211_EXT_FEATURE_SECURE_NAN. * @NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS: u16 bitmap of supported * NAN pairing bootstrapping methods as defined in Wi-Fi Aware * specification Table 9-321. Each bit corresponds to one method. Requires @@ -7989,6 +8002,17 @@ enum nl80211_nan_func_term_reason { * uses include the NAN Identity Resolution attribute for pairing * verification in Publish and Subscribe messages. Requires * %NL80211_NAN_CAPA_FUNC_EXTRA_ATTRS. + * @NL80211_NAN_FUNC_GROUP_KEYS: u8 attribute, see &enum nl80211_nan_group_keys. + * Group-key support of the service, advertised in the Cipher Suite Info + * attribute of the Service Discovery Frames of this function. With + * %NL80211_NAN_CAPA_OFFLOAD_NDP the device also uses it for NDPs of the + * service: it advertises it in the NDP setup frames (an NDP initiator uses + * its subscribe function) and establishes the group keys that both peers + * support. If absent, no group-key support is advertised. Requires + * %NL80211_EXT_FEATURE_SECURE_NAN. + * @NL80211_NAN_FUNC_BIP_GMAC_256: flag attribute. IGTK and BIGTK use + * NCS-BIP-GMAC-256 instead of NCS-BIP-CMAC-128. Requires + * @NL80211_NAN_FUNC_GROUP_KEYS and %NL80211_EXT_FEATURE_SECURE_NAN. * * @NUM_NL80211_NAN_FUNC_ATTR: internal * @NL80211_NAN_FUNC_ATTR_MAX: highest NAN function attribute @@ -8026,6 +8050,8 @@ enum nl80211_nan_func_attributes { NL80211_NAN_FUNC_CHAN, NL80211_NAN_FUNC_RANGE_REPORT, NL80211_NAN_FUNC_EXTRA_ATTRS, + NL80211_NAN_FUNC_GROUP_KEYS, + NL80211_NAN_FUNC_BIP_GMAC_256, /* keep last */ NUM_NL80211_NAN_FUNC_ATTR, @@ -8244,7 +8270,8 @@ enum nl80211_nan_conf_attributes { * it carries the PMKID received in the peer's SCIA for cached-PMK lookup. * @NL80211_NAN_NDP_ATTR_GTK_REQUIRED: flag indicating that GTK protection is * required for group-addressed data frames. Requires - * @NL80211_NAN_NDP_ATTR_GTK_CIPHER; IGTK and BIGTK are not covered. + * @NL80211_NAN_NDP_ATTR_GTK_CIPHER. IGTK and BIGTK are set up according to + * the group-key support of the service, see %NL80211_NAN_FUNC_GROUP_KEYS. * @NL80211_NAN_NDP_ATTR_GTK_CIPHER: u32 GTK cipher suite ID. Required if * @NL80211_NAN_NDP_ATTR_GTK_REQUIRED is set. * @NL80211_NAN_NDP_ATTR_IPV6_INTF_ID: binary IPv6 link-local interface @@ -9562,7 +9589,8 @@ enum nl80211_s1g_short_beacon_attrs { * device learns and manages peer NAN schedules; userspace must not set them * with %NL80211_CMD_NAN_SET_PEER_SCHED. The device assigns NDP IDs for * locally initiated NDPs and derives, installs, and removes data path keys - * (PTK and, when requested, GTK). The device creates and removes NDI peer + * (PTK and, when negotiated, GTK, IGTK, and BIGTK, see + * %NL80211_NAN_FUNC_GROUP_KEYS). The device creates and removes NDI peer * stations for offloaded NDPs. Userspace must not add those NDI peer stations * or their keys. NDP offload is supported on every band that the device * reports for NAN in %NL80211_ATTR_BANDS. The device supplies the band-specific diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 1856b9cd3f1c..9b105379f3ef 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1477,6 +1477,10 @@ nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = { NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_nan_func_extra_attrs, IEEE80211_MAX_DATA_LEN), + [NL80211_NAN_FUNC_GROUP_KEYS] = + NLA_POLICY_RANGE(NLA_U8, NL80211_NAN_GROUP_KEYS_GTK_IGTK, + NL80211_NAN_GROUP_KEYS_GTK_IGTK_BIGTK), + [NL80211_NAN_FUNC_BIP_GMAC_256] = { .type = NLA_FLAG }, }; /* policy for Service Response Filter attributes */ @@ -17787,6 +17791,11 @@ static int nl80211_nan_add_func(struct sk_buff *skb, func->security_required = nla_get_flag(tb[NL80211_NAN_FUNC_SECURITY_REQUIRED]); func->gtk_required = nla_get_flag(tb[NL80211_NAN_FUNC_GTK_REQUIRED]); + if (tb[NL80211_NAN_FUNC_GROUP_KEYS]) + func->group_keys = + nla_get_u8(tb[NL80211_NAN_FUNC_GROUP_KEYS]); + func->bip_gmac_256 = + nla_get_flag(tb[NL80211_NAN_FUNC_BIP_GMAC_256]); if (func->security_required && !func->data_path_required) { NL_SET_ERR_MSG(info->extack, @@ -17796,6 +17805,8 @@ static int nl80211_nan_add_func(struct sk_buff *skb, } if (func->security_required || func->gtk_required || + tb[NL80211_NAN_FUNC_GROUP_KEYS] || + tb[NL80211_NAN_FUNC_BIP_GMAC_256] || tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] || tb[NL80211_NAN_FUNC_CSIDS] || tb[NL80211_NAN_FUNC_ND_PMK]) { if (!wiphy_ext_feature_isset(wdev->wiphy, @@ -17806,6 +17817,13 @@ static int nl80211_nan_add_func(struct sk_buff *skb, goto out; } + if (func->bip_gmac_256 && !func->group_keys) { + NL_SET_ERR_MSG(info->extack, + "BIP-GMAC-256 requires group key support"); + err = -EINVAL; + goto out; + } + if (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS]) func->pairing_bootstrap_methods = nla_get_u16(tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS]); -- 2.34.1