Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3319949pxf; Mon, 15 Mar 2021 07:04:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4Hba4FZrHOSoHpqe6SuPBJpuMsSyHgK6fSaNeietE///LPJ8aVSp5Tzb6sLYuNiIm7Huu X-Received: by 2002:a17:906:cc89:: with SMTP id oq9mr23567900ejb.258.1615817097355; Mon, 15 Mar 2021 07:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817097; cv=none; d=google.com; s=arc-20160816; b=O0Ckv5VRLqopzMBHp6HdPiX2SjSO8GGJ7VRCrSNfezBqVjWpqP/AquzI5CDCxAbY9J opzW4/xgjHNzJIgfgPoDgatydNWH2Y7JtAPmjTNn612P+m9VVh48feEZMe0koCdO+jAA 7CD/gf2RkSrivOhFHg7CQN6Bc6sYK5ekygzAVK2Zu8uiQWJcAyYut7tiimk8bBPg7Jd8 j0yLK8UgaT0l7C1Vr8XJL+38GOys6zuhTdcNbOoVhIw6l3cIz4K/F6sUg86l5+WHkuhV Yht+gqrroQ4x4oBOcMY1i7DAtHhOPmNhAJcKWoXkeuV17l8PfFpzOdbuhnI+RwXty2Oc pUPQ== 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=pT1lXKzt4nm7Rva8tYCi1kU5tZ6oIVLHTgAai7vH8znEgxDb7Zmf2kLp5Yn8fyNU70 U6Ia+w54Z8OyQW23bqubrQW7BeAfVRPZc+K2U9DY2KnocTgDZKXCtNI36QQw4q8Vxino b05oysrlAo24Iu0D9gB/MQ1Exba/+w2lIjKapbwegWWf8s4DJJ6SBIzWz2vhTwhoPVa3 IR9CcucD/Ish8ZAKu7MHU927REYqnMzSjrMqyQyR0eO9+u8sVbl6VdHr0dzPBj7qtvMK 7YSrwHxcEbV6Kc/LZqa1YrYQr5VdbFJRTLHDhbhJsAaePF+fe7om/0dCj4zt2hSUqTmI pOHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lrXtmtVS; 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 l15si7904832edb.89.2021.03.15.07.04.34; Mon, 15 Mar 2021 07:04:57 -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=lrXtmtVS; 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 S233548AbhCOOB7 (ORCPT + 99 others); Mon, 15 Mar 2021 10:01:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:33462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbhCON4q (ORCPT ); Mon, 15 Mar 2021 09:56:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6DA464EEC; Mon, 15 Mar 2021 13:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816606; bh=qOnis5ASUbtP4DBaEjgypEoRm67TjZW/8eJm0wxkdp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lrXtmtVSqN2Vp3UCSymhIWNuHLkF58R+eKAvZQC6++gu3f1q43JO/ePjTUmcxnpyH dlOIbz2GgbT3LYD5qn7jRKaqVOzub9lLApaEN9TRcWfg5icuevH0whzmtGredAKMqT H6zOVo8MFYGUfvMClvJd/TXMlM3+PctOYSkmO1jI= 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.10 009/290] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 Date: Mon, 15 Mar 2021 14:51:42 +0100 Message-Id: <20210315135542.257552702@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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;