Commit 6af88da1 authored by David S. Miller's avatar David S. Miller

l2tp: Fix locking in l2tp_core.c

l2tp_xmit_skb() must take the socket lock.  It makes use of ip_queue_xmit()
which expects to execute in a socket atomic context.

Since we execute this function in software interrupts, we cannot use the
usual lock_sock()/release_sock() sequence, instead we have to use
bh_lock_sock() and see if a user has the socket locked, and if so drop
the packet.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2f16270f
...@@ -1060,6 +1060,12 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len ...@@ -1060,6 +1060,12 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
IPSKB_REROUTED); IPSKB_REROUTED);
nf_reset(skb); nf_reset(skb);
bh_lock_sock(sk);
if (sock_owned_by_user(sk)) {
dev_kfree_skb(skb);
goto out_unlock;
}
/* Get routing info from the tunnel socket */ /* Get routing info from the tunnel socket */
skb_dst_drop(skb); skb_dst_drop(skb);
skb_dst_set(skb, dst_clone(__sk_dst_get(sk))); skb_dst_set(skb, dst_clone(__sk_dst_get(sk)));
...@@ -1106,6 +1112,8 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len ...@@ -1106,6 +1112,8 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
l2tp_skb_set_owner_w(skb, sk); l2tp_skb_set_owner_w(skb, sk);
l2tp_xmit_core(session, skb, data_len); l2tp_xmit_core(session, skb, data_len);
out_unlock:
bh_unlock_sock(sk);
abort: abort:
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment