From patchwork Thu May 25 21:49:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13255731 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 48DC820982 for ; Thu, 25 May 2023 21:49:43 +0000 (UTC) Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39C1910FC for ; Thu, 25 May 2023 14:49:23 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-75b0b5c9eb8so19291085a.1 for ; Thu, 25 May 2023 14:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685051361; x=1687643361; 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=ualsJr250Jlatwvq3JxdtUEX7Vc86H8V8s6taY1rrr4=; b=MctaKa07SA6PnzzgGFo27OJbtiRiZ6Wcc7MVlo1DpMe91RU2F4WWHfIio+aPjNZx6M 1jZ2N4J18c8/1CS6OVxmwDu2dMjTe8ciiG6mV8MIcpzSwoblUEEWgSjUUlsS6jgd7NKN 44zrX676nbCo6k84RudSx78Cd08SbJABFQihVvpdsSMvFZWXcsBMHD+nKmU/8dtVVGQm 6CugwM9gjWZELHIBTOMJ2jaQF3/Fl9RfQ1FOIna3MAfmPomhRIMb2BEg16eeUU8fjh0F 2B009E9pab38hZnNg66uECcsQG0D7CgjNQXYVp0LybtqLB3bJIVHk8Ux4r6pnJcOBqPr oplw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685051361; x=1687643361; 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=ualsJr250Jlatwvq3JxdtUEX7Vc86H8V8s6taY1rrr4=; b=YsKQs9KfZ8CPKwwUgkKnpZDxpEd2Gz0R1yOyJQbRUVZq65smCNQoZLWq0dSwvve2DO sn2/ZEQymM9q9wwROtRrKUbwP0IAYzgILSG6+3k06hmioU2V8jQpQqHtg2yleWkyjbbN Ok28htuHPF/AJaosXI76C/Eb8x2IppkNtRzUyhpjpkLjJKdlmJqbwTfBAhJKJU+6xsRf 5W6RUPCVi2nvCjQUadmbleorTC00hXOH93Unxl/dTAuUUqiEn/OQDiE27C3xF/ZexbTH CrBr5qevvS5kG5zefIxRD40dJIGyY2xv86xx79D2itIca/i1iF6IRadJ7/O5bJasjSgI NPtQ== X-Gm-Message-State: AC+VfDyrB1sEI6AEvlpxXMDLAcs+GHOx5koY7TndFZt5Wu4j/nTQfwxE TmZMJ+Utfz05IhsK+y0fgmECImFKK+pmtg== X-Google-Smtp-Source: ACHHUZ6vbRhZz+8+ICsflj752zj/uFbqYO22G0cT3VtrXzX6SE6IfAqBjp6lJMcLiV35NDM/mPGsxw== X-Received: by 2002:ac8:7e95:0:b0:3f6:b0dc:1084 with SMTP id w21-20020ac87e95000000b003f6b0dc1084mr1241206qtj.54.1685051360840; Thu, 25 May 2023 14:49:20 -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 x7-20020ac81207000000b003f7f66d5a0esm735742qti.44.2023.05.25.14.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 14:49:20 -0700 (PDT) From: Xin Long To: network dev Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Thomas Graf , Alexander Duyck Subject: [PATCH net 1/3] rtnetlink: move validate_linkmsg into rtnl_create_link Date: Thu, 25 May 2023 17:49:15 -0400 Message-Id: <7fde1eac7583cc93bc5b1cb3b386c522b32a94c9.1685051273.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 In commit 644c7eebbfd5 ("rtnetlink: validate attributes in do_setlink()"), it moved validate_linkmsg() from rtnl_setlink() to do_setlink(). However, as validate_linkmsg() is also called in __rtnl_newlink(), it caused validate_linkmsg() being called twice when running 'ip link set'. The validate_linkmsg() was introduced by commit 1840bb13c22f5b ("[RTNL]: Validate hardware and broadcast address attribute for RTM_NEWLINK") for existing links. After adding it in do_setlink(), there's no need to call it in __rtnl_newlink(). Instead of deleting it from __rtnl_newlink(), this patch moves it to rtnl_create_link() to fix the missing validation for the new created links. Fixes: 644c7eebbfd5 ("rtnetlink: validate attributes in do_setlink()") Signed-off-by: Xin Long Reviewed-by: Simon Horman --- net/core/rtnetlink.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 653901a1bf75..d1f88ba7e391 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2377,15 +2377,13 @@ static int rtnl_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate, static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[], struct netlink_ext_ack *extack) { - if (dev) { - if (tb[IFLA_ADDRESS] && - nla_len(tb[IFLA_ADDRESS]) < dev->addr_len) - return -EINVAL; + if (tb[IFLA_ADDRESS] && + nla_len(tb[IFLA_ADDRESS]) < dev->addr_len) + return -EINVAL; - if (tb[IFLA_BROADCAST] && - nla_len(tb[IFLA_BROADCAST]) < dev->addr_len) - return -EINVAL; - } + if (tb[IFLA_BROADCAST] && + nla_len(tb[IFLA_BROADCAST]) < dev->addr_len) + return -EINVAL; if (tb[IFLA_AF_SPEC]) { struct nlattr *af; @@ -3285,6 +3283,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 +3319,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) { @@ -3534,10 +3538,6 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, m_ops = master_dev->rtnl_link_ops; } - err = validate_linkmsg(dev, tb, extack); - if (err < 0) - return err; - if (tb[IFLA_LINKINFO]) { err = nla_parse_nested_deprecated(linkinfo, IFLA_INFO_MAX, tb[IFLA_LINKINFO], From patchwork Thu May 25 21:49:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13255732 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 287A624EBE for ; Thu, 25 May 2023 21:49:44 +0000 (UTC) Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F5B11702 for ; Thu, 25 May 2023 14:49:23 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-3f7fd59bb13so10613881cf.3 for ; Thu, 25 May 2023 14:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685051362; x=1687643362; 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=2wL1AkVOAyRTlNU+Tx0ajbjL9OHVFrEnvCQlNmY/nOQ=; b=n+KLLMiPZAWZ1slEabD5htcj+OX229Q32j8QdddmBElOen4nxDLFXz243W/gLN7Qdp DtGapUyamsk5lmBXeZMtViR6BGEL1KX29WFZFSmQsHtHLv8xC/YOuVYqtVwY3djPGRQ8 al8NopYicPQwqIvnaotWKU+t2jcur0/T0MHd99CeiYx3vL9mizkMk5iOrUtK/GL9vuSO mJYg14PXmEEqJtkDcKn8a1iQjbkDGuuCFw510nyMhg3emnx0tfVXH5cxpCLNGXXa5neE hk2P2+KLMnPjNnN31CDh/bhvqGoV6PNbjxI6PaRGaePL6b8ZWM+h2oHUzmY+tEVIdZNm 7qRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685051362; x=1687643362; 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=2wL1AkVOAyRTlNU+Tx0ajbjL9OHVFrEnvCQlNmY/nOQ=; b=gTrj/6vyRUJi8fHrZiVH6BubHy6B8wKgEy7tkmmPcAbjcNkXtW2+g+YG345/XwPFZd SYdUc3GEsG4Iju7lVC0I54ZlLr08TZ8tWxghdmrek8CeJbGxsF1HwsVqvTwOWFpoCfQB 5bvOTDsfEmDbpLR9E0xyCMCedgnXbjlSXecbGJHd8DIJqTyRJgZ64ct/xHDW6BjE9Gj1 mae6eygc61HagdoxaZQn1BYhNOPGRVbp+N+E/fZ1Klttsi5A0A6GT7sRMHq6q8tIq0hL rPJzaxiXdxjmCXjXmqHivAIS4gks+qcrwxZ44jnG9k0Nuwmt9KsAchILYfa6fpr2fkVL 60WQ== X-Gm-Message-State: AC+VfDxabFTH5whgyy30VzA68QkNJ+qw5NGhe584KidO4bisx07kzuOw TiFT8vX8NLJ7Pz+flK0ZkABcXks/rnxvBA== X-Google-Smtp-Source: ACHHUZ5iBATTCITOJ0DpTJOTPeQMPVcTa3GZxApbhivV03v4H1OadzQkYPKhs/hRJqHkI3Yy9jeVyQ== X-Received: by 2002:ac8:7f51:0:b0:3f5:c257:9f13 with SMTP id g17-20020ac87f51000000b003f5c2579f13mr989553qtk.51.1685051361975; Thu, 25 May 2023 14:49:21 -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 x7-20020ac81207000000b003f7f66d5a0esm735742qti.44.2023.05.25.14.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 14:49:21 -0700 (PDT) From: Xin Long To: network dev Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Thomas Graf , Alexander Duyck Subject: [PATCH net 2/3] rtnetlink: move IFLA_GSO_ tb check to validate_linkmsg Date: Thu, 25 May 2023 17:49:16 -0400 Message-Id: <63779aa1c36d5bdcb6c004df23430372db351d46.1685051273.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 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 d1f88ba7e391..68a58d0a7b79 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[], 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]) { struct nlattr *af; int rem, err; @@ -2856,11 +2875,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; @@ -2870,11 +2884,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; @@ -2893,11 +2902,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 Thu May 25 21:49:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13255733 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 7832C24EAA for ; Thu, 25 May 2023 21:49:46 +0000 (UTC) Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A20B170D for ; Thu, 25 May 2023 14:49:24 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-3f805d07040so2268591cf.3 for ; Thu, 25 May 2023 14:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685051363; x=1687643363; 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=9b9oQQEcQI1nKAm6uixVG0PKEiMtQci0LL4e5riL3yY=; b=Hjin/XYbx7VeVEP0X3YARthb2xefjOQhQU0+Qj7YBCpxMJ13D8pVDHGrh5RTqVbkvf cW0odLnmOToygKD9ts8kqgl8Y1S1R6fxT0eWHXWKR5K6WGzi5efPGG8qMdon2dYsoTCU 1C/cJSKFdtXpuFxH9oAYUlLyU5lsmCSgSazWUNsxT3JxgXFfBlZmrP0UWcUag0eiEP1q Ur8Qs/PUfrhBksfe0EmW6a5ImbCjwRzwyVNfqRx+Z5WgNQ1vAGpgvLOo4n9oeXsb/8sx naLWvuionS5Q4uQ0Fifsf4U8kHF6qtDLXzhbAk/Td0rbFhXa0jwrGTxseJ2Oy26Vi6xf MjNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685051363; x=1687643363; 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=9b9oQQEcQI1nKAm6uixVG0PKEiMtQci0LL4e5riL3yY=; b=TPqOgxAQqsM5nomtVUcS2aY7TkcnqLNvtHtX/v/igChYw5vhwMLFUAzGLkjRrjc8wN gS/wuIFjx49l8lg0tjn0SOzmzcJW8UU1zfX+Zkspo9G6DvnphxuoR3iGpwrVfmWNrzrE Ul0FlwTonBEnPdlD13fumomHoAWFd4wOVnisAOJjSIpDjTQPeZaJBiBwe0xZ/LRR29kK 2Z2CMYzAgFex+zpt066r9OBfXv+e5orGuXx1SNx1IqN3S4IQkRZ635e2kG343+MgwLYe ASV1VFE1qZyY9HawOAMHhpTQDiGhx3Ty9lOLFzdy3U3ByvVdmm/T2ZZwmyVCQxQU6WfN HCSw== X-Gm-Message-State: AC+VfDyBCWNy/B7oZxDkfPrEpcaado6UsTcx1obR9qnaEaQ9ezeaghvH bEz8dvVf71tHYsZJ2GwTHHGXk2jTnvp56A== X-Google-Smtp-Source: ACHHUZ6SFJRhU18yCnx9kxWrc1xoOv8R64Mi9egL44gb55G9XixlOO6iIWNUplnal4eJRcB17CGOOQ== X-Received: by 2002:ac8:7d48:0:b0:3f8:364:70da with SMTP id h8-20020ac87d48000000b003f8036470damr1121880qtb.32.1685051362969; Thu, 25 May 2023 14:49:22 -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 x7-20020ac81207000000b003f7f66d5a0esm735742qti.44.2023.05.25.14.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 14:49:22 -0700 (PDT) From: Xin Long To: network dev Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Thomas Graf , Alexander Duyck Subject: [PATCH net 3/3] rtnetlink: add the missing IFLA_GRO_ tb check in validate_linkmsg Date: Thu, 25 May 2023 17:49:17 -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 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 |grep gro_max_size 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 68a58d0a7b79..4c7d84072bd4 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2398,12 +2398,24 @@ 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]) { struct nlattr *af; int rem, err;