I have two places in a kernel module (Linux 3.13):
- One is
module_init
- The other is code I hook with running an invalid opcode (by hacking interrupt description table).
My code is to enable hardware performance counter. When I put it in module_init
, the code works fine. But when I put it to second place (triggered by running an instruction with an invalid opcode), the code gets a permission denied
error (i.e. errno:-13
).
Since both places are in a single kernel module, is it true that "even in kernel space, there are different privileges?"
Updates: something that is worth to mention is that when I run the invalid opcode as root
in user space, the -13
errno is gone; otherwise, it stays...
I speculate that "the privilege of an instruction execution decides that of its interrupt handler's execution."