Recursive page table mapping and permissions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Recursive page table mapping and permissions

Post by NickJohnson »

After realizing the benefits of doing a "recursive mapping" of page tables, I've been rewriting my kernel's memory manager. By recursive mapping, I mean putting the page directory as the last page table, thereby mapping all of the page tables from 0xFFC00000 through 0xFFFFE000 (and the page directory itself at 0xFFFFF000). My issue is that if I want to allow user processes to use memory mapped by a table, the user flag must be set on that table. But if the user flag is set on the table, the recursive mapping of that table is then user accessible - a *very* bad thing for security. I know others use this technique; how do you solve this problem?
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: Recursive page table mapping and permissions

Post by frank »

Mark the page directory entry as supervisor, the one that you point back to the page directory, that way the page table permissions won't matter.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Recursive page table mapping and permissions

Post by NickJohnson »

I see now. That's probably one of the reasons why there's a permission system for the page tables in the first place. Thanks for the fast response.
Post Reply