Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1968227lqt; Sun, 21 Apr 2024 18:11:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWG6343WOGiybVSh0MOFRJTbJcYZK257By77UFKix0Xn9AM2LXIygYviJcxZyOMAua4t+kET0nowwtpSGNHlNFqoApHtBJwQwxn8sr/4g== X-Google-Smtp-Source: AGHT+IF7yIoxN6KPSp6s66H/U3aNHcbqr20nlk9O67FQ9Fw495dJgFf6lebWnxHgSWkMyzWhi1hm X-Received: by 2002:a05:620a:158d:b0:789:ec18:6996 with SMTP id d13-20020a05620a158d00b00789ec186996mr9201575qkk.26.1713748317032; Sun, 21 Apr 2024 18:11:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713748317; cv=pass; d=google.com; s=arc-20160816; b=U0KSeGkuvmVC0WIHhNiEBICNs1wt2/u/sMWpcbnZw0huPjrPeSUmfNVy5+jQQJ+ry9 TCuG6WrMGVQBbaYsvnZQfw3Sy2N4w9Hql+dusGLAi7Q+mf+tdSyxnMY454JXoybBc4fR /v/FzhMv9ZP2GH83xVckpBhG3QwKF5eU6REwMcltsV3DanOwIQkgik4pcw2slkwD1wVP j+lpjHlvPurDoDwN8VKoVb8VEGI9juJAKMtAMxJwgdfpr2MM2reTR4ver58ryb63pTGr 50GDJqgdvepHMPZ4NC1xK8MBTWvenL+6BrLF8p2qQWfAvgxJcplPUtryGwbrMvoiHxYu oVNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=oLdFKfYXdSzCm4z9kOmHeuan4RoHnuxi5DVYTbPg8Ko=; fh=oqm+fTMvN/krF84okT2wcman4/SNDbbijWCuWKyK65Y=; b=QXdDaBiSptJRMAK21UEHvS3HJOs1xhc4QJ0bg0Wg+G32Qq2fasMX+uI2pZj1DIu0H/ fMFoEkvNpgJo2xYr1CYJYARWt5Ng0wJNOmxzjAoO2mcgpAG7eBS6kQ6fwtdFND0pYAEA kfkxQTw7Q0XdaN29fGDI5cSRnzwiNGz52tBWy5PnSgIOxm517oGyOtIl/mqxfyWfyALW AtQW2fCyYne4C42ymHAXI1+KmZbhnWoonMoQBeEcboroUr8v2adtxJFsA6DQFkpsJA6t 4iWnTLcwXBOt+lCZGpWyX9tSOvcVIVJOrVXfux9hwODpYHT5tdNyMN4r4Rdgo6l8GR8R CL6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-152667-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152667-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id qr22-20020a05620a391600b0078d65d5a1f7si10419313qkn.305.2024.04.21.18.11.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 18:11:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152667-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; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-152667-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152667-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.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 AAF8E1C20AC7 for ; Mon, 22 Apr 2024 01:11:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C38363D71; Mon, 22 Apr 2024 01:11:48 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (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 9028810FD; Mon, 22 Apr 2024 01:11:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713748308; cv=none; b=OEado03h+wkPCCPqO3jkoAFmjODBcOKR7xGRd2PmGSr8jRaArusKMqjOIqBWFCcBg2BkvjcxKMm3f6iYiAFeHRfR+4/aeEAwqvoZeHtjr7kKzX93RRSy8HbPqxZ9pd3SoKz6AXHN5ZNxQTYFdCKbWtTNelccIYkt8hltoeqVOKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713748308; c=relaxed/simple; bh=pb8XSFdHSsldxcufWu9UmZV9xZHG679siZZgcIEnJFE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=A6hL/NCSNjkixYRgSzE71KqSPXovXHNKRnFA1Zzdu2ZDr7CDzsJmtl6v60Kl9F+XndIre5zqQazu2w8uL0aXBf/bBQM3YjICnZ0jv6PfRXFQtlkudoDW/anKMDDXljg423vPE7VAfX9pLmtF+UcqIWWTZtR+vdqITCCQSSB9+HM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VN6Zb0NkPz1R8nM; Mon, 22 Apr 2024 09:08:39 +0800 (CST) Received: from dggpemd500003.china.huawei.com (unknown [7.185.36.29]) by mail.maildlp.com (Postfix) with ESMTPS id 6C28A18007A; Mon, 22 Apr 2024 09:11:37 +0800 (CST) Received: from localhost.localdomain (10.175.101.6) by dggpemd500003.china.huawei.com (7.185.36.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Mon, 22 Apr 2024 09:11:36 +0800 From: gaoxingwang To: , CC: , , , , , Subject: [PATCH] net: ipv6: fix wrong start position when receive hop-by-hop fragment Date: Mon, 22 Apr 2024 09:10:52 +0800 Message-ID: <20240422011052.2932165-1-gaoxingwang1@huawei.com> X-Mailer: git-send-email 2.27.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemd500003.china.huawei.com (7.185.36.29) In IPv6, ipv6_rcv_core will parse the hop-by-hop type extension header and increase skb->transport_header by one extension header length. But if there are more other extension headers like fragment header at this time, the skb->transport_header points to the second extension header, not the transport layer header or the first extension header. This will result in the start and nexthdrp variable not pointing to the same position in ipv6frag_thdr_trunced, and ipv6_skip_exthdr returning incorrect offset and frag_off.Sometimes, the length of the last sharded packet is smaller than the calculated incorrect offset, resulting in packet loss. We can use network header to offset and calculate the correct position to solve this problem. Fixes: 9d9e937b1c8b (ipv6/netfilter: Discard first fragment not including all headers) Signed-off-by: Gao Xingwang --- net/ipv6/reassembly.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 5ebc47da1000..b3fc3a53cbbe 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -369,7 +369,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb) * the source of the fragment, with the Pointer field set to zero. */ nexthdr = hdr->nexthdr; - if (ipv6frag_thdr_truncated(skb, skb_transport_offset(skb), &nexthdr)) { + if (ipv6frag_thdr_truncated(skb, skb_network_offset(skb) + siezof(struct ipv6hdr), &nexthdr)) { __IP6_INC_STATS(net, __in6_dev_get_safely(skb->dev), IPSTATS_MIB_INHDRERRORS); icmpv6_param_prob(skb, ICMPV6_HDR_INCOMP, 0); -- 2.27.0