Something overwrittes memory after address space mapping

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
daniilq
Posts: 2
Joined: Sun Apr 25, 2021 9:55 am
Libera.chat IRC: Intel

Something overwrittes memory after address space mapping

Post by daniilq »

Hi,
There is a small operating system I developed. I try to implement multitasking in kernel mode. I load my exe file into memory with dma controller and floppy disk. I hardcoded physical address 0x20000 for my program (I've tryed other addresses, it doesn't matter). If I do identity mapping of the first megabyte and start new process with the EIP register that is equal 0x20000 everything is fine. It works as expected. When I try to map 0x20000 of physical memory to 0 address of virtual address space something happens. Something overwrite 0x20000 physical memory address. I tryed analyze it, I tryed to find a bug in my code I didn't have any result. I hope somebody faced something similar. Thank you!
P.S. I attached normal and overwritted memory screenshots.
Attachments
Overwritten memory
Overwritten memory
Good memory
Good memory
sj95126
Member
Member
Posts: 151
Joined: Tue Aug 11, 2020 12:14 pm

Re: Something overwrittes memory after address space mapping

Post by sj95126 »

It sounds like you may be dereferencing a null pointer and overwriting something you don't want to overwrite.

As a matter of practice, it's usually good to make virtual address 0 unusable, for exactly this reason. You may want to try either removing the mapping for that address, or at least set it read-only and see what happens.
daniilq
Posts: 2
Joined: Sun Apr 25, 2021 9:55 am
Libera.chat IRC: Intel

Re: Something overwrittes memory after address space mapping

Post by daniilq »

Thanks a lot! When I made memory read only I faced with another issue, but moving of memory mapping helped me! I tried to use virtual address 1 instead of virtual address 0 and it started to work. \:D/
Post Reply