mirror of
https://github.com/amnezia-vpn/amneziawg-linux-kernel-module.git
synced 2026-12-03 19:22:43 +07:00
[PR #272] fix: retain session keys for the maximum configured lifetime #272
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#272
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/272
Author: @YoungReckless4
Created: 10/25/2026
Status: 🔄 Open
Base:
master← Head:codex/key-lifetime-regression📝 Commits (2)
8f90300test: add native key lifetime regression coverage54a362cfix: use maximum lifetime for session key cleanup📊 Changes
4 files changed (+503 additions, -2 deletions)
View changed files
📝
src/timers.c(+3 -2)➕
tests/README.md(+67 -0)➕
tests/key-cleanup.py(+117 -0)➕
tests/key-lifetime.py(+316 -0)📄 Description
Summary
For a wide
RejectAfterTimerange such as1-210,wg_timers_session_derived()can currently scheduletimer_zero_key_materialafter just 3 seconds, while the keys should remain usable for up to 210 seconds. Snapshot the configured range withREAD_ONCEand use its upper bound, matching amneziawg-go's keychainExpireTime(). The zero/default and fixed-value cases retain their current deadlines.Add a deterministic callback test using the actual C function/range helpers with a timer/RNG shim, plus an opt-in native RX/TX integration test. The latter reproduces #227 / #240 with fresh Noise IKpsk2 sessions and deliberately ignores rehandshake requests, so rekeying cannot hide an incorrect expiration boundary.
This addresses the session-derived cleanup path, complementing the separate fixes in #238 (failed-handshake cleanup), #239 (refresh clamp), and #240 (data-path lifetime). It does not duplicate those code changes. Passing the complete native
--expect fixedsuite requires the related data-path corrections as well; this timer-only change does not fix all of #227 by itself.Evidence
key-cleanup.py --source <original src/timers.c>deterministically fails when the RNG shim selects a valid low endpoint: After: the actual patched callback passes the default, fixed, wide and maximum-range cases with both RNG endpoints:RejectAfterTime = 4.After (native, combined candidate): expiry works for
4and4-8; with1-210, RX/TX works at age 185 seconds and expires after 210 seconds. The combined candidate includes the RX/TX upper-bound change, this cleanup change, failed-handshake cleanup correction and refresh clamp. Failed initial handshakes or initial RX/TX are errors, not successful expiration tests.v3.1.20260906/4569c4c67f3a, Linux7.2.12-x64v3-xanmod1, Python 3 +cryptography. The published native script is AST-equivalent to that regression (imports split and a hash lambda rewritten as a function). The callback test compiles with-Wall -Wextra -Werror; Python compilation, Black and Ruff pass.Merge Danger
Door: two-way
The code change affects only the session-derived key-material cleanup deadline. Reverting restores the prior choice. No protocol, config-format, or UAPI changes.
Blast Radius: kernel
Wide ranges can retain key material longer than a randomly chosen low deadline, up to the existing three-times-maximum lifetime policy used by the Go implementation. Root-only integration tests use generated keys in a fresh network namespace, reject an existing namespace with their reserved name, and clean up on exit/timeout. They do not modify host routes, firewall rules, or existing peers. Callback shims validate the calculation, not kernel scheduling/concurrency.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.