Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1699638ybi; Wed, 17 Jul 2019 20:21:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9fOSvAkYiJcBgG4PddjYa7HVqpieiOdAVXm873gx0q/qELOuZ1qPZlMsFNpDBdtJB7p6l X-Received: by 2002:a63:714a:: with SMTP id b10mr10538661pgn.25.1563420098171; Wed, 17 Jul 2019 20:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563420098; cv=none; d=google.com; s=arc-20160816; b=kcWWPJYhWBTg2tsDZOSIuMJGBiSZZ68He1CfH7/9naE+qjVUdT/wSNDbAalcRd6Pn8 dHGKUJRRDNnWqnD3dI0+VeuAP9yTzmv5fbANzav/UHbNkGALrOAQXy6EngZ1QDkPXoKw J5zANBphFT+ednucg32sf4zZ0ftfcJ1Pfuw+ycUxsPp6jGpD9X5/bgYQYEeH5h6puHRZ nIxfbCts7+dc8iIBPHlCh08sT4Z6BNESZcSTos0FUxrV9sjtKoFbO5eTo/QCzzK6GtFG GNNtamb5NyTFcS/jKFHB58MMq/Icf8/x/0BtrneOohz/U4RALU8xU3ZxISbZdotSRxgx +OZA== 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=WqEgYfPibe2L72JXx1ve4touhAAGfMQsr4iiAYNg9Ds=; b=cZW1j7W0O+mP3AzwidCbGhMKabibYLzVrdFhALN0bDACqraXavhYk3j6zV2JEgOgp7 yTboz182fdwc878fr23ZffJjzOlSIXPgai2m9jrkub8LAP5jCqRax5Q4aowPsKgmCmiu XmQKEn0VjZCFGS7vv2qH/FLiPX4hfa3TnYoaGj1EB8Yg4x1W1kbrBSWmbse/01ian0YO hADvCuq5Mxsn/G6VoPFHTmKPLoKfX0IIAbV05hHJOu6dIZ7aGV1x+s/g9PzJN7siRI0n ZgpRXpzZLzMAeMbCS3hyO6y1gyAet2Gri0Wl9GS/6QrR0NAmLv+TB9wPzhYD0nS463wr CX4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eBjCWwyA; 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 o12si370655pjp.72.2019.07.17.20.21.21; Wed, 17 Jul 2019 20:21:38 -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=eBjCWwyA; 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 S2392027AbfGRDS7 (ORCPT + 99 others); Wed, 17 Jul 2019 23:18:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:46664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390901AbfGRDMU (ORCPT ); Wed, 17 Jul 2019 23:12:20 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (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 1817F2053B; Thu, 18 Jul 2019 03:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419539; bh=IjEZr8ulDEb3B1Lc+bRons4bfO/doO5ceruCF0OtxCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eBjCWwyAaXVnD9GQ972laAutBWOz7v5XnJdz/kyCzuybfH6q7rkQI3mHD79/Yxh0a MHv6BqV7P9ndmOY1FY3CvF4nx+5FAskMaPaaBE6gzNo4T+wwLrY00aqcNEPNTZQbIc LhpqwCzTLdREbL5WMCVXoG7vanXvNPsm3L/KmZ54= 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.9 08/54] netfilter: ipv6: nf_defrag: fix leakage of unqueued fragments Date: Thu, 18 Jul 2019 12:01:38 +0900 Message-Id: <20190718030049.783720080@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030048.392549994@linuxfoundation.org> References: <20190718030048.392549994@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 1e1fa99b3243..e6114a6710e0 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -292,7 +292,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