public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] rtnetlink: not allow dev gro_max_size to exceed GRO_MAX_SIZE
@ 2023-05-19 17:16 Xin Long
  2023-05-19 20:43 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Xin Long @ 2023-05-19 17:16 UTC (permalink / raw)
  To: network dev; +Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Alexander Duyck

In commit 0fe79f28bfaf ("net: allow gro_max_size to exceed 65536"),
it limited GRO_MAX_SIZE to (8 * 65535) to avoid overflows, but also
deleted the check of GRO_MAX_SIZE when setting the dev gro_max_size.

Currently, dev gro_max_size can be set up to U32_MAX (0xFFFFFFFF),
and GRO_MAX_SIZE is not even used anywhere.

This patch brings back the GRO_MAX_SIZE check when setting dev
gro_max_size/gro_ipv4_max_size by users.

Fixes: 0fe79f28bfaf ("net: allow gro_max_size to exceed 65536")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/core/rtnetlink.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 653901a1bf75..59b24b184cb0 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2886,6 +2886,11 @@ static int do_setlink(const struct sk_buff *skb,
 	if (tb[IFLA_GRO_MAX_SIZE]) {
 		u32 gro_max_size = nla_get_u32(tb[IFLA_GRO_MAX_SIZE]);
 
+		if (gro_max_size > GRO_MAX_SIZE) {
+			err = -EINVAL;
+			goto errout;
+		}
+
 		if (dev->gro_max_size ^ gro_max_size) {
 			netif_set_gro_max_size(dev, gro_max_size);
 			status |= DO_SETLINK_MODIFIED;
@@ -2909,6 +2914,11 @@ static int do_setlink(const struct sk_buff *skb,
 	if (tb[IFLA_GRO_IPV4_MAX_SIZE]) {
 		u32 gro_max_size = nla_get_u32(tb[IFLA_GRO_IPV4_MAX_SIZE]);
 
+		if (gro_max_size > GRO_MAX_SIZE) {
+			err = -EINVAL;
+			goto errout;
+		}
+
 		if (dev->gro_ipv4_max_size ^ gro_max_size) {
 			netif_set_gro_ipv4_max_size(dev, gro_max_size);
 			status |= DO_SETLINK_MODIFIED;
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-21 23:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-19 17:16 [PATCH net] rtnetlink: not allow dev gro_max_size to exceed GRO_MAX_SIZE Xin Long
2023-05-19 20:43 ` Stephen Hemminger
2023-05-21 17:25   ` Eric Dumazet
2023-05-21 23:27     ` Xin Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox