From patchwork Wed May 31 16:01:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13262498 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF83D1772C for ; Wed, 31 May 2023 16:01:56 +0000 (UTC) Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22D5CB2 for ; Wed, 31 May 2023 09:01:49 -0700 (PDT) Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-75b14216386so386884685a.0 for ; Wed, 31 May 2023 09:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685548908; x=1688140908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/hlEU0XF/2Mqn0G2krh1FGSwitk86scNBgWmnM1kvyw=; b=Dgi4HiC/yCjCq8qNbpWUG8kLzvvyey4pTnalGnW6v6t+pZ47I5jJ8Ntvo2ILzBX71m oVfYn9ucL31etM7yXnLL00Tft5hN1BlV6QzGALalq6zaeQQXZP6GkaXKsauHu6+pA+V4 rGEQariq/JP+sNDxR8FGD99tyUdDOhzk/Po26ELCQ5QH9il4aePgFcqTsFuuorGWTufw hDWSqp2too0j3AZKq1yEZFvedwug+pVtfDzIySeO6495+aksVoRpMWHos40Z12eykOdS Z55DOC26bOdm+rOp/igq9LBtkEOJ0DBGvr3mhTDxiuZt5TlvL5uEmYgP3esn0Th/SIQ4 DukQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685548908; x=1688140908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/hlEU0XF/2Mqn0G2krh1FGSwitk86scNBgWmnM1kvyw=; b=FbUUZghKV4tCjx3gCYBZ6QnhXkWKIbqEN8AOxvroTEFlV0LuEFNgducoCKJI7xpD9c VB9x96umVmSBXuZqSiX/OyjXR2FzmL5YHEuwMYBVri6fGDlfjJ46IvIxI84pYL/TAP/E eHKYEsvIHi/a+TI/yPOHgMhUzT84yp5ZbPcZ/IvbX1JDdhrTC+rHp+1ttm6zglii3EKz VBJY4h/bwb1b45+sjmYAQpusMdZcAiARMC/V/weGziyj/Zvikso1YWfB68nH4ACEAQky 6X98E7/80FgxSw1LMDAy4FEne6VP11+DB8A8dHHC5Hh3jrul6Oz+OJNou9SQzycHYRTd Zj7A== X-Gm-Message-State: AC+VfDx2O1nTH5hqlKoRYm2CmHjECNcR5ZMVPw2c9BCwxSwewlLMCK6v KWO+FdbYUXRoStmzTElFThGNIgwjuE5C9Q== X-Google-Smtp-Source: ACHHUZ6AokcW6w70RBX1XOIszqaWYujAZWUdfJHHsgiI1Ifk2uXIPjhnfzC89gHI42zwTR/eGWbt7w== X-Received: by 2002:a05:620a:26a2:b0:75b:23a0:e7c4 with SMTP id c34-20020a05620a26a200b0075b23a0e7c4mr6444239qkp.37.1685548907964; Wed, 31 May 2023 09:01:47 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id s11-20020ae9f70b000000b007594a7aedb2sm5261050qkg.105.2023.05.31.09.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 09:01:47 -0700 (PDT) From: Xin Long To: network dev Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Stephen Hemminger , Patrick McHardy , Thomas Graf , Alexander Duyck , Simon Horman Subject: [PATCHv2 net 1/3] rtnetlink: call validate_linkmsg in rtnl_create_link Date: Wed, 31 May 2023 12:01:42 -0400 Message-Id: <88aed7f9225eee76e6bf46dc573c7a0d917d5143.1685548598.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org validate_linkmsg() was introduced by commit 1840bb13c22f5b ("[RTNL]: Validate hardware and broadcast address attribute for RTM_NEWLINK") to validate tb[IFLA_ADDRESS/BROADCAST] for existing links. The same check should also be done for newly created links. This patch adds validate_linkmsg() call in rtnl_create_link(), to avoid the invalid address set when creating some devices like: # ip link add dummy0 type dummy # ip link add link dummy0 name mac0 address 01:02 type macsec Fixes: 0e06877c6fdb ("[RTNETLINK]: rtnl_link: allow specifying initial device address") Signed-off-by: Xin Long Reviewed-by: Simon Horman --- net/core/rtnetlink.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 653901a1bf75..824688edb722 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -3285,6 +3285,7 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname, struct net_device *dev; unsigned int num_tx_queues = 1; unsigned int num_rx_queues = 1; + int err; if (tb[IFLA_NUM_TX_QUEUES]) num_tx_queues = nla_get_u32(tb[IFLA_NUM_TX_QUEUES]); @@ -3320,13 +3321,18 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname, if (!dev) return ERR_PTR(-ENOMEM); + err = validate_linkmsg(dev, tb, extack); + if (err < 0) { + free_netdev(dev); + return ERR_PTR(err); + } + dev_net_set(dev, net); dev->rtnl_link_ops = ops; dev->rtnl_link_state = RTNL_LINK_INITIALIZING; if (tb[IFLA_MTU]) { u32 mtu = nla_get_u32(tb[IFLA_MTU]); - int err; err = dev_validate_mtu(dev, mtu, extack); if (err) { From patchwork Wed May 31 16:01:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13262499 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9694D17AD4 for ; Wed, 31 May 2023 16:01:58 +0000 (UTC) Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 104E0E2 for ; Wed, 31 May 2023 09:01:50 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-75b0830e2eeso64587385a.1 for ; Wed, 31 May 2023 09:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685548909; x=1688140909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9XixacrYPdu8hpoaAamQBV+6PgyNbJudw+yfUyFQC9I=; b=JL51xSzzRTEl+APbDTePMQj+8A/I9Rhuky4LMBqqFhvBrtJ9e35daE4WkYI4I8TcIM I+LZ1uNEbui4RZNSZP2salQSgiS/osxr2GGEEngtkpfcBOiXk51dGjvipVD+U0PyipSp 7Msf8mG6GHBc1hEbM1Tsn5O399PPRXhi0CMlANmwhHdQLeukT3K6rTqtKU8xWkp2O2Tc VtvAAfkcL45KlSu7pxqeEXYRUMivfPNfnGntSj3Ujsxp8AkH4PItWqIBQZQdJbgyIsv1 rQSvvOD9ip0Z7LEW4TEheiuaj4HNE0pQIyVVWiwJ/yZkFljgUJxVEOIMXgcHy54rNAVn 3GQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685548909; x=1688140909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9XixacrYPdu8hpoaAamQBV+6PgyNbJudw+yfUyFQC9I=; b=ZTPsjJCUxC0hl78Dwsv3HbNX2+p3qj6S9GXLcogjUkTH2Exp/wQ9JvQRElLomHSl/T BaKp35yrcFCAjyKOi2jXJy5eeBtjn9Wr8hbbp40qh3NXvBzKWCXN5fGRpEPY2eT9b1WB nZtHFnS/ZJsBhaeNLu74+sSoUSM9A6Sik3QUofIJcOTQ2vczH7q/0qCMXKaVIbqmsb57 +W8F9tj6h3omGE+HtSHQFXN9Z476u2zK2UaOS2xwKyBY57Gz0xMHspDIsQPdoGTRrnl2 DarurEHphUOeygFa0/Q7ddSOuM4ekaate43QteiVTcKTHcnOjUFhNodXTjRvHLDia1f/ +Jgg== X-Gm-Message-State: AC+VfDyBRminhupibYf8f0F1dnMPtl43PnwRv3yKen2bXr2gQGEWiVDw TUJt0rwHE5/gwtFCMsBFTPeGqT2Yu0aVVQ== X-Google-Smtp-Source: ACHHUZ619nOxHzomhdx/E/6FYUNGdAC3MPdZTLsdH3mgIM5WOM46fv+CNqa9wjAOKKe+DIuM0h8pCw== X-Received: by 2002:a37:420e:0:b0:75b:23a1:d847 with SMTP id p14-20020a37420e000000b0075b23a1d847mr13983752qka.9.1685548908980; Wed, 31 May 2023 09:01:48 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id s11-20020ae9f70b000000b007594a7aedb2sm5261050qkg.105.2023.05.31.09.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 09:01:48 -0700 (PDT) From: Xin Long To: network dev Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Stephen Hemminger , Patrick McHardy , Thomas Graf , Alexander Duyck , Simon Horman Subject: [PATCHv2 net 2/3] rtnetlink: move IFLA_GSO_ tb check to validate_linkmsg Date: Wed, 31 May 2023 12:01:43 -0400 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org These IFLA_GSO_* tb check should also be done for the new created link, otherwise, they can be set to a huge value when creating links: # ip link add dummy1 gso_max_size 4294967295 type dummy # ip -d link show dummy1 dummy addrgenmode eui64 ... gso_max_size 4294967295 Fixes: 46e6b992c250 ("rtnetlink: allow GSO maximums to be set on device creation") Fixes: 9eefedd58ae1 ("net: add gso_ipv4_max_size and gro_ipv4_max_size per device") Signed-off-by: Xin Long Reviewed-by: Simon Horman --- net/core/rtnetlink.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 824688edb722..bc068a857219 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2385,6 +2385,25 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[], if (tb[IFLA_BROADCAST] && nla_len(tb[IFLA_BROADCAST]) < dev->addr_len) return -EINVAL; + + if (tb[IFLA_GSO_MAX_SIZE] && + nla_get_u32(tb[IFLA_GSO_MAX_SIZE]) > dev->tso_max_size) { + NL_SET_ERR_MSG(extack, "too big gso_max_size"); + return -EINVAL; + } + + if (tb[IFLA_GSO_MAX_SEGS] && + (nla_get_u32(tb[IFLA_GSO_MAX_SEGS]) > GSO_MAX_SEGS || + nla_get_u32(tb[IFLA_GSO_MAX_SEGS]) > dev->tso_max_segs)) { + NL_SET_ERR_MSG(extack, "too big gso_max_segs"); + return -EINVAL; + } + + if (tb[IFLA_GSO_IPV4_MAX_SIZE] && + nla_get_u32(tb[IFLA_GSO_IPV4_MAX_SIZE]) > dev->tso_max_size) { + NL_SET_ERR_MSG(extack, "too big gso_ipv4_max_size"); + return -EINVAL; + } } if (tb[IFLA_AF_SPEC]) { @@ -2858,11 +2877,6 @@ static int do_setlink(const struct sk_buff *skb, if (tb[IFLA_GSO_MAX_SIZE]) { u32 max_size = nla_get_u32(tb[IFLA_GSO_MAX_SIZE]); - if (max_size > dev->tso_max_size) { - err = -EINVAL; - goto errout; - } - if (dev->gso_max_size ^ max_size) { netif_set_gso_max_size(dev, max_size); status |= DO_SETLINK_MODIFIED; @@ -2872,11 +2886,6 @@ static int do_setlink(const struct sk_buff *skb, if (tb[IFLA_GSO_MAX_SEGS]) { u32 max_segs = nla_get_u32(tb[IFLA_GSO_MAX_SEGS]); - if (max_segs > GSO_MAX_SEGS || max_segs > dev->tso_max_segs) { - err = -EINVAL; - goto errout; - } - if (dev->gso_max_segs ^ max_segs) { netif_set_gso_max_segs(dev, max_segs); status |= DO_SETLINK_MODIFIED; @@ -2895,11 +2904,6 @@ static int do_setlink(const struct sk_buff *skb, if (tb[IFLA_GSO_IPV4_MAX_SIZE]) { u32 max_size = nla_get_u32(tb[IFLA_GSO_IPV4_MAX_SIZE]); - if (max_size > dev->tso_max_size) { - err = -EINVAL; - goto errout; - } - if (dev->gso_ipv4_max_size ^ max_size) { netif_set_gso_ipv4_max_size(dev, max_size); status |= DO_SETLINK_MODIFIED; From patchwork Wed May 31 16:01:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13262500 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6179182AA for ; Wed, 31 May 2023 16:01:59 +0000 (UTC) Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B7DD8E for ; Wed, 31 May 2023 09:01:51 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6af7d6f6f41so2936758a34.1 for ; Wed, 31 May 2023 09:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685548910; x=1688140910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2+aAf6CEo9Mvn0fPnc4Wgd4UhgHJNzVrY0YQmWkbWvc=; b=NnSPsF3DTlFdVwzZ368wo1p/KxjMThEpMVqdr+/it0n5cj4sgq2t5MSqamgYsWNmmb VckJPHIohx2p1FhVDR0WrFLvVBQdmnhZi1fwVJQZpxP8LKdE3Skk0HrHh0oqnzhjMT6+ FwFHjNWpxHYtKmFBS043C9CQZ8jeTeRsnIj10w7n3M1p4D81aebFJ1wZtIT8TbnIeMei /oAQs90dhFA8pWxZYEb09AWGQC7dof+tjYQevkfOdsITncRpoO6JtAEoIQm27zaYmNJW bB0ZlJTsAg8aAAOfFhD3LWMs10qBFDeWOKzpK3nQrIK5s6ixuEcF5fH+nQRVUC8i3x4i nLfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685548910; x=1688140910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2+aAf6CEo9Mvn0fPnc4Wgd4UhgHJNzVrY0YQmWkbWvc=; b=jYQZ7i9MSUj5OauDECCeOsdnhx32Yb7cgakjK2Jx26MNy0jMkR6FzWNbGxNPSxmhTL qdcWUYt0QQc7m/GeT9ezTk+2MH8qdgcr2Pe9ShSu3Cl2urqINPiFNsJRs7dif8LFVedC SNgEfdqyuAVGqDowUOd8CccRmUqrv8YgRApeZHspU/DC1u68a+kkNozT4l1ttW/OGwwq VqKYTRqdVfVnupIQXqieRu7Ywphcg84Zy0D8R38+ujg0h1ZAhYbNJt4bb4C4b0nIMOjm cqLxPQTKrb4pepIAIzB6dmSC9iuqH/vK8w7m6roH70AyvAWHyZe/9mpnIJhm7JDfqgYp W+VQ== X-Gm-Message-State: AC+VfDwCsQm9mB8WSqCfIHfDoxeYlYL3DFT3unAE+h6UvfVydUglJn4k iizkm7WccAUH3yi2p815yq+tMAHnWhWZVw== X-Google-Smtp-Source: ACHHUZ7Dkr6HU/2q6W3k5wH3Jka22DKQWd2/5dLb+w3NHCcnVEqFQF6lk7UIHhh6lR2mHD+wDWe+Ww== X-Received: by 2002:a05:6830:22e3:b0:6a6:4ef2:7c98 with SMTP id t3-20020a05683022e300b006a64ef27c98mr2550883otc.31.1685548909871; Wed, 31 May 2023 09:01:49 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id s11-20020ae9f70b000000b007594a7aedb2sm5261050qkg.105.2023.05.31.09.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 09:01:49 -0700 (PDT) From: Xin Long To: network dev Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Stephen Hemminger , Patrick McHardy , Thomas Graf , Alexander Duyck , Simon Horman Subject: [PATCHv2 net 3/3] rtnetlink: add the missing IFLA_GRO_ tb check in validate_linkmsg Date: Wed, 31 May 2023 12:01:44 -0400 Message-Id: <70169240cb4430a9b09e89c27ef268e772b68548.1685548598.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This fixes the issue that dev gro_max_size and gso_ipv4_max_size can be set to a huge value: # ip link add dummy1 type dummy # ip link set dummy1 gro_max_size 4294967295 # ip -d link show dummy1 dummy addrgenmode eui64 ... gro_max_size 4294967295 Fixes: 0fe79f28bfaf ("net: allow gro_max_size to exceed 65536") Fixes: 9eefedd58ae1 ("net: add gso_ipv4_max_size and gro_ipv4_max_size per device") Reported-by: Xiumei Mu Signed-off-by: Xin Long Reviewed-by: Simon Horman --- net/core/rtnetlink.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index bc068a857219..41de3a2f29e1 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2399,11 +2399,23 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[], return -EINVAL; } + if (tb[IFLA_GRO_MAX_SIZE] && + nla_get_u32(tb[IFLA_GRO_MAX_SIZE]) > GRO_MAX_SIZE) { + NL_SET_ERR_MSG(extack, "too big gro_max_size"); + return -EINVAL; + } + if (tb[IFLA_GSO_IPV4_MAX_SIZE] && nla_get_u32(tb[IFLA_GSO_IPV4_MAX_SIZE]) > dev->tso_max_size) { NL_SET_ERR_MSG(extack, "too big gso_ipv4_max_size"); return -EINVAL; } + + if (tb[IFLA_GRO_IPV4_MAX_SIZE] && + nla_get_u32(tb[IFLA_GRO_IPV4_MAX_SIZE]) > GRO_MAX_SIZE) { + NL_SET_ERR_MSG(extack, "too big gro_ipv4_max_size"); + return -EINVAL; + } } if (tb[IFLA_AF_SPEC]) {