From: Tanuj Sharma <ertanuj96@gmail.com>
To: pkshih@realtek.com, rtl8821cerfe2@gmail.com
Cc: security@kernel.org, kvalo@kernel.org,
linux-wireless@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH v2] wifi: rtlwifi: fix P2P NoA bounds check using truncated length
Date: Tue, 1 Dec 2026 02:27:50 +0530 [thread overview]
Message-ID: <20261130205750.64080-1-ertanuj96@gmail.com> (raw)
In-Reply-To: <d2a222a066a1419a89d1c8b2c119066a@realtek.com>
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: 8c55dedb795b ("rtlwifi: Fix potential overflow on P2P code")
Signed-off-by: Tanuj Sharma <ertanuj96@gmail.com>
---
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
next parent reply other threads:[~2026-11-30 20:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d2a222a066a1419a89d1c8b2c119066a@realtek.com>
2026-11-30 20:57 ` Tanuj Sharma [this message]
2026-12-01 2:59 ` [PATCH v2] wifi: rtlwifi: fix P2P NoA bounds check using truncated length Ping-Ke Shih
2026-12-01 7:34 ` [PATCH v3] " Tanuj Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130205750.64080-1-ertanuj96@gmail.com \
--to=ertanuj96@gmail.com \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.com \
--cc=rtl8821cerfe2@gmail.com \
--cc=security@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.