Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1871359pxb; Mon, 8 Mar 2021 08:19:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7rJoumU+J4J66p4v+v7dlX9//Ojq43xvXvnUvWBV2AZ2w5Gpt7qZqC8aoBWofFOvNPWW4 X-Received: by 2002:a05:6402:704:: with SMTP id w4mr23697963edx.175.1615220352416; Mon, 08 Mar 2021 08:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615220352; cv=none; d=google.com; s=arc-20160816; b=NEqqPwkNjSB1J28ogccLRL1ZK0kieOXLPjSiFqZw1NYZ0kvBW5+XNIUQXF0z35YVNR 9giViCRXbhmAXJlybFCCXSRPJRQIX76vvgwFik5qmZOMgDZZ76rkXe8qvoC70Hl1tYRr VnrYTPTWLgJhLjF6LjyQAREQEvt6Wrj+tWkTB3lZ8W8T/jtEmVuvzaLNYNN+5iS3CAkl xfpI6ZdpvVPVHwDpRn3gDFPv7WUPv9Jy1Wxh7pGlHa4gXCbL1apovcH8yNXDFSEdZERL KO16XtsAlLR0D4ZMzvm2fGtJc3JHB9lNjC7od+5Dw4sYvn+nLvOpv4IK+IOTRym0ckTE jlCg== 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=NEZnGRLyGUv6j7TBBXQHVAxZPQHAwJbm1fTojXbpoFk=; b=bqjygZ/Vuvhu55Uqoymeyk3UPxInz871ytZrqqk+mn04iFTH6c6Fmef4N8UeIIBCn2 H2CPhwbYVB5S3sCb0pRE6WAfextaYXQGlNANn1ZjFCLml6tK4ona8o40R90zlJVtyTIy 5lUWjXMHEKryqknL06pLKvryph2/6JlBKvpP/gcP6fVQfa2PG7pwRe/9E7psfy6Fou6d 6GALjDoCyoskBgBpTP6bzSxWjhSXuAKC8MCgXqDXcr023oU97g5cv2wwOVzkCLow7P/A OvGQzYsygz9MryFRnTpOLPSd5Gg89HSyQlmRyNEW9sGeLPxyf5dsds26Gm4y1sveyotx G0gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Cho/P6nH"; 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 kq25si7365436ejb.366.2021.03.08.08.18.49; Mon, 08 Mar 2021 08:19:12 -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="Cho/P6nH"; 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 S229646AbhCHQRm (ORCPT + 99 others); Mon, 8 Mar 2021 11:17:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230412AbhCHQRP (ORCPT ); Mon, 8 Mar 2021 11:17:15 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E30C2C06174A; Mon, 8 Mar 2021 08:17:14 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id k2so9326350ili.4; Mon, 08 Mar 2021 08:17:14 -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=NEZnGRLyGUv6j7TBBXQHVAxZPQHAwJbm1fTojXbpoFk=; b=Cho/P6nHpddiaz/cI1Z1BsYnIITIQzQDsk046xSUrqx8QMsc8lymC8Zvpqvnk93caH oym9P1XKRpUdJideJc/wyuG4gidGl313q71cT9fYHCJp6jTMGw6Abk2CHRTgCudmJjld eqGo7w1zwJU5IBG4XY/2pP0S1Ygw6Iazs8a+na2aU9T0tGFTnSpCqK3e+s/tJUiifeiP gb2UgxGvD8a8ZhX7azlyeC1jQGywcjJnDmz3OB4+oVvhwjHkokmEMSutsPeDR5MXiKSl Y+D+cV+bLkzs8Kt1xvIuNkjoXrpgArxisoKOInGmLnpSxaLYhq69OCb/ine50c4/Cz2V 5bgw== 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=NEZnGRLyGUv6j7TBBXQHVAxZPQHAwJbm1fTojXbpoFk=; b=mezlrFwa7pwweVImXlGDvGXu60kb/dRuCdYorQlgzqVS9ilZ9DBdqot5Dg+Ydgs/D5 Ry9QGcPHpp8WC+lycQO4+iX6cY0/Mk4xnQ1RJY5M4nK9cLeec2ITAR6WUdUmV1ZrFwp/ ejWT8I4L7JsyYUr92mLMtIoUgaX+b6z2gRWrEQsOQcGHj962Qnj9Ashh321/wmNyf7ie pjQ9R2KEd/eUUNCz2Y04N6FG++cH+OgN92qCcG6no5dBIZLHZuATRKVi+aJdxzAVi5BP TAwIgO07N0eRFpqeaiEQDK17XX9TWIjNaF0xHbFJsp9vLbbwWcfEVl9S8I9b3uawJRHu v+Sg== X-Gm-Message-State: AOAM5307/muIrpOhpkQRANrRT18SblSvXtbbtx7DN49ZWe8IsQUYddLw p79AFfbU5frOlblDC8dfzhhXH/cA/o8= X-Received: by 2002:a05:6e02:12e3:: with SMTP id l3mr20948602iln.24.1615220234437; Mon, 08 Mar 2021 08:17:14 -0800 (PST) Received: from Davids-MacBook-Pro.local ([8.48.134.40]) by smtp.googlemail.com with ESMTPSA id 128sm6201496iov.1.2021.03.08.08.17.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Mar 2021 08:17:13 -0800 (PST) Subject: Re: [PATCH v2 2/2] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 To: Willem de Bruijn , Balazs Nemeth Cc: Network Development , linux-kernel , "Michael S. Tsirkin" , Jason Wang , David Miller , virtualization@lists.linux-foundation.org References: <85e04e1e6367f19c8f538d145b32f5bb93788d8a.1615199056.git.bnemeth@redhat.com> From: David Ahern Message-ID: <718e4f13-31a8-037c-9725-08ae3cd93ccd@gmail.com> Date: Mon, 8 Mar 2021 09:17:12 -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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.