Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1637093pxb; Mon, 8 Mar 2021 02:36:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTRcVYvoSUF9u5AQFxuUOmGNvI+a7tOWwlfCyt/yzza4BiVfCcw62DQ/yZV3ApQrqt3fT0 X-Received: by 2002:a17:906:b817:: with SMTP id dv23mr14686624ejb.281.1615199780907; Mon, 08 Mar 2021 02:36:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615199780; cv=none; d=google.com; s=arc-20160816; b=1LHDSYQ/4T670mVr52G6B8GKHLC2LQ8gA8X55riyEgGyHutTfbKZzzsvwmDycU8Bl7 ae4RqTZzGaQ4SABloq2M82qaFYk1W4aT7DuIc4fuBA6972/JewftgBK0FIv2Cs7eO+fn YdhUBhXYO7CaO/Zk4+oE8P3/TXlTCBBUR7oNEJblYIHf82/Smb9aS8F+OC2FRHI+xemu gYng7PJ2Cvl5Hj5FANFLeXH1oOAyo2kJh/3/B0XeXQyIeQ0i0/QlZf8oTI7ZvCwjnSXG zbgpldMTA3JaFKYYnTCONoZ8b08yfN3JZ59//hIplbF+OeCczzWDKuWcxCrCs7IZiqSS +F+A== 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=tzgm3Jq54JoBtwEStS2p3zfh75LFir9ok6NSzKhJVag=; b=rREhWJ1U5MBCQz7pNkshPt1dUjFyIIsPirxySGxJ6rBhHUWVD8F5qKCycQrkOYEnmX ZclaoflWetR1fuELrKQ/m27aEPkx6G1txzjMuBSQhILqGkjnNeUjNlbrBi7/Uncc7+AK 5j2wP0z0cy6i0yNxuq5kVrVfoO5rWpP2pcP6PRgppxAwur5EhRomBCq3XoZ8U+Vq5TLv MGycd0h0gGGmaoVJwsyWV8QbQK+7llCyOrROGZgme1fudyHK0BGvjZ0/47jMBk0jbov2 T0Es2Vu7V5m9LAiZCiwfLrq3f+qQeotWTBM/SnF6bpQBxGYNPsJ/FeU3DOUyOQhrs3KH rHxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WjVJ0FIH; 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 a7si6941163edy.54.2021.03.08.02.35.58; Mon, 08 Mar 2021 02:36:20 -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=WjVJ0FIH; 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 S231688AbhCHKcs (ORCPT + 99 others); Mon, 8 Mar 2021 05:32:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39649 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231592AbhCHKcY (ORCPT ); Mon, 8 Mar 2021 05:32:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615199543; 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=tzgm3Jq54JoBtwEStS2p3zfh75LFir9ok6NSzKhJVag=; b=WjVJ0FIH+3Y7Db+1KAFPx0XyXBmXj49fLVjveTjf0Dl4sfzuRX2CHyo68E5W5U2qcJcg7q ViiYGiho7FculT2xc9zOXnvb0ThkQwi9PyuLuxLtS78+bhMAGbMNlVVrHG/rFO+ksCQ9TO aqFgv+lz8/YF6QFMofIgBg1g3RugkG0= 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-412-JIv8FvDnMqW9ja_fv9GHLA-1; Mon, 08 Mar 2021 05:32:21 -0500 X-MC-Unique: JIv8FvDnMqW9ja_fv9GHLA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 876CE108BD09; Mon, 8 Mar 2021 10:32:20 +0000 (UTC) Received: from bnemeth.users.ipa.redhat.com (ovpn-113-99.ams2.redhat.com [10.36.113.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8239360D79; Mon, 8 Mar 2021 10:32:18 +0000 (UTC) From: Balazs Nemeth To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, willemb@google.com, virtualization@lists.linux-foundation.org, bnemeth@redhat.com Subject: [PATCH v2 2/2] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 Date: Mon, 8 Mar 2021 11:31:26 +0100 Message-Id: <85e04e1e6367f19c8f538d145b32f5bb93788d8a.1615199056.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.13 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. Signed-off-by: Balazs Nemeth --- net/mpls/mpls_gso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c index b1690149b6fa..cc1b6457fc93 100644 --- a/net/mpls/mpls_gso.c +++ b/net/mpls/mpls_gso.c @@ -27,7 +27,7 @@ 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(!pskb_may_pull(skb, mpls_hlen))) + if (unlikely(!mpls_hlen || !pskb_may_pull(skb, mpls_hlen))) goto out; /* Setup inner SKB. */ -- 2.29.2