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 | 31 +++++++++++++++++++++++++------ include/uapi/linux/nl80211.h | 34 +++++++++++++++++++++++++++++++--- net/wireless/nl80211.c | 18 ++++++++++++++++++ 3 files changed, 74 insertions(+), 9 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index b539266d0256..f056eea67a0d 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 + * &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 + * &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 + * &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,19 @@ 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 + * 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. @@ -4727,6 +4743,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; @@ -6779,8 +6797,9 @@ 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 + * initiated NDPs, derives, installs, and removes PTKs and, when + * negotiated, GTKs, IGTKs, and BIGTKs (see &cfg80211_nan_func.group_keys). + * The device creates and removes NDI peer stations for offloaded * NDPs. NDP offload is supported on all bands in * &wiphy.nan_supported_bands. The device supplies the band-specific * capabilities, such as the HE 6 GHz band and EHT capabilities, and the diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index e0d81820204c..2ab8f0c0bd1d 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -7881,6 +7881,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 * @@ -7945,7 +7956,9 @@ enum nl80211_nan_func_term_reason { * and %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 @@ -7980,6 +7993,17 @@ enum nl80211_nan_func_term_reason { * Subscribe messages, and Vendor Specific attributes are accepted; any * other attribute is rejected. The device appends the attributes * unmodified. 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 @@ -8017,6 +8041,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, @@ -8235,7 +8261,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 @@ -9556,7 +9583,8 @@ enum nl80211_s1g_short_beacon_attrs { * 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 + * 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 diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 537bd6cb934f..a4e86c420ef4 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1486,6 +1486,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 */ @@ -17797,6 +17801,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, @@ -17806,6 +17815,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, @@ -17816,6 +17827,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