Kernel memory leak when using Linux system as router

I am working on two embedded Linux systems (kernel-6.2.10) both based on Toradex colibri IMX6ULL SoM (V1.1A). The first one (system A) is configured to work as a wifi access point (with hostapd), and the second (system B) is connected to this access point (with wpa_supplicant).

When I want to make an FTP data transfer from the system B to my PC through system A, I observe a memory leak into system A. This only happen in this configuration. Transferring data from system A to my PC does not show any memory leak.

It seems to be reproducible with any kind of network communication but easier to reproduce with an FTP data transfer.

Using kmemleak, it seems that the memory leak comes from the Marvell driver mwifiex :

  unreferenced object 0x83a2f540 (size 184):
  comm "kworker/0:2", pid 43, jiffies 4294947832 (age 162.950s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<802864f0>] kmem_cache_alloc+0x188/0x2c4
    [<808946f0>] __netdev_alloc_skb+0xe8/0x194
    [<7f01af44>] ieee80211_amsdu_to_8023s+0x1b0/0x498 [cfg80211]
    [<7f1528e4>] mwifiex_11n_dispatch_pkt+0x7c/0x174 [mwifiex]
    [<7f1535ac>] mwifiex_11n_rx_reorder_pkt+0x388/0x3dc [mwifiex]
    [<7f1640f4>] mwifiex_process_uap_rx_packet+0xc0/0x200 [mwifiex]
    [<7f075ee8>] mwifiex_decode_rx_packet+0x1d4/0x224 [mwifiex_sdio]
    [<7f07858c>] mwifiex_process_int_status+0x850/0xd70 [mwifiex_sdio]
    [<7f1480a4>] mwifiex_main_process+0x124/0xa30 [mwifiex]
    [<8080b9c4>] process_sdio_pending_irqs+0xe4/0x1d8
    [<8080bc90>] sdio_irq_work+0x3c/0x64
    [<80134fa0>] process_one_work+0x1d8/0x3e4
    [<80135204>] worker_thread+0x58/0x54c
    [<8013c9f0>] kthread+0xcc/0xe8
    [<80100148>] ret_from_fork+0x14/0x2c
unreferenced object 0x82fa2a40 (size 184):
  comm "kworker/0:2", pid 43, jiffies 4294947833 (age 162.940s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<80286228>] kmem_cache_alloc_node+0x198/0x2d8
    [<808922b8>] __alloc_skb+0x10c/0x168
    [<80894644>] __netdev_alloc_skb+0x3c/0x194
    [<7f14ce9c>] mwifiex_alloc_dma_align_buf+0x14/0x40 [mwifiex]
    [<7f07852c>] mwifiex_process_int_status+0x7f0/0xd70 [mwifiex_sdio]
    [<7f1480a4>] mwifiex_main_process+0x124/0xa30 [mwifiex]
    [<8080b9c4>] process_sdio_pending_irqs+0xe4/0x1d8
    [<8080bc90>] sdio_irq_work+0x3c/0x64
    [<80134fa0>] process_one_work+0x1d8/0x3e4
    [<80135204>] worker_thread+0x58/0x54c
    [<8013c9f0>] kthread+0xcc/0xe8
    [<80100148>] ret_from_fork+0x14/0x2c

Before going deeper into kernel driver code, which I am not expert in, I would like to be sure that it is the only solution to fix my issue.

Any kind of help would be appreciated !

Hello @Willy,

we forwarded this to our team and will get back to you.

Best Regards,

Matthias

Hi @Willy!

I have some remarks/questions:

  • According to the Kernel Memory Leak Detector — The Linux Kernel documentation, it is quite possible that it gives you false positive results. Can you in any way confirm that what you are getting is not a false positive?

  • Memory leaks can be a problem because your system will have less memory available as time proceeds. You can check it by running your tests for several hours (10h, 20h, …) and monitor the memory usage.

Having said that directly answering your question:

If the memory leak really exists, going to the source code might be the only way to solve it.

Best regards,

Hi @henrique.tx !

Thank you for your answer.

The only way that confirms I’m not getting a false positive is using a downstream driver, and it works, the memory leak disappeared. So I decided to use this driver to fix my issue.

Best regards

Hi @Willy !

Thanks for the feedback.

I will bring this up internally, as this is an important topic.

Also, could you please mark your answer as the solution? Thanks!

Have a nice day!