mirror of
https://github.com/amnezia-vpn/amneziawg-linux-kernel-module.git
synced 2026-10-13 21:34:34 +00:00
[GH-ISSUE #212] keepalive flag is read after the skb is freed (3.0.20260805) #122
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amnezia-vpn/amneziawg-linux-kernel-module#122
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wobujidao on GitHub (Aug 10, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/issues/212
Thanks for the keepalive fix in 3.0.20260805 — it does solve the old
S4 > 0case, but the new flag is read after the skb is already gone:wg_socket_send_skb_to_peer()consumes the skb on every path — that's why it savesskb_lenbefore sending — so!PACKET_CB(skb)->is_keepalivereads freed memory. When the recycled memory reads as false, the keepalive counts as data, the "no reply in 15 s" timer is armed, and the peer starts a new handshake. Every handshake ends with another keepalive, so it loops: one handshake every ~15 s for as long as the other side stays quiet. Unlike the old bug, this also happens with plainS4=0.Measured with an idle peer (120 s window, dynamic debug on, counting handshakes the server started itself):
S4=0S4=0S4=16+ header protectionBeing a use-after-free, it is timing dependent: an idle test box often hides it, a box with real traffic shows it immediately. On one of our exits a user's phone was rekeying every 15–17 s while every other peer kept the normal 120 s interval.
Reading the flag before the send fixes it — upstream WireGuard computes it before the send for the same reason:
Tested on Debian 13 / kernel 6.12 and Ubuntu / kernel 6.8.
@ValdikSS commented on GitHub (Aug 13, 2026):
Fixed in
github.com/amnezia-vpn/amneziawg-linux-kernel-module@0d5f03c543@wobujidao commented on GitHub (Aug 14, 2026):
Confirmed, thank you. We have been running the same one-liner on top of 3.0.20260805 on our exits since 2026-08-10, and the fix in
0d5f03cis identical in effect.Re-measured numbers from the report, idle peer, 120 s window, counting handshakes the server started itself:
Feel free to close this one.
@ygurov commented on GitHub (Aug 14, 2026):
Hi @wobujidao,
Yep, it was fixed by PR #213. Thanks for debugging and reporting the issue from your side but that one was faster 🥇