[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200111011835.GG2159@dhcp-12-139.nay.redhat.com>
Date: Sat, 11 Jan 2020 09:18:35 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: David Ahern <dsahern@...il.com>
Cc: netdev@...r.kernel.org,
Jakub Kicinski <jakub.kicinski@...ronome.com>,
"David S . Miller" <davem@...emloft.net>
Subject: Re: [PATCH net] net/route: remove ip route rtm_src_len, rtm_dst_len
valid check
On Fri, Jan 10, 2020 at 02:48:03PM -0700, David Ahern wrote:
> On 1/10/20 1:24 AM, Hangbin Liu wrote:
> > 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.
>
> kernel does not handle route gets for a range. Any output is specific to
> the prefix (192.0.2.0 in your example) so it seems to me the /24 request
> should fail.
>
OK, so we should check all the range field if NETLINK_F_STRICT_CHK supplied,
like the following patch, right?
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 87e979f2b74a..a681c5cfbf13 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3063,8 +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) ||
+ if (rtm->rtm_src_len || rtm->rtm_dst_len ||
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");
@@ -3083,12 +3082,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;
Thanks
Hangbin
Powered by blists - more mailing lists