From patchwork Tue May 12 13:15:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chung-Hsien Hsu X-Patchwork-Id: 2236872 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=AFNd0rtn; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=infineon.com header.i=@infineon.com header.a=rsa-sha256 header.s=IFXMAIL header.b=OMDqkI0O; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4gFHHf20Bkz1yJ5 for ; Tue, 12 May 2026 23:19:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H2HzuDmdTEGxDKW/UIJ737//jbHXwwIcvp17BQX4Jvw=; b=AFNd0rtndDz7Pk BF/VJRvosYapSLqXgaAjrx5K0EaR1EqjkCOJa3o4cFqHB+BREeNe3FilyAzq6YtV/vIsTsRNqvLR7 XKqGatpSg7JSEVHGVFNAfdqZy+5tiID5AabCe++bR+t2FbikOaJiqYsOsKgpuJBdUshRsiGcRrbkx bhU8ZzeVwapVnZv+nTBD2U2PXbGQKWVqC3REvn/p1IIzy9nDUmbz17w/NuZ/n0i59R+x8EbFEzS5H gFmOKrYEAhmSyrO/UIAWIbwTJ5ZEeyHJB1CKfYsNYoqdEir68a4WrXAEnrFpFLhTqCGxEYE+g/73S Hum5n2TUb9h5O8uYmUoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wMmzi-0000000GnqW-0JbA; Tue, 12 May 2026 13:17:54 +0000 Received: from smtp2.infineon.com ([2a00:18f0:1e00:4::4]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wMmzf-0000000GnpF-0mfR for hostap@lists.infradead.org; Tue, 12 May 2026 13:17:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infineon.com; i=@infineon.com; q=dns/txt; s=IFXMAIL; t=1778591871; x=1810127871; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iyh8QxMz0K7AeJX/ve8RB3+LRrgkKFV/DoyEbFveWFE=; b=OMDqkI0O70WeU5EbdpkZEpX+A6rJ2UgA3HDjo2zr+CkyXIAGSbwFiZlk QFt/ZqcTJlBRY52o8nX5+8gDODFGSUT7P0EGVUbMqMnc4WPmGi92ZpQZg KvK9AAjKGRNwOPArcNE4kDWxrCsiaWvTkZNpoO61/J333EAI1LH7dPjYP 8=; X-CSE-ConnectionGUID: SpfuMTBDStSKk5KXtVR1eQ== X-CSE-MsgGUID: U/J8EH+tQRy6rzs7Mb4lCg== X-IronPort-AV: E=McAfee;i="6800,10657,11783"; a="157288499" X-IronPort-AV: E=Sophos;i="6.23,230,1770591600"; d="scan'208";a="157288499" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO MUCSE819.infineon.com) ([172.23.29.45]) by smtp2.infineon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2026 15:17:49 +0200 Received: from MUCSE825.infineon.com (172.23.29.18) by MUCSE819.infineon.com (172.23.29.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 12 May 2026 15:17:49 +0200 Received: from ISCN5CG4472QHC.infineon.com (10.161.6.196) by MUCSE825.infineon.com (172.23.29.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 12 May 2026 15:17:48 +0200 From: Chung-Hsien Hsu To: CC: Chung-Hsien Hsu Subject: [PATCH 2/2] RSN: Reject invalid MLO GTK KDE length in msg 3/4 Date: Tue, 12 May 2026 21:15:58 +0800 Message-ID: <20260512131558.18020-3-chung-hsien.hsu@infineon.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260512131558.18020-1-chung-hsien.hsu@infineon.com> References: <20260512131558.18020-1-chung-hsien.hsu@infineon.com> MIME-Version: 1.0 X-Originating-IP: [10.161.6.196] X-ClientProxiedBy: MUCSE804.infineon.com (172.23.29.30) To MUCSE825.infineon.com (172.23.29.18) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260512_061751_545167_07FBDFA8 X-CRM114-Status: GOOD ( 15.44 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Validate MLO GTK KDE lengths in EAPOL-Key message 3/4 before transmitting message 4/4. The MLO GTK KDE length is already checked when processing each per-link GTK for installation. However, that validation is reached only after message 4/4 has been transmitted. This allows a malformed m [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 DMARC_PASS DMARC pass policy X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Validate MLO GTK KDE lengths in EAPOL-Key message 3/4 before transmitting message 4/4. The MLO GTK KDE length is already checked when processing each per-link GTK for installation. However, that validation is reached only after message 4/4 has been transmitted. This allows a malformed message 3/4 with an invalid MLO GTK KDE length to be acknowledged even though the supplicant later rejects the GTK and fails the handshake. Reject message 3/4 before sending message 4/4 if any per-link MLO GTK KDE is too short to include the MLO GTK KDE prefix, or if the GTK payload would exceed the local GTK buffer. Reuse the same helper in the later MLO GTK installation path to keep the validation rules consistent. Signed-off-by: Chung-Hsien Hsu --- src/rsn_supp/wpa.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index ecc0eddd45ab..acc50f4c77bd 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -1409,6 +1409,18 @@ static int wpa_supplicant_validate_gtk_kde_len(size_t gtk_len) } +static int wpa_supplicant_validate_mlo_gtk_kde_len(size_t gtk_len) +{ + struct wpa_gtk_data gd; + + if (gtk_len < RSN_MLO_GTK_KDE_PREFIX_LENGTH || + gtk_len - RSN_MLO_GTK_KDE_PREFIX_LENGTH > sizeof(gd.gtk)) + return -1; + + return 0; +} + + static int wpa_supplicant_install_gtk(struct wpa_sm *sm, const struct wpa_gtk_data *gd, const u8 *key_rsc, int wnm_sleep) @@ -1602,8 +1614,7 @@ static int wpa_supplicant_mlo_gtk(struct wpa_sm *sm, u8 link_id, const u8 *gtk, "RSN: received GTK in pairwise handshake", gtk, gtk_len); - if (gtk_len < RSN_MLO_GTK_KDE_PREFIX_LENGTH || - gtk_len - RSN_MLO_GTK_KDE_PREFIX_LENGTH > sizeof(gd.gtk)) + if (wpa_supplicant_validate_mlo_gtk_kde_len(gtk_len) < 0) return -1; gd.keyidx = gtk[0] & 0x3; @@ -2886,6 +2897,14 @@ static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm, goto failed; } + if (wpa_supplicant_validate_mlo_gtk_kde_len( + ie.mlo_gtk_len[i]) < 0) { + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "RSN: Invalid MLO GTK KDE length %lu for link ID %u", + (unsigned long) ie.mlo_gtk_len[i], i); + goto failed; + } + if (sm->mgmt_group_cipher != WPA_CIPHER_GTK_NOT_USED && wpa_cipher_valid_mgmt_group(sm->mgmt_group_cipher) && wpa_validate_mlo_ieee80211w_kdes(sm, i, &ie) < 0)