aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2016-12-28 11:52:15 -0500
committerDavid S. Miller <davem@davemloft.net>2016-12-29 14:05:15 -0500
commit4775cc1f2d5abca894ac32774eefc22c45347d1c (patch)
treeac0f9d20f70784f778aa821c870bb0dcf3ccd6a8
parentb2eb09af7370fedc6b9d9f05762f01625438467a (diff)
rtnl: stats - add missing netlink message size checks
We miss to check if the netlink message is actually big enough to contain a struct if_stats_msg. Add a check to prevent userland from sending us short messages that would make us access memory beyond the end of the message. Fixes: 10c9ead9f3c6 ("rtnetlink: add new RTM_GETSTATS message to dump...") Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/rtnetlink.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 18b5aae99bec..75e3ea7bda08 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3898,6 +3898,9 @@ static int rtnl_stats_get(struct sk_buff *skb, struct nlmsghdr *nlh)
3898 u32 filter_mask; 3898 u32 filter_mask;
3899 int err; 3899 int err;
3900 3900
3901 if (nlmsg_len(nlh) < sizeof(*ifsm))
3902 return -EINVAL;
3903
3901 ifsm = nlmsg_data(nlh); 3904 ifsm = nlmsg_data(nlh);
3902 if (ifsm->ifindex > 0) 3905 if (ifsm->ifindex > 0)
3903 dev = __dev_get_by_index(net, ifsm->ifindex); 3906 dev = __dev_get_by_index(net, ifsm->ifindex);
@@ -3947,6 +3950,9 @@ static int rtnl_stats_dump(struct sk_buff *skb, struct netlink_callback *cb)
3947 3950
3948 cb->seq = net->dev_base_seq; 3951 cb->seq = net->dev_base_seq;
3949 3952
3953 if (nlmsg_len(cb->nlh) < sizeof(*ifsm))
3954 return -EINVAL;
3955
3950 ifsm = nlmsg_data(cb->nlh); 3956 ifsm = nlmsg_data(cb->nlh);
3951 filter_mask = ifsm->filter_mask; 3957 filter_mask = ifsm->filter_mask;
3952 if (!filter_mask) 3958 if (!filter_mask)