ovpn: avoid nesting TCP transport socket locks
Subsystems (2)
PATCH v3 1/1 ovpn: avoid nesting TCP transport socket locks
From: Antonio Quartulli <[email protected]>
ovpn_tcp_send_skb() and ovpn_tcp_release() transmit while holding the transport socket spinlock. If the outer packet is routed into an ovpn interface, ovpn_tcp_send_skb() takes the spinlock of the selected peer's socket while the first one is still held. This deadlocks when it is the same socket or when two peers are routed through each other.
Defer transmission to the TX worker when the skb comes from an ovpn TCP transport socket.
Fixes 11851cbd60ea ("ovpn: implement TCP transport")
Reported-by Bernhard Schmidt <[email protected]>
Signed-off-by Antonio Quartulli <[email protected]>
---
v3:
- queue new packets behind already deferred ones to preserve ordering (Sashiko)
v2: https://lore.kernel.org/all/[email protected]/
drivers/net/ovpn/io.c | 2 +- drivers/net/ovpn/peer.h | 2 +- drivers/net/ovpn/tcp.c | 109 ++++++++++++++++++++++++++++++---------- drivers/net/ovpn/tcp.h | 2 +- 4 files changed, 85 insertions(+), 30 deletions(-)
drivers/net/ovpn/io.c +1 -1
@@ -284,7 +284,7 @@ void ovpn_encrypt_post(void *data, int ret)ovpn_udp_send_skb (peer, sock->sk, skb);break ;case IPPROTO_TCP : -ovpn_tcp_send_skb (peer, sock->sk, skb); +ovpn_tcp_send_skb (peer, sock, skb);break ;default :/* no transport configured yet */
drivers/net/ovpn/peer.h +1 -1
@@ -45,7 +45,7 @@ struct ovpn_route_key {* @tcp: keeps track of TCP specific state * @tcp.strp: stream parser context (TCP only) * @tcp.user_queue: received packets that have to go to userspace (TCP only) -* @tcp.out_queue: packets on hold while socket is taken by user (TCP only) +* @tcp.out_queue: packets deferred for later transmission (TCP only) * @tcp.tx_in_progress: true if TX is already ongoing (TCP only) * @tcp.out_msg.skb: packet scheduled for sending (TCP only) * @tcp.out_msg.offset: offset where next send should start (TCP only)
drivers/net/ovpn/tcp.c +82 -27
157 lines not on this page · raw message
drivers/net/ovpn/tcp.h +1 -1
@@ -30,7 +30,7 @@ void ovpn_tcp_socket_wait_finish(struct ovpn_socket *sock);* Required by the OpenVPN protocol in order to extract packets from * the TCP stream on the receiver side. */ -void ovpn_tcp_send_skb (struct ovpn_peer *peer,struct sock *sk, +void ovpn_tcp_send_skb (struct ovpn_peer *peer,struct ovpn_socket *sock,struct sk_buff *skb);void ovpn_tcp_tx_work (struct work_struct *work);
Signature · 8 lines
2.56.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel