Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3514138pxf; Mon, 15 Mar 2021 11:13:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAhqFhwRF20cXb2/KIIv23IRfAvAoKz8Tu/OJCPlT+Ppl0k6BQJ1InlQoADSrqFqyE5hZQ X-Received: by 2002:a17:907:9808:: with SMTP id ji8mr25210202ejc.333.1615832014762; Mon, 15 Mar 2021 11:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832014; cv=none; d=google.com; s=arc-20160816; b=xpqkUUYMgLqvnZmzF24y5XLBXxTbbVB5WvS7DXF+NrjVyikUA9w+3sRWUkdnA67Sdu 5513vkXn6r8f691WAlGRXfvu1Kwrn7NLJauK/rfWWltGvSfMhIGsXCq5YQSqIdjXSpm9 wEsg3m2WRPpPSgG3y5fYOiA1z0g8nMgc+uxUWIKE6JVdhFc8O5pz3hhCFKm4oR0xKy+x HWBaD31gy/RiSZqQ29anjgaK/cyaAFkC9WpR44MLGBPMcY+mFmMKGg7qiIKzbJTmDfWU u7BTiqWR8fXd7y4/HMkZUnUPugt5FkwSxVhbx3supFpAsBRkLjdG7+b0NJEQTmQU8Qi7 2PDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6/A3UHyn6yVnG65YxOFyCOB82BvgZK7DY5T43QpEud8=; b=KyIc8KNqU/GYGJgBoPAsb47s2BeCsjUBJn5ZqNO6jwV3S1VNGSwnjekOs/sKA/+ev3 oT7ZurnTFqITa12H+tEKmPKK71w3RM43gGn9m+cuIXm7EIsDjp925FUDNKiY8yL+zOg/ qHFQzCVo1gcUvMXFx9jzNBi9h4EBlT5/l6FGLcbAa6AGYfSvWc2X5Vp6BAREsCsvVMrT IDkt4WBAZXVBorrVnrzYtAmNiNOpsg+AqDGBZZV/ZM4n/d3lB16INli0VcEnla6JPQmV ME+VT4Gl2fD0C+8eLXH4U7M/NvJSI3uqD1pNLIOQjJXPi+dMXD5QQERoadBNsz/R/Gov U4AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="JV3rwOj/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si12063132edd.486.2021.03.15.11.13.12; Mon, 15 Mar 2021 11:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="JV3rwOj/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236243AbhCOOMj (ORCPT + 99 others); Mon, 15 Mar 2021 10:12:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:35446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbhCON6j (ORCPT ); Mon, 15 Mar 2021 09:58:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A55F264F22; Mon, 15 Mar 2021 13:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816708; bh=30qpCNvgCAC4jJqpN+nWjFnoFgCNXtc8piRFPskl9po=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JV3rwOj/eTDCjOhQ4qVAfOzypgm0iomeQxfRqSx7pbz0sJT2VaEgDktS5Aviv9ROb zB3txZ8A4Ns307aRqaeaVEX0GwbR8mC9CgP3w+7TISU6YVeBSIWNOxMgMZXPL9qL20 Ly74oeV4ftrSaxyheSA20mAq8v2DUOgrp3eIMVXw= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Balazs Nemeth , Willem de Bruijn , David Ahern , "David S. Miller" Subject: [PATCH 4.19 019/120] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 Date: Mon, 15 Mar 2021 14:56:10 +0100 Message-Id: <20210315135720.638602447@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Balazs Nemeth commit d348ede32e99d3a04863e9f9b28d224456118c27 upstream. A packet with skb_inner_network_header(skb) == skb_network_header(skb) and ETH_P_MPLS_UC will prevent mpls_gso_segment from pulling any headers from the packet. Subsequently, the call to skb_mac_gso_segment will again call mpls_gso_segment with the same packet leading to an infinite loop. In addition, ensure that the header length is a multiple of four, which should hold irrespective of the number of stacked labels. Signed-off-by: Balazs Nemeth Acked-by: Willem de Bruijn Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/mpls/mpls_gso.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/mpls/mpls_gso.c +++ b/net/mpls/mpls_gso.c @@ -18,6 +18,7 @@ #include #include #include +#include static struct sk_buff *mpls_gso_segment(struct sk_buff *skb, netdev_features_t features) @@ -31,6 +32,8 @@ static struct sk_buff *mpls_gso_segment( skb_reset_network_header(skb); mpls_hlen = skb_inner_network_header(skb) - skb_network_header(skb); + if (unlikely(!mpls_hlen || mpls_hlen % MPLS_HLEN)) + goto out; if (unlikely(!pskb_may_pull(skb, mpls_hlen))) goto out;