[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220509222149.1763877-4-eric.dumazet@gmail.com>
Date: Mon, 9 May 2022 15:21:39 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: netdev <netdev@...r.kernel.org>,
Alexander Duyck <alexanderduyck@...com>,
Coco Li <lixiaoyan@...gle.com>,
Eric Dumazet <edumazet@...gle.com>,
Eric Dumazet <eric.dumazet@...il.com>
Subject: [PATCH v5 net-next 03/13] net: limit GSO_MAX_SIZE to 524280 bytes
From: Eric Dumazet <edumazet@...gle.com>
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 <edumazet@...gle.com>
---
include/linux/netdevice.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9a34cc45b20a4465a9e1532c39f410b26604144f..2ef9254a9d3a57403f510d32194d8be6730b1645 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2263,12 +2263,17 @@ struct net_device {
/* for setting kernel sock attribute on TCP connection setup */
#define GSO_LEGACY_MAX_SIZE 65536u
-#define GSO_MAX_SIZE UINT_MAX
+#define GSO_MAX_SEGS 65535u
+
+/* 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;
--
2.36.0.512.ge40c2bad7a-goog
Powered by blists - more mailing lists