Skip to contentSkip to conversation

wifi: mac80211_hwsim: require exact alpha2 attribute length

PATCH New Mariano Baragiola 1 participant 1 message Aug 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mac80211_hwsim: require exact alpha2 attribute length

The HWSIM_ATTR_REG_HINT_ALPHA2 policy accepts one-byte strings. mac80211_hwsim_new_radio() later copies two bytes from the attribute into data->alpha2, so a short value reads beyond the attribute payload.

Require the exact two-byte payload used by build_radio_msg(). This rejects malformed requests before hwsim_new_radio_nl() handles them.

Fixes 26b0e411d37a ("mac80211_hwsim: restore regulatory testing functionality")
---
 drivers/net/wireless/virtual/mac80211_hwsim_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/virtual/mac80211_hwsim_main.c +1 -1
index 02b6d81cccd1..4a567a2d885b 100644
@@ -876,7 +876,7 @@ static const struct nla_policy hwsim_genl_policy[HWSIM_ATTR_MAX + 1] = {
 	[HWSIM_ATTR_COOKIE] = { .type = NLA_U64 },
 	[HWSIM_ATTR_CHANNELS] = { .type = NLA_U32 },
 	[HWSIM_ATTR_RADIO_ID] = { .type = NLA_U32 },
-	[HWSIM_ATTR_REG_HINT_ALPHA2] = { .type = NLA_STRING, .len = 2 },
+	[HWSIM_ATTR_REG_HINT_ALPHA2] = NLA_POLICY_EXACT_LEN(2),
 	[HWSIM_ATTR_REG_CUSTOM_REG] = { .type = NLA_U32 },
 	[HWSIM_ATTR_REG_STRICT_REG] = { .type = NLA_FLAG },
 	[HWSIM_ATTR_SUPPORT_P2P_DEVICE] = { .type = NLA_FLAG },
Signature · 1 line
2.55.0