]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ovpn: set sk_user_data before overriding callbacks
authorRalf Lici <ralf@mandelbit.com>
Fri, 30 Jan 2026 17:32:48 +0000 (18:32 +0100)
committerAntonio Quartulli <antonio@openvpn.net>
Thu, 12 Feb 2026 14:28:56 +0000 (15:28 +0100)
commit93686c472eb7b09a51b97a096449e7092fefcd1f
tree5cf9954ade12eabebf047c45eccf65dab5b8b9f8
parentbf9cf80cab81e39701861a42877a28295ade266f
ovpn: set sk_user_data before overriding callbacks

During initialization, we override socket callbacks and set sk_user_data
to an ovpn_socket instance. Currently, these two operations are
decoupled: callbacks are overridden before sk_user_data is set. While
existing callbacks perform safety checks for NULL or non-ovpn
sk_user_data, this condition causes a "half-formed" state where valid
packets arriving during attachment trigger error logs (e.g., "invoked on
non ovpn socket").

Set sk_user_data before overriding the callbacks so that it can be
accessed safely from them. Since we already check that the socket has no
sk_user_data before setting it, this remains safe even if an interrupt
accesses the socket after sk_user_data is set but before the callbacks
are overridden.

This also requires initializing all protocol-specific fields (such as
tcp_tx_work and peer links) before calling ovpn_socket_attach, ensuring
the ovpn_socket is fully formed before it becomes visible to any
callback.

Fixes: f6226ae7a0cd ("ovpn: introduce the ovpn_socket object")
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
drivers/net/ovpn/socket.c
drivers/net/ovpn/tcp.c
drivers/net/ovpn/udp.c