Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1956974pxb; Mon, 8 Mar 2021 10:15:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBYXVu852H93HsMEwrYG+uATtMDyyHOqgXyHG6D+nBupox3gXBAnatCm6SpEnMlZ3eUiY1 X-Received: by 2002:aa7:c850:: with SMTP id g16mr23149710edt.324.1615227322472; Mon, 08 Mar 2021 10:15:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615227322; cv=none; d=google.com; s=arc-20160816; b=ZDb/8JhxytMe+KKCmXKc1vSkql73GaTr5WsQNqzYIg63G89OhXrvpfl/nAOLtL0L7+ X/DJ+0PvwAfFmiJ0FM8JAB/Y9L69NnHVsWehwGyyjBo0rR7q9AjRv9C9IShGiQWEWrIJ fMYPMQMeuMLWGCfuoGq1Ose4X5s1icCVAGLS73//TePJwoPVF8EIQQkP3mNFB1/kGPXP CKV+Eu8IafCHyEzEr9ndpq4LP278SxMxIHEoigOo9fI8/bygOo0D/Ya1mk0n9mYhY+gG QSMRDqQkT19W/8jQZ+IkZVkSwhw4r49x179hNky60HB342VCQtg5XarOIaCvqxbNiKOM KUVQ== 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=OqopxqISgbDC0SR+TF4LgpGs83P68cEOgU0oL+9mBy0=; b=zNKyHPKOOEYym6oH3LzsrkLV/f/UB9xKywhbGw2Q1d/8rryayuzBxyYEOQPjbktMek cI1ZuLOvG1QlOpO9uznVFkB5ylTqJWgOgwac3I5glcLybzFZJlhMybdtUlSYqftZlEUk pRPaidyQxjBpBQq/VmTf9qoDNkpLBjxbsm19aLtuHLgYdOdRe2toqtNXCI5k0v0LqIbX W3Nc6W7cUjCYcu/NhXngp+goF0dqC9JYmu1Lf9rBxt+4iUFSH9ilGUSE4YUlW+HOZYZV U8cEjAZYERCK71/YYEvMkLlOpGX3yq4MDDmLwCLONy3Fx8F0uYABrdv9YqEa5voxxlxT AcAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rK4orARi; 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 eb13si7727957edb.315.2021.03.08.10.14.22; Mon, 08 Mar 2021 10:15:22 -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=rK4orARi; 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 S230301AbhCHSMo (ORCPT + 99 others); Mon, 8 Mar 2021 13:12:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230212AbhCHSMN (ORCPT ); Mon, 8 Mar 2021 13:12:13 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29633C06175F for ; Mon, 8 Mar 2021 10:12:13 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id b13so16143967edx.1 for ; Mon, 08 Mar 2021 10:12:13 -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=OqopxqISgbDC0SR+TF4LgpGs83P68cEOgU0oL+9mBy0=; b=rK4orARib+uFue26kj7MItzjbMeCQujuEDB+aGDeIbin57sP23YVBgNZsvAxZ2H28v YnNz46zJWdkav61XGtp4BuQc2/KlwBhX3wlN0n6jMM9STBkezask2A7Fl3DxRM5R0mbb 8SeMgsh5Y7LeqSf/6iRHsTYBPkntQaOqEogzT5gszPvnQAWC9LpHNHLYhh0r3hcZI5Yr 9i5A84YYMdUZUcQnGNPFpp2FmYojMQuyy2aOPKeQg6OxP5w3ey768Pwtajg1mBjHRNpH PDLfuJ0VviolFVEl/DEyob/fNM0ZzFnJfYRt1685C/d7RqbZKTIriWmB+y0DuwtUsLK7 GjoQ== 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=OqopxqISgbDC0SR+TF4LgpGs83P68cEOgU0oL+9mBy0=; b=kn9I2hBXwCFwSihTzP6eQuITLdIuDqg5WjzHkQKAeuLQHmbm8uR66GeFpwFbU4Qzwi mC3G7lJ5kDBAQuhxNvVlUbrVhXuTIkHsAKVfTOIFW6YPwZfGfoAGPrI1IRKOK59BBez/ vL5Y0SXkJ7MB7m++8PK4vRPfW7G2vPxQQ1vAGzcyexUWbpyIlntUIhQMmk+SqR09sFZ4 x95xNJyxXgNqBh7ByXlCX7MTD/Dk9CwDZnxqJrscW+LTcTr8CDbXUWO6hhKq5HNs3Ge9 vD9LfEHrDb7SWn1k1DMl7A0Gmo8Y6qEHxDPQhMtnBn1dGSYa4j71vv1ChWHjta52ibso tozg== X-Gm-Message-State: AOAM530YWEo+RMpFsgsi66DWvqxvXpa8gexeZtXGWXCURF3D91CNmk8Y KSi+7ugEC2j0mnGlZvx2IcjsSsLmQFU= X-Received: by 2002:a05:6402:b41:: with SMTP id bx1mr23679479edb.69.1615227131173; Mon, 08 Mar 2021 10:12:11 -0800 (PST) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com. [209.85.221.52]) by smtp.gmail.com with ESMTPSA id n25sm7838979edq.55.2021.03.08.10.12.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Mar 2021 10:12:10 -0800 (PST) Received: by mail-wr1-f52.google.com with SMTP id u16so12458257wrt.1 for ; Mon, 08 Mar 2021 10:12:10 -0800 (PST) X-Received: by 2002:adf:ee92:: with SMTP id b18mr22954054wro.275.1615227129949; Mon, 08 Mar 2021 10:12:09 -0800 (PST) MIME-Version: 1.0 References: <85e04e1e6367f19c8f538d145b32f5bb93788d8a.1615199056.git.bnemeth@redhat.com> <718e4f13-31a8-037c-9725-08ae3cd93ccd@gmail.com> <543ebc518aa31f04bb6a85b66f37d984ede4b031.camel@redhat.com> In-Reply-To: From: Willem de Bruijn Date: Mon, 8 Mar 2021 13:11:30 -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: David Ahern Cc: Balazs Nemeth , Willem de Bruijn , 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 11:43 AM David Ahern wrote: > > On 3/8/21 9:26 AM, Balazs Nemeth wrote: > > 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. On second thought, since mpls_gso_segment pulls all these headers, it is correct to require it to be a multiple of MPLS_HLEN.