rust-osdev/linked-list-allocator

[Feature request] Heap canary

开放

#58 创建于 2022年4月12日

 (3 条评论) (1 个反应) (0 位负责人)Rust (56 个派生)github user discovery
help wanted

仓库指标

星标
 (241 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Recently I occurred a heap corruption bug in one of my real life projects:

Kernel panic - aborting: at /home/kazurin/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/linked_list_allocator-0.9.1/src/hole.rs:311: attempt to add with overflow

It took me long before I was able to discover the root cause, due to the complication of kernel debugging and the need to read the source code of various crates. It might be handy to have some simple heap canary mechanism (just like what Valgrind does) built into the allocator in such cases.

Features that I consider useful:

  • Ability to detect the corruption of heap control structures (namely the Holes) using some predefined magic bytes in the structure
  • Ability to reveal the corrupted structure's address in the panic message (for easier debugging)
  • Ability to verify the integrity of the whole heap at any time
  • The heap canary feature should be completely optional, in order not to cause preformance impact on production code

If such features are acceptable but not planned, perhaps I could do a PR in the future :)

贡献者指南