Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 6af88da

Browse files
committed
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: David S. Miller <[email protected]>
1 parent 2f16270 commit 6af88da

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

net/l2tp/l2tp_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,12 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
10601060
IPSKB_REROUTED);
10611061
nf_reset(skb);
10621062

1063+
bh_lock_sock(sk);
1064+
if (sock_owned_by_user(sk)) {
1065+
dev_kfree_skb(skb);
1066+
goto out_unlock;
1067+
}
1068+
10631069
/* Get routing info from the tunnel socket */
10641070
skb_dst_drop(skb);
10651071
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
11061112
l2tp_skb_set_owner_w(skb, sk);
11071113

11081114
l2tp_xmit_core(session, skb, data_len);
1115+
out_unlock:
1116+
bh_unlock_sock(sk);
11091117

11101118
abort:
11111119
return 0;

0 commit comments

Comments
 (0)