Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2475232pxb; Tue, 9 Mar 2021 03:33:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWuwHSD9N4bS7VeAlOalLnmUjdwMIVjrQ4UkFO+LQbfb0iHd5NUG9zc29nHZh45FB9twys X-Received: by 2002:a17:906:6558:: with SMTP id u24mr20100963ejn.185.1615289637405; Tue, 09 Mar 2021 03:33:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615289637; cv=none; d=google.com; s=arc-20160816; b=vDsauFaVy5OCMzWkL3ptkcKwO8104tjG9jsaD1hgTOnu9Lt2Q1JXWVvxMfAwDZ4RSD H2kbi2a318a6ihK0bs0SSaW5MeynA1gkXePDKYJxI/4igpKek2v98qMQUELoJ5GFWVr/ PlUhHdeNymhOEYAtDmUsRAOSzucjhP0j1q1dcSm/Ptu+ccTBZb9z3wV3asiUdN6kT1QJ hENOot/MtKrLkzU1Zt7dDrZiwovYw4FfKED7aHiwYDyhn4POD2WndWrfWPtVvGTzlTF/ kqYlcDQuBbphMroPG1nEQDmA3qVIuLnzpiuNDtJxp7YxlC4rJASQQ+pbYTG1kDHU4epS iE0g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cf0QMVa+tzpe3b3+8CoGD2oHk5WObOuzjL75R7Y/Sow=; b=URzxVDFjMLw0ainnxC2Ry0mEHoshxu19i5vnMEjodicGlSFF4C53t5AQFltrbsb273 OQWuXP2mkeNDFAsn06xJQvgD5VUEb386kVZT+k82dqxZrD6Kq1UFZZoXpQzpDCm3QRWW gEjKsLIRl4WeGTyaIWppbwGpXY5jK+VSH9uWDwsKxBFYfPc0MtwxOmL2EaVdPNSZ+feY OxdaGC3OhJtRRKrF766rIsUCo+zC3B0sgbP32yrzcBV6FKy1GMj8rIvTLFZLiXG+wMVR JldT3fh9vSxSRaQvycq5KH3/g+FT0IwdJZNW1v+svNODJq6nQxaNF7WyGMqnYZfFhfey fxjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eCIZceVL; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r20si5240182ejo.22.2021.03.09.03.33.34; Tue, 09 Mar 2021 03:33:57 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=eCIZceVL; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230490AbhCILcN (ORCPT + 99 others); Tue, 9 Mar 2021 06:32:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25332 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbhCILcH (ORCPT ); Tue, 9 Mar 2021 06:32:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615289527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cf0QMVa+tzpe3b3+8CoGD2oHk5WObOuzjL75R7Y/Sow=; b=eCIZceVL5PLZ1S1qJYqI8wJcwNIRfmQXGJnoUAvpnEdocJnw0raRdRoqiPg42giBhaqpgp iE1dZ3e4eoPY4+qdv6sGpsMk7FA6ku7hOuervHvbgRkEzREzuyG2im69nItgrQNuon4Ms7 A+6RnsDpBUUdc2JmDalnimtfvTS6SxY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-491-be4yljztPlytGZMQC_CBkA-1; Tue, 09 Mar 2021 06:32:04 -0500 X-MC-Unique: be4yljztPlytGZMQC_CBkA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3ED20801503; Tue, 9 Mar 2021 11:32:03 +0000 (UTC) Received: from bnemeth.users.ipa.redhat.com (ovpn-115-104.ams2.redhat.com [10.36.115.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 381B06062F; Tue, 9 Mar 2021 11:32:01 +0000 (UTC) From: Balazs Nemeth To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, dsahern@gmail.com, davem@davemloft.net, willemb@google.com, virtualization@lists.linux-foundation.org, bnemeth@redhat.com Subject: [PATCH net v3 2/2] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 Date: Tue, 9 Mar 2021 12:31:01 +0100 Message-Id: <9b79f43d2dfec8b2cb8e896b5591e7b1c3cc1f6c.1615288658.git.bnemeth@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/mpls/mpls_gso.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c index b1690149b6fa..1482259de9b5 100644 --- 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(struct sk_buff *skb, 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; -- 2.29.2