From patchwork Tue May 10 03:32:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12844480 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1247FC433EF for ; Tue, 10 May 2022 03:32:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235460AbiEJDgb (ORCPT ); Mon, 9 May 2022 23:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233562AbiEJDgZ (ORCPT ); Mon, 9 May 2022 23:36:25 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 612CE179096 for ; Mon, 9 May 2022 20:32:28 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id c11so15612853plg.13 for ; Mon, 09 May 2022 20:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xzXs/zuHTV23h7UsS5AYqZN2KZ1Khfn0fAekTFBxMZ4=; b=c7n40i8M5WH/lLlh9KUi+JHDJOAPqZAXB17zwLdGDTfyNOxgoRUGy8h2sQUl3oDfxZ MatChBh5pJXhMAy2nsUjho6LvwTY9UsF4700U4ATkRGtwSqrlkysBmkCqWOa/td8cyoz VZhMGCNjfpH3DXW7qMU1AvX0nc6xvThQ2rZHubP6kO5RZyF6uu2NnSd5YmY6d0kuGR0v zKYI9fmP8SoqOfRuPQfr+DuBK190JgP/Ay+Y24uDaxnGI0nEdAauhrJJmczPY8fJNpWW VxCFEVWmUz9JdLlEHF8anCLsLb0Ce+A6trFtIkSOL8IoQv1m5ks0qSIB2kCYeMGrZxWs 2FXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xzXs/zuHTV23h7UsS5AYqZN2KZ1Khfn0fAekTFBxMZ4=; b=2QnPIaTmcrvEp7YySzWyp0QodI05FPbouVzbt8g1IBJVxWEQTYyH6twbc5VUxigPhL qqidPllF129zACUdBZwlM+XSKCapp2h003rJ9XrCpPxVNQKxFGC5Bkl/8fL2hYY9FKI2 pQml+USDwunw1qsm6ukkzTVBxcoL8XXkp0fEcIsbI6Mijz53zRfKBqqmQ/1vk0wKcV5o 7r90S9aathWYCvsAlVb1s7JpF7V9pGEyPeB3BmH/2chA0Tuo4lEYWeOmmDJgjxD+y8Th uQWQWOzW+9oqf8wf1dEhdeLT9qEBxxK9M+zm000fxwHfGpvyE+13udPq7pFll4gq/LKh S3Kw== X-Gm-Message-State: AOAM532xagXueAZ+YIXNoU3Bp0TGaWK1CKtaCRIdGF9Ra1crc4O2AZLI 9Dp94Q06jmGg1zcGRFWnjT03HMN2/a8= X-Google-Smtp-Source: ABdhPJyFbiJynlu3iQ2D4Ed9vJXgtcEk1eIX1QZcfUc2nqvjyVBwO81Wk8p4P4TjNbo/Cm2A4RKj5w== X-Received: by 2002:a17:902:e393:b0:15c:f1c1:c527 with SMTP id g19-20020a170902e39300b0015cf1c1c527mr19033228ple.22.1652153547965; Mon, 09 May 2022 20:32:27 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:5d30:4e79:203f:a909]) by smtp.gmail.com with ESMTPSA id me16-20020a17090b17d000b001d77f392280sm538185pjb.30.2022.05.09.20.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 20:32:27 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v6 net-next 03/13] net: limit GSO_MAX_SIZE to 524280 bytes Date: Mon, 9 May 2022 20:32:09 -0700 Message-Id: <20220510033219.2639364-4-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220510033219.2639364-1-eric.dumazet@gmail.com> References: <20220510033219.2639364-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Make sure we will not overflow shinfo->gso_segs Minimal TCP MSS size is 8 bytes, and shinfo->gso_segs is a 16bit field. TCP_MIN_GSO_SIZE is currently defined in include/net/tcp.h, it seems cleaner to not bring tcp details into include/linux/netdevice.h Signed-off-by: Eric Dumazet --- include/linux/netdevice.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 6150e3a7ce9dc743129d3f4f240329dd688b49a4..673c444aae874428b117df45dffcaf702ac72a47 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2262,14 +2262,17 @@ struct net_device { const struct rtnl_link_ops *rtnl_link_ops; /* for setting kernel sock attribute on TCP connection setup */ +#define GSO_MAX_SEGS 65535u #define GSO_LEGACY_MAX_SIZE 65536u -#define GSO_MAX_SIZE UINT_MAX +/* TCP minimal MSS is 8 (TCP_MIN_GSO_SIZE), + * and shinfo->gso_segs is a 16bit field. + */ +#define GSO_MAX_SIZE (8 * GSO_MAX_SEGS) unsigned int gso_max_size; #define TSO_LEGACY_MAX_SIZE 65536 #define TSO_MAX_SIZE UINT_MAX unsigned int tso_max_size; -#define GSO_MAX_SEGS 65535 u16 gso_max_segs; #define TSO_MAX_SEGS U16_MAX u16 tso_max_segs;