diff options
author | Patrick McHardy <kaber@trash.net> | 2007-02-01 02:16:40 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-02-08 15:38:41 -0500 |
commit | 26932566a42d46aee7e5d526cb34fba9380cad10 (patch) | |
tree | 3991d9209ddf2454ba4c71daccdc33951811dcf1 /net/ipv6/route.c | |
parent | 2cf6c36cb46d69057db2ebae0d8ec352e065f48b (diff) |
[NETLINK]: Don't BUG on undersized allocations
Currently netlink users BUG when the allocated skb for an event
notification is undersized. While this is certainly a kernel bug,
its not critical and crashing the kernel is too drastic, especially
when considering that these errors have appeared multiple times in
the past and it BUGs even if no listeners are present.
This patch replaces BUG by WARN_ON and changes the notification
functions to inform potential listeners of undersized allocations
using a unique error code (EMSGSIZE).
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 5f0043c30b70..f4fda80a41a2 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -2040,7 +2040,7 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | |||
2040 | 2040 | ||
2041 | nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtm), flags); | 2041 | nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtm), flags); |
2042 | if (nlh == NULL) | 2042 | if (nlh == NULL) |
2043 | return -ENOBUFS; | 2043 | return -EMSGSIZE; |
2044 | 2044 | ||
2045 | rtm = nlmsg_data(nlh); | 2045 | rtm = nlmsg_data(nlh); |
2046 | rtm->rtm_family = AF_INET6; | 2046 | rtm->rtm_family = AF_INET6; |
@@ -2111,7 +2111,8 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | |||
2111 | return nlmsg_end(skb, nlh); | 2111 | return nlmsg_end(skb, nlh); |
2112 | 2112 | ||
2113 | nla_put_failure: | 2113 | nla_put_failure: |
2114 | return nlmsg_cancel(skb, nlh); | 2114 | nlmsg_cancel(skb, nlh); |
2115 | return -EMSGSIZE; | ||
2115 | } | 2116 | } |
2116 | 2117 | ||
2117 | int rt6_dump_route(struct rt6_info *rt, void *p_arg) | 2118 | int rt6_dump_route(struct rt6_info *rt, void *p_arg) |
@@ -2222,9 +2223,12 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info) | |||
2222 | goto errout; | 2223 | goto errout; |
2223 | 2224 | ||
2224 | err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0); | 2225 | err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0); |
2225 | /* failure implies BUG in rt6_nlmsg_size() */ | 2226 | if (err < 0) { |
2226 | BUG_ON(err < 0); | 2227 | /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ |
2227 | 2228 | WARN_ON(err == -EMSGSIZE); | |
2229 | kfree_skb(skb); | ||
2230 | goto errout; | ||
2231 | } | ||
2228 | err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any()); | 2232 | err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any()); |
2229 | errout: | 2233 | errout: |
2230 | if (err < 0) | 2234 | if (err < 0) |