Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3319783pxf; Mon, 15 Mar 2021 07:04:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzS2nZktl+JklpF0bazdq6rczU/2HZVALXLkKAyJHKamtXqZelCsM1PXIXicd0Rn7Dcgmd X-Received: by 2002:a17:906:cd12:: with SMTP id oz18mr23748992ejb.498.1615817087919; Mon, 15 Mar 2021 07:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817087; cv=none; d=google.com; s=arc-20160816; b=qIlcyOJE6SSL+/Y9r1G36MmfBKPJRdplNpLRDilFCHacywYb+WAUXukC4AlrxCYQwx BF3Fa3MDf3P2y8WrmitNkWBPGKRWAnx2Y2VvOE3uWE/Ad5Ux6wNz50olYZYLO1tn8Uao goNdhkdGRJk6Cpx+xWlCGmiiPuhqYB55SRixrz782AeYv+D0Vy7MFvkB0SDXP628O8g+ 82RaduHeZW18gaBcMOCjuIvnhRCJ0rg7fHX1H9ZS1YaTyXqejskZRBJSq6kTWAN5ob6g SuBa4Ve1yEBx0alrgVdh6jTBbBvy6mpwvUFYDpRNThwz4pDfxB0/WwiAivypoiM8wAsG Lezg== 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=EWJi0d/9U0eaQ5yxTkWpJzIy9Lo6hgaws//YonA/K98=; b=DXwsfqSICGJaF1e9wCMEI1mLsJsvGmVLT759o8P2E/XRxQJLllr4NGfru1+Dcu+dY8 C4R7Ypo5EH0j6R5w0oGnVWWKBSR7WDtvzZRG1kAmuFmBERQWSIERl6J9wyqCzpdXEs+f kgKAC6x59MY7iaqovH2E4oA8UsWqZvi/Olxy4egS8lk0ezKuOQRMj2JD0xMrEqAX1L/s gDzCdviJflu1ij+lqmfxKyZ5Rb9fyk2NtRgL1kq/jV5BiwAF4eNC8iWBUcNc+tQ+L0/7 8p01wj37cGmFzrebTsZmrI2wONNBHk2EDSOfL9ajhUAOujTF6KpJtJ2Hh7L6i+QCU970 0VMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jmXve5fc; 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 c12si11232128edq.130.2021.03.15.07.04.24; Mon, 15 Mar 2021 07:04:47 -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=jmXve5fc; 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 S234099AbhCOOC4 (ORCPT + 99 others); Mon, 15 Mar 2021 10:02:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:34070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231854AbhCON47 (ORCPT ); Mon, 15 Mar 2021 09:56:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 03D7564EFD; Mon, 15 Mar 2021 13:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816618; bh=qOnis5ASUbtP4DBaEjgypEoRm67TjZW/8eJm0wxkdp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmXve5fcH7v+ChPd2RZ/SQ1u7HgftkkVxZh0WlabTVFXHFXVo6fd3obJVPPZNQVM5 4MNkYztgAfeu5MpFMcIHjKY9/eppaEPBmnYeQekrUwdf8ezfcUuj3UR/rm++7Qefky x+DI109V5Dc6EhfqMGvJK9h9wUgNFsiXiL1dsLHA= 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 5.4 007/168] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 Date: Mon, 15 Mar 2021 14:53:59 +0100 Message-Id: <20210315135550.578251893@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 @@ -14,6 +14,7 @@ #include #include #include +#include static struct sk_buff *mpls_gso_segment(struct sk_buff *skb, netdev_features_t features) @@ -27,6 +28,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;