mirror of
https://github.com/amnezia-vpn/amneziawg-linux-kernel-module.git
synced 2026-10-13 21:34:34 +00:00
[PR #142] fix: free old buffers and reset mods_size in jp_spec_setup #202
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#202
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/142
Author: @thebtf
Created: 2/21/2026
Status: 🔄 Open
Base:
master← Head:fix/jp-spec-setup-mods-overflow📝 Commits (1)
28eeae0fix: reset mods_size and free old buffers in jp_spec_setup📊 Changes
1 file changed (+5 additions, -2 deletions)
View changed files
📝
src/junk.c(+5 -2)📄 Description
Problem
jp_spec_setup()is called every time the AWG interface configuration changes. On repeated calls, the function allocates newspec->pktandspec->modsbuffers without freeing the old ones first and without resettingspec->mods_size. This causes:spec->mods_sizeretains its value from the previous call, causinglist_for_each_entry_reverseto write past the newly allocated buffer.Observed in production:
refill_obj_stockcrashed with page fault on corrupted kernel pointer, leading toBUG: scheduling while atomicand RCU stall persisting until manual reboot.Prior fix
Commit
87a06ff(fix: memleak in jp_spec_setup due to uninit pkt_size) addedspec->pkt_size = 0. This PR addresses the remaining issues.Fix
Free both old buffers and reset both size fields before allocating new ones:
`c
kfree(spec->pkt);
kfree(spec->mods);
spec->pkt_size = 0;
spec->mods_size = 0;
spec->pkt = kzalloc(pkt_size, GFP_KERNEL);
spec->mods = kzalloc(mods_size * sizeof(*spec->mods), GFP_KERNEL);
`
Testing
Verified on Ubuntu 24.04 (kernel 6.8.0-100-generic, amneziawg DKMS 1.0.0). Server ran stable under repeated
awg syncconfcalls without heap corruption or memory growth.@coderabbitai ignore
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.