From patchwork Mon Apr 22 01:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gaoxingwang X-Patchwork-Id: 13637582 X-Patchwork-Delegate: kuba@kernel.org 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemd500003.china.huawei.com (7.185.36.29) X-Patchwork-Delegate: kuba@kernel.org 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);