diff mbox series

[v7] WPA: Add workaround for APs with out-of-range IGTK KeyID

Message ID 20260918070341.4604-1-chao.meng@unisoc.com
State New
Headers show
Series [v7] WPA: Add workaround for APs with out-of-range IGTK KeyID | expand

Commit Message

Chao Meng Sept. 18, 2026, 7:03 a.m. UTC
Some APs send an IGTK KeyID larger than 4095 with a valid key index (4
or 5) in the low byte and spurious bits in the high byte, which would
make the keyidx > 4095 validation reject the IGTK and force a
disconnection. Detect this case by checking whether the low byte of the
KeyID is a valid key index and, if so, mask off the high byte and use
the low byte as the key index to install the IGTK with the corrected
KeyID instead of disconnecting. Log an informational message instead of
a warning.

Signed-off-by: Chao Meng <chao.meng@unisoc.com>
---
 src/rsn_supp/wpa.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

--
2.21.0.windows.1
diff mbox series

Patch

diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
index 040ce6ed8..4e032d6b5 100644
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
@@ -1727,9 +1727,22 @@  static int wpa_supplicant_install_igtk(struct wpa_sm *sm,
                keyidx, MAC2STR(igtk->pn));
        wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", igtk->igtk, len);
        if (keyidx > 4095) {
-               wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
-                       "WPA: Invalid IGTK KeyID %d", keyidx);
-               return -1;
+               int masked = keyidx & 0xFF;
+               if (masked == 4 || masked == 5) {
+                       /* Some APs send an IGTK KeyID larger than 4095 with
+                        * a valid key index (4 or 5) in the low byte and
+                        * spurious bits in the high byte. Mask off the high
+                        * byte and use the low byte as the key index instead
+                        * of rejecting the IGTK and disconnecting. */
+                       wpa_msg(sm->ctx->msg_ctx, MSG_INFO,
+                               "WPA: Workaround for non-compliant AP: corrected IGTK KeyID %d to %d",
+                               keyidx, masked);
+                       keyidx = masked;
+               } else {
+                       wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
+                               "WPA: Invalid IGTK KeyID %d", keyidx);
+                       return -1;
+               }
        }
        if (wpa_sm_set_key(sm, -1, wpa_cipher_to_alg(sm->mgmt_group_cipher),
                           broadcast_ether_addr,