[BUG] Module load relocation hashtable size can become huge and unallocatable

William Pierce wgpierce17 at gmail.com
Sun Mar 30 13:12:48 PDT 2025


Hello, I have a kernel module that requires a huge number
of relocations upon loading.

On other architectures, it loads into the kernel just fine.
However, on riscv, while allocating memory for its relocation
hashtable, it ends up requesting 2097152 elements to kmalloc_array.

Right here I've dumped the values by recompiling the kernel:
num_relocations: 1630985, hastable_size: 2097152
https://elixir.bootlin.com/linux/v6.14-rc6/source/arch/riscv/kernel/module.c#L734

which kmalloc_array->...->___kmalloc_large_node->...->
__alloc_frozen_pages_noprof can't handle and returns
"Cannot allocate memory" on insmod.

How would it be recommended to fix this?
I could imagine allocating a more discontiguous data structure
to track the relocations or otherwise reworking the tracking to
do the relocation tracking inline.

Thank you,
Will Pierce



More information about the linux-riscv mailing list