Writing to kernel address space && KWE UWE bits in PTE
Mulyadi Santosa
mulyadi.santosa at gmail.com
Sat Feb 4 02:14:35 EST 2012
Hi Santosh :)
On Sat, Feb 4, 2012 at 13:22, SaNtosh kuLkarni
<santosh.yesoptus at gmail.com> wrote:
> My doubt is when , in a, say 3:1 partition of kernel user space address
> space, if a user space application tries to write/access the 1gb portion of
> kernel space which it cant, is it because there is not page table entry in
> the user space process page table entry or......... is it because of a PTE
> ( page table entry) entry related to access control set to KWE and a
> kernel trap occurs.
it's due to CPL (current privilege level) doesn't match the privilege
level of kernel address space (which is marked as 0 in their PTEs). In
user mode, your CPL is 3, whereas you're targetting privilege level 0.
If it is the other way around, kernel mode accessing user space, then
there won't be any problem.
>What events take place when a user land process tries to
> write to kernel space address.
i think it's page fault. I forgot the exact route, but I guess it
starts as hardware trap (due to the above explanation), kernel trap
handler kicks in, knowing that it is due privilege level mismatch and
simply throws instruction pointer back to user mode together with
error code (IMO it's EFAULT).
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
More information about the Kernelnewbies
mailing list