Skip to content

mcheck implementation for U-Boot

Eugene Uriev u-boot 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9mcheck: prepare +1 tier for mcheck-wrappers, in dl-*alloc commandscommon/dlmalloc.c+41 -250 replies
2/9mcheck: Use memset/memcpy instead of MALLOC_ZERO/MALLOC_COPY for mcheck.common/dlmalloc.c+4 -00 replies
3/9mcheck: introduce essentials of mcheckcommon/mcheck_core.inc.h include/mcheck.h+262 -00 replies
4/9mcheck: integrate mcheck into dlmalloc.ccommon/dlmalloc.c+67 -00 replies
5/9mcheck: support memaligncommon/dlmalloc.c common/mcheck_core.inc.h+24 -30 replies
6/9mcheck: add pedantic mode supportcommon/dlmalloc.c common/mcheck_core.inc.h include/mcheck.h+62 -00 replies
7/9mcheck: introduce mcheck_on_ramrelocation(.)common/board_f.c common/mcheck_core.inc.h+15 -00 replies
8/9mcheck: add stats, add a comment with test resultscommon/mcheck_core.inc.h+17 -10 replies
9/9mcheck: let mcheck_abortfunc_t print the pointercommon/mcheck_core.inc.h include/mcheck.h+9 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/9] mcheck implementation for U-Boot

There was no "mcheck" for U-Boot before.

Since U-Boot has only 1 thread, and normally makes 4000+ - 6000+ mallocs, it's better to use havier canaries to protect heap-chunks. My variant uses 2x8 = 16byte-long protector. And
the multiplier could be changed to tune speed/protection tradeoff. This protects not only against memset()-s, but against "near" wild pointers too, and makes more probable to catch "distant" ones.

The core file of the set is included into the C-file, not complied separately in order to enable (potential) coexisting of mcheck-protectors, e.g. malloc_simple(.) and dlmalloc simultaneously.

My tests were for ARM SoC, 64bit, so the patch is
aware of alignment.

Primary this patch is for using by developers: to verify, if a change doesn't break the heap integrity.
By default the mcheck is disabled and wouldn't affect the boot.

I used pedantic mode, canary=16byte, registry-size=6608. For my system the overhead was 230ms.

I assume, the merge window coming. So I send it now.

Eugene Uriev (9):
mcheck: prepare +1 tier for mcheck-wrappers, in dl-*alloc commands
mcheck: Use memset/memcpy instead of MALLOC_ZERO/MALLOC_COPY for
mcheck.
mcheck: introduce essentials of mcheck
mcheck: integrate mcheck into dlmalloc.c
mcheck: support memalign
mcheck: add pedantic mode support
mcheck: introduce mcheck_on_ramrelocation(.)
mcheck: add stats, add a comment with test results
mcheck: let mcheck_abortfunc_t print the pointer

 common/board_f.c         |   4 +
 common/dlmalloc.c        | 154 ++++++++++++++++----
 common/mcheck_core.inc.h | 304 +++++++++++++++++++++++++++++++++++++++
 include/mcheck.h         |  51 +++++++
 4 files changed, 488 insertions(+), 25 deletions(-)
 create mode 100644 common/mcheck_core.inc.h
 create mode 100644 include/mcheck.h
Signature · 1 line
2.25.1