Discussion:
dynamically allocating memory in the kernel
Carter Cheng
2018-12-05 20:46:15 UTC
Permalink
Hello,

I was wondering if someone here could help me understand something about
the kernel for a project I am working on tracking dynamically allocated
memory. How many ways are there to dynamically allocate memory in the
kernel presently? I know of 4.

get_free_pages family of functions
kmalloc family (including vmalloc)
slab allocation
mempools.

Are there others? I am trying to track them all down so I have
comprehensively know when all allocations occur and all "frees".

Thanks for your help,

Carter.
Kees Cook
2018-12-05 23:00:49 UTC
Permalink
Post by Carter Cheng
Hello,
I was wondering if someone here could help me understand something about the kernel for a project I am working on tracking dynamically allocated memory. How many ways are there to dynamically allocate memory in the kernel presently? I know of 4.
get_free_pages family of functions
kmalloc family (including vmalloc)
vmalloc is quite different from kmalloc (see below).
Post by Carter Cheng
slab allocation
kmalloc is a type of slab allocation, so the base parts are the same.
Post by Carter Cheng
mempools.
Are there others? I am trying to track them all down so I have comprehensively know when all allocations occur and all "frees".
I would recommend looking at KASAN hooks (which tracks use-after-free)
to see if there are any areas you're missing.

-Kees
--
Kees Cook
Carter Cheng
2018-12-06 01:51:43 UTC
Permalink
Thanks, I'll check them out.
Post by Carter Cheng
Post by Carter Cheng
Hello,
I was wondering if someone here could help me understand something about
the kernel for a project I am working on tracking dynamically allocated
memory. How many ways are there to dynamically allocate memory in the
kernel presently? I know of 4.
Post by Carter Cheng
get_free_pages family of functions
kmalloc family (including vmalloc)
vmalloc is quite different from kmalloc (see below).
Post by Carter Cheng
slab allocation
kmalloc is a type of slab allocation, so the base parts are the same.
Post by Carter Cheng
mempools.
Are there others? I am trying to track them all down so I have
comprehensively know when all allocations occur and all "frees".
I would recommend looking at KASAN hooks (which tracks use-after-free)
to see if there are any areas you're missing.
-Kees
--
Kees Cook
Loading...