Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1878882pxb; Mon, 8 Mar 2021 08:29:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgOfPiVMNWTWIIvyDH9vZ7HWt3tiC30Vfi9H2qaNui1HpSgA/eaKXzhv50eNfqnCsGJSjT X-Received: by 2002:a17:906:4b0e:: with SMTP id y14mr4477167eju.393.1615220979718; Mon, 08 Mar 2021 08:29:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615220979; cv=none; d=google.com; s=arc-20160816; b=SDWnI/bA95wU47iG1UwtdptXSzis6ANtCdSlxgUx/NU+X3Rx1fcJ9pG7E9+kbsADNL aEwBE/7J9Zig9ryZFn/0Y4fsN1A0ZN5zBGEBFL7AR2bCFLdzju8d8rEyN9WBJbp8ANzJ aLeb4Vq8oTFDStKHkxgzD9GtNhGdL4THw0x1QUB/koNiltHRiaP4r0gbovMcYb9clOmz /vTKsJAKTA2pbnfSzFGaqGR7yOiNj0y1jKSg4tCW1CqPSsVKELVjxtDPuDelc4LPbutg YdtL4dYRRZEJa1jKaRu9O6ZCeIMxg6MS3CLEAFFR5c9t3nf6Pvr7sUzUifTLTE0d4b6F cwGw== 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:date:cc:to:from:subject :message-id:dkim-signature; bh=SssBAwjVIlVsmWMO7PiZrFKkubwCKH4nIDdW9qq+hs0=; b=lNUp5hzmXsaFN9fYDS6GudVfS19y3Huik8mrKNhBxO+xL8Qeh2aHHQJsAJQ/Hie7zO dWl9gh4n8bFqOzjA6CBHMGHqixFvrp9MvWMtsulGTlcAx2zjekdvawz3YKBXZmPC61x+ aULscz7KNY3J5bpjeHjm7ClhQHU6j13LGvnkEY1TSVXzi0bK3V+pfV0B0FNLC8wPzRZS OzqcCeClGvuYBpygfWd2FL7Vg03fPO3XtiC7vE/IQ8AOKNBPmWy2zCzm1BgPJhdiQiq+ Hw6Hfr4LTGMvd7Xoh9hzXUzAgqGzlSNIFYMaqREqnlpWCmA/T97vBWh8aT+B68wm0vm1 Hs8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g3LKjHRl; 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 m5si2045902ejn.599.2021.03.08.08.29.16; Mon, 08 Mar 2021 08:29:39 -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=g3LKjHRl; 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 S230173AbhCHQ15 (ORCPT + 99 others); Mon, 8 Mar 2021 11:27:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22995 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbhCHQ1b (ORCPT ); Mon, 8 Mar 2021 11:27:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615220850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SssBAwjVIlVsmWMO7PiZrFKkubwCKH4nIDdW9qq+hs0=; b=g3LKjHRlxFIR4JmGqHSh+G56vBddEDMyCI73PxL32v6GU4Mg69sqdoePuWR+oISOBcXPOe lqZ6VcbgW/lXX8DHx8dBivh1yt5/sRnXvy7LkRxT7ZxEXFu7Yp+RKWjjnA3bv/NlpNZ3tU 6kkbFQFi/Lnc4P4iRZ7S5/hTIz2pVAI= 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-455-stQCLjH9NYqiHO2iz4QXVA-1; Mon, 08 Mar 2021 11:27:28 -0500 X-MC-Unique: stQCLjH9NYqiHO2iz4QXVA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B1D3DF8B2; Mon, 8 Mar 2021 16:26:51 +0000 (UTC) Received: from bnemeth.users.ipa.redhat.com (ovpn-112-139.ams2.redhat.com [10.36.112.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 746C760C04; Mon, 8 Mar 2021 16:26:49 +0000 (UTC) Message-ID: <543ebc518aa31f04bb6a85b66f37d984ede4b031.camel@redhat.com> Subject: Re: [PATCH v2 2/2] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 From: Balazs Nemeth To: David Ahern , Willem de Bruijn Cc: Network Development , linux-kernel , "Michael S. Tsirkin" , Jason Wang , David Miller , virtualization@lists.linux-foundation.org Date: Mon, 08 Mar 2021 17:26:48 +0100 In-Reply-To: <718e4f13-31a8-037c-9725-08ae3cd93ccd@gmail.com> References: <85e04e1e6367f19c8f538d145b32f5bb93788d8a.1615199056.git.bnemeth@redhat.com> <718e4f13-31a8-037c-9725-08ae3cd93ccd@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-03-08 at 09:17 -0700, David Ahern wrote: > On 3/8/21 9:07 AM, Willem de Bruijn wrote: > > > 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. > > > > MPLS_HLEN can be used here. > What about sizeof(struct mpls_label), like in net/ipv4/tunnel4.c?