diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2012-03-04 07:32:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-03-04 22:02:55 -0500 |
commit | a4b64fbe482c7766f7925f03067fc637716bfa3f (patch) | |
tree | e2e447e8f37092eaccc914ffb6d3eea455cd56fa /net | |
parent | 709e1b5cd9e1915ad4f6c470ebf6b55d4a911d8c (diff) |
rtnetlink: fix rtnl_calcit() and rtnl_dump_ifinfo()
nlmsg_parse() might return an error, so test its return value before
potential random memory accesses.
Errors introduced in commit 115c9b81928 (rtnetlink: Fix problem with
buffer allocation)
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Greg Rose <gregory.v.rose@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/rtnetlink.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 606a6e8f3671..f965dce6f20f 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -1060,11 +1060,12 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) | |||
1060 | rcu_read_lock(); | 1060 | rcu_read_lock(); |
1061 | cb->seq = net->dev_base_seq; | 1061 | cb->seq = net->dev_base_seq; |
1062 | 1062 | ||
1063 | nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX, | 1063 | if (nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX, |
1064 | ifla_policy); | 1064 | ifla_policy) >= 0) { |
1065 | 1065 | ||
1066 | if (tb[IFLA_EXT_MASK]) | 1066 | if (tb[IFLA_EXT_MASK]) |
1067 | ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]); | 1067 | ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]); |
1068 | } | ||
1068 | 1069 | ||
1069 | for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { | 1070 | for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { |
1070 | idx = 0; | 1071 | idx = 0; |
@@ -1900,10 +1901,11 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
1900 | u32 ext_filter_mask = 0; | 1901 | u32 ext_filter_mask = 0; |
1901 | u16 min_ifinfo_dump_size = 0; | 1902 | u16 min_ifinfo_dump_size = 0; |
1902 | 1903 | ||
1903 | nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX, ifla_policy); | 1904 | if (nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX, |
1904 | 1905 | ifla_policy) >= 0) { | |
1905 | if (tb[IFLA_EXT_MASK]) | 1906 | if (tb[IFLA_EXT_MASK]) |
1906 | ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]); | 1907 | ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]); |
1908 | } | ||
1907 | 1909 | ||
1908 | if (!ext_filter_mask) | 1910 | if (!ext_filter_mask) |
1909 | return NLMSG_GOODSIZE; | 1911 | return NLMSG_GOODSIZE; |