From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796110462; b=GKllFs1vMBmciWimT0la4tGfK6pt6sKV6Jl1RbOmwpoVxa/5FaS2OQh2+wB3U9jdcd6W pCapziHkZBBslK/b2BnXS8Nfm8AGXemrTWkUSWHsaBm3LKqHPCCEpBVKlYSsDnWWFnHwq rd43osklo8hcnMrNk915J9o+9f6uUxUT9VhiG0nXYnDdGidKtC5WT/SQV3hkYtW8kgWK/ 5OGcORqc6YlkH14z1Drb4SLk1TLGUOh4RHHUB3RQtCV2l+5R0MDsLe3G4HlPHxp3ie/WZ H597ozYRujcWT3ZWgatNvjNWXmctxruoxbChVGTmEEOkWNK2yn6/wgFjsLaNYnhPLdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796110462; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=bEtYVBPnetlu+mkT/eB9yST4JrqgOiDIGUxKuUjNecw=; b=Gypn1jBMNQUzk80EXy6Y9Q63tKfsla7nyu8A+7qxDEMICT3OtUYtlRXpilo52O0iszyX 9G8/zMN4q+6UWgqPPSdstuH2ZlBHwCW54C5o101NAX3DEt58m88XPKFbsUrfsuUmi6HkC gk9NCMx3I/ZZYRkyoOt6uhTtdiQobo3tQto2H3Ta+CDaMrvu/ITwwikGVsMskyuib94dW Jic0ej84EBdb4vgLVfCTu7xceEC5nPINVYRZB/XRWLoJa9z9WPFA4QEKceW2Dcsny1MO+ jCrPUBxe2fEV/9/JaKnLNWpggNx6KMf87Eebhoj/1aaIGixpFNzZw2QRI20T4WJs8vw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=I3EdOUWi; arc=none smtp.remote-ip=74.125.82.42 Received: from mail-dl1-f42.google.com (mail-dl1-f42.google.com [74.125.82.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29A68606A33B for ; Tue, 1 Dec 2026 07:34:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 29A68606A33B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=I3EdOUWi Received: by mail-dl1-f42.google.com with SMTP id a92af1059eb24-1a2761c69fbso19153308c88.0 for ; Mon, 30 Nov 2026 23:34:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796110460; x=1796715260; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bEtYVBPnetlu+mkT/eB9yST4JrqgOiDIGUxKuUjNecw=; b=I3EdOUWibzDRRt1q7fwF19TREFvllCd0PQiRUK5uMZyWkUpb4mvCARDpF8JVfus5b8 +Frzi8eOcuFMO+5E/O1ZVHHZ5tdP9iU2o6VcMD69gpOScpFApCrd4hICMPqPgqvQltpV J04WgYDr67l+Cl1NQziQkOl2VatD79nJ+tyjE/BDyYAM0EU9Ts6w4negW3Pyrtzc2pTq 8LlB6r2r0Bpd60KoEOgP/pzZlknF6P5AXVM5RQ3jyyGaKqrTJ01yjppPTS8V1OBh07X+ UOifHznzj3kQ7K3khNY81K7SuTH01t8LNJnfz3ybjMYdnJ18j2owh27M6d1QggYkjonW /bFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796110460; x=1796715260; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=bEtYVBPnetlu+mkT/eB9yST4JrqgOiDIGUxKuUjNecw=; b=UK+dg5wIFSjO2fbYfBoCMmnAZ5c8IlV5eOqzE+akWZnjhJxKVHbHDdpp+jBIDgJfgE zElJ3NNErx5oxzTAuNTWxc/1DN0vLlOPo9YriVvI2DaDICLcDVDONWndYv9XAaCc/y8D 1GvZ1EpPON+VcD4Ha600erIzMxaSoNZDfzCxksU4c76vmZKH71F4QBQIPeKMfYN0qqwX 8l1OnZTP53XsTdyqAPYCFQmgPa21BoNGTkrWgiw8ccn8L7/+gMaZAtA1i4hAhMOsWoQY RokT0ndiXrRc0khga04qEYCYds0h+4rkdYcKT9/9vI9irpcHth5/ibcRIx3nY82oUYnz Me3A== X-Forwarded-Encrypted: i=1; AL+hErGodHbd47IRIwRhGzGV0nkqjjJrYxHa9K96F25LuC2DTStBZ9o3LZzrLW8h/FMAAWY8qk/8bUE=@vger.kernel.org X-Gm-Message-State: APuU4Z9PO2igSfCazr6cE++OxV8ZRXJ68WE9aE9wBBvC9ZL/8NQiIh32 t4pj+yYp1nM42ZdyX4E0cFgKTFhJ4Rhf2J/wbHqjMbmpBo746LCF66OZ X-Gm-Gg: AZFdTZdMBZxBrUfL5JD3i795X2YxLXVf8ppW6Z0W2SRhoIWfM0Meu8OPiqenArPwvZD Unw9nJrZMibosfjWdKjS3HhA8zACyvZ3lJIiBL5M8tyKOOSuk27uEoHSONHO1RZdlTsa4AHgSpH Es8mTnA9ZqF8jJXL8A4rA4k3fvZvjFS+MkmH25QJSqlx+hnxvzziN4FDujbGlinKMLZObzSZoTU VCg1ekZPvNq2zVz06j6jKRnuPlYJmBGtVi9yHOyF12VfwCDCRrWtGLBOZQhM7iUQNa2LvVV5OZ/ VubHB45f0AdyrL+Ho6YPqyA6WgwRn5jVvVhKDN4QRcdG95BZG2MhVkVdmMzwY6UAHeilxOhYJ1a rB5G8HpW8kdacXusyrhGQmQdE/eKAwAjuip8IAgYKAOTdwGHfLPrbMbmf1WrU+KfW2QFWwwjHqN YK+JWUOYg/8oH/++tbYpBBmHlgw4jkIaL50dwXFkRdRbs+neQGiAQwExFWzlWGYrbvHvz+PqgGo DT0YYaXsiZ6IY0mk4qNX1o+u1SF+M6IVd2tNdqyaQtaRCj5eH8ioWe/qNgv12e8Ru6k0r1OzS4v 6RRQZUrYnjguGjEmhXnegn5CBGBjELgxjcGE+epSNsLyuLvisg== X-Received: by 2002:a05:7022:ea45:b0:1b5:31db:cc3e with SMTP id a92af1059eb24-1b5568b2b4bmr31493319c88.11.1796110460055; Mon, 30 Nov 2026 23:34:20 -0800 (PST) Received: from Mac.lan ([2409:40d2:2011:872e:f431:a5dd:a675:986c]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385672ce402sm100438879eec.16.2026.11.30.23.34.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 23:34:19 -0800 (PST) From: Tanuj Sharma To: pkshih@realtek.com Cc: security@kernel.org, kvalo@kernel.org, linux-wireless@vger.kernel.org, stable@vger.kernel.org, gregkh@linuxfoundation.org, Tanuj Sharma Subject: [PATCH v3] wifi: rtlwifi: fix P2P NoA bounds check using truncated length Date: Tue, 1 Dec 2026 13:04:12 +0530 Message-ID: <20261201073412.83583-1-ertanuj96@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <4999a75ee6e24db18c019bb6e5fcda6a@realtek.com> References: <4999a75ee6e24db18c019bb6e5fcda6a@realtek.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Both rtl_p2p_noa_ie() and rtl_p2p_action_ie() parse P2P sub-elements whose length field is 16 bits (little-endian at bytes 1-2 of each sub-element header). The code reads the full 16-bit value into noa_len: noa_len = le16_to_cpu(*((__le16 *)&ie[1])); but the bounds check only uses the low byte: if (ie + 3 + ie[1] > end) When the high byte (ie[2]) is non-zero, the bounds check passes with a smaller value than the actual length, allowing the inner NOA descriptor loop to read up to 26 bytes past the validated region. Use noa_len in the bounds check to match the actual length used for parsing. Additionally, the while loop condition 'ie + 1 < end' only guarantees ie[0] and ie[1] are readable, but the le16_to_cpu read accesses both ie[1] and ie[2]. Change the condition to 'ie + 2 < end' to ensure the full 3-byte sub-element header (attribute ID + 16-bit length) is accessible before reading. Cc: stable@vger.kernel.org Fixes: 26634c4b1868 ("rtlwifi Modify existing bits to match vendor version 2013.02.07") Signed-off-by: Tanuj Sharma Acked-by: Ping-Ke Shih --- Changes in v3: - Fix the Fixes tag to point to the commit that introduced the vulnerable code (Ping-Ke Shih) Changes in v2: - Use 'ie + 2 < end' instead of 'ie + 3 <= end' for the while loop condition to match the existing coding style (Ping-Ke Shih) drivers/net/wireless/realtek/rtlwifi/ps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c index 6241e4fed4f64..807d88fc5c6bc 100644 --- a/drivers/net/wireless/realtek/rtlwifi/ps.c +++ b/drivers/net/wireless/realtek/rtlwifi/ps.c @@ -720,9 +720,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data, return; find_p2p_ie = true; /*to find noa ie*/ - while (ie + 1 < end) { + while (ie + 2 < end) { noa_len = le16_to_cpu(*((__le16 *)&ie[1])); - if (ie + 3 + ie[1] > end) + if (ie + 3 + noa_len > end) return; if (ie[0] == 12) { @@ -815,9 +815,9 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data, rtl_dbg(rtlpriv, COMP_FW, DBG_LOUD, "action frame find P2P IE.\n"); /*to find noa ie*/ - while (ie + 1 < end) { + while (ie + 2 < end) { noa_len = le16_to_cpu(*(__le16 *)&ie[1]); - if (ie + 3 + ie[1] > end) + if (ie + 3 + noa_len > end) return; if (ie[0] == 12) { -- 2.43.0