Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1863859pxb; Mon, 8 Mar 2021 08:09:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1xtXlMLN99Owd/wTyzGWhaCzyatX5+OQAgltuIw2XKNBQbxIthiIWz4jRL3dRh0qnutHp X-Received: by 2002:aa7:c916:: with SMTP id b22mr23303850edt.299.1615219770426; Mon, 08 Mar 2021 08:09:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615219770; cv=none; d=google.com; s=arc-20160816; b=lNYoQdXWIMCibWQAUch9b2VCM/eKUUIMLCd42QcwMRPyew1zajjkK2hDp6bmDFvc4P c693HSp5Ei0mTLyvQ8f+AiPH5d+8MX5gWBsX3H88LigM1qItMYfLLh3pkEuPx1RNghGj kNDdzPsJNDVqTh4omMtAv3j+VHDPZJV12r2Ls9uuNipPKbKkgjDwVxy/oSp1m3kdt2Il bfsJNc1X7Vcpw+XdY+52kGb9QRVU/uVhQs76YGwE6OX8SbGdxoUIWbBcUO+y5hwM+yvR XfgLyMdlAobhgRiHrecdEuBYU54JXCKCEbWbouUyPVijBfBbBqeJ4BqsbZ4ka8Y7l5/P d8Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9fWdVn7nLt3E3L4QID9g8tlOiKwr5cryDbVteVsjhto=; b=pZXnYJL/i/b+OmrwxDW10Pz7NnFnjLTGmGEQzem73dPVA1CJaUkzy/ZTZbhZm1TZfl 8aQ7ObS9TmjeANvTsMVRna3aCoWzz77PD6zhE7putbNZuOXy0jCNklNirmZP3s2eQfV0 mt4LGKQ5fCWDsSCKy54OQ86GjYrUFJThm6ljjnD8QfjuDxikq2q3WLaOdyQ38UZ9k2HH QI6VlGpOEnTNC79rOHCDV6QiQMqCehLiWFhc3AkhRHiKMj+WpaBItnbiK0zG61gtAk3b GF32wfcbl21dnp0yLjQP57Z87EC/fKImavPPxYGLefYtJfDBPs2fjQJkdtcsDrvYd8bf xoFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hby+9gRw; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do13si2777202ejc.87.2021.03.08.08.09.05; Mon, 08 Mar 2021 08:09:30 -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=@gmail.com header.s=20161025 header.b=hby+9gRw; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbhCHQID (ORCPT + 99 others); Mon, 8 Mar 2021 11:08:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbhCHQHx (ORCPT ); Mon, 8 Mar 2021 11:07:53 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A565C06174A for ; Mon, 8 Mar 2021 08:07:53 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id p7so10023323eju.6 for ; Mon, 08 Mar 2021 08:07:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9fWdVn7nLt3E3L4QID9g8tlOiKwr5cryDbVteVsjhto=; b=hby+9gRwE9g9hGAihLCdCtBZ+y4eU1Zfe61MagbI6fqe4FrPk/dLp7WrdubLG93OD4 xs6lPQ1gHQheNmcoCu6iCEgcfHG9g7FxaBOxs8BB5gxPKEvR1YTBtFilN6gcbe1qPGol D1kArFIP6UYLue+0sZkge50+rXKAFp+ylwJ0rVzlyX/UmyDc0tzOPaL6pGW42eG2hSZ5 dXvgTuHFS/YR8OBxpnDOBvgzZXiuIp//VjqV9BVEjoAlxoX8AodWem+MR0qvm79GGDEu DrJvlQdq/Oo/XWQVkj5+PHPoz+34btM4p7tCUKmuKJ7GvdUaDMYsSCQeLQr2jw/AtUJi b1Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9fWdVn7nLt3E3L4QID9g8tlOiKwr5cryDbVteVsjhto=; b=RcELJxoJQMqKMX6qg4ZAFV0mmQx6S2o9jHR6NuphHyfFqQht+Bv4UpQfAnmqEgepkj 1WXXgmiKG/yN9xo4lziVkigmt9IW+gqSTvZBa7QLXwzOR3M1ip4xYAhHp6daSoOP4W/q elzasjLN4waDaxJ4Cvj05sAjFKq5tCGKQY7ugq7wHp81QHB3VwRxKy9Ou0PHY8f2+oj8 OTHJiiWXNs+UdTskIlL+sxU/RIDFek2fgxGCcyb4CzP2EOXgtuQliIivKKm72u/njBMb YeFrISnC2M6QmAh/mbt1ZCDf7inlWRuOaiR0axaEr4pEwz86dETGcQ9fC8e4+Idl1q4H /KLQ== X-Gm-Message-State: AOAM533YOoGcNpAwCIKYuHmxcTkHXx08rpnidjMeC60mzC1owWwOXRlV ml39VCRd1+Szxo3HoXjbOjh8Iy2ZlV8= X-Received: by 2002:a17:906:53d7:: with SMTP id p23mr15860850ejo.140.1615219671238; Mon, 08 Mar 2021 08:07:51 -0800 (PST) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com. [209.85.128.45]) by smtp.gmail.com with ESMTPSA id a12sm7439506edx.91.2021.03.08.08.07.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Mar 2021 08:07:50 -0800 (PST) Received: by mail-wm1-f45.google.com with SMTP id b2-20020a7bc2420000b029010be1081172so4139421wmj.1 for ; Mon, 08 Mar 2021 08:07:50 -0800 (PST) X-Received: by 2002:a05:600c:4150:: with SMTP id h16mr21312488wmm.120.1615219669904; Mon, 08 Mar 2021 08:07:49 -0800 (PST) MIME-Version: 1.0 References: <85e04e1e6367f19c8f538d145b32f5bb93788d8a.1615199056.git.bnemeth@redhat.com> In-Reply-To: <85e04e1e6367f19c8f538d145b32f5bb93788d8a.1615199056.git.bnemeth@redhat.com> From: Willem de Bruijn Date: Mon, 8 Mar 2021 11:07:10 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 To: Balazs Nemeth Cc: Network Development , linux-kernel , "Michael S. Tsirkin" , Jason Wang , David Miller , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 8, 2021 at 5:32 AM Balazs Nemeth wrote: > > 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; Good cathc. Besides length zero, this can be more strict: a label is 4B, so mpls_hlen needs to be >= 4B. Perhaps even aligned to 4B, too, but not if there may be other encap on top. Unfortunately there is no struct or type definition that we can use a sizeof instead of open coding the raw constant.