Received: by 10.213.65.68 with SMTP id h4csp2160688imn; Sun, 8 Apr 2018 21:17:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Yuww80THsiA1j4oYxh4zu7csaUL+mTdFzYAn2YHWsElWzux7JjoxVGg8O3uoQG9Lvr5HE X-Received: by 10.99.102.196 with SMTP id a187mr8644055pgc.349.1523247457402; Sun, 08 Apr 2018 21:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523247457; cv=none; d=google.com; s=arc-20160816; b=zx2nk++dxm1/5KywQiNlvAgA/xANKD2JYFk8mN8HvwXim3M64EHdLuzpQbZui/PIcF wlf3wMB8LyAwXsWq4rtz0g4XNfzYgp0rrX+I7PuwZezhEgMUY5qP7ckF8dFChKc4uOB2 /zO4Ugvcoi9ZMH7LcIVgfUHJIulNUanHato1GmmD8tlDsMGiwWRX6tEX+p1KQqt4B2RF 4JPgNT6+VhiqxtUWkRQUApN8Jmve0PiNDrlIHp/rmIfp1Rgad26gXk7I8fi/aeMN57ts 4mMtyZPnJaF0Ec0A3qW6zvfYD7LlwcntaNlrBRPvwkpshW4ppRaIG2cab3O7OECAn47O D0EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=UXgtw3eHGdleAb6gOz6h4O88NQ7JUNffH6CySdEa/js=; b=g3AhjT+/hFGa74bGWvezPPZwG6+UJaiNlqN0Zm92APdJ73R8Dz6sws2QYUSKEUU4/G L6NjUp0h/CLrOv/VA/WaXllWcdt/WZrBUlObvj1/vQACSziz1yMmtOfRjTgI/Hog8fQv ME74AZhyo3saVAEVmylPFhlECrhdehbPFuHzY2Le+mrqrR/TRq5PkdQ6q6RHDtTb01pc TONXu0nmRs8RCWt0aBb5EPbKU1MlhkclMby9bw6u3bZ6Xw2pYwNpSZkXgU2/buRBMXjP Q7z6sdV+XiczRHwYXsyZzUYoO3Euz5XZ4o+OIEVWuKOJP0caRO0u+XlQ/4A6ifr/Mt0X 5RJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=gbY4u5PW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62si11897170pfw.173.2018.04.08.21.17.00; Sun, 08 Apr 2018 21:17:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=gbY4u5PW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754251AbeDIELo (ORCPT + 99 others); Mon, 9 Apr 2018 00:11:44 -0400 Received: from mail-co1nam03on0128.outbound.protection.outlook.com ([104.47.40.128]:49080 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752943AbeDIARA (ORCPT ); Sun, 8 Apr 2018 20:17:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=UXgtw3eHGdleAb6gOz6h4O88NQ7JUNffH6CySdEa/js=; b=gbY4u5PW+HGCFCa6oDG6lfUtc0FV38lZIMiC7EJm1q/Du/hjn3564xh6P3Cp8Z4O/ue5kxqZLF17zgS0MfATxGcG7+gx9gS7M40C356BQeHEkE5lCoZI3sHa2bchkk48FrhED+Qe6eLO3WnkgPp+6BIWIJO3MeHB/uvnOPjKp8w= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1127.namprd21.prod.outlook.com (52.132.132.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:16:54 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:16:54 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Subash Abhinov Kasiviswanathan , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 013/189] netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460 Thread-Topic: [PATCH AUTOSEL for 4.15 013/189] netfilter: ipv6: nf_defrag: Pass on packets to stack per RFC2460 Thread-Index: AQHTz5gQ/CSsyyy2QkaeZjLbUbysqQ== Date: Mon, 9 Apr 2018 00:16:54 +0000 Message-ID: <20180409001637.162453-13-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1127;7:XCMG/Tb+8uJIlW2tPcI5immKbIQyVfTpUhks5cUsc8ZSsEKu8rC2fOoBjce80iujJ0ZXEyQbjDIPXDjg27xM9EowpZ8vN2oPYioQuIARcmvW4WCbw3TgNM/4Ph2RGZxD21s0bCnFcmCzgbw5SGm7tcW4sjPvLJQNfckvJQLqaxTCvtz2ZjVc7JOToJ6x7sDQZmjjeKvuRUbo0whwFTbw4H07jkuH4XyGEbAuvv+vVMjjzbbhUJ2YdZc+TDHH3aJZ;20:XsHNk0VhSzimgo2Lp6icasTKohyWUv8M7KZ5hpIGARAPc9sDBEA92qiso9owozfiUzMM7GSEiqJrpGiqMOzq3gWILElPbX0BGBh3aBuqYhnIkRuHDXLpSjkFzQHLvKPsyMQqWnYsro+3XxeF1oSYSvx0gMZGpcqrqQMcxtnYil0= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 027761fd-b392-4b24-f125-08d59daf3319 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1127; x-ms-traffictypediagnostic: DM5PR2101MB1127: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1127;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1127; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39380400002)(39860400002)(376002)(346002)(366004)(189003)(199004)(105586002)(186003)(66066001)(6486002)(54906003)(7736002)(26005)(86362001)(316002)(305945005)(110136005)(478600001)(3280700002)(86612001)(10290500003)(25786009)(5250100002)(2616005)(99286004)(22452003)(5660300001)(966005)(3660700001)(2900100001)(81166006)(3846002)(2906002)(106356001)(6506007)(59450400001)(107886003)(486006)(8676002)(81156014)(14454004)(10090500001)(68736007)(4326008)(6116002)(1076002)(72206003)(102836004)(6306002)(97736004)(11346002)(8936002)(476003)(2501003)(6436002)(6512007)(446003)(76176011)(36756003)(53936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1127;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: S4XJ1HKflInpBWSvWWdtcjKDPtp7MMTjp7HrxtFvly2uA7uuHmQ4hqG10bACmuekDJMeB8fAC2DcIs8tFSK+I5hD2CEM+BQyu9nl6pERpySRVs13Hq7Mmv9EhjV0jExIznPBYAe4szJVYyKiwDW9EbXmWT1wSpUrL2AGhDmToF+YRgpVN9WMXGOKKqfH7z2Ge3sHW6D/FdM+intrfckyy11EuDv0HhU/ce5ZfjARLFO6EUUBy+hNTruNMibmtEc8cTDEYazEm7SsWH3i+V3X6txLU+sJAmkPuJp3TfgruMS+t0I5umV5nWCalwi9x3KHedo0Mj9VjVSRUkXchxVBY9vHQ6R8iRGbQmgcmfpEYScBlvfHMKv5jq/7Ujs+ga1F6CI+Ijk9UVoSr9TleNCN5uyoTbEph07HtBLLr0UAfpU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 027761fd-b392-4b24-f125-08d59daf3319 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:16:54.3406 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1127 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Subash Abhinov Kasiviswanathan [ Upstream commit 83f1999caeb14e15df205e80d210699951733287 ] ipv6_defrag pulls network headers before fragment header. In case of an error, the netfilter layer is currently dropping these packets. This results in failure of some IPv6 standards tests which passed on older kernels due to the netfilter framework using cloning. The test case run here is a check for ICMPv6 error message replies when some invalid IPv6 fragments are sent. This specific test case is listed in https://www.ipv6ready.org/docs/Core_Conformance_Latest.pdf in the Extension Header Processing Order section. A packet with unrecognized option Type 11 is sent and the test expects an ICMP error in line with RFC2460 section 4.2 - 11 - discard the packet and, only if the packet's Destination Address was not a multicast address, send an ICMP Parameter Problem, Code 2, message to the packet's Source Address, pointing to the unrecognized Option Type. Since netfilter layer now drops all invalid IPv6 frag packets, we no longer see the ICMP error message and fail the test case. To fix this, save the transport header. If defrag is unable to process the packet due to RFC2460, restore the transport header and allow packet to be processed by stack. There is no change for other packet processing paths. Tested by confirming that stack sends an ICMP error when it receives these packets. Also tested that fragmented ICMP pings succeed. v1->v2: Instead of cloning always, save the transport_header and restore it in case of this specific error. Update the title and commit message accordingly. Signed-off-by: Subash Abhinov Kasiviswanathan Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/ipv6/netfilter/nf_conntrack_reasm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/n= f_conntrack_reasm.c index 977d8900cfd1..ce53dcfda88a 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -231,7 +231,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, str= uct sk_buff *skb, =20 if ((unsigned int)end > IPV6_MAXPLEN) { pr_debug("offset is too large.\n"); - return -1; + return -EINVAL; } =20 ecn =3D ip6_frag_ecn(ipv6_hdr(skb)); @@ -264,7 +264,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, str= uct sk_buff *skb, * this case. -DaveM */ pr_debug("end of fragment not rounded to 8 bytes.\n"); - return -1; + return -EPROTO; } if (end > fq->q.len) { /* Some bits beyond end -> corruption. */ @@ -358,7 +358,7 @@ found: discard_fq: inet_frag_kill(&fq->q, &nf_frags); err: - return -1; + return -EINVAL; } =20 /* @@ -567,6 +567,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *= prevhoff, int *fhoff) =20 int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) { + u16 savethdr =3D skb->transport_header; struct net_device *dev =3D skb->dev; int fhoff, nhoff, ret; struct frag_hdr *fhdr; @@ -600,8 +601,12 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff= *skb, u32 user) =20 spin_lock_bh(&fq->q.lock); =20 - if (nf_ct_frag6_queue(fq, skb, fhdr, nhoff) < 0) { - ret =3D -EINVAL; + ret =3D nf_ct_frag6_queue(fq, skb, fhdr, nhoff); + if (ret < 0) { + if (ret =3D=3D -EPROTO) { + skb->transport_header =3D savethdr; + ret =3D 0; + } goto out_unlock; } =20 --=20 2.15.1