From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10C5D433E86; Mon, 6 Jul 2026 03:46:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783309588; cv=none; b=CXoPG/rySa5IbekAfH9j8H8h7iWGv5Ps8jfIkGrd4/tl+0HD/9c+is/nwPNAlBFhwTAQqWgEtexneo3Wg/RZziFSdzYc0f4B/sytC9o1YKRQxUumynLVeUYSAAZX6PviYX6nkwFlbTZ8cIzaLPh1V7hfGqd2bia+IjE4Mv611PI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783309588; c=relaxed/simple; bh=aYGqhIlWzDNFJSeTbbRG5Ro1ftlYUG+s1yC7z4WW1nA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=vBrMgqfURCoX8KHa6KBt/UhFNfC30n4AVldapU1LCjqBbHJIWQigSoDvelhAdXdKJbmvYxl/eWOXNHJbFuEnsbbdUI9R2NfatX/iFrgCn+yYwAf1LX15oyadoaZOw70gnN3a4J/hJ6yq3JpnNCa0RWoCSCbROt1Kh6nbHiCI/6M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=cXK7numw; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="cXK7numw" X-UUID: 3efd691078ed11f18dc8c9802ae25ab1-20260706 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=LqsXzutP87HE+Xx+LEl6Pc9gDk2yfOymiSOqdmfgY8U=; b=cXK7numwkxRxjBUoECHpVJRwnE/kIlUG2fMCYuz0vkYlZyxUobe8OQ47btxsmL2ud3YdWiSMtSfEgnMHVwY59wl/LkYXpoo+URLuOtf3nPTJo6Zq4aQDvZvJqzToCrqGiTPuP4OYXX25eX9f5hlP+dGwV37BjcYL6witC1qSQwM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.17,REQID:0f3d17b3-73b6-4e52-8efc-9d86c22f525e,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:d497b38,CLOUDID:633ae786-650a-40ac-85ae-e6913513c89f,B ulkID:nil,BulkQuantity:0,SF:102|836|865|888|898,TC:-5,Content:0|15|50|99,E DM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:-1,COL:0,OSI:0,OSA:0, AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 3efd691078ed11f18dc8c9802ae25ab1-20260706 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1550544001; Mon, 06 Jul 2026 11:46:18 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Mon, 6 Jul 2026 11:46:17 +0800 Received: from mbjsdccf07.gcn.mediatek.inc (10.15.20.246) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Mon, 6 Jul 2026 11:46:15 +0800 From: Shiming Cheng To: , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH v5] net: gro: fix double aggregation of flush-marked skbs Date: Mon, 6 Jul 2026 11:46:04 +0800 Message-ID: <20260706034611.360-1-shiming.cheng@mediatek.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N The skb_gro_receive_list() function is missing a critical safety check that exists in the skb_gro_receive() implementation. Specifically, it does not validate NAPI_GRO_CB(skb)->flush before allowing packet aggregation This allows already-GRO'd packets with existing frag_list to be re-aggregated into a new GRO session, corrupting the frag_list chain structure. When skb_segment() attempts to unpack these malformed packets, it encounters invalid state and triggers a kernel panic. Scenario (Tethering/Device forwarding): 1. Driver: Generated aggregated packet P1 via LRO with frag_list 2. Dev A: Receives aggregated fraglist packet and flush flag set 3. Dev A: Re-enters GRO, skb_gro_receive_list() is called 4. Missing flush check allows re-aggregation despite flush flag 5. Frag_list chain becomes corrupted (loops or dangling refs) 6. Dev B: TX path calls skb_segment(), crashes on corrupted frag_list Root cause in skb_segment(): The check at line ~4891: if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) && (skb_headlen(list_skb) == len || sg)) { When frag_list is corrupted by double aggregation, when list_skb is a NULL pointer from skb->next, skb_headlen(list_skb) dereference NULL/corrupted pointers occurs. Call Trace: skb_headlen(NULL skb) skb_segment tcp_gso_segment tcp4_gso_segment inet_gso_segment skb_mac_gso_segment __skb_gso_segment skb_gso_segment validate_xmit_skb validate_xmit_skb_list sch_direct_xmit qdisc_restart __qdisc_run qdisc_run net_tx_action Fix: Add NAPI_GRO_CB(skb)->flush validation to the early-return check in skb_gro_receive_list(), matching the defensive programming pattern of skb_gro_receive(). Fixes: 3a1296a38d0c ("net: Support GRO/GSO fraglist chaining.") Cc: stable@vger.kernel.org Signed-off-by: Shiming Cheng --- net/core/gro.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/core/gro.c b/net/core/gro.c index 35f2f708f010..b1573d98f3a5 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -229,7 +229,14 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb) { - if (unlikely(p->len + skb->len >= 65536)) + /* + * Packets marked with NAPI_GRO_CB(skb)->flush have already gone + * through GRO/LRO processing and must not be aggregated again. + * Re-entering frag_list GRO may corrupt the frag_list chain and + * later crash during GSO segmentaiont. + */ + if (unlikely(p->len + skb->len >= 65536 || + NAPI_GRO_CB(skb)->flush)) return -E2BIG; if (!pskb_may_pull(skb, skb_gro_offset(skb))) { -- 2.45.2