Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp913621pxy; Wed, 5 May 2021 17:52:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfZ9riIBMBNBgTjT0903j7mgr1JrZiz8WgrR4IDzVdzllm7cj+G0i0bloIrwAbDf6UpCj8 X-Received: by 2002:a17:906:f42:: with SMTP id h2mr1488396ejj.317.1620262342226; Wed, 05 May 2021 17:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620262342; cv=none; d=google.com; s=arc-20160816; b=HAc1G9NiOWfqyQLvhGk/sULLvVbDeFOHLFBxwRQF/v0nnc0W2oQubTdP9kc3x8+nfC swMhon2mBzrwXmnnMiTNbPRORRrvNDB8cLMrPsjolWaB+d7fqEZnCEInqTJ/8K4EjvM8 3FjjxBiIUGKESoSdpXN6Bpy90nXuiOzE08wnXs5TSlwCk121JgsRs4q/B6IJy3HtEdh7 bnDyyuUZ6OcZuaX67y425isabj+usdQywPj5qqUnisKKbY+Vb9OrBueTccpBiWJRMtm1 FNHlN+eJRDj4JMSa2GKHP4BIssWDvn2omV2kz1wJSGpCeeYEkGgwSUChNoWTvxRmAIhd Id7Q== 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=CiOK3qGZ7nBWoEAHSm+8G1elh3nIWvLZdgFSdlkXHcE=; b=yaNvrn0dVs/ti5TfEPG3um4h4HG6pX7CTtLVw7F+8G/PSPdAK1Ih7cfN/0SxHLO9gK VeToRZoU6U8Fl/M/+tzi/NBOEXJDEa3WBESeXS67iDHs67d0ny8x9klgReoh+HRq56Hv HpC/aMachgt3U+N/LIGlafAhjBSH5SZgCt9d9SKEDmdhrsp3iNBm3OhjsBHCFcIv8OHt jjvsv6rJ8VdGe3DagsmRD2BKiSOCX+oVH10v7gmutx0SjhE+gArx5WJfIl0sD18n3rCG /z2Y0nTyYFL5mznUUpZO1mBHfd5iK0ItvHplrcFRAjh/syqF1Ckp3pR5zMg4+sT7XIGO 37QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=gvxJMo7d; 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 t6si794458eji.728.2021.05.05.17.51.58; Wed, 05 May 2021 17:52:22 -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=gvxJMo7d; 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 S229916AbhEFAqK (ORCPT + 99 others); Wed, 5 May 2021 20:46:10 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:35574 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229867AbhEFAqJ (ORCPT ); Wed, 5 May 2021 20:46:09 -0400 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210506004510epoutp03eef4e2d763c023c76d0b7f7e4822d980~8U5_bsR9W0428104281epoutp03P for ; Thu, 6 May 2021 00:45:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210506004510epoutp03eef4e2d763c023c76d0b7f7e4822d980~8U5_bsR9W0428104281epoutp03P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1620261910; bh=CiOK3qGZ7nBWoEAHSm+8G1elh3nIWvLZdgFSdlkXHcE=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=gvxJMo7d1beHIupqu5lrZmc9blb3ljuNP6jauNtfhsDDpfIcYbrbvpLQ4nRKRn6gw BntHVRfJrdLcs6mVT3LSmJbXo1r2ESqmHfy2pwEwf2wSuPaSONdAtVaje6flra2NNn h/QaFUHY39PMp86Ma8aHHCWRivzJ7FBIyOVNUkgY= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20210506004510epcas2p2b2d6f174318e9894fc6b022182bd4c93~8U59x0lO-1290612906epcas2p2k; Thu, 6 May 2021 00:45:10 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.40.188]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4FbFGr6TBCz4x9QJ; Thu, 6 May 2021 00:45:08 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 3A.CF.09604.41C33906; Thu, 6 May 2021 09:45:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20210506004508epcas2p18bf556bc66604f19e3613badc48e5831~8U5763EJr2032920329epcas2p1e; Thu, 6 May 2021 00:45:08 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210506004508epsmtrp1ff420a29a508c8a748ca8e7a68e547db~8U575_u9x0403004030epsmtrp1j; Thu, 6 May 2021 00:45:08 +0000 (GMT) X-AuditID: b6c32a45-38939a8000002584-0f-60933c1449ee Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id C9.46.08163.41C33906; Thu, 6 May 2021 09:45:08 +0900 (KST) Received: from KORDO035731 (unknown [12.36.185.47]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210506004507epsmtip1cab4cc63a47d8d01d1d811ad76a2c1a4~8U57rMT1Y0420704207epsmtip1T; Thu, 6 May 2021 00:45:07 +0000 (GMT) From: "Dongseok Yi" To: "'Daniel Borkmann'" , Cc: "'Alexei Starovoitov'" , "'Andrii Nakryiko'" , "'Martin KaFai Lau'" , "'Song Liu'" , "'Yonghong Song'" , "'John Fastabend'" , "'KP Singh'" , "'David S. Miller'" , "'Jakub Kicinski'" , , , In-Reply-To: <8c2ea41a-3fc5-d560-16e5-bf706949d857@iogearbox.net> Subject: RE: [PATCH bpf] bpf: check for data_len before upgrading mss when 6 to 4 Date: Thu, 6 May 2021 09:45:07 +0900 Message-ID: <02bf01d74211$0ff4aed0$2fde0c70$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Content-Language: ko Thread-Index: AQKypHYW3xad5/j2XvChPebQmKG2owG+YoocAqFpyMuo+9TVEA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDJsWRmVeSWpSXmKPExsWy7bCmqa6IzeQEg4+ztS2+/57NbPHl5212 i89HjrNZLF74jdlizvkWFoumHSuYLF58eMJo8XxfL5PFhW19rBaXd81hszi2QMzi5+EzzBaL f24Aqlgyg9GBz2PLyptMHhOb37F77Jx1l92j68YlZo9NqzrZPD5vkgtgi8qxyUhNTEktUkjN S85PycxLt1XyDo53jjc1MzDUNbS0MFdSyEvMTbVVcvEJ0HXLzAG6VkmhLDGnFCgUkFhcrKRv Z1OUX1qSqpCRX1xiq5RakJJTYGhYoFecmFtcmpeul5yfa2VoYGBkClSZkJNx4+oDxoK5IhVH Fl9nb2DczN/FyMkhIWAiseNSA0sXIxeHkMAORomrv54yQzifGCV6Xs1mA6kSEvjMKPH0tz5M x/H9s1khinYxS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1l92j68YlZo9NqzrZPD5vkgtgi+KySUnNySxLLdK3 S+DKuHH1AWPBXJGKI4uvszcwbubvYuTkkBAwkTi+fzZrFyMXh5DADkaJZxuvsncxcgAlJCR2 bXaFqBGWuN9yBKrmGaPElO4eZpAEm4CWxJtZ7awg9SIC7hLbjheD1DALXGWW2LBxBVTDKUaJ lTt/soM0cAo4Shyf/AmsWVggUKL/3y1GEJtFQEXi2aM5rCA2r4ClxPHDX5khbEGJkzOfsIDY zALaEr0PWxkhbHmJ7W/nMENcpyDx8+kyVoi4iMTszjawuIiAk8S1y0cYJzAKz0IyahaSUbOQ jJqFpH0BI8sqRsnUguLc9NxiwwKjvNRyveLE3OLSvHS95PzcTYzg6NTS2sG4Z9UHvUOMTByM hxglOJiVRHgL1vYnCPGmJFZWpRblxxeV5qQWH2KU5mBREue90HUyXkggPbEkNTs1tSC1CCbL xMEp1cDkYZCmb9/wZ5eb9D8es0+iER8WFGX8WRSdLr5gmf9WDu0HLy1f8m05nBmuMIP/sZS6 qojBJIdF6oVPS3frMVknx5e2vOYq9QypYEn5c5rr4DnTldkl18y+3HSb2XZKWSXknOyBrw1B 7rMtbv0N/bRsdkjtk0+/n35wMDG3Wf32ldkilu7Z8mfmZDsksgTsCc6zn3PQlvOV3MF0dZP9 K/NrYy77xCdzH7pYXf737sp13QdLJyzbZciUmXa+4urpLqXg0tmzlP/ocegW1l/61qCUW5m9 fu4imU3850uN9hV1ZNW1Niq90uIqu3vmb7dnL4totF/yl+mFV06nPrO/Z8Cp+uFyxdlLbaLB 036Vr1JiKc5INNRiLipOBABIWw+cPQMAAA== X-CMS-MailID: 20210506004508epcas2p18bf556bc66604f19e3613badc48e5831 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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; > >