mirror of
https://github.com/amnezia-vpn/amneziawg-linux-kernel-module.git
synced 2026-12-03 19:22:43 +07:00
[PR #273] fix: harden obfuscation updates and handshake error handling #273
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#273
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?
📋 Pull Request Information
Original PR: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/pull/273
Author: @YoungReckless4
Created: 10/29/2026
Status: 🔄 Open
Base:
master← Head:codex/awg31-kernel-hardening📝 Commits (1)
293ce22fix: harden obfuscation updates and handshake error handling📊 Changes
15 files changed (+734 additions, -60 deletions)
View changed files
📝
src/device.c(+1 -1)📝
src/device.h(+2 -1)📝
src/header_protection.c(+12 -8)📝
src/header_protection.h(+3 -2)📝
src/junk.c(+33 -28)📝
src/netlink.c(+42 -13)📝
src/receive.c(+1 -1)📝
src/send.c(+11 -6)📝
src/type.h(+8 -0)➕
tests/README.md(+83 -0)➕
tests/build-hardening-kernel.sh(+27 -0)➕
tests/cps-parser.py(+78 -0)➕
tests/cps-shim.h(+60 -0)➕
tests/hardening-vm.py(+97 -0)➕
tests/kernel-hardening.py(+276 -0)📄 Description
Summary
Obfuscation configuration errors and allocation failures can corrupt memory or crash the kernel. HPK packet reception also acquires a sleeping lock from the UDP receive path.
The malformed-CPS and invalid-range cases enter through administrative netlink configuration.
Reject reversed device/peer ranges through netlink, including partial Jmin/Jmax updates. Preserve valid settings, packet encoding and the configured junk sequence; an allocation failure defers the attempt rather than omitting configured junk packets.
Evidence
v3.1.20260906fails all three native regression cases for range validation, CPS update preservation and HPK RX locking. The debug kernel reportsBUG: sleeping function called from invalid contextandInvalid wait contextinawg_header_protection_init.After: all six native cases pass in an offline, two-vCPU Linux 6.6.87 QEMU VM with KASAN, lockdep and DEBUG_ATOMIC_SLEEP. They include bidirectional traffic in ordinary WireGuard, legacy AWG and HPK-enabled AWG 3.1 modes.
After: the same injection is consumed, the attempt retries automatically, and all six configured junk packets precede the handshake. No BUG/KASAN/Oops/RCU diagnostics.
After: four ASan/UBSan groups pass, including aggregate limits and every allocation-failure point.
7.2.13-x64v3-xanmod1(Clang 21). This change applies alongside the existing RejectAfterTime patch; that separate patch is not included here.Reproduction helpers and their limits are documented in
tests/README.md. The tests do not establish a cause for historical client stalls or measure production/mobile-network reliability.Merge Danger
Door: two-way
Revert the module change to roll back; no database or client-key migration is required.
Blast Radius: networking
Changes affect HPK locking, CPS configuration publication and handshake retries. Reversed ranges and CPS packets exceeding the IPv4 UDP payload limit now fail explicitly. Valid packet formats and configured obfuscation parameters remain unchanged.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.