Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2133338lqt; Mon, 22 Apr 2024 02:21:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2Brex0vL1ZwhYrgFnUNe+Rrm2DDIw8jlGj3sQrGiLdF1x5OJPo7LDWwwZFg6ovK1fHuSSx3g1E2a0dmCrwxTTjuA3NcsLnNDABg4l7g== X-Google-Smtp-Source: AGHT+IFOaLFRWCzwse/4H1MC5jSvNG9vLg1ELbV1ND0otrWYjwHRGwkzKhg1JahjBMSWm375IMpH X-Received: by 2002:a05:6e02:1ca5:b0:36a:3101:42b7 with SMTP id x5-20020a056e021ca500b0036a310142b7mr14058757ill.29.1713777671256; Mon, 22 Apr 2024 02:21:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713777671; cv=pass; d=google.com; s=arc-20160816; b=FmGxOHcthPzF6ZpJq7VnR8yVzi6UsL8NugkiVjWJahqFA3ODdzi4IvKfAkEFyEBbp7 /YI0b8+1gcDkqERjoOdanMC0hDJGZFzMS03c6H3NMFFxRc11WH0oxdgRJVp+Dy5Wi7d6 ntdu3UQkroDHvaNexjf07ilVbEOnJQIp5+ZBXxFRQpEypmSjopep3D5utfpBo+iKY3HR vpiZSCNMh2tTd7szmJhqO7GTlnh88q01LPZnoYhRuVnYS3JxzboS/oOiLOwT19fjwjmN NEtAofdnXlFULIUO6Yaxs4s6klo1r3qI/LK2zg3Rf90RRkIBgR5cHsnciiu70gh2suuK yGfg== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=HaA02Ym7i8pscYSZoFCxsEEG0CpIvjvukcY/hMRTISk=; fh=j5OUo1U0wDhwqkUy7VfzcMF4ZpUjFd8LthHueep3Nko=; b=bWve68vyVdgnAiulsiHqphJUMXCB9hKYi3/xZ5IGUO3/HBYEa00kaWEJPYOx14bMxL Za4Hp+iaKAZtWjxqOKPR1Ra7MdF8E0st4ziblx9RholuQQXsfSupQQlXIukgO34mV3zb kT/SybDkKXpwyrewP3bhzUxMzkfndYR3Amw63nP9rx4II7oxc27Gl+qZtqsqKKWwafT4 uCcZT9RFdGu9llsf4cXUvbaNgJNSsxrPntcbaUcE+wLTjeDKdwNqXvu0z7VXNSpFk4kd mh7BNaORAoyLsmk2HqjvPVRQU6nhZh8LK/iQvSLWCoF0t02Hu43AAiI0Jb+WfjPD+u+V HPgQ==; 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-153081-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z17-20020a656651000000b005f7fd2f966fsi5522271pgv.824.2024.04.22.02.21.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 02:21:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153081-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-153081-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153081-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 88B1C282BDB for ; Mon, 22 Apr 2024 09:21:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BE5B12FB18; Mon, 22 Apr 2024 09:20:18 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 2E0325490E; Mon, 22 Apr 2024 09:20:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713777618; cv=none; b=QEOCYZrvGOYuoa3BlKNPh2WPx4ramBd3vUCGkSU3U/Ounsw6I/k9MXYB818sFeFPuMQz0WKR/cHHwfKeRrZ4GwWoLaCDKUr5M6kGUjsr+YA/QSfKTmvRuXL9XeCL25v09HGjNgppzVLfY47CZkPLLxV+AZhiCmbT4DpcAgOUXs0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713777618; c=relaxed/simple; bh=mQQw5lMBFpwd1ib2VzuyorFSwtH397b/MvRxcKg2qkE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q1SmGkMnwjdaY3DVXKvxYSfTKHHtUhZ0XchSVW7arOJE2RQNJxBwl5aehAF3qNhoNcph8crVaVZB/JzZqW0ACRjWRnP7FswFEMDZNDOZk0W9PgZvmkhwJX5z6CzaoCO6NyUQjkYyEMi6OFyUD+db8OiAUmwUGKIqT7ZYcklTbX8= 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.35 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.162.112]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4VNKQ772jWz1RCjQ; Mon, 22 Apr 2024 17:17:03 +0800 (CST) Received: from dggpemd500003.china.huawei.com (unknown [7.185.36.29]) by mail.maildlp.com (Postfix) with ESMTPS id B842C1403D2; Mon, 22 Apr 2024 17:20:06 +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 17:20:06 +0800 From: gaoxingwang To: CC: , , , , , , , Subject: [PATCH v2] net: ipv6: fix wrong start position when receive hop-by-hop fragment Date: Mon, 22 Apr 2024 17:19:17 +0800 Message-ID: <20240422091917.3221601-1-gaoxingwang1@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240422011052.2932165-1-gaoxingwang1@huawei.com> References: <20240422011052.2932165-1-gaoxingwang1@huawei.com> 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: dggems701-chm.china.huawei.com (10.3.19.178) 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..2af98edef87e 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) + sizeof(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