* [PATCH] wifi: mac80211_hwsim: require exact alpha2 attribute length
@ 2026-08-14 14:40 Mariano Baragiola
0 siblings, 0 replies; only message in thread
From: Mariano Baragiola @ 2026-08-14 14:40 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, linux-kernel
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")
Signed-off-by: Mariano Baragiola <mbaragiola@linux.com>
---
drivers/net/wireless/virtual/mac80211_hwsim_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
index 02b6d81cccd1..4a567a2d885b 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -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 },
--
2.55.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-14 14:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 14:40 [PATCH] wifi: mac80211_hwsim: require exact alpha2 attribute length Mariano Baragiola
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.