From patchwork Wed Apr 1 16:18:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 228371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41978C2BA12 for ; Wed, 1 Apr 2020 16:48:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D63202063A for ; Wed, 1 Apr 2020 16:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759727; bh=vHUjieBU5aslM55rEOP09v3yMqm7chbEbPX1sJ1IF44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=eYnnS0LSdtYFvS9OL1GVlg8A3I6PHhTimdwLz2PmNqZY/zuvHmpRj6xHifPFX1rJC wsi8iJNtsjphTtrgWbnR1vMjAqGXwOQykbYHO1sbQ5RniQrhrr22bIX7sfIRqmYX0i bzRUnfO7VoFpcFFXt6wquU/eGlwBOV+MIdet5giE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389859AbgDAQpk (ORCPT ); Wed, 1 Apr 2020 12:45:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:46884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389403AbgDAQpj (ORCPT ); Wed, 1 Apr 2020 12:45:39 -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 B31D12063A; Wed, 1 Apr 2020 16:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585759538; bh=vHUjieBU5aslM55rEOP09v3yMqm7chbEbPX1sJ1IF44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wIU7nbsGF5P0nQNgOxJ/lO3Llts9VHJOz9c8ULyrGvSAPw3lmY3JBpLxzI3LhixP8 6c33ImlPnQPndqp6ue5kbiJwsNsCmYT4BcQT7i+K3v08T4FqG0apgW4sPe7ZdqOGFo IV+5iYmAz9KPaLvh7GO4PDFH1zNvU7Pz1ztE+EgE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Torsten Hilbrich , Nicolas Dichtel , Steffen Klassert Subject: [PATCH 4.14 110/148] vti6: Fix memory leak of skb if input policy check fails Date: Wed, 1 Apr 2020 18:18:22 +0200 Message-Id: <20200401161603.129286885@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161552.245876366@linuxfoundation.org> References: <20200401161552.245876366@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Torsten Hilbrich commit 2a9de3af21aa8c31cd68b0b39330d69f8c1e59df upstream. The vti6_rcv function performs some tests on the retrieved tunnel including checking the IP protocol, the XFRM input policy, the source and destination address. In all but one places the skb is released in the error case. When the input policy check fails the network packet is leaked. Using the same goto-label discard in this case to fix this problem. Fixes: ed1efb2aefbb ("ipv6: Add support for IPsec virtual tunnel interfaces") Signed-off-by: Torsten Hilbrich Reviewed-by: Nicolas Dichtel Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_vti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ipv6/ip6_vti.c +++ b/net/ipv6/ip6_vti.c @@ -315,7 +315,7 @@ static int vti6_rcv(struct sk_buff *skb) if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { rcu_read_unlock(); - return 0; + goto discard; } ipv6h = ipv6_hdr(skb);