From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>,
"David S . Miller" <davem@davemloft.net>,
Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCH net] net/route: remove ip route rtm_src_len, rtm_dst_len valid check
Date: Fri, 10 Jan 2020 16:24:56 +0800 [thread overview]
Message-ID: <20200110082456.7288-1-liuhangbin@gmail.com> (raw)
In patch set e266afa9c7af ("Merge branch
'net-use-strict-checks-in-doit-handlers'") we added a check for
rtm_src_len, rtm_dst_len, which will cause cmds like
"ip route get 192.0.2.0/24" failed.
There is no sense to restrict rtm_src_len, rtm_dst_len to 32 for IPv4,
or 128 for IPv6. Remove this check.
Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: d0440029831b ("net: ipv4: ipmr: perform strict checks also for doit handlers")
Fixes: a00302b60777 ("net: ipv4: route: perform strict checks also for doit handlers")
Fixes: 0eff0a274104 ("net: ipv6: route: perform strict checks also for doit handlers")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
net/ipv4/ipmr.c | 10 +---------
net/ipv4/route.c | 10 +---------
net/ipv6/route.c | 10 +---------
3 files changed, 3 insertions(+), 27 deletions(-)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 6e68def66822..293a0189ff4e 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -2500,9 +2500,7 @@ static int ipmr_rtm_valid_getroute_req(struct sk_buff *skb,
rtm_ipv4_policy, extack);
rtm = nlmsg_data(nlh);
- if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) ||
- (rtm->rtm_dst_len && rtm->rtm_dst_len != 32) ||
- rtm->rtm_tos || rtm->rtm_table || rtm->rtm_protocol ||
+ if (rtm->rtm_tos || rtm->rtm_table || rtm->rtm_protocol ||
rtm->rtm_scope || rtm->rtm_type || rtm->rtm_flags) {
NL_SET_ERR_MSG(extack, "ipv4: Invalid values in header for multicast route get request");
return -EINVAL;
@@ -2513,12 +2511,6 @@ static int ipmr_rtm_valid_getroute_req(struct sk_buff *skb,
if (err)
return err;
- if ((tb[RTA_SRC] && !rtm->rtm_src_len) ||
- (tb[RTA_DST] && !rtm->rtm_dst_len)) {
- NL_SET_ERR_MSG(extack, "ipv4: rtm_src_len and rtm_dst_len must be 32 for IPv4");
- return -EINVAL;
- }
-
for (i = 0; i <= RTA_MAX; i++) {
if (!tb[i])
continue;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 87e979f2b74a..fb36780ee415 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3063,9 +3063,7 @@ static int inet_rtm_valid_getroute_req(struct sk_buff *skb,
rtm_ipv4_policy, extack);
rtm = nlmsg_data(nlh);
- if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) ||
- (rtm->rtm_dst_len && rtm->rtm_dst_len != 32) ||
- rtm->rtm_table || rtm->rtm_protocol ||
+ if (rtm->rtm_table || rtm->rtm_protocol ||
rtm->rtm_scope || rtm->rtm_type) {
NL_SET_ERR_MSG(extack, "ipv4: Invalid values in header for route get request");
return -EINVAL;
@@ -3083,12 +3081,6 @@ static int inet_rtm_valid_getroute_req(struct sk_buff *skb,
if (err)
return err;
- if ((tb[RTA_SRC] && !rtm->rtm_src_len) ||
- (tb[RTA_DST] && !rtm->rtm_dst_len)) {
- NL_SET_ERR_MSG(extack, "ipv4: rtm_src_len and rtm_dst_len must be 32 for IPv4");
- return -EINVAL;
- }
-
for (i = 0; i <= RTA_MAX; i++) {
if (!tb[i])
continue;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index affb51c11a25..4e82d4fd1b53 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5714,9 +5714,7 @@ static int inet6_rtm_valid_getroute_req(struct sk_buff *skb,
rtm_ipv6_policy, extack);
rtm = nlmsg_data(nlh);
- if ((rtm->rtm_src_len && rtm->rtm_src_len != 128) ||
- (rtm->rtm_dst_len && rtm->rtm_dst_len != 128) ||
- rtm->rtm_table || rtm->rtm_protocol || rtm->rtm_scope ||
+ if (rtm->rtm_table || rtm->rtm_protocol || rtm->rtm_scope ||
rtm->rtm_type) {
NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for get route request");
return -EINVAL;
@@ -5732,12 +5730,6 @@ static int inet6_rtm_valid_getroute_req(struct sk_buff *skb,
if (err)
return err;
- if ((tb[RTA_SRC] && !rtm->rtm_src_len) ||
- (tb[RTA_DST] && !rtm->rtm_dst_len)) {
- NL_SET_ERR_MSG_MOD(extack, "rtm_src_len and rtm_dst_len must be 128 for IPv6");
- return -EINVAL;
- }
-
for (i = 0; i <= RTA_MAX; i++) {
if (!tb[i])
continue;
--
2.19.2
next reply other threads:[~2020-01-10 8:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 8:24 Hangbin Liu [this message]
2020-01-10 21:48 ` [PATCH net] net/route: remove ip route rtm_src_len, rtm_dst_len valid check David Ahern
2020-01-11 1:18 ` Hangbin Liu
2020-01-11 17:38 ` David Ahern
2020-01-13 6:39 ` Hangbin Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200110082456.7288-1-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).