From nobody Mon Feb 9 05:52:46 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CE4A1D516C for ; Thu, 22 Jan 2026 17:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769101498; cv=none; b=tN089AGlibXCRcBomSjHiFoD1n9v2L7xIsE2qxM9G5Fi5vwjsKvcnmm78280nnVm5C4iDD3D4IeCbnU/U7FDCg+Jt3Q4Voud3aGe756DMKKNe75JBfXeDPKhp5Zrt6rv6TinqkuPJdEfqng/CC9GU6UefDfIS40QiceG0idTq+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769101498; c=relaxed/simple; bh=ZSIt5K2QVBjFlexKCHulTBbdjtVBQtnj9xX2vLzZ3fs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=R7pnxa4Er2eGkKsws54LAZ5GmWxE9xjRkwzydFiUCIxyZiSjHOmOWOwlFY6CAF0++XNiB6R5Rik3rKjVOroy2a5pS9HX31ELR7zbbaZlfi4h3OTyJhE0ONv7Y7TJ6zjDVbv0GVsVGUclXCbGaBmaq+/36MbBKAOU8opR/l1vW8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TFHr91kU; arc=none smtp.client-ip=209.85.210.169 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.b="TFHr91kU" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-81f47610542so715904b3a.0 for ; Thu, 22 Jan 2026 09:04:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769101487; x=1769706287; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kGcbnpURpKElDduIyavGnVliQJdwBmRCfzXVX+YJb8Y=; b=TFHr91kUncWz5x9fIx21Scf9pKpKNumMauiGfghUHbGd2q3thTdxMTiR8WZdPHk6xf E67ITbCghg/QRIoUpmSHQy9cksMlNqWmff5vzj7gcjIZftoGVk6JqLaPHpb+D0cG7hEa Z6aZDALB4J/26YPSobay9ivQuGoNfyDxHk2gpt1/SeEnX9zk8oRIW9/Q8vJhhOlHDW3/ wRjUFGPZtd+GCvLM/yugvWjcUWI1xwJDJRL80apbEBCmqhQ2eevd7ps7PlwgSsWLJDyy yym+FT6TFINRaTtFUwF82siiZTFsEiGFEuuMl24ATtMXC7qguwHKbm4O9n5x+Ia5PxVQ DACw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769101487; x=1769706287; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kGcbnpURpKElDduIyavGnVliQJdwBmRCfzXVX+YJb8Y=; b=ithVMXrGEt51RhOqFq6B/ozIHvItfWWnG8L/UrRqkB+LJg/giaAwPOAi2E5mSQx22B ex4rMg3Rud2VjZx6rkyhYYs3uV2dRn9FG8nE5wMSvY7LkfECByRP2tKo1AnUmDONTeTQ qAYExeRw2PH2UdHfX6JM6cVQ751AkwaBbTg8JZcrV24W3RM/4Py+FzuzX0Kb4tV7gWav 1lr8Nk2Z58//6avh5isE1i8K/Tgnp4re/6kyH56+OuwXJg6vX1stumq23EaTfMPRikF4 C04b1gW+x1SUHXzwVf1EWJEJ6KI8HLklrL+CJ23NxnTKBgC7tDv6hCBjogQYpSUks5gr tx8w== X-Forwarded-Encrypted: i=1; AJvYcCX3kSrliXlzeq/fTWkIgfiFpJmdbl00nIYVepeGApdxPvN4mMUUzPwKCa+k5EQ72NOI8bjG41Ctib6Y4AU=@vger.kernel.org X-Gm-Message-State: AOJu0YwOBD8LpMh1d5fmhe7fzD7HI7IYjvkL9hvtMybNIWvWmPFnQNof F9d+KhOXHGf5zHb9g4RbnAc7dIG/1UGPkO5SqsoYfMmVzTon3ur31gA= X-Gm-Gg: AZuq6aJhOS9u6s0q3d7Y/acL+y64VlvGWU7hATOG5uGPeRfdgASjbG9OGsvJ2LU8rZH JLv9L0v0HWyxdCG4r7HlYEQh5rv1Z2zr047Ej6CSHtFe+i9CpqQ+OLs85r1BMerLbDGARcjzCdV UkI+CGuetSWtgL8KaesKpLY6IvSLICwtKzsyXis/uLQ7uJR13yKvG0gkbUiLMnod7h3KcK5DfJG RT7Uf9EY+LphGtytCV2VtIVHm+Hq7F5Dxm6KPP3ik3Zgw19wgmSGwK1QkuC8yRtGjkir6Cv2wBi zrOw0Rrn+ydKcn21wC6L/tTRQwlf9XkkbO8YR7qWpPGE1VYjQ2ZJj+SYbpC/sJ9tHKQyyHV/vrS h3TFbYjQJDmo5jg5CnMoNkK7CDBtzC2PpaJi1iFiwEb7IPZ3fFVPn1/JMaLxNeLa21iD5hDrtlF c60CtYYPMa51B09pA= X-Received: by 2002:a05:6a00:a88c:b0:81f:9f14:ecc8 with SMTP id d2e1a72fcca58-82317d23a23mr17551b3a.27.1769101487148; Thu, 22 Jan 2026 09:04:47 -0800 (PST) Received: from DESKTOP-BKIPFGN ([38.76.140.13]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-81fa1277966sm18546162b3a.31.2026.01.22.09.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 09:04:46 -0800 (PST) From: Kery Qi To: chandrashekar.devegowda@intel.com, loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com, ricardo.martinez@linux.intel.com, johannes@sipsolutions.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kery Qi Subject: [PATCH] net: wwan: t7xx: fix potential skb->frags overflow in RX path v2 Date: Fri, 23 Jan 2026 01:04:01 +0800 Message-ID: <20260122170401.1986-2-qikeyu2017@gmail.com> X-Mailer: git-send-email 2.50.1.windows.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When receiving data in the DPMAIF RX path, the t7xx_dpmaif_set_frag_to_skb() function adds page fragments to an skb without checking if the number of fragments has exceeded MAX_SKB_FRAGS. This could lead to a buffer overflow in skb_shinfo(skb)->frags[] array, corrupting adjacent memory and potentially causing kernel crashes or other undefined behavior. This issue was identified through static code analysis by comparing with a similar vulnerability fixed in the mt76 driver commit b102f0c522cf ("mt76: fix array overflow on receiving too many fragments for a packet"). The vulnerability could be triggered if the modem firmware sends packets with excessive fragments. While under normal protocol conditions (MTU 3080 bytes, BAT buffer 3584 bytes), a single packet should not require additional fragments, the kernel should not blindly trust firmware behavior. Malicious, buggy, or compromised firmware could potentially craft packets with more fragments than the kernel expects. Fix this by adding a bounds check before calling skb_add_rx_frag() to ensure nr_frags does not exceed MAX_SKB_FRAGS. The check must be performed before unmapping to avoid a page leak and double DMA unmap during device teardown. Fixes: d642b012df70a ("net: wwan: t7xx: Add data path interface") Signed-off-by: Kery Qi --- drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/= t7xx/t7xx_hif_dpmaif_rx.c index b76bea6ab2d7..5af90ca6e063 100644 --- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c +++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c @@ -395,6 +395,7 @@ static int t7xx_dpmaif_set_frag_to_skb(const struct dpm= aif_rx_queue *rxq, struct sk_buff *skb) { unsigned long long data_bus_addr, data_base_addr; + struct skb_shared_info *shinfo =3D skb_shinfo(skb); struct device *dev =3D rxq->dpmaif_ctrl->dev; struct dpmaif_bat_page *page_info; unsigned int data_len; @@ -402,18 +403,22 @@ static int t7xx_dpmaif_set_frag_to_skb(const struct d= pmaif_rx_queue *rxq, =20 page_info =3D rxq->bat_frag->bat_skb; page_info +=3D t7xx_normal_pit_bid(pkt_info); - dma_unmap_page(dev, page_info->data_bus_addr, page_info->data_len, DMA_FR= OM_DEVICE); =20 if (!page_info->page) return -EINVAL; =20 + if (shinfo->nr_frags >=3D MAX_SKB_FRAGS) + return -EINVAL; + + dma_unmap_page(dev, page_info->data_bus_addr, page_info->data_len, DMA_FR= OM_DEVICE); + data_bus_addr =3D le32_to_cpu(pkt_info->pd.data_addr_h); data_bus_addr =3D (data_bus_addr << 32) + le32_to_cpu(pkt_info->pd.data_a= ddr_l); data_base_addr =3D page_info->data_bus_addr; data_offset =3D data_bus_addr - data_base_addr; data_offset +=3D page_info->offset; data_len =3D FIELD_GET(PD_PIT_DATA_LEN, le32_to_cpu(pkt_info->header)); - skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page_info->page, + skb_add_rx_frag(skb, shinfo->nr_frags, page_info->page, data_offset, data_len, page_info->data_len); =20 page_info->page =3D NULL; --=20 2.34.1