From aba3da32ac847a6d430f917855d30ae34af6cc90 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 2 Apr 2020 00:45:55 -0500 Subject: [PATCH] netdev: work around APs that send igtk in big endian It seems some APs send the IGTK key in big endian format (it is a uin16). The kernel rightly reports an -EINVAL error when iwd issues a NEW_KEY with such a value, resulting in the connection being aborted. Work around this by trying to detect big-endian key indexes and 'fixing' them up. --- src/netdev.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/netdev.c b/src/netdev.c index 799f01e3..f999a14c 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1297,6 +1297,14 @@ static void netdev_set_igtk(struct handshake_state *hs, uint16_t key_index, return; } + if (key_index == 0x0400 || key_index == 0x0500) { + l_warn("Received an invalid IGTK key index (%04hx)" + " that is likely in" + " big endian format. Trying to fix and" + " proceed anyway", key_index); + key_index = bswap_16(key_index); + } + msg = nl80211_build_new_key_group(netdev->index, cipher, key_index, igtk_buf, igtk_len, ipn, ipn_len, NULL);