Re: [TOMOYO 03/15](repost) Memory and pathname management functions.

Tetsuo Handa
2007-10-03T11:12:24Z

Hello.

James Morris wrote:
> Would you please explain why you need another level of memory allocation?
>
> What does it do apart from let you check for memory leaks?

Difference between tmy_alloc() and kmalloc() are

tmy_alloc() allows administrator know "how much memory is used by TOMOYO Linux modules"
via /sys/kernel/security/tomoyo/meminfo interface.
This feature was requested by TOMOYO Linux users.
/proc/slabinfo can show how much memory is used by all modules,
but it cannot show how much memory is used by TOMOYO Linux modules.

tmy_alloc() can indicate memory-leaking bug and can avoid double-kfree() bug
by keeping the pointer returned by kmalloc() in a local "cache_list" list.

tmy_alloc() also keeps the size of memory allocated by kmalloc() in "cache_list" list
so that administrator can know "how much memory is used by TOMOYO Linux modules".
Calling ksize() after kmalloc() in tmy_alloc() and
calling ksize() before kfree() in tmy_free() might be better
if double-kfree-checks and memory-leaking-checks (i.e. "tmy_cachep") are unneeded.

Regards.