Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7149617ybi; Mon, 8 Jul 2019 15:38:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHCBh/bObBYtbDGuM0n0wofNGES47OgaMN0TvOszyjSFBywqlmfhl6ougy4db3tGDPhDl3 X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr6067389pll.321.1562625511246; Mon, 08 Jul 2019 15:38:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625511; cv=none; d=google.com; s=arc-20160816; b=D3CFSdmPCppgd5z97JwRf77yCJ65ws1RF+gozpeZVHCAZWE1sP+zOwLIEKM/RWYPLf xU8m4eBJXbXIWPmCZKBBCYmcwrW0N1OC3ScgLJghw90hhugkCWa+lWdESdqkOWteimze 0Ga3Jls2Lbk6IgO+DFQktR2GJ5ejbXmKHnaZEKX6s3hKFn0sWM66l1MbsnvqXnqhmfXo KGaOfGazFgM99es8821ZVZ2lDGbWxmCyFXJhtvfYmp2RGJMnaKbAvCTYpK3lQedQxR5S CnNPTLBPhX39C/0fOXzXNFK2J4q3y2IYL09aqePnn6/3FTyVa/BN/lRw4wTQow2GIEH8 AFvg== 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=mE2tde8vAnQNh+BMshk8BDOM/J/dZN2sxaXPP7zkAOI=; b=hQV6gXvcHqtpFYzVeUPvlUmSG4tRI7S+/EGnYNmUPVgV+3ojbQ5tWwEsN3wL8b7U6I iKlkcFTHn4oHHKbvM6VWUPlxDB297nn0vu2Pdg5eOrsQEIHed9EdQnrmtE7hiEhpm+T6 E3MJyZ7fTe2N3+STek+X2UB66Rkz+rrGhdLf78xXvMM7uUvlkvVI5nWWl5yBgcH0rBWZ Iw6Eknnr+FClJpTzS96tAQSViDzDvMD9eCEfKb2qVgyou1s0p8too0D5ne76D3tGqEo+ rQHzdSgVSmJJumnk13dMHSO6Ux5w7ITP60lX99UUEW51gE1NkOO7sFNYfZCV03gOAqZ9 CzdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LAAviDeT; 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 a144si20587868pfd.72.2019.07.08.15.38.16; Mon, 08 Jul 2019 15:38:31 -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=LAAviDeT; 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 S2389789AbfGHPaC (ORCPT + 99 others); Mon, 8 Jul 2019 11:30:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:58638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389585AbfGHP3p (ORCPT ); Mon, 8 Jul 2019 11:29:45 -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 EDE61216F4; Mon, 8 Jul 2019 15:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599784; bh=5Bi1ejuRESz61bUYqPNkEyic9P7oSHxXtmSYp6EISkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LAAviDeTVHrn7RqMCi4WqO0YcMzEm3ut+rgXAtNdJJhr+LD1KLF5DeGNnpnnmWezo C4cWpPdbb9JYG8nAzChqnOPbqYoLnneSvvFaNpZW51Pfj5BjH4P2kRGY+GOj+AMgJZ 1FQYdwIrpqcmR9w4KVrOaJg5SoQ4BCclZxtC8YfQ= 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 77/90] netfilter: ipv6: nf_defrag: fix leakage of unqueued fragments Date: Mon, 8 Jul 2019 17:13:44 +0200 Message-Id: <20190708150526.237087551@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 a0d56cb911ca301de81735f1d73c2aab424654ba ] With commit 997dd9647164 ("net: IP6 defrag: use rbtrees in nf_conntrack_reasm.c"), nf_ct_frag6_reasm() is now called from nf_ct_frag6_queue(). With this change, nf_ct_frag6_queue() can fail after the skb has been added to the fragment queue and nf_ct_frag6_gather() was adapted to handle this case. But nf_ct_frag6_queue() can still fail before the fragment has been queued. nf_ct_frag6_gather() can't handle this case anymore, because it has no way to know if nf_ct_frag6_queue() queued the fragment before failing. If it didn't, the skb is lost as the error code is overwritten with -EINPROGRESS. Fix this by setting -EINPROGRESS directly in nf_ct_frag6_queue(), so that nf_ct_frag6_gather() can propagate the error as is. Fixes: 997dd9647164 ("net: IP6 defrag: use rbtrees in nf_conntrack_reasm.c") Signed-off-by: Guillaume Nault Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/ipv6/netfilter/nf_conntrack_reasm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index cb1b4772dac0..73c29ddcfb95 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -293,7 +293,11 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, skb->_skb_refdst = 0UL; err = nf_ct_frag6_reasm(fq, skb, prev, dev); skb->_skb_refdst = orefdst; - return err; + + /* After queue has assumed skb ownership, only 0 or + * -EINPROGRESS must be returned. + */ + return err ? -EINPROGRESS : 0; } skb_dst_drop(skb); @@ -481,12 +485,6 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user) ret = 0; } - /* after queue has assumed skb ownership, only 0 or -EINPROGRESS - * must be returned. - */ - if (ret) - ret = -EINPROGRESS; - spin_unlock_bh(&fq->q.lock); inet_frag_put(&fq->q); return ret; -- 2.20.1