NICMx / Jool

SIIT and NAT64 for Linux
GNU General Public License v2.0
328 stars 66 forks source link

Memory leak on `modprobe -r` #320

Closed ydahhrk closed 4 years ago

ydahhrk commented 4 years ago
$ sudo modprobe jool
$ sudo jool instance add --i -6 64:ff9b::/96
$ sudo jool pool4 add 192.0.2.1 80 --tcp
$ sudo jool bib add 2001:db8::1#80 192.0.2.1#80
$ sudo dmesg -C
$ sudo modprobe -r jool
$ dmesg -t
=============================================================================
BUG bib_nodes (Tainted: G    B      OE    ): Objects remaining in bib_nodes on __kmem_cache_shutdown()
-----------------------------------------------------------------------------

INFO: Slab 0x000000006d1f3be4 objects=42 used=1 fp=0x00000000be60edc0 flags=0xfffffc0000200
CPU: 0 PID: 8419 Comm: modprobe Tainted: G    B      OE     5.5.0-050500-generic #202001262030
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
Call Trace:
 dump_stack+0x6d/0x9a
 slab_err+0xb7/0xdc
 ? free_cpumask_var+0x9/0x10
 ? on_each_cpu_cond_mask+0xb1/0x130
 __kmem_cache_shutdown.cold+0x30/0x100
 shutdown_cache+0x18/0x1d0
 kmem_cache_destroy+0x243/0x260
 bib_teardown+0x15/0x30 [jool_common]
 jool_nat64_put+0x53/0xa0 [jool_common]
 nat64_exit+0x23/0xfe3 [jool]
 __x64_sys_delete_module+0x147/0x2b0
 ? exit_to_usermode_loop+0xea/0x160
 do_syscall_64+0x57/0x1b0
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f82071a81b7
Code: 73 01 c3 48 8b 0d d1 8c 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d a1 8c 2c 00 f7 d8 64 89 01 48
RSP: 002b:00007ffded271fe8 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
RAX: ffffffffffffffda RBX: 00005608bfa00650 RCX: 00007f82071a81b7
RDX: 0000000000000000 RSI: 0000000000000800 RDI: 00005608bfa006b8
RBP: 00005608bfa00650 R08: 00007ffded270f91 R09: 0000000000000000
R10: 00007f8207224cc0 R11: 0000000000000206 R12: 00005608bfa006b8
R13: 0000000000000001 R14: 00005608bfa006b8 R15: 00007ffded2733d0
INFO: Object 0x00000000a86ead72 @offset=0
kmem_cache_destroy bib_nodes: Slab cache still has objects
CPU: 0 PID: 8419 Comm: modprobe Tainted: G    B      OE     5.5.0-050500-generic #202001262030
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
Call Trace:
 dump_stack+0x6d/0x9a
 kmem_cache_destroy.cold+0x15/0x1a
 bib_teardown+0x15/0x30 [jool_common]
 jool_nat64_put+0x53/0xa0 [jool_common]
 nat64_exit+0x23/0xfe3 [jool]
 __x64_sys_delete_module+0x147/0x2b0
 ? exit_to_usermode_loop+0xea/0x160
 do_syscall_64+0x57/0x1b0
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f82071a81b7
Code: 73 01 c3 48 8b 0d d1 8c 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d a1 8c 2c 00 f7 d8 64 89 01 48
RSP: 002b:00007ffded271fe8 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
RAX: ffffffffffffffda RBX: 00005608bfa00650 RCX: 00007f82071a81b7
RDX: 0000000000000000 RSI: 0000000000000800 RDI: 00005608bfa006b8
RBP: 00005608bfa00650 R08: 00007ffded270f91 R09: 0000000000000000
R10: 00007f8207224cc0 R11: 0000000000000206 R12: 00005608bfa006b8
R13: 0000000000000001 R14: 00005608bfa006b8 R15: 00007ffded2733d0
NAT64 Jool v4.0.7.1 module removed.
Jool: Deleted instance 'default'.
Jool: Core Jool v4.0.7.1 module removed.

It's a bad cleanup. Only happens during modprobe -r; it will not exhaust memory during normal operation. Was first introduced in Jool 4.0.6.

Temporal workaround: Delete all NAT64 instances before running modprobe -r jool, delete all SIIT instances before running modprobe -r jool_siit.

ydahhrk commented 4 years ago

Oops; Bad type tag.