]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ovpn: hold peer before scheduling keepalive work
authorShuvam Pandey <shuvampandey1@gmail.com>
Sat, 23 May 2026 14:53:27 +0000 (20:38 +0545)
committerAntonio Quartulli <antonio@openvpn.net>
Mon, 20 Jul 2026 13:49:55 +0000 (15:49 +0200)
commita4710ae2e7e322fdaefb4be8604228279cfaf48c
treee5d0bd90e7794d670deae0af94a74b4907310f14
parent63bbe18fc03062f483c627838a566a707b62da79
ovpn: hold peer before scheduling keepalive work

ovpn_peer_keepalive_send() passes its peer reference to
ovpn_xmit_special(), which ultimately drops it. The keepalive scheduler
currently queues the work first and takes the reference only after
schedule_work() reports that the work was queued.

Once schedule_work() queues the item, another CPU may run the worker
before the caller gets to ovpn_peer_hold(). In that case the worker can
consume a reference that was not acquired for it, corrupting the peer
lifetime accounting.

Take the peer reference before queueing the work and drop it again when
the work was already pending.

Fixes: 3ecfd9349f40 ("ovpn: implement keepalive mechanism")
Cc: stable@vger.kernel.org
Signed-off-by: Shuvam Pandey <shuvampandey1@gmail.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
drivers/net/ovpn/peer.c