Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp861897lqa; Sun, 28 Apr 2024 07:30:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2cBcDy3KKec2p3xFfqs/II2dVGU8v2XNjz4SAoQPeHcxiw3Ya2LcB77CuuOzrSyHj8cfDTdmNcsOQWbaQ9sTiQme7Eos99NocjhG9KQ== X-Google-Smtp-Source: AGHT+IE4gz+oxTeZwAbb3tNAmpLynvZ1Bg1tPZrr3sO7QYg7nm1lBzOgCwFxFm9SHECWvvXPYRCq X-Received: by 2002:a05:6214:da8:b0:6a0:cef7:c54d with SMTP id h8-20020a0562140da800b006a0cef7c54dmr524318qvh.56.1714314610059; Sun, 28 Apr 2024 07:30:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714314610; cv=pass; d=google.com; s=arc-20160816; b=Ve0Qq/0r2zyXGFldp/J21zWzsP4e+y/EMh8/dHPRAtxFMSQrdZ7VS82k1egwPsCpGz 5+bUAxNkV421EcI8+xF1GnOOkWL7XOfE6dPR0UgfNViQTXRH+GG+0ml1zMHXjGrjrwLQ Y3OJfEF2W7h+GDkDg8lPaXLOnnx0fFWfFjfoBjcu1AnFMwFddIZvp7nfqr8gyU4GYHN3 /NSLFLWAOTJab4pifMGb5vF1KqljtE+gjYy7nvcni+XesldfGPpeBrtcfvE73hPhimjL wxJmklsYzzuqTBePDe+2ELg38eGofSbIZETuuVw3aIssgD7j9WhUyB4Cu7MYo+Oi3uO1 ZLBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=XXRJ81xwIuTFUgX0JZRvcELJ+oqPi5PwBncGpAHuDC0=; fh=g2Z6nFUi9O7M4WruPoeiD/fr6oRKSTFifkQcLJdXMp0=; b=XVgsZoBJ0TfYqAHq1Dj7qROYRZSEEBXEPZrxXfu6fJwphj9QyZeSha8mCJUUlVz9C/ zoarU1K8D4fi/U39751cGMG2I4YUk7Oy1+tXjGMnsx9sMiHNnkqpYtN+NjGUFHgzHAp/ dIOvrhiSArBWyZwVD+Fu2F3WCGXsFp6KM0Kb6G16NXcou/d38symzn7GifSX2mD8nyOW mHSIe7KhUdOp0mqjyVvICISTUpvth2m6iRUE9mIeV7Ozz72E3FSa7ul8JP5QSxIJRNht dwwPgvvTFMdvTZw6+ynng+mElhxGE4zFtF1ruXNyLyM90iO4qEoJIGk2SHLPkR0Lty+r qB1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=J0R83qi6; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-161453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jo24-20020a056214501800b006a0c765cc1dsi1906627qvb.376.2024.04.28.07.30.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 07:30:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=J0R83qi6; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-161453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A52F61C20F32 for ; Sun, 28 Apr 2024 14:30:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D1141F602; Sun, 28 Apr 2024 14:30:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="J0R83qi6" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 A7C651C32; Sun, 28 Apr 2024 14:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714314602; cv=none; b=qTWO0uUExI6SxwtW+WsmCKx6gqNZMBHS3j3mRW3Vzq6OqgADiwu3SR2eImemQ3I4ZPeMGugvvbUogHdb/NtlUpJaMzSdJ1WGGq8WMNuOeKvUHilHpeVAzrg+MM/Crpbvf0YmK00RWA6zRiuFI7vn8GUK+vrAYKh1hWqLWMDCBXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714314602; c=relaxed/simple; bh=NqZBkRYnYes+Rg+x6msRDkpz+oUasi4o3teBF2EsQy4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=i8+cP8XRAj0KYkgqzJtP0NkSBpvmXfp4hxAZnFo9d6T+ujIwXn6rJcdStHnkpZ+DiTLTCsTVZGHRMBnD5OfCBr7ww3aExVlouR8OqXWQBosCJTG+iICMMwPjLCw9Kh7TPulbpKu0C/3ZFejxiI8KNJG3wi4M3Akd7Vy9k3K6P/c= 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=J0R83qi6; arc=none smtp.client-ip=60.244.123.138 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 X-UUID: c8911534056b11efb92737409a0e9459-20240428 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=XXRJ81xwIuTFUgX0JZRvcELJ+oqPi5PwBncGpAHuDC0=; b=J0R83qi65ZejTNxWY547thJUp8/BMHx3kmKTlKW0/5c6NJg2E4nfXpqcWkXipuwMLQsLxiFkdO2CNnIpT1T932lITIdH8RfbRi7fIHg/qL+5mrcP1FPQY/SphoNSlNbm7vre/7liEDavXq7/P2OhNhoiL4BCH6349DQa34WlRt8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:06c68dc0-168e-4e65-bcd9-97a7df2127f0,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:82c5f88,CLOUDID:720ab166-72bc-4ae0-ab39-a531fe78e0a5,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES :1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_ULN,TF_CID_SPAM_SNR X-UUID: c8911534056b11efb92737409a0e9459-20240428 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2096129537; Sun, 28 Apr 2024 22:29:55 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by MTKMBS09N1.mediatek.inc (172.21.101.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Sun, 28 Apr 2024 22:29:54 +0800 Received: from mbjsdccf07.gcn.mediatek.inc (10.15.20.246) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sun, 28 Apr 2024 22:29:53 +0800 From: To: , , , , , CC: , , , Lena Wang Subject: [PATCH net] net: drop pulled SKB_GSO_FRAGLIST skb Date: Sun, 28 Apr 2024 22:30:10 +0800 Message-ID: <20240428143010.18719-1-shiming.cheng@mediatek.com> X-Mailer: git-send-email 2.18.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N From: Shiming Cheng A SKB_GSO_FRAGLIST skb without GSO_BY_FRAGS is expected to have all segments except the last to be gso_size long. If this does not hold, the skb has been modified and the fraglist gso integrity is lost. Drop the packet, as it cannot be segmented correctly by skb_segment_list. The skb could be salvaged. By linearizing, dropping the SKB_GSO_FRAGLIST bit and entering the normal skb_segment path rather than the skb_segment_list path. That choice is currently made in the protocol caller, __udp_gso_segment. It's not trivial to add such a backup path here. So let's add this backstop against kernel crashes. Fixes: 3a1296a38d0c ("net: Support GRO/GSO fraglist chaining.") Signed-off-by: Shiming Cheng Signed-off-by: Lena Wang --- net/core/skbuff.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b99127712e67..4777f5fea6c3 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4491,6 +4491,7 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb, { struct sk_buff *list_skb = skb_shinfo(skb)->frag_list; unsigned int tnl_hlen = skb_tnl_header_len(skb); + unsigned int mss = skb_shinfo(skb)->gso_size; unsigned int delta_truesize = 0; unsigned int delta_len = 0; struct sk_buff *tail = NULL; @@ -4504,6 +4505,9 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb, if (err) goto err_linearize; + if (mss != GSO_BY_FRAGS && mss != skb_headlen(skb)) + return ERR_PTR(-EFAULT); + skb_shinfo(skb)->frag_list = NULL; while (list_skb) { -- 2.18.0