Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp964457pxy; Wed, 5 May 2021 19:30:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmer3DEPSnVHj26Jf7a67FJ3Bk3J0vZlOy1rgscT2RrNDZKJcJn+eNCPoFh83LxT0bf+iW X-Received: by 2002:a17:906:2546:: with SMTP id j6mr1820734ejb.51.1620268206961; Wed, 05 May 2021 19:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620268206; cv=none; d=google.com; s=arc-20160816; b=dczrLjUhBR7EzS4nDCoVjtGH3pD6cP3rGhCJcjsKX+M9Jvc6IgfxurvN+Q9miDlGi/ 5vRpL3l2fmd+keTCqGCjfEVT6ZWhlFtIDw02xcGoB034Bf7us8qXlNRPbWlkFAsiXDKU UY2CcB3lkRl7H7G1c2YHFcUHqT/w9DfSIRezPYpc2xDf+40i3xezSrG7e2hvpucKmHWw LmQfVmeerHtU62ZUD5jIwC/ALfHPYU8rO/Rvz65SNHH8tpvomRYImG/0K2jqGPCydi9m Ru4aSedbrCWjf/H/q7Gj9fW9DplneFnx7pK8sSlSnu94OGZooacyj3BFrlSgGx/BV6Tu 8xJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:thread-index :content-language:content-transfer-encoding:mime-version:message-id :date:subject:in-reply-to:cc:to:from:dkim-signature:dkim-filter; bh=u/oFc+RysAcbNw7YBahwmspRG76JwCdAvRU5YZymBtQ=; b=h0YDmxw9eoLE8jIgbwqSTz2onOARW4ikcGQRT38CLpOOqUCL3g6MOYsurqZ1lBiS0l DXDFJT48RFhH9cYsPnPhETjm7TB8NvbXVJ0N2cDyjgDRywrpAvikTee+blAwEkuaV7Ng od29KbbaKB2mJmw0S0uNUAl9utjf6no5Yo5LHs4ef+j9AVtKa8jbdPrHXBVSoE6+cd3V X+JRDD9lrGCGPyBXX+3oJH4F2II38NXhlCoedmc84RFRPPuDGAcLg2gqtfWJiATDg7r9 8/dC/8eEPV5rATvPyAt6qA+fRhS9XipX+aw2R6h1ypVtn5l58kjM6PXRonBdQeDjqR2R +U5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="mv72/qx6"; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp41si203958ejc.551.2021.05.05.19.29.43; Wed, 05 May 2021 19:30:06 -0700 (PDT) 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=@samsung.com header.s=mail20170921 header.b="mv72/qx6"; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231499AbhEFC2t (ORCPT + 99 others); Wed, 5 May 2021 22:28:49 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:64926 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231416AbhEFC2s (ORCPT ); Wed, 5 May 2021 22:28:48 -0400 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210506022749epoutp0254a74bb3b290f88d72297a9446b16c51~8WTlzqChw0137301373epoutp02k for ; Thu, 6 May 2021 02:27:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210506022749epoutp0254a74bb3b290f88d72297a9446b16c51~8WTlzqChw0137301373epoutp02k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1620268069; bh=u/oFc+RysAcbNw7YBahwmspRG76JwCdAvRU5YZymBtQ=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=mv72/qx6upbyf+Ci1uVmZupfffIgESs0Yx2cPbh6PLqRedP0DDybU17fFGDHp2WsK OYlRrCJQRwI37I4NCC7JXYObRGD8l36dgvzwCMV19r7XGIQrECL/faENtmUTv199MZ Bd1IMuNag5zEPyA9RLqmze721vp0tUCuqgc3g9ig= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20210506022748epcas2p1610e9e45315dba4e420e0e5ec7537405~8WTlPMEpu1397613976epcas2p1B; Thu, 6 May 2021 02:27:48 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.40.189]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4FbHYG2K7Zz4x9Py; Thu, 6 May 2021 02:27:46 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id A7.6F.09694.12453906; Thu, 6 May 2021 11:27:45 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20210506022744epcas2p1207466493a0e0da9d4ee6c14e1182242~8WThDuF8-1656616566epcas2p10; Thu, 6 May 2021 02:27:44 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210506022744epsmtrp11024c10fdd7d1a791bd0e1c772001a60~8WThCwYcr2275722757epsmtrp1a; Thu, 6 May 2021 02:27:44 +0000 (GMT) X-AuditID: b6c32a46-e17ff700000025de-73-609354217f03 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id E6.85.08163.F1453906; Thu, 6 May 2021 11:27:43 +0900 (KST) Received: from KORDO035731 (unknown [12.36.185.47]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210506022743epsmtip10680df7c93430fe8d7f9f3eff2744b4d~8WTgzxUwN2316123161epsmtip1S; Thu, 6 May 2021 02:27:43 +0000 (GMT) From: "Dongseok Yi" To: "'Willem de Bruijn'" Cc: "'Daniel Borkmann'" , "'bpf'" , "'Alexei Starovoitov'" , "'Andrii Nakryiko'" , "'Martin KaFai Lau'" , "'Song Liu'" , "'Yonghong Song'" , "'John Fastabend'" , "'KP Singh'" , "'David S. Miller'" , "'Jakub Kicinski'" , "'Network Development'" , "'linux-kernel'" In-Reply-To: Subject: RE: [PATCH bpf] bpf: check for data_len before upgrading mss when 6 to 4 Date: Thu, 6 May 2021 11:27:43 +0900 Message-ID: <02c801d7421f$65287a90$2f796fb0$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Content-Language: ko Thread-Index: AQKypHYW3xad5/j2XvChPebQmKG2owG+YoocAqFpyMsBZavlXQIxNaIYqN8+O7A= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFJsWRmVeSWpSXmKPExsWy7bCmqa5iyOQEg9NdEhbff89mtvjy8za7 xecjx9ksFi/8xmwx53wLi0XTjhVMFi8+PGG0eL6vl8niwrY+VovLu+awWRxbIGbx8/AZZovF PzcAVSyZwejA57Fl5U0mj4nN79g9ds66y+7RdeMSs8emVZ1sHp83yQWwReXYZKQmpqQWKaTm JeenZOal2yp5B8c7x5uaGRjqGlpamCsp5CXmptoqufgE6Lpl5gBdq6RQlphTChQKSCwuVtK3 synKLy1JVcjILy6xVUotSMkpMDQs0CtOzC0uzUvXS87PtTI0MDAyBapMyMm4cr2PuWCBUsW5 HSsYGxgnSnYxcnJICJhIPF47k72LkYtDSGAHo8SsGQvYQBJCAp8YJea9d4VIfGaUODtpOjtM R+u0LYwQiV2MEn/XTWCBcF4wSmx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wenzfJBbBFcdmkpOZklqUW6dsl cGVcud7HXLBAqeLcjhWMDYwTJbsYOTkkBEwkWqdtYQSxhQR2MErs73LoYuQAiktI7NrsClEi LHG/5QhrFyMXUMkzoJLVm1lAEmwCWhJvZrWzgtgiAlYS/2efYAcpYhZYwSJxoOM9O0THXiaJ K1c/g1VxCgRK7J71gxnEFgay+//dYgTZxiKgIrHhqgtImFfAUqJ782Z2CFtQ4uTMJ2DLmAW0 JXoftjJC2PIS29/OYYa4TkHi59NlrBBxEYnZnW3MEAf5STx+9JF9AqPwLCSjZiEZNQvJqFlI 2hcwsqxilEwtKM5Nzy02LDDKSy3XK07MLS7NS9dLzs/dxAiOTC2tHYx7Vn3QO8TIxMF4iFGC g1lJhLdgbX+CEG9KYmVValF+fFFpTmrxIUZpDhYlcd4LXSfjhQTSE0tSs1NTC1KLYLJMHJxS DUzunKIp6Y2Mia6LOrPfOtxWNebcetf1TuWCtGqjiwzTps7cV+mb5fpkY3UEK+uU7mlqbb8/ bluz4+SvfVl+PK+vvzG9GzT/vOTfDdYO7FeNfte1J+3WUNv2VcU+1D1tk5z0pFuO1Yxf120z a35h91cvy/6WEuf9JuuyadzTPV9POijOr/Jcx2/17Zc1FoXXtva93GzvvmN78pF4rxuiilPv iGg/Ob7EKdHtSnnJjFuVwkrqBzbdUWgQ7mmdb8HGLxJ1ri5x85pp/OdCrrClbpQMjm248mid 2bYU84Wtk9lYJjPyas24EdPJ9mBuot35y1PNeAJv1c7kPur7bOrLlQfmLvxRKhce/vClbEed QpMSS3FGoqEWc1FxIgAgod7UOwMAAA== X-CMS-MailID: 20210506022744epcas2p1207466493a0e0da9d4ee6c14e1182242 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210429102143epcas2p4c8747c09a9de28f003c20389c050394a References: <1619690903-1138-1-git-send-email-dseok.yi@samsung.com> <8c2ea41a-3fc5-d560-16e5-bf706949d857@iogearbox.net> <02bf01d74211$0ff4aed0$2fde0c70$@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 05, 2021 at 09:45:37PM -0400, Willem de Bruijn wrote: > On Wed, May 5, 2021 at 8:45 PM Dongseok Yi wrote: > > > > On Wed, May 05, 2021 at 10:55:10PM +0200, Daniel Borkmann wrote: > > > On 4/29/21 12:08 PM, Dongseok Yi wrote: > > > > tcp_gso_segment check for the size of GROed payload if it is bigger > > > > than the mss. bpf_skb_proto_6_to_4 increases mss, but the mss can be > > > > bigger than the size of GROed payload unexpectedly if data_len is not > > > > big enough. > > > > > > > > Assume that skb gso_size = 1372 and data_len = 8. bpf_skb_proto_6_to_4 > > Is this a typo and is this intended to read skb->data_len = 1380? This is not a typo. I intended skb->data_len = 8. > > The issue is that payload length (1380) is greater than mss with ipv6 > (1372), but less than mss with ipv4 (1392). > > I don't understand data_len = 8 or why the patch compares > skb->data_len to len_diff (20). skb_gro_receive(): unsigned int len = skb_gro_len(skb); [...] done: NAPI_GRO_CB(p)->count++; p->data_len += len; head_skb's data_len is the sum of skb_gro_len for each skb of the frags. data_len could be 8 if server sent a small size packet and it is GROed to head_skb. Please let me know if I am missing something. > > One simple solution if this packet no longer needs to be segmented > might be to reset the gso_type completely. I am not sure gso_type can be cleared even when GSO is needed. > > In general, I would advocate using BPF_F_ADJ_ROOM_FIXED_GSO. When > converting from IPv6 to IPv4, fixed gso will end up building packets > that are slightly below the MTU. That opportunity cost is negligible > (especially with TSO). Unfortunately, I see that that flag is > available for bpf_skb_adjust_room but not for bpf_skb_proto_6_to_4. > > > > > > would increse the gso_size to 1392. tcp_gso_segment will get an error > > > > with 1380 <= 1392. > > > > > > > > Check for the size of GROed payload if it is really bigger than target > > > > mss when increase mss. > > > > > > > > Fixes: 6578171a7ff0 (bpf: add bpf_skb_change_proto helper) > > > > Signed-off-by: Dongseok Yi > > > > --- > > > > net/core/filter.c | 4 +++- > > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/net/core/filter.c b/net/core/filter.c > > > > index 9323d34..3f79e3c 100644 > > > > --- a/net/core/filter.c > > > > +++ b/net/core/filter.c > > > > @@ -3308,7 +3308,9 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb) > > > > } > > > > > > > > /* Due to IPv4 header, MSS can be upgraded. */ > > > > - skb_increase_gso_size(shinfo, len_diff); > > > > + if (skb->data_len > len_diff) > > > > > > Could you elaborate some more on what this has to do with data_len specifically > > > here? I'm not sure I follow exactly your above commit description. Are you saying > > > that you're hitting in tcp_gso_segment(): > > > > > > [...] > > > mss = skb_shinfo(skb)->gso_size; > > > if (unlikely(skb->len <= mss)) > > > goto out; > > > [...] > > > > Yes, right > > > > > > > > Please provide more context on the bug, thanks! > > > > tcp_gso_segment(): > > [...] > > __skb_pull(skb, thlen); > > > > mss = skb_shinfo(skb)->gso_size; > > if (unlikely(skb->len <= mss)) > > [...] > > > > skb->len will have total GROed TCP payload size after __skb_pull. > > skb->len <= mss will not be happened in a normal GROed situation. But > > bpf_skb_proto_6_to_4 would upgrade MSS by increasing gso_size, it can > > hit an error condition. > > > > We should ensure the following condition. > > total GROed TCP payload > the original mss + (IPv6 size - IPv4 size) > > > > Due to > > total GROed TCP payload = the original mss + skb->data_len > > IPv6 size - IPv4 size = len_diff > > > > Finally, we can get the condition. > > skb->data_len > len_diff > > > > > > > > > + skb_increase_gso_size(shinfo, len_diff); > > > > + > > > > /* Header must be checked, and gso_segs recomputed. */ > > > > shinfo->gso_type |= SKB_GSO_DODGY; > > > > shinfo->gso_segs = 0; > > > > > > > >