From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=211.75.126.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796180596; b=V0+ZLSQU5jdfVU/T5VXsBVrPruUtbjPvc5TOQz24NEmRoEtb3W4jsTMnv+N38fkDc2sF vNm0Vlz3UYcNoOkftvEM8DBiDlqpIGwzsu7jM0ZuKAm9WLAlvN9keavY26hpECLVn2GRj M5hNhTlgnwJ92Twh5MKYjc1bnH/lD0oSZASbn9eFSt3LbB7pWt8vNTXMQyLMD6aU1WTpd 8YNLUQe+7YxXCUFurEO3QQTSjmdOEziTBDXEWtJCWt94awgtTukzZachfOhBuXM8nFlcn 3Q4Rw8SD3aSzFeZIuV1gjf60Xo++MXcR1VHqxU3jMkw/9DOt1Yq0dfbd2jWZa+OyoRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796180596; h=DMARC-Filter:X-SpamFilter-By:DKIM-Signature:Received:Received: Received:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID: References:In-Reply-To:Accept-Language:Content-Language: x-originating-ip:Content-Type:Content-Transfer-Encoding:MIME-Version; bh=OFiK/Lc1kxLWGOnF40p3CpqphvjcNtUdp08DicCz84Q=; b=aNzilxRm4pFOuj4aj7taF+dG5mQwyy/JOnCOTfpF31nwbHmt9fyDdpz4Gkkoi3Ftsoqm erQjYNL5B63ksFdI+dnexDk5iMcKq7LxyEoSlv5jxQfcMFFITamd+tlepfJyXemGYcnWa P8TkBGbhS/qZrMIpe3Amw78aJQXvICxNAxYLYfisc9zZclyrlPDh8tjA5gMLMWlluROrC +pm+mIo5qo9qE2/ImEOlnFXflL6TRrmNvfbzggUkgSz+XYmnhyKfh3AHGWdVdtOww6VF8 cw9W5tso9PBMrsCs6mYRiWv0gzdKVDBUbj/l97kGzb8INo7t9kRkCOlPcPcNT2emeBA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; dkim=pass header.d=realtek.com header.i=@realtek.com header.a=rsa-sha256 header.s=dkim header.b=Tjr8cQ2A; arc=none smtp.remote-ip=211.75.126.72 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC46F606A31A for ; Wed, 2 Dec 2026 03:03:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CC46F606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=realtek.com header.i=@realtek.com header.a=rsa-sha256 header.s=dkim header.b=Tjr8cQ2A X-SpamFilter-By: ArmorX SpamTrap 5.80 with qID 6B233BZY0647951, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realtek.com; s=dkim; t=1796180591; bh=OFiK/Lc1kxLWGOnF40p3CpqphvjcNtUdp08DicCz84Q=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:Content-Transfer-Encoding:MIME-Version; b=Tjr8cQ2ArjxoXEynJmcy8dwo6GFHy1sIxVGvEJ0vZxBdLeX6sH01zCdHiDm6RskQO Y7yNCo3tj0gz88MQdKKpMdAEBA4PpoxVyntWwzW2KosqQhZv7MQOifDa0wWBbjbO93 8Xacd23s4jE/HN+8YXRYKFEPBhet749Z8J7NsSQ/bVlVMF8GFHAMvaZ2Zfk6dKna1J Xi9bHnitRjjXCx3Fao/jWpIy8Ije6DfpcKk6PYI1NoG7Sf/E+7HaX31iAHWzCtyzZb 1J/ax+1Cxh3H7CTxmg07oNchLFEFIiT8C8mWytOTBNbIcb5NN7/ElrWOUaxjRyudIm 7cm0/5nm0NicA== Received: from mail.realtek.com (rtkexhmbs03.realtek.com.tw[10.21.1.53]) by rtits2.realtek.com.tw (8.15.2/3.29/5.94) with ESMTPS id 6B233BZY0647951 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 2 Dec 2026 11:03:11 +0800 Received: from RTKEXHMBS06.realtek.com.tw (10.21.1.56) by RTKEXHMBS03.realtek.com.tw (10.21.1.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Wed, 2 Dec 2026 11:03:11 +0800 Received: from RTKEXHMBS06.realtek.com.tw ([fe80::eeeb:c765:ca73:5eef]) by RTKEXHMBS06.realtek.com.tw ([fe80::eeeb:c765:ca73:5eef%10]) with mapi id 15.02.2562.056; Wed, 2 Dec 2026 11:03:11 +0800 From: Ping-Ke Shih To: Maoyi Xie CC: "linux-wireless@vger.kernel.org" Subject: RE: [PATCH rtw-next 3/4] wifi: rtw89: phy: check LPS report C2H event length Thread-Topic: [PATCH rtw-next 3/4] wifi: rtw89: phy: check LPS report C2H event length Thread-Index: AQHdgXKdOV1r8yY5C0OSbizBwdjw57dJEAaQ Date: Wed, 2 Dec 2026 03:03:10 +0000 Message-ID: <2347be3ddfd141e29f3550f4b9efab6a@realtek.com> References: <20261201090138.3652600-1-maoyixie.tju@gmail.com> <20261201090138.3652600-4-maoyixie.tju@gmail.com> In-Reply-To: <20261201090138.3652600-4-maoyixie.tju@gmail.com> Accept-Language: en-US, zh-TW Content-Language: zh-TW Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Maoyi Xie wrote: > The LPS report handler checks the length from the C2H header and the > counts in the report against each other, but not against the skb. If > the header claims more data than arrived, the debug prints read up to > 16 KB past the skb data, even with the debug mask off. >=20 > Check the skb length before processing the report. >=20 > Found with a CodeQL-based static analysis tool. Reproduced in a > userspace harness under AddressSanitizer. Not tested on hardware. >=20 > Signed-off-by: Maoyi Xie > --- > I used an LLM to help write the harness and this patch. >=20 > drivers/net/wireless/realtek/rtw89/phy.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wirel= ess/realtek/rtw89/phy.c > index 133b591ffa7f..b4f1802025c9 100644 > --- a/drivers/net/wireless/realtek/rtw89/phy.c > +++ b/drivers/net/wireless/realtek/rtw89/phy.c > @@ -3449,6 +3449,9 @@ rtw89_phy_c2h_lps_rpt(struct rtw89_dev *rtwdev, str= uct sk_buff *c2h, u32 len) > const __le16 *addr; > const u8 *info; >=20 > + if (c2h->len < sizeof(*c2h_rpt) || len > c2h->len) > + return; > + Validate 'len > c2h->len' earlier (with unlikely) at rtw89_fw_c2h_cmd_handl= e(). > /* elements size of BBCR/BBMCUCR/RFCR are 6/6/10 bytes respective= ly */ > cr_len =3D c2h_rpt->cnt_bbcr * 6 + > c2h_rpt->cnt_bbmcucr * 6 + > -- > 2.34.1