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/ipv4/inet_diag.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/ipv4/inet_diag.c')
-rw-r--r-- | net/ipv4/inet_diag.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 77761ac4f7bb..9cd53addb784 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -153,7 +153,7 @@ static int inet_csk_diag_fill(struct sock *sk, | |||
153 | rtattr_failure: | 153 | rtattr_failure: |
154 | nlmsg_failure: | 154 | nlmsg_failure: |
155 | skb_trim(skb, b - skb->data); | 155 | skb_trim(skb, b - skb->data); |
156 | return -1; | 156 | return -EMSGSIZE; |
157 | } | 157 | } |
158 | 158 | ||
159 | static int inet_twsk_diag_fill(struct inet_timewait_sock *tw, | 159 | static int inet_twsk_diag_fill(struct inet_timewait_sock *tw, |
@@ -209,7 +209,7 @@ static int inet_twsk_diag_fill(struct inet_timewait_sock *tw, | |||
209 | return skb->len; | 209 | return skb->len; |
210 | nlmsg_failure: | 210 | nlmsg_failure: |
211 | skb_trim(skb, previous_tail - skb->data); | 211 | skb_trim(skb, previous_tail - skb->data); |
212 | return -1; | 212 | return -EMSGSIZE; |
213 | } | 213 | } |
214 | 214 | ||
215 | static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, | 215 | static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, |
@@ -274,11 +274,14 @@ static int inet_diag_get_exact(struct sk_buff *in_skb, | |||
274 | if (!rep) | 274 | if (!rep) |
275 | goto out; | 275 | goto out; |
276 | 276 | ||
277 | if (sk_diag_fill(sk, rep, req->idiag_ext, | 277 | err = sk_diag_fill(sk, rep, req->idiag_ext, |
278 | NETLINK_CB(in_skb).pid, | 278 | NETLINK_CB(in_skb).pid, |
279 | nlh->nlmsg_seq, 0, nlh) <= 0) | 279 | nlh->nlmsg_seq, 0, nlh); |
280 | BUG(); | 280 | if (err < 0) { |
281 | 281 | WARN_ON(err == -EMSGSIZE); | |
282 | kfree_skb(rep); | ||
283 | goto out; | ||
284 | } | ||
282 | err = netlink_unicast(idiagnl, rep, NETLINK_CB(in_skb).pid, | 285 | err = netlink_unicast(idiagnl, rep, NETLINK_CB(in_skb).pid, |
283 | MSG_DONTWAIT); | 286 | MSG_DONTWAIT); |
284 | if (err > 0) | 287 | if (err > 0) |