MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / CheckKernelPointer

Function CheckKernelPointer

Kernel/src/arch/x86_64/paging.cpp:188–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186 }
187
188 bool CheckKernelPointer(uintptr_t addr, uint64_t len){
189 if(PML4_GET_INDEX(addr) != PML4_GET_INDEX(KERNEL_VIRTUAL_BASE)){
190 return 0;
191 }
192
193 if(!(kernelPDPT[PDPT_GET_INDEX(addr)] & 0x1)){
194 return 0;
195 }
196
197 if(PDPT_GET_INDEX(addr) == KERNEL_HEAP_PDPT_INDEX){
198 if(!(kernelHeapDir[PAGE_DIR_GET_INDEX(addr)] & 0x1)){
199 return 0;
200 }
201
202 if(!(kernelHeapDir[PAGE_DIR_GET_INDEX(addr)] & PDE_2M)){
203 if(!(kernelHeapDirTables[PAGE_DIR_GET_INDEX(addr)][PAGE_TABLE_GET_INDEX(addr)] & 0x1)){
204 return 0;
205 }
206 }
207 } else if(PDPT_GET_INDEX(addr) == PDPT_GET_INDEX(KERNEL_VIRTUAL_BASE)){
208 if(!(kernelDir[PAGE_DIR_GET_INDEX(addr)] & 0x1)){
209 return 0;
210 }
211 } else {
212 return 0;
213 }
214
215 return 1;
216 }
217
218 bool CheckUsermodePointer(uintptr_t addr, uint64_t len, address_space_t* addressSpace){
219 if(addr >> 48) return 0; // Non-canonical or higher-half address

Callers 1

PrintStackTraceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected