The ksize() description in mm/slab.c matches exactly what netfilter
wants to do:
* kmalloc may internally round up allocations and return more memory
* than requested. ksize() can be used to determine the actual amount
of
* memory allocated. The caller may use this additional memory, even though
* a smaller amount of memory was initially specified with the kmalloc
call.
I don't think there is anything broken with that code.
The initial allocation size is calculated as max(size, min slab size)
and is stored as ext->alloc_size. When adding the first extension,
it allocates ext->alloc_size of memory and stores both the real amount
of space used (ext->len) and the actual size (ext->real_len).
When adding further extensions, it calculates the new total amount of
space needed (newlen). If that is larger than the real amount of
memory allocated (real_len), it reallocates.
What am I missing here?
--