Basics

For different tasks it is necessary to allocate a chunk of memory. Especially in the Linux kernel, stack space is pretty tight, so you quite often cannot simply declare some large variable and hope it works out.

The usual way to allocate kernel memory is using kmalloc/kfree for rather small amounts (allocated continuously as real memory) and vmalloc/vfree (virtual memory) for large sizes. Unfortunately, you have to find out yourself, which method is better. kmalloc will fail, if you try to allocate more than 128M - anyway, continous memory of several pages might be difficult to get.

RSBAC memory allocation

RSBAC provides some own memory management functions. These functions also get exported for modules, if REG support has been enabled.

In kernel versions from 2.4.0, separate RSBAC memory slabs are used for kmalloc style memory to provide better control of memory usage through /proc/slabinfo.

#include <rsbac/rkmem.h>
void * rsbac_kmalloc (size_t size);
void rsbac_kfree (const void *objp);
void * rsbac_vkmalloc
 (size_t size, boolean * vmalloc_used_p);
void rsbac_vkfree (void *objp, boolean vmalloc_used);