Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1322257lkv; Thu, 29 Apr 2021 03:22:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBl/NaOuOC1pdY2EC26cxkYQvbfMnLgxb1fxcmVyxZH6WTb8ExgpITLnFdAgmwf4fRuprf X-Received: by 2002:a65:4048:: with SMTP id h8mr4701647pgp.123.1619691760090; Thu, 29 Apr 2021 03:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619691760; cv=none; d=google.com; s=arc-20160816; b=SARXUP5ldgmpsmXNi/TRkILvlAUKl6+bvBgvO+sRoxKXr+Uex2F77n4lD6VHFA4a9g 6+z3lw+sq51sCp16dJQW/CkIgkoNVKzf42iBVI9rV0D0gl94q4I3gm3P3HBMelaDaLRv GuKAHQV1IxEiJuptRAYxkloKyCu9lD3iJyBJw76Ayo8q+kWGKcUsa67V8UpqBBUWAZHN FJIDru0IqcIfJFVsLmWJ9aZgkoRSP+s3GKRtYeMIIh7EXJvpjFE5ESqJYC7rpdWGW+Rq XRWQKV3VjtrXyLU7f3/6tzDCoPA1q7t+LrMhaWcy+NGbKKJqyREO1a4EvgfmU3D+59AR E2aQ== 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:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=qvvGTSpuXSrZtizggQL76UqiLnmybbPMcVCYW4PRp8U=; b=XxOIW6c2FMKPMcHQdbGuZVt8SDGMqO9ivvMepqa5zgtxbOtw+4LotBDKDlxbfHiSRM nsQxPJ/TAGEXnwE5yrOvIe7U9C2iSPp8gHZh9kUidOPUJE9CH2CZV29FG1E1qRGnoZwQ sPEOnGIS37B0YfR6Wowj/uNJb+5h2cxUIq3TfoEGdKbkO+PweM65BSJGWUBqVWWXXhxq SfsysQQznbrgCLmgvFqIdEALqdyzD0ANQQpc8UJqJIhOMz0LOd+rQwwj4X/u8vq42eEi WDQ2BMctGytBe2LvhN6grQz6TkmE8xGRtfQx8Cszyffp17r4Ie5HMlBHXrWU3kW4mdFH jBtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=OI+QhfWl; 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 d20si3125554pgi.311.2021.04.29.03.22.26; Thu, 29 Apr 2021 03:22:40 -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=OI+QhfWl; 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 S240363AbhD2KWe (ORCPT + 99 others); Thu, 29 Apr 2021 06:22:34 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:16570 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237774AbhD2KWd (ORCPT ); Thu, 29 Apr 2021 06:22:33 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210429102145epoutp023e6e181cb512180fd200ed0ba347d07d~6TQZjHhIM0141601416epoutp02g for ; Thu, 29 Apr 2021 10:21:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210429102145epoutp023e6e181cb512180fd200ed0ba347d07d~6TQZjHhIM0141601416epoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1619691705; bh=qvvGTSpuXSrZtizggQL76UqiLnmybbPMcVCYW4PRp8U=; h=From:To:Cc:Subject:Date:References:From; b=OI+QhfWleKdc3NdMtqWVlNv/raS3+0xkQ9/78OuyB9muuNA7NIdUFXnZ2o2L8zl3e y0AVdrFVhak6hZrmzmt/trKbnk1lfv0CHDmmlE6H+3lfTVxnrAB2ofY5AUIcuhF1Ht R7iiroTcXdPVoB/mSG+inMEvIGFh7EeJzM50pCh0= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20210429102145epcas2p1527c0ca6f17df83a2ea754dd54b36dce~6TQY7zRHr0094500945epcas2p1T; Thu, 29 Apr 2021 10:21:45 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.40.190]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4FWBPM5nFxz4x9Q3; Thu, 29 Apr 2021 10:21:43 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 0A.D4.09433.7B88A806; Thu, 29 Apr 2021 19:21:43 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20210429102143epcas2p4c8747c09a9de28f003c20389c050394a~6TQXNHUkO1667016670epcas2p40; Thu, 29 Apr 2021 10:21:43 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210429102143epsmtrp1e70eec154bd490fe7419c00b0a701a1b~6TQXLU3Q22489024890epsmtrp1_; Thu, 29 Apr 2021 10:21:43 +0000 (GMT) X-AuditID: b6c32a47-f61ff700000024d9-3f-608a88b7e43d Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 93.23.08637.7B88A806; Thu, 29 Apr 2021 19:21:43 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210429102143epsmtip2a518c690a833daf0b90c4ca5b2986392~6TQW7ko2V1939219392epsmtip25; Thu, 29 Apr 2021 10:21:43 +0000 (GMT) From: Dongseok Yi To: bpf@vger.kernel.org Cc: Dongseok Yi , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf] bpf: check for data_len before upgrading mss when 6 to 4 Date: Thu, 29 Apr 2021 19:08:23 +0900 Message-Id: <1619690903-1138-1-git-send-email-dseok.yi@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNKsWRmVeSWpSXmKPExsWy7bCmhe72jq4EgxlHtS2+/57NbPHl5212 i89HjrNZLF74jdlizvkWFosr0/4wWjTtWMFk8eLDE0aL5/t6mSwubOtjtbi8aw6bxbEFYhY/ D59htnixZAajA5/HlpU3mTwmNr9j99g56y67R9eNS8wem1Z1snn0bVnF6PF5k1wAe1SOTUZq YkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7QyUoKZYk5pUCh gMTiYiV9O5ui/NKSVIWM/OISW6XUgpScAkPDAr3ixNzi0rx0veT8XCtDAwMjU6DKhJyM7dPm shUc5qzYcW4hUwPjffYuRg4OCQETiVPzHbsYuTiEBHYwSmzvOMMO4XxilFj6cxILhPONUWLW 3CNMXYycYB2LV/+CSuxllFjxYB1Uyw9GiQMvW1lAqtgENCT2v3vBCmKLCIhLLDi2gQmkiFng HLPEpflzGEESwgL+ErMfvGQGsVkEVCV+XPsE1sAr4Cyx7P9vdoh1chI3z3UygzRLCHxll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ngFrNE 98k5jCAJYQFfiYaZ38G2sQioSvy49gmsgVfAWWLZ/99QV8hJ3DzXyTyBkWcBI8MqRsnUguLc 9NxiwwLDvNRyveLE3OLSvHS95PzcTYzg8NTS3MG4fdUHvUOMTByMhxglOJiVRHh/r+tMEOJN SaysSi3Kjy8qzUktPsQozcGiJM57oetkvJBAemJJanZqakFqEUyWiYNTqoHJrCna96D0zSvH ufolTp7banuD5/ObwPZX7w6YanoZvXE7sCnzPKO+xtqfj5UfWDye7XjnVN6Hv3tns7+QT0le 9uO01Uafxqe6z47Fql6bHn/g8qPTW5tu8tutzsyIStp4/1l+q+cd1t8x8w2ieQp8Lfouvda+ v5x3H4+tierR4Cu/vnmfFbH6kfpTTTVg2l2L6gkxa2esPvW2b4Ig/9cmbeuSXe0vHl+MulRQ vnvBT4XNKUzBO5447Np40aPn9epN1/YdaOf1ml7oqF9cctv6QN26Ta633543ZXdvEfM48D2c T1GqPb2fN+bEtSi5+rDpuqZ34pXjFs4pL3W6p8usPHlR8KkDP0OS+14FnGBhUGIpzkg01GIu Kk4EANEaXsW+AgAA X-CMS-MailID: 20210429102143epcas2p4c8747c09a9de28f003c20389c050394a 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) + 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; -- 2.7.4