aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2018-10-09 14:10:43 -0400
committerDavid S. Miller <davem@davemloft.net>2018-10-11 01:46:17 -0400
commitd8a66aa25405e4e3015e4e4e856ef716585d59df (patch)
treed4ff82d1d4562212944cd77b85f5207b08f830df
parent83b59b46c8efe35756cdbf7f520728d4bb95f9a6 (diff)
net/mpls: Implement handler for strict data checking on dumps
Without CONFIG_INET enabled compiles fail with: net/mpls/af_mpls.o: In function `mpls_dump_routes': af_mpls.c:(.text+0xed0): undefined reference to `ip_valid_fib_dump_req' The preference is for MPLS to use the same handler as ipv4 and ipv6 to allow consistency when doing a dump for AF_UNSPEC which walks all address families invoking the route dump handler. If INET is disabled then fallback to an MPLS version which can be tighter on the data checks. Fixes: e8ba330ac0c5 ("rtnetlink: Update fib dumps for strict data checking") Reported-by: Randy Dunlap <rdunlap@infradead.org> Reported-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/mpls/af_mpls.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 7f891ffffc05..5fe274c47c41 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -2031,6 +2031,40 @@ nla_put_failure:
2031 return -EMSGSIZE; 2031 return -EMSGSIZE;
2032} 2032}
2033 2033
2034#if IS_ENABLED(CONFIG_INET)
2035static int mpls_valid_fib_dump_req(const struct nlmsghdr *nlh,
2036 struct netlink_ext_ack *extack)
2037{
2038 return ip_valid_fib_dump_req(nlh, extack);
2039}
2040#else
2041static int mpls_valid_fib_dump_req(const struct nlmsghdr *nlh,
2042 struct netlink_ext_ack *extack)
2043{
2044 struct rtmsg *rtm;
2045
2046 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
2047 NL_SET_ERR_MSG_MOD(extack, "Invalid header for FIB dump request");
2048 return -EINVAL;
2049 }
2050
2051 rtm = nlmsg_data(nlh);
2052 if (rtm->rtm_dst_len || rtm->rtm_src_len || rtm->rtm_tos ||
2053 rtm->rtm_table || rtm->rtm_protocol || rtm->rtm_scope ||
2054 rtm->rtm_type || rtm->rtm_flags) {
2055 NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for FIB dump request");
2056 return -EINVAL;
2057 }
2058
2059 if (nlmsg_attrlen(nlh, sizeof(*rtm))) {
2060 NL_SET_ERR_MSG_MOD(extack, "Invalid data after header in FIB dump request");
2061 return -EINVAL;
2062 }
2063
2064 return 0;
2065}
2066#endif
2067
2034static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb) 2068static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb)
2035{ 2069{
2036 const struct nlmsghdr *nlh = cb->nlh; 2070 const struct nlmsghdr *nlh = cb->nlh;
@@ -2042,7 +2076,7 @@ static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb)
2042 ASSERT_RTNL(); 2076 ASSERT_RTNL();
2043 2077
2044 if (cb->strict_check) { 2078 if (cb->strict_check) {
2045 int err = ip_valid_fib_dump_req(nlh, cb->extack); 2079 int err = mpls_valid_fib_dump_req(nlh, cb->extack);
2046 2080
2047 if (err < 0) 2081 if (err < 0)
2048 return err; 2082 return err;