[PR #236] fix: handle junk buffer allocation failure #250

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

📋 Pull Request Information

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

Base: master ← Head: fix/junk-buffer-allocation


📝 Commits (1)

  • 97ae2af fix: handle junk buffer allocation failure

📊 Changes

1 file changed (+9 additions, -7 deletions)

View changed files

📝 src/send.c (+9 -7)

📄 Description

Summary

Check the dummy junk packet buffer allocation before using it during
handshake initiation.

Previously kzalloc(wg->jmax, GFP_KERNEL) was dereferenced unconditionally.
If the allocation failed under memory pressure, the following
get_random_bytes() call would operate on a NULL buffer.

With this change, dummy junk packets are skipped for that handshake attempt
when the allocation fails, while the actual handshake initiation continues
normally.

Scope

This PR addresses only the unchecked junk-buffer allocation reported in #225.

The Jmin > Jmax range issue is handled separately in #235, and the ispec
teardown ordering issue is handled in #234.

A broader earlier attempt in #188 included a similar allocation check together
with unrelated fixes; this PR intentionally isolates just this send-path
allocation failure.

Related to #225


🔄 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/236 **Author:** [@HeisLuka](https://github.com/HeisLuka) **Created:** 9/14/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/junk-buffer-allocation` --- ### 📝 Commits (1) - [`97ae2af`](https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/commit/97ae2af94f2adc1f36ebbcfc07a0824be49c8a16) fix: handle junk buffer allocation failure ### 📊 Changes **1 file changed** (+9 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/send.c` (+9 -7) </details> ### 📄 Description ## Summary Check the dummy junk packet buffer allocation before using it during handshake initiation. Previously `kzalloc(wg->jmax, GFP_KERNEL)` was dereferenced unconditionally. If the allocation failed under memory pressure, the following `get_random_bytes()` call would operate on a NULL buffer. With this change, dummy junk packets are skipped for that handshake attempt when the allocation fails, while the actual handshake initiation continues normally. ## Scope This PR addresses only the unchecked junk-buffer allocation reported in #225. The `Jmin > Jmax` range issue is handled separately in #235, and the ispec teardown ordering issue is handled in #234. A broader earlier attempt in #188 included a similar allocation check together with unrelated fixes; this PR intentionally isolates just this send-path allocation failure. Related to #225 --- <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#250
No description provided.