Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3320653pxf; Mon, 15 Mar 2021 07:05:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxX1tjKsQcvUNvlKqiuFOnt3FsXTn2478fxkIZNTDI1HjOSRK/o+kZQ2AkKPY+bvVk5ONsx X-Received: by 2002:a50:ed96:: with SMTP id h22mr18999710edr.39.1615817143546; Mon, 15 Mar 2021 07:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817143; cv=none; d=google.com; s=arc-20160816; b=GlwSHoSMd1i85W4pkAZBIqDJpT2CXOjct3oCNWLkox75PgoMHbRT0l7PSfmSesv5ZE ScagTlcnWF9CaZ3A0M89sCBNEj0ahKRT6f7vmDe2URdIZRDYevWiuhMVFJ/THOf9UBGA Mvm/HiItDWDV9Zx1f2McQKCIYXIbXTUKkioCVoO7WQtjwZN9fpWDw8t20siewvRRFdLi zA77e0pMB8Pvgle+psIz7GMzUZpeW9tvulO0mPQhasSxhFIOX+flS+EBEEVSAVeC6T4E 8DR+Uzay8xzYybqME5mLWsMZQ0wrvdUR3170u8qOF4raKCmExAFpLot5oGc7LJE1BG3J 5NjA== 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=0UI1DvF1L2TY3p1WpG31fBmlKM0R2aYpuTDeujTHuzWoXXiBnHUfUDgI4WkDDKOYNF IwaQKL5mLHUdc4MGhitpJobwt3rt5Iuf+crZ83hW1l9oNnPeHVZrdlMRKrzMYrTHzRUt j10ClzoQ4K7vVBPOnCm/2H5/1pi4p7pEBOUEqfpkthtsWKCpqMzwJ0AC5MW+ODWo1H2W nT8E5tqsQEkUH25fpgOh3f55zNrIEcGtd6G1rDOGehE098DsHsNdvdLrLLo/stbACqmF WMpxWEwaUszuc9SDHmgZN8XoYO4yP+QWMZYJ35K5AQdlM/2StFOMORIhZv4eljZGLv7z dIOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fFwb55Z0; 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 m26si11951748edv.514.2021.03.15.07.05.20; Mon, 15 Mar 2021 07:05:43 -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=fFwb55Z0; 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 S233238AbhCOOBN (ORCPT + 99 others); Mon, 15 Mar 2021 10:01:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:33286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbhCON4j (ORCPT ); Mon, 15 Mar 2021 09:56:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA56564DAD; Mon, 15 Mar 2021 13:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816596; bh=qOnis5ASUbtP4DBaEjgypEoRm67TjZW/8eJm0wxkdp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFwb55Z0ZIP1kcOV/ICDKv11LVsPEZcZiUb1UlDi321qYwf8CfDImARzd45h7r7y2 eA+Sn+9F3aDIT5k6lIfz4jB8vFlnu01uUB5QkCdZ7Yh0qFxxDZIIvy+xz3KskzNETk xFfxjer4OItmwfucXvkmjvjDA1C5WzZb7IsQZxdo= 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.11 011/306] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 Date: Mon, 15 Mar 2021 14:51:14 +0100 Message-Id: <20210315135507.999543928@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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;