[PR #239] fix: clamp negative receive key refresh timeout #252

Open
opened 2026-10-13 21:08:00 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/pull/239
Author: @HeisLuka
Created: 9/14/2026
Status: 🔄 Open

Base: master ← Head: fix/clamp-key-fresh-timeout


📝 Commits (1)

  • 6081f62 fix: clamp negative receive key refresh timeout

📊 Changes

1 file changed (+3 additions, -1 deletions)

View changed files

📝 src/receive.c (+3 -1)

📄 Description

## Summary

Clamp the receive-side key refresh timeout at zero before passing it to
`wg_birthdate_has_expired()`.

`key_fresh_timeout()` subtracts `KeepaliveTimeout` and `RekeyTimeout` from
`RejectAfterTime`. For configurations where the result is negative, that
signed value is later passed to `wg_birthdate_has_expired()`, which accepts an
unsigned timeout.

As a result, a negative timeout can become a very large unsigned value instead
of causing an immediate key refresh.

This change clamps the calculated timeout to zero, matching the behavior of
`amneziawg-go`, which uses:

```go
max(0, rejectAfterTime-keepaliveTimeout-rekeyTimeout)

Scope

This PR addresses only problem 3 from #227.

The data-path RejectAfterTime expiration checks are intentionally left for a
separate change.

Related to #227


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/pull/239 **Author:** [@HeisLuka](https://github.com/HeisLuka) **Created:** 9/14/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/clamp-key-fresh-timeout` --- ### 📝 Commits (1) - [`6081f62`](https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/commit/6081f6251288d59356ee541dcfedf377d553f5eb) fix: clamp negative receive key refresh timeout ### 📊 Changes **1 file changed** (+3 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/receive.c` (+3 -1) </details> ### 📄 Description ````md ## Summary Clamp the receive-side key refresh timeout at zero before passing it to `wg_birthdate_has_expired()`. `key_fresh_timeout()` subtracts `KeepaliveTimeout` and `RekeyTimeout` from `RejectAfterTime`. For configurations where the result is negative, that signed value is later passed to `wg_birthdate_has_expired()`, which accepts an unsigned timeout. As a result, a negative timeout can become a very large unsigned value instead of causing an immediate key refresh. This change clamps the calculated timeout to zero, matching the behavior of `amneziawg-go`, which uses: ```go max(0, rejectAfterTime-keepaliveTimeout-rekeyTimeout) ```` ## Scope This PR addresses only problem 3 from #227. The data-path `RejectAfterTime` expiration checks are intentionally left for a separate change. Related to #227 ``` ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-linux-kernel-module#252
No description provided.