Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1889123pxb; Mon, 8 Mar 2021 08:44:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgk4liX/TtJLLnN62jtojc1O0ZrL2Vlu2ItUYHqVYGRdClc7UjRM7D+7JaNwzh/bxiLiUV X-Received: by 2002:a17:906:2312:: with SMTP id l18mr16272854eja.468.1615221855774; Mon, 08 Mar 2021 08:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615221855; cv=none; d=google.com; s=arc-20160816; b=ta+WD3GTlCx9nv2h0PJH9UpK2rCC0dlSh9HoUhE7dhqORwJLcT+nc3t/NC3cONcDU0 VeebaQHOwcCG/zq49JEHKCS2JWGlAKHz4kOCRhMqzvt9qxT2k1nTQIiPxbwz6BJT245r T6MjYEeRBaanORbdihCw/XoQimkoUSM9AEwH4asqYvlA1hE5e3tEf26+BDttFIWZOPVZ q9T1eZNRdZu79hMduhhlia0xV0bFqMw1Hpp7MilDUi9kTPoXUUlby91DTHM7mIilr/SA HAqBLHSLW7opWwrmS/YaCnFV0CpGSNXVN/uPTlrNDnlVyFb79p01o57TWFX0S9pDLuko I3HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=BNlx4YPfM1nidlUove0a2nwdF4iPwX2FX54lO9BqECo=; b=G0T84DNTw04dK3B5OdIc0ks8RqLwqBwEDzNPJNClUhb6lbAsPpygNXwgdfixHEgdI+ 8FzgHvRxlrrBbY9fsoJzlSJU693PcTLF2pOpDIc2SYhpHP2L8lsE6cSKNW/pmxJzrqjn 5AOaHmygmAGDfO46xj7RYgE4Aq7LZ3L+aKYEZMRzUZUT7tad/vikrC/lQJ7qu5z4U8zq Eh3emING94JDLOx4jGnQcd3ttm2QDupvT6KTgUw3Hsbo02wkL6aQdANA+LOPgnsrdf0Y KJuRbDvhujxrIXQPy6/BgkkRemhivUEvOnzpzFus+9cqOeHHKlDS6rqvlzEf/n1a26Xs hEuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PrcHqWM7; 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 s11si7603498edd.147.2021.03.08.08.43.52; Mon, 08 Mar 2021 08:44:15 -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=PrcHqWM7; 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 S230212AbhCHQm4 (ORCPT + 99 others); Mon, 8 Mar 2021 11:42:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230165AbhCHQmw (ORCPT ); Mon, 8 Mar 2021 11:42:52 -0500 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35FDFC06174A; Mon, 8 Mar 2021 08:42:52 -0800 (PST) Received: by mail-io1-xd36.google.com with SMTP id i8so10607175iog.7; Mon, 08 Mar 2021 08:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BNlx4YPfM1nidlUove0a2nwdF4iPwX2FX54lO9BqECo=; b=PrcHqWM7PnbSdR1uQ2JziJWlKjjLrk2YVlkPA6r/nL9C/TPD9MIerRj2HQKQ71IvB5 JZU4S05UPtRRGfcpGqJtEnZv4A7oASYA2vliIUFOdfFaoWy2tITkB2UETbyZ9QQ6EjCJ KUjWfSANCUvDkJYwX9160gXx8laQ8HA5OFt9Jcjv63VLYFq7e7Q7812gxrMeSAx9Rc2y HCRy9naWrSGM4I0ISYuLtmW5rYiX/RKy0a7rg7uJfNC5W8IkWhZ/hbIcpLkATg8bTaaJ uwcj/UHKS1bqp8Qf7+5Jddb55e5G5zDtBp/9y3nZBfCZAl3WYaW4VhQ234YZY1hBZPuw G+Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BNlx4YPfM1nidlUove0a2nwdF4iPwX2FX54lO9BqECo=; b=kNLzruWJJepRVn7Ab6CavNZY2IxmyDii6tACNCzPSnjg+c6p0ZLuA62YSyy79+e8KO zJuOVPzRMXfrzMm5v9PO+iDIen9ieCr84F9PCN/0Kto1Htvya9R2B3aX67/Q8DOzQUGt 6bwOaWy33x8wOP9dwPvwHFbjd2kQCOISCwwMxU8temcnblSuXtZSB/kizFEpCI9YWJuE ty/gcN69hBvom0jNPs3gKHChcJBhwJZz+Zqyvymd3Fpb9GXoHkd5J1+KAe/O7trHwV0U djiIz/tk5NQ6oSYaqNc3dU9N9gSvgH3t4bSe7ttewb/YroclLFzwOoLz4X3ujccg8YoV 0Yxw== X-Gm-Message-State: AOAM5322MNDtyg3rcVBUvMykMQiNZ+YsVqgqFpOvhSIA7gYClLO0feyd BQ5ua3/SiY8oybJW7VDk+p0= X-Received: by 2002:a6b:7302:: with SMTP id e2mr19112165ioh.106.1615221771648; Mon, 08 Mar 2021 08:42:51 -0800 (PST) Received: from Davids-MacBook-Pro.local ([8.48.134.40]) by smtp.googlemail.com with ESMTPSA id k10sm6291465iop.42.2021.03.08.08.42.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Mar 2021 08:42:51 -0800 (PST) Subject: Re: [PATCH v2 2/2] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 To: Balazs Nemeth , Willem de Bruijn Cc: Network Development , linux-kernel , "Michael S. Tsirkin" , Jason Wang , David Miller , virtualization@lists.linux-foundation.org References: <85e04e1e6367f19c8f538d145b32f5bb93788d8a.1615199056.git.bnemeth@redhat.com> <718e4f13-31a8-037c-9725-08ae3cd93ccd@gmail.com> <543ebc518aa31f04bb6a85b66f37d984ede4b031.camel@redhat.com> From: David Ahern Message-ID: Date: Mon, 8 Mar 2021 09:42:49 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <543ebc518aa31f04bb6a85b66f37d984ede4b031.camel@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >>> >>> 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? > I was thinking MPLS_HLEN because of its consistent use with skb manipulations. net/mpls code uses mpls_shim_hdr over mpls_label. Looks like the MPLS code could use some cleanups to make this consistent.