Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7151033ybi; Mon, 8 Jul 2019 15:40:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqypJZn10pgTrGL14YqpDf+rTmyShJitLx1PRZtCAr1+iQVXjq8Zfhc1dRzuBoj6efxZdusq X-Received: by 2002:a17:90a:d996:: with SMTP id d22mr28623032pjv.86.1562625626129; Mon, 08 Jul 2019 15:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625626; cv=none; d=google.com; s=arc-20160816; b=SShagpb5wnwNi7Gl3vLRQeZEsE5zOF3FfCfRzMVpeuKEGAW+tBivPUt/l0bh3DrV6I ymxc9zLAGMYz4SY5q1vkMTnkNfHGgN6efHeISoG7z8Xvboz0OsPBpQRmK14PA7O3YhEf yoop1Sg1/p9VN1F8cH4njeq24nHgiXgq/3oTKClHHTdSIGlJJNnkFDwXE+IETMiVJNcy /xewFxrP+Ny+ndQlI2mx7eAfbbzK+t1VZ7wi3nHkMYkyoib9mVBQVObCz0WLfNmI+xH5 FvJcCO3QxiEWzacFq0Sfhk/KYmqenI1cjPnPqXcykaZp/04PwAcDcgnu5EL28whKXdNb tRXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=22PO3WL4EP1wJwH0qObvySA/hmTl6E7prSuJkQnAQuw=; b=Y3/c8nPYo6HYYEJdMpx2TFLrEoDyPmBu0OVq2mB2LIdQouExfealwcK5ysi7gBdP13 oXC0g68feMwUI6ibFCrQ871W8cp8S+Fz7ZSVzSR6VzpAtviLBW+h8wRfZ1PG9qxALc2H t50muQBmZcEMQQLUJeZXBO/vQZiNn45+N+kkHlKENyOVPjJ9r04juh/xnJb06Hkvcn/I x7XQ/KUFUvIMROHjsZJgH+GfTxMykB6r1M5SWNwFHh4jY22zvuJ1+9N2FPmjh5yPP6wE 2zxHKKgNcEH0popwCquXDbNAHsmhSIIzIJPPvNkiGLxP1nuuSM3FEluM3lgtSGaYhy8L 2g6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nE1e5MS4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y187si20662306pgd.66.2019.07.08.15.40.11; Mon, 08 Jul 2019 15:40:26 -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=@kernel.org header.s=default header.b=nE1e5MS4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389811AbfGHPjB (ORCPT + 99 others); Mon, 8 Jul 2019 11:39:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:58870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389782AbfGHPaA (ORCPT ); Mon, 8 Jul 2019 11:30:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5CAA216C4; Mon, 8 Jul 2019 15:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599799; bh=+3pnNI24UcgqddC+16lnH/sPlaUZ2koWchHGt+Hx0XE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nE1e5MS4mP6t0+CO9XgYa/EbKlNPKSq8EPXh93vXgFRpnXlQ7rIG6uZWL4BEwVRax XsFpBxdpZGK3eSVSvZnYLvVXAQmMtYCyVezFa32TDJ6k11URLncCfUy0wtc/omIaWH BxWssMTVFqwQxN37jvUpPjS0LcIf8FkQY+hJbP8U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guillaume Nault , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.19 81/90] netfilter: ipv6: nf_defrag: accept duplicate fragments again Date: Mon, 8 Jul 2019 17:13:48 +0200 Message-Id: <20190708150526.488683525@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150521.829733162@linuxfoundation.org> References: <20190708150521.829733162@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 8a3dca632538c550930ce8bafa8c906b130d35cf ] When fixing the skb leak introduced by the conversion to rbtree, I forgot about the special case of duplicate fragments. The condition under the 'insert_error' label isn't effective anymore as nf_ct_frg6_gather() doesn't override the returned value anymore. So duplicate fragments now get NF_DROP verdict. To accept duplicate fragments again, handle them specially as soon as inet_frag_queue_insert() reports them. Return -EINPROGRESS which will translate to NF_STOLEN verdict, like any accepted fragment. However, such packets don't carry any new information and aren't queued, so we just drop them immediately. Fixes: a0d56cb911ca ("netfilter: ipv6: nf_defrag: fix leakage of unqueued fragments") Signed-off-by: Guillaume Nault Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/ipv6/netfilter/nf_conntrack_reasm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 73c29ddcfb95..35d5a76867d0 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -265,8 +265,14 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, prev = fq->q.fragments_tail; err = inet_frag_queue_insert(&fq->q, skb, offset, end); - if (err) + if (err) { + if (err == IPFRAG_DUP) { + /* No error for duplicates, pretend they got queued. */ + kfree_skb(skb); + return -EINPROGRESS; + } goto insert_error; + } if (dev) fq->iif = dev->ifindex; @@ -304,8 +310,6 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, return -EINPROGRESS; insert_error: - if (err == IPFRAG_DUP) - goto err; inet_frag_kill(&fq->q); err: skb_dst_drop(skb); -- 2.20.1