mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-19 08:05:27 +08:00
ipv4: fix ip_send_skb()
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 3a7c384ffd
(ipv4: tcp: unicast_sock should not
land outside of TCP stack)
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
63d02d157e
commit
b5ec8eeac4
@ -120,7 +120,7 @@ extern struct sk_buff *__ip_make_skb(struct sock *sk,
|
|||||||
struct flowi4 *fl4,
|
struct flowi4 *fl4,
|
||||||
struct sk_buff_head *queue,
|
struct sk_buff_head *queue,
|
||||||
struct inet_cork *cork);
|
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 int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4);
|
||||||
extern void ip_flush_pending_frames(struct sock *sk);
|
extern void ip_flush_pending_frames(struct sock *sk);
|
||||||
extern struct sk_buff *ip_make_skb(struct sock *sk,
|
extern struct sk_buff *ip_make_skb(struct sock *sk,
|
||||||
|
@ -1366,9 +1366,8 @@ out:
|
|||||||
return skb;
|
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;
|
int err;
|
||||||
|
|
||||||
err = ip_local_out(skb);
|
err = ip_local_out(skb);
|
||||||
@ -1391,7 +1390,7 @@ int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Netfilter gets whole the not fragmented skb. */
|
/* Netfilter gets whole the not fragmented skb. */
|
||||||
return ip_send_skb(skb);
|
return ip_send_skb(sock_net(sk), skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -758,7 +758,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4)
|
|||||||
uh->check = CSUM_MANGLED_0;
|
uh->check = CSUM_MANGLED_0;
|
||||||
|
|
||||||
send:
|
send:
|
||||||
err = ip_send_skb(skb);
|
err = ip_send_skb(sock_net(sk), skb);
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err == -ENOBUFS && !inet->recverr) {
|
if (err == -ENOBUFS && !inet->recverr) {
|
||||||
UDP_INC_STATS_USER(sock_net(sk),
|
UDP_INC_STATS_USER(sock_net(sk),
|
||||||
|
Loading…
Reference in New Issue
Block a user