OSDev.org
https://forum.osdev.org/

Kernel heap question
https://forum.osdev.org/viewtopic.php?f=15&t=33650
Page 1 of 1

Author:  LIC [ Sat Apr 20, 2019 11:07 am ]
Post subject:  Kernel heap question

Hi, I am currently trying to implement a heap for my kernel, however I was wondering about one thing concerning security.
In my kernel, paging is enabled and the heap is going from 0x100000 to 0x150000 in physical memory.
My question is: Is it ok to map all pages concerning heap in the kernel page table at the beginning or is it better/safer to map pages as the heap grows?
I hope my question was clear.

Author:  Korona [ Sat Apr 20, 2019 11:33 am ]
Post subject:  Re: Kernel heap question

Security-wise, this does not make a huge difference. If someone can write to kernel memory (or even read it), the security of the system is compromised anyway.

There are, however, reasons to map not everything at once: doing so will obviously consume more physical memory and it might not be desirable to fix the size of the kernel heap to some smallish number of pages.

Author:  songziming [ Mon Apr 22, 2019 12:22 am ]
Post subject:  Re: Kernel heap question

I map all physical memory 1:1 to kernel space (above canonical hole). So kernel heap only need to know which pages belongs to it, no need to map them dynamically.

Kernel space is shared between all processes. If dynamic mapping is used within kernel space, then the kernel have to update every process' page table.

Author:  LIC [ Tue Apr 23, 2019 10:20 am ]
Post subject:  Re: Kernel heap question

Okay, thank you for your replies!

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/