* [PATCH] ipv4: fix ip_send_skb()
@ 2012-08-10 12:22 Eric Dumazet
2012-08-10 21:09 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2012-08-10 12:22 UTC (permalink / raw)
To: David Miller; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
ip_send_skb() can send orphaned skb, so we must pass the net pointer to
avoid possible NULL dereference in error path.
Bug added by commit 3a7c384ffd57 (ipv4: tcp: unicast_sock should not
land outside of TCP stack)
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/ip.h | 2 +-
net/ipv4/ip_output.c | 5 ++---
net/ipv4/udp.c | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/include/net/ip.h b/include/net/ip.h
index bd5e444..5a5d84d 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -120,7 +120,7 @@ extern struct sk_buff *__ip_make_skb(struct sock *sk,
struct flowi4 *fl4,
struct sk_buff_head *queue,
struct inet_cork *cork);
-extern int ip_send_skb(struct sk_buff *skb);
+extern int ip_send_skb(struct net *net, struct sk_buff *skb);
extern int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4);
extern void ip_flush_pending_frames(struct sock *sk);
extern struct sk_buff *ip_make_skb(struct sock *sk,
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index ec410e0..147ccc3 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1366,9 +1366,8 @@ out:
return skb;
}
-int ip_send_skb(struct sk_buff *skb)
+int ip_send_skb(struct net *net, struct sk_buff *skb)
{
- struct net *net = sock_net(skb->sk);
int err;
err = ip_local_out(skb);
@@ -1391,7 +1390,7 @@ int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4)
return 0;
/* Netfilter gets whole the not fragmented skb. */
- return ip_send_skb(skb);
+ return ip_send_skb(sock_net(sk), skb);
}
/*
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index b4c3582..6f6d1ac 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -758,7 +758,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4)
uh->check = CSUM_MANGLED_0;
send:
- err = ip_send_skb(skb);
+ err = ip_send_skb(sock_net(sk), skb);
if (err) {
if (err == -ENOBUFS && !inet->recverr) {
UDP_INC_STATS_USER(sock_net(sk),
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ipv4: fix ip_send_skb()
2012-08-10 12:22 [PATCH] ipv4: fix ip_send_skb() Eric Dumazet
@ 2012-08-10 21:09 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-08-10 21:09 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 10 Aug 2012 14:22:47 +0200
> From: Eric Dumazet <edumazet@google.com>
>
> ip_send_skb() can send orphaned skb, so we must pass the net pointer to
> avoid possible NULL dereference in error path.
>
> Bug added by commit 3a7c384ffd57 (ipv4: tcp: unicast_sock should not
> land outside of TCP stack)
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-10 21:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-10 12:22 [PATCH] ipv4: fix ip_send_skb() Eric Dumazet
2012-08-10 21:09 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).