>kfree calls kfree_debugcheck which looks like (I shortened it):
struct page *page;
if (!virt_addr_valid(objp))
BUG();
page = virt_to_page(objp);
if (!PageSlab(page))
BUG();
It seems to me that these are the functions you look for.
thanks, I will check this out.
I wonder, if above mentioned checks are really going to work for him,
because the requirement is not only to check validity of received kernel
pointer but also to be exact pointer (what was passed to application,
because the pointer is pointer to some context).
The macro virt_addr_valid(kaddr) expands to
pfn_to_page(((unsigned long)(kaddr)-PAGE_OFFSET) >> PAGE_SHIFT)
For example, the address passed from kernel to application is 0xC1234567
(which is pointing to some transaction allocated). Now if user application
passed back as 0xC1234568, the above macro will fail to detect (Of course
address is a valid one, but not what expected). For that matter, in my
opinion, it won't be possible to check anyway against such examples.
I really don't think, receiving a pointer from user space is a good idea. I
suggest to take recourse of table mechanism suggested in earlier emails.
Regards,
Mohanlal
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/