[GH-ISSUE #253] down_read in awg_header_protection_init causes kernel complaint (kernel 4.4) #138

Open
opened 2026-10-13 21:06:54 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @achpile on GitHub (Sep 22, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/issues/253

On kernel 4.4 i'm having this:

[  354.170000] BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:21
[  354.180000] in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/2
[  354.190000] CPU: 2 PID: 0 Comm: swapper/2 Tainted: P           O    4.4.140 #1
[  354.200000] Stack : 00000000 00000000 80b66a0a 00000042 80b60000 00000000 80600000 00000009
      806d7030 8fcb1524 80771fe7 80b6374c 8a69f718 00000001 9950b3aa c0a89a44
      00000000 8007613c 00000000 00000000 80b66a0a 00000000 806db3e8 8fc33ba4
      89e5e180 800a9f98 8a69f718 89dfc8ac 00000002 00000000 8fc33ba4 806d7030
      00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      ...
[  354.240000] Call Trace:
[  354.240000] [<80018b24>] show_stack+0x2c/0x88
[  354.240000] [<801f96d0>] dump_stack+0x90/0xd0
[  354.250000] [<805c5c48>] down_read+0x24/0x38
[  354.250000] [<c47cd49c>] awg_header_protection_init+0x3c/0x15c [amneziawg]
[  354.260000] [<c47c31d8>] wg_packet_send_keepalive+0x694/0xca8 [amneziawg]
[  354.270000] [<804593a4>] fib_rules_lookup+0x1a0/0x22c
[  354.270000] [<8050e860>] __fib_lookup+0x28/0x48
[  354.280000] [<8050044c>] fib_validate_source+0x30c/0x3a4

My lack of kernel knowledge doesn't let me investigate this further.

Originally created by @achpile on GitHub (Sep 22, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/issues/253 On kernel 4.4 i'm having this: ``` [ 354.170000] BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:21 [ 354.180000] in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/2 [ 354.190000] CPU: 2 PID: 0 Comm: swapper/2 Tainted: P O 4.4.140 #1 [ 354.200000] Stack : 00000000 00000000 80b66a0a 00000042 80b60000 00000000 80600000 00000009 806d7030 8fcb1524 80771fe7 80b6374c 8a69f718 00000001 9950b3aa c0a89a44 00000000 8007613c 00000000 00000000 80b66a0a 00000000 806db3e8 8fc33ba4 89e5e180 800a9f98 8a69f718 89dfc8ac 00000002 00000000 8fc33ba4 806d7030 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ... [ 354.240000] Call Trace: [ 354.240000] [<80018b24>] show_stack+0x2c/0x88 [ 354.240000] [<801f96d0>] dump_stack+0x90/0xd0 [ 354.250000] [<805c5c48>] down_read+0x24/0x38 [ 354.250000] [<c47cd49c>] awg_header_protection_init+0x3c/0x15c [amneziawg] [ 354.260000] [<c47c31d8>] wg_packet_send_keepalive+0x694/0xca8 [amneziawg] [ 354.270000] [<804593a4>] fib_rules_lookup+0x1a0/0x22c [ 354.270000] [<8050e860>] __fib_lookup+0x28/0x48 [ 354.280000] [<8050044c>] fib_validate_source+0x30c/0x3a4 ``` My lack of kernel knowledge doesn't let me investigate this further.
Author
Owner

@achpile commented on GitHub (Sep 23, 2026):

upd: on kernel 5.15 everything is ok

<!-- gh-comment-id:5793558913 --> @achpile commented on GitHub (Sep 23, 2026): upd: on kernel 5.15 everything is ok
Author
Owner

@achpile commented on GitHub (Sep 25, 2026):

My guess is fib_validate_source runs in a non-sleeping atomic context.

github.com/amnezia-vpn/amneziawg-linux-kernel-module@4569c4c67f/src/header_protection.c (L11)

I changed it to:

if (!down_read_trylock(&p->lock))
    return res;

And it seemed to help with the issue.

<!-- gh-comment-id:5834905077 --> @achpile commented on GitHub (Sep 25, 2026): My guess is fib_validate_source runs in a non-sleeping atomic context. https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/blob/4569c4c67f3a57414969260cafbbd04694fbaae0/src/header_protection.c#L11 I changed it to: ``` if (!down_read_trylock(&p->lock)) return res; ``` And it seemed to help with the issue.
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#138
No description provided.