Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp837013ybi; Fri, 12 Jul 2019 05:28:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5kz2dEHJch2MRNVFgYJLbblMNppBniCvCPPWg1Imw1Bp+X6A5nfUZBbCXFQuqCITGgZmT X-Received: by 2002:a17:902:e287:: with SMTP id cf7mr11114399plb.32.1562934515469; Fri, 12 Jul 2019 05:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934515; cv=none; d=google.com; s=arc-20160816; b=bkXp3HGkJl3mxn+9mi83GFmN41wqjvUGu6F5/IaYaMtlAcngi6iUABH3q0kKIC24ND 2nVTdvHOoZ/Ix32OB0p7rdOSmqWmIRMADg7inLPVO7dNjMi8MO6DZRCKR+npNS1XH6dj ywJZ7dF+Tz1W/eg5ScVh2K/MXceel8HkVnD7/8tK3QPMk5tKVWYTb+70uAjh/gXCorxF mKNGM4AOEEqX5cCy2vVNZJd7P7nBkxEImM+54FS02K8FlCn2kdQRfVRHzV+k64WTo5uc ZWSQgB2hnqPeLMVxUhY12aqofYLeLfot9XK/H3l8Sidw2ESWLpZM3K7y1AIxbrUFYVea 0KFQ== 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=PsdMc8AvstaDyhN6yjW65UGz2sJbU6nEBeovQXGC2dU=; b=QZIBLRTglUR4qh1agkPHKkjRUPXUyC+ZmFuL1V3Gj0sasrAX3RyU3DB3bgVYe3WiaQ w6bnO1buNQsx3bj0TOrR1P4W5mKVoiQ59ltfhGJss6+RXvzTNx7g3uRTSw1Aq1UjXKhD TajlQYs3giKn1vGTXzm9O215C+f05AAeSUH/YB2BfZTcOvWLyq2HsrQjaZfxiGwLPH6I uC6lLU0zAoJAUKxBokTZl4iOhC5IB4iEKX67zuvOhmF6mKj7tvUkhsqHSeyTGz3mq8WS aNqXsdiab9K5aV8GgO9lIcEoWIxFX/BqvKZed/vlEzvySStuvMN1bY4uS5yDMaytnzs6 6c6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OBC9Qb1a; 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 r140si8239497pfc.27.2019.07.12.05.28.20; Fri, 12 Jul 2019 05:28:35 -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=OBC9Qb1a; 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 S1728616AbfGLM1X (ORCPT + 99 others); Fri, 12 Jul 2019 08:27:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727645AbfGLM1V (ORCPT ); Fri, 12 Jul 2019 08:27:21 -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 99876208E4; Fri, 12 Jul 2019 12:27:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934441; bh=RX8cF7VBzex5Kn9MPBH8m1pu80iOwfgVJoULW21VESE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OBC9Qb1aQpn31ydgVmUUNweyNxOZy/ym3OlYB+cypFxZBF+u0xmphNzgehEcCuReh NdsVE/kfaPJOOSpsMlYWOU5+otys9IeQ747J8xO9dV7coP56cKbso3dSEqY5IO34mK linNWAdNrAhMojEMIp9iXFZhsyFgdQuvsIkOEVng= 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 5.1 029/138] netfilter: ipv6: nf_defrag: fix leakage of unqueued fragments Date: Fri, 12 Jul 2019 14:18:13 +0200 Message-Id: <20190712121629.817098776@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@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 3de0e9b0a482..5b3f65e29b6f 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); @@ -480,12 +484,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