mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
Kernel: Add crash logging heuristic for uninitialized kmalloc()/kfree()
Since we scrub both kmalloc() and kfree() with predictable values, we can log a helpful message when hitting a crash that looks like it might be a dereference of such scrubbed data.
This commit is contained in:
parent
f2846e8e08
commit
8d51352b96
3 changed files with 11 additions and 2 deletions
|
@ -166,7 +166,7 @@ void* kmalloc_impl(size_t size)
|
|||
sum_alloc += a->nchunk * CHUNK_SIZE;
|
||||
sum_free -= a->nchunk * CHUNK_SIZE;
|
||||
#ifdef SANITIZE_KMALLOC
|
||||
memset(ptr, 0xbb, (a->nchunk * CHUNK_SIZE) - sizeof(allocation_t));
|
||||
memset(ptr, KMALLOC_SCRUB_BYTE, (a->nchunk * CHUNK_SIZE) - sizeof(allocation_t));
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ void kfree(void* ptr)
|
|||
sum_free += a->nchunk * CHUNK_SIZE;
|
||||
|
||||
#ifdef SANITIZE_KMALLOC
|
||||
memset(a, 0xaa, a->nchunk * CHUNK_SIZE);
|
||||
memset(a, KFREE_SCRUB_BYTE, a->nchunk * CHUNK_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue