Hi...
Comments are inlined...
static int
klife_open(struct inode* indode, struct file* filp)
{
int ret;
struct klife *k;
ret = klife_alloc(&k);
if (ret)
return ret;
OK, first you pass a pointer that lives inside kernel stack... Then..
static int
klife_alloc(struct klife **pk)
{
int ret;
struct klife *k;
k = kmalloc(sizeof(*k), GFP_KERNEL);
if (!k)
return -ENOMEM;
memset(k, 0, sizeof(*k));
ret = init_klife(k);
if (ret)
kfree(k);
*pk = k;
return ret;
}
You assign memory block to this pointer. Then you get back to
klife_open(). This function itself eventually exits and the kernel stack
size is reduced (but not gone at the moment, esp register is just
increased IIRC).
Up until nothing mess with kernel stack, your hook will be just fine.
But as soon as something use kernel stack, it will overwrite your
klife_struct *k pointer so it no longer points to correct memory
address...and boom.
Solution: make that pointer static or put it outside function scope.
That way, it won't reside on kernel stack.
regards,
Mulyadi
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ