Article View: linux.kernel.netdev
Article #5392[PATCH] net: wwan: iosm: validate msg_head before indexing msg_ring
From: liuc63
Date: Tue, 20 Oct 2026 09:42
Date: Tue, 20 Oct 2026 09:42
38 lines
9738 bytes
9738 bytes
From: Liu Chao <liuc63@xiaopeng.com>
ipc_protocol_free_msg_get() reads msg_head from shared memory and
uses it directly as an index into msg_ring[]. If the head is out
of range, the subsequent memset() writes beyond the message ring.
Validate head against IPC_MEM_MSG_ENTRIES before using it as an
index. The ring is a circular buffer, so a value outside the valid
range indicates a corrupted head pointer; report the error and fail
the allocation instead of writing out of bounds.
Fixes: 64516f633bfd ("net: iosm: protocol operations")
Cc: stable@vger.kernel.org
Reviewed-by: Fang Xieyan <fangxy@xiaopeng.com>
Signed-off-by: Liu Chao <liuc63@xiaopeng.com>
---
drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c b/drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c
index f2f86f41fd10..004920068c45 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c
@@ -14,6 +14,11 @@ ipc_protocol_free_msg_get(struct iosm_protocol *ipc_protocol, int *index)
u32 new_head = (head + 1) % IPC_MEM_MSG_ENTRIES;
union ipc_mem_msg_entry *msg;
+ if (head >= IPC_MEM_MSG_ENTRIES) {
+ dev_err(ipc_protocol->dev, "invalid message head %u", head);
+ return NULL;
+ }
+
if (new_head == le32_to_cpu(ipc_protocol->p_ap_shm->msg_tail)) {
dev_err(ipc_protocol->dev, "message ring is full");
return NULL;
--
2.50.1
Technical Details
Message-ID:
<20261020094254.4017726-1-liuc63@xiaopeng.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349160-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349160-linux-kernel-netdev=dewy.ru
From: liuc63@xiaopeng.com (liuc63)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] net: wwan: iosm: validate msg_head before indexing msg_ring
Date: Tue, 20 Oct 2026 17:42:49 +0800
Organization: Usenet Network
Message-ID: <20261020094254.4017726-1-liuc63@xiaopeng.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3824664"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:BR0PRem3D6w/hEI21j5HeaoVb5M= sha256:mBQoWOF4k5BWBoLdOT0V6Tv0mKuqGfqo5S5TYFsiW8Q=
sha1:4VSPvPxJ6+fm4H87ocERV/2k15s= sha256:1i9LMnn9JdMvDFwbqMnGan1iKdfJ8p+qcULw1Dyzv+s=
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 25255110C2F; Tue, 20 Oct 2026 12:52:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
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=xiaopeng.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 87SqWERFO0t0;
Tue, 20 Oct 2026 12:52:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-349160-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id ADF10110C6E; Tue, 20 Oct 2026 12:51:59 +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 23A9565829; Tue, 20 Oct 2026 09:44:08 +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=1792489388;
b=JpSB8IJ+KDoxn9xJQVVbg2Nry0msuJRxYopr9llvtBMk326oBh8u2y7DndZyHvhppOvF
/g3Rvwux3EfOqNKzXxxoF8c//xEQtkE7LORT1dF79zCLnTyqvktQOHaRVZjQJxZxtLYlZ
1rYCdcA+FSCY7NlffUJJED4wv72vdOY7eGsUcuqEOrFOTLM3mufOOzybi+uJVffyDJaL0
o4QDbyK8xVpJUz0S8JE4S0OyEKD9DP8ztn+Hrc/hp1Uz+7G/pnx+X4TqZITgmSE9u0BYn
vuQSHlFLGF/1/f+C5RgtTBHahcaMO6KqgO/fmSedegqVmLL6UnEVzmKOaxOIUZH4hYg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792489388;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
X-Alimail-AntiSpam:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=fZUhw0CWQnff/DPaxOVvAeyjDYBTZif+6gSrN7s7hlM=;
b=D/VXjEXctJvVJdcYwrpOvMz8b2uu2cHQ2RHAbp+YY95aqLla4D40Qb8gcBFiCWWCoK3X
dhzrwjuD8h0KHS9kxtpwUEJVxWl7V+LJwb86y/3Ezgspn2Xm9zW7cDOLfuja9Ezw9shC0
RidaFWuR/Ej7s1/+YUQ7CkgR3YQWgqioTCT+fo/riYuhg69dZiqow3R8xsn8G8eafGrnY
W5UmcpQgDsVGaPZiM0XEn8l5IhX3abixCYkGLR86/rsmB/V7AYr08No87T7jHJnoqF2ab
n7rLyLZTjk3Rmw10VlCdW6FAUIh+/owLrOLpx+ILbK/LEzYJPoU6vqQwWrifTiU9AOg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=DYvPlAHP;
dmarc=none header.from=xiaopeng.com;
spf=pass smtp.mailfrom=xiaopeng.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 2535A60A2620;
Tue, 20 Oct 2026 09:43:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key, unprotected) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=DYvPlAHP
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.73
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792489382;
b=JaRd/TQHa0/wLcWWeeZX7nt1nH5gvga3///dlnmI4w1JY6IoWTI0fIsD1gPkaNWGj7L2
+b/QdxQgcWzX5FG0Hu8JGJgyZinK+s1xIQjS47+XK79+NH+hJ8N9yatY6RJUMhex14euP
mubv09TGOE8cIDrxbtmuSbFGWBv/pNKZt/FAShlyIh0XJTMXwHpA1IPK5IsnT4xnP24Co
Jy7kRm2WD0wWRR9NNs5wlB+6/25q//LRZHlMRdS3/gCoV4vDXMysAR1vCdrh9Cf89Had9
uJ6Qb0r8TI2UeUPv8nQtPVRIehe4ltP/G+FO4P/GSy+JN91zF48krwd/wfGQYt5Dumg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792489382;
h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=fZUhw0CWQnff/DPaxOVvAeyjDYBTZif+6gSrN7s7hlM=;
b=02eP0Epj7fF4PLWZoEcxdnl9+hiKtP849yNixGThRkqajzR8KwKJgL47FVvpaq9B4Tga
V94ZZKyPy/7wpxZNgjOnRDjgjftnvc2AVdDLBnGnFf4bd0y3xjcRtsj2AbTnMHonGwUDN
IB73edVtFqAtz5jx0nvqHvibNdma36tdncYtLGsUJoTmtgkZtNcVI22LKh1t2bbZoCmdv
VKzUryuwituk+fUxmxE6akoaLBZbr5opXjPRtb2iRUrKuWjkDRUF+JnJYIJ/rahNBprWu
qnH2D214fJDp4+2vnrYYPJT6SpC+UDE+NtqKvcv655uFGQedFHC0CSfd/s72gYoXi0A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=none header.from=xiaopeng.com;
spf=pass smtp.mailfrom=xiaopeng.com;
dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=DYvPlAHP;
arc=none smtp.remote-ip=115.124.28.73
X-Received: from out28-73.mail.aliyun.com (out28-73.mail.aliyun.com [115.124.28.73])
(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 97741606A321;
Tue, 20 Oct 2026 09:42:59 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 97741606A321
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaopeng.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=xiaopeng.com; s=default;
t=1792489376; h=From:To:Subject:Date:Message-ID:MIME-Version;
bh=fZUhw0CWQnff/DPaxOVvAeyjDYBTZif+6gSrN7s7hlM=;
b=DYvPlAHP4TsYGps2k/rIJ9FD+Xh3dPyn/3+1bxvOTnYdFlkwnIRuy5pmP7bEalmNVPKAuLxqv6wnaYbsZ4JkzMTwLIQ0NH4bXtZd2uObRydLPpyNjSKrmmBZ+be6eixlMrvPCTSsqS+X+dWI8SJiKBwKwjEbylJNfD5aYCy9ud4=
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.0835114|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.00524836-0.0014099-0.993342;FP=10105117881427270734|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam011083099174;MF=liuc63@xiaopeng.com;NM=1;PH=DS;RN=9;RT=9;SR=0;TI=SMTPD_---.jlb8AAG_1792489374;
X-Received: from localhost(mailfrom:liuc63@xiaopeng.com fp:SMTPD_---.jlb8AAG_1792489374 cluster:ay29)
by smtp.aliyun-inc.com;
Tue, 20 Oct 2026 17:42:55 +0800
X-Cc: Loic Poulain <loic.poulain@oss.qualcomm.com>,
Sergey Ryazanov <ryazanov.s.a@gmail.com>,
Johannes Berg <johannes@sipsolutions.net>,
Fang Xieyan <fangxy@xiaopeng.com>,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Liu Chao <liuc63@xiaopeng.com>,
stable@vger.kernel.org
X-Mailer: git-send-email 2.50.1
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