Article View: linux.kernel.netdev
Article #26179[PATCH net 3/5] t7xx: reject malformed runtime-feature handshake data
From: Wanquan Zhong
Date: Thu, 03 Dec 2026 06:26
Date: Thu, 03 Dec 2026 06:26
90 lines
11599 bytes
11599 bytes
This is for B.1. Malformed runtime-feature blobs can make the host
walk off the end of the handshake buffer.
Validate the feature header and payload lengths before using them.
Fail a truncated header or data_len with -EINVAL. Propagate PORT_ENUM
errors for MUST features.
Do not require FEATURE_COUNT entries: firmware may advertise a
subset of complete runtime features. A truncated record is not a
subset; a subset ends on a complete feature at offset == length.
Signed-off-by: Wanquan Zhong <zwq2226404116@163.com>
---
drivers/net/wwan/t7xx/t7xx_modem_ops.c | 42 ++++++++++++++++----------
1 file changed, 26 insertions(+), 16 deletions(-)
diff --git a/drivers/net/wwan/t7xx/t7xx_modem_ops.c b/drivers/net/wwan/t7xx/t7xx_modem_ops.c
index adb29d30c63f..e5065bf55bd6 100644
--- a/drivers/net/wwan/t7xx/t7xx_modem_ops.c
+++ b/drivers/net/wwan/t7xx/t7xx_modem_ops.c
@@ -453,40 +453,50 @@ static int t7xx_parse_host_rt_data(struct t7xx_fsm_ctl *ctl, struct t7xx_sys_inf
{
enum mtk_feature_support_type ft_spt_st, ft_spt_cfg;
struct mtk_runtime_feature *rt_feature;
- int i, offset;
+ int i, offset, ret = 0;
+ size_t remaining, feat_data_len;
offset = sizeof(struct feature_query);
- for (i = 0; i < FEATURE_COUNT && offset < data_length; i++) {
- size_t remaining = data_length - offset;
- size_t feat_data_len, feat_total;
+ if (!data || data_length < offset)
+ return -EINVAL;
- if (remaining < sizeof(*rt_feature))
+ for (i = 0; i < FEATURE_COUNT && offset < data_length; i++) {
+ remaining = data_length - offset;
+ if (remaining < sizeof(*rt_feature)) {
+ ret = -EINVAL;
break;
+ }
rt_feature = data + offset;
feat_data_len = le32_to_cpu(rt_feature->data_len);
-
- if (feat_data_len > remaining - sizeof(*rt_feature))
+ if (feat_data_len > remaining - sizeof(*rt_feature)) {
+ ret = -EINVAL;
break;
-
- feat_total = sizeof(*rt_feature) + feat_data_len;
- offset += feat_total;
+ }
ft_spt_cfg = FIELD_GET(FEATURE_MSK, core->feature_set[i]);
- if (ft_spt_cfg != MTK_FEATURE_MUST_BE_SUPPORTED)
+ if (ft_spt_cfg != MTK_FEATURE_MUST_BE_SUPPORTED) {
+ offset += sizeof(*rt_feature) + feat_data_len;
continue;
+ }
ft_spt_st = FIELD_GET(FEATURE_MSK, rt_feature->support_info);
- if (ft_spt_st != MTK_FEATURE_MUST_BE_SUPPORTED)
- return -EINVAL;
+ if (ft_spt_st != MTK_FEATURE_MUST_BE_SUPPORTED) {
+ ret = -EINVAL;
+ break;
+ }
if (i == RT_ID_MD_PORT_ENUM || i == RT_ID_AP_PORT_ENUM) {
- t7xx_port_enum_msg_handler(ctl->md, rt_feature->data,
- feat_data_len);
+ ret = t7xx_port_enum_msg_handler(ctl->md, rt_feature->data,
+ feat_data_len);
+ if (ret)
+ break;
}
+
+ offset += sizeof(*rt_feature) + feat_data_len;
}
- return 0;
+ return ret;
}
static int t7xx_core_reset(struct t7xx_modem *md)
--
2.53.0
Technical Details
Message-ID:
<eddba215978ad61a8ade0d4b383dc341b4a67bb3.1796279181.git.zwq2226404116@163.com>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376329-linux-kernel-netdev=dewy.ruReferences:
<cover.1796279181.git.zwq2226404116@163.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376329-linux-kernel-netdev=dewy.ru From: zwq2226404116@163.com (Wanquan Zhong) Newsgroups: linux.kernel.netdev Subject: [PATCH net 3/5] t7xx: reject malformed runtime-feature handshake data Date: Thu, 3 Dec 2026 14:26:33 +0800 Organization: Usenet Network Message-ID: <eddba215978ad61a8ade0d4b383dc341b4a67bb3.1796279181.git.zwq2226404116@163.com> References: <cover.1796279181.git.zwq2226404116@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2199690"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:PDjKxyYlgtcEP4FvYctiFZKPJuk= sha256:/arFVbGcQZrJU58xrWNsB3fmU4luW1N9nbkKDlMfMJY= sha1:CDk9CweWyd31w1tpDQt3qDQV8GA= sha256:0gUD2SI0fTk3wxSe2GGgGEn/08c3v8bT9STIsYr6Urc= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D395D117841; Thu, 3 Dec 2026 09:28:16 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.048 X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0imph7cZIPY9; Thu, 3 Dec 2026 09:28:14 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376329-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id DD845117817; Thu, 3 Dec 2026 09:28:05 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 15B852B12A; Thu, 3 Dec 2026 06:27:46 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796279266; b=V9HgPnoM6Ua4aBsZtsGBz2cPEE6y74rXUbvxGxCzbUBuZNcwQ2H4JqeJq+alhdwH+jJh WBoUqsmtsylpGXJIXvQKIPDnx97oRLpF1smHpRdlTwoaKM0uH6n5HSQ9oqQJsH7Q3Zyri sB9z2UU2nmpxvqSftqHQAXQ8DnWp0q7R3XGkp2K4DSWBRoeQgR/gAn95iunAzZcGuHSWv gDmbFhQhfSEn3UDMnH28flSgaiYA4olB47yoaIoKVfd2JAILbcQjEh7YOxLFXaxFZvpeF BtpaBdWyAej2NXLILmxGrMGJ/SaclK8UUpD6Hr/R16AsIYncSbjd2HmLDc5CIh4QA7A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796279266; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=cVV5Rfboo/RvWn92E6fp+RE/ZyeXGi+9mPTylSQrz+4=; b=UlEE7HeTdORYjRu4g1OXDkyCC3pne76RSumpL7HRvLfSdLXW1KmiWWqtFGahll/tCPuq EWxgWCRK93xS8f5+Obxs1Lq+MdmMvK13T6Dy0YMMB9S11G0FT89QXYfleGSP+Vp6X7AcA MyatKs76rEvPOMDdEdWUJGqShOcYz2vnL4eAbZgsNxBxJNIgmXz2YDbSeiQDcTmc9+Xqn 15Zemlot1XyrWP371yfCNEmnaXUn8QzkquJ9G8jtdlpBm+nW8asmTGQ1iHQVAoJiQ+j9/ gCyjfZFRkHHUIZIX0i/Lce9Seu3c3gqEAY1tjw7dgGuWP9+bz4ATQXHd56cVAVEbVVQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=bUQvp+PN; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1C95606A339; Thu, 3 Dec 2026 06:27:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=bUQvp+PN X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.4 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796279265; b=wTgVp1u3+m+LIIAT9chsjBBc/jj31/oyS5+I9KFmm5R8z6ZiwjtUgRxDYOak5HYJAq4d E/GrdVBRbiOpGgvpgU2oYNuKeB3CmGfY2uarGHQSGJrlI/PDaWyPsHeb4eKtU9urL7c5W y+hR3S1Jse/cWwtLBDwYENH1Ie3Cd9MrWMxbt12/8iiDdHZKyXOn+t5HfZdCFe1yj3Trh MDqTX8YsWXkxpmJgc2FJwfYDfBC4NUuhspPGZ911R/c9dJGIrICjyCMgosMn/5zH4bZia f2GMSqcQSosxcH7ZO0uu7Emu+7jOcR1JynlGDReMzoOgLT1xdH16Nmh1nZhuRVIjAzg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796279265; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=cVV5Rfboo/RvWn92E6fp+RE/ZyeXGi+9mPTylSQrz+4=; b=bwVVu8cGZ6pmDH4PH4h+UetAvaxe2EsJfJWdl4EMXBsGE0fLLLrQoUX7am0p5wDt7cpZ pamI4TVGDWZ9J8v4UpMBEMXJSuks9HZYUn+hna4pmZx5GSn4ERA58boBY2SqdZ+lol5O/ xtquLvdrRsF54rkl07JfUYdD2VpyMeKTYvYkhSWvMVtZhWTSfmYfPjZfJJ0+zluh92LgJ 2Ry2sutqTA0C5fPhW4nAgKFfmKTT82QGsh+BqrsTDeYFOQUJ2beAoRF/aMt/1gbrsQlSo AF4k4qVmoUdvpj4uFrMpOT4mI6HpXpDq8COkJvSnV9xE42ww9uocs5hqlxov643aWfA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=bUQvp+PN; arc=none smtp.remote-ip=117.135.210.4 X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (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 D9A75606A32C; Thu, 3 Dec 2026 06:27:43 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D9A75606A32C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=cV V5Rfboo/RvWn92E6fp+RE/ZyeXGi+9mPTylSQrz+4=; b=bUQvp+PNtjr5JIf19r 42T2e+nzVppqlm4OC2WjNOe4LfSByTNAGenBnw9xVQFeeuGmA8ElRfHx0Vw5suvJ uEpICW8Kuy8HNSdQ0pHATkhwEstw4TTvcpUPIF6Yw8jKQnCIgeCCFvkZaJtNM2PI tz911xleki8KwLfUlPwSIv1E8= X-Received: from GHT-5854251031.localdomain (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wD3_3acCxFrkx5aMA--.29802S5; Thu, 03 Dec 2026 14:26:40 +0800 (CST) X-Cc: chandrashekar.devegowda@intel.com, haijun.liu@mediatek.com, ricardo.martinez@linux.intel.com, loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, zwq2226404116@163.com X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <cover.1796279181.git.zwq2226404116@163.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-CM-TRANSID: _____wD3_3acCxFrkx5aMA--.29802S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFy5JF1fuFy3XrW8AFy7KFg_yoW5WF1xpa 4xGa4Yyr98JF1Fka1xJrs3A3W5CryxWFWjqryjk3WqkFyxK345Ca129F92qF1qya48XFy3 Gr4qqr9F9as0kFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEeOpZUUUUU= X-CM-SenderInfo: h2ztjjaswuikqrrwqiywtou0bp/xtbC0QAKYWsRC6ChCgAA3A