Is there any protection provided by kernel? Because when we tried to allocate memory using an malloc() from user space, the kernel allowed to allocated around 124 MB of memory, and when we try to write into it, the kernel crashed. If there was protection of kernel memory area, this wouldn't have happened
In kernel-space there is no memory protection. Then again, malloc() isn't available in kernel-space, so what are you asking?
Allocating memory in the kernel requires special consideration. It would be very helpful if you could post your code, or better explain your need for 'guaranteed' memory within kernel space.
Please keep in mind, kernel space is not _infinite_
, in user space the kernel is what manages overcommitment. You have a very, very hard limit on memory within the kernel and lots of consumers competing to use it.
Again, if you post your code, many here could help you come up with a better design, which I believe is what you probably need.
Note, the link is from 2006. This illustrates my other point, what version of the kernel are you working with?