summaryrefslogtreecommitdiff
path: root/tools/perf/python/stackcollapse.py
diff options
context:
space:
mode:
authorDanish Khateeb <danishkhateeb03@gmail.com>2026-09-26 10:24:14 -0500
committerThomas Weißschuh <linux@weissschuh.net>2026-09-30 21:27:03 +0200
commit2111eb4273e7fda0815de85319653104f323c441 (patch)
tree46c502184490bad6c113077d469e2b2348042b57 /tools/perf/python/stackcollapse.py
parentb7db3ba9434cbad3d15f62500104525bfa28a304 (diff)
downloadlinux-next-2111eb4273e7fda0815de85319653104f323c441.tar.gz
linux-next-2111eb4273e7fda0815de85319653104f323c441.zip
tools/nolibc: check for overflow in malloc()
malloc() adds the size of its header to the requested size without checking for overflow. For a size within the header size of SIZE_MAX, the sum wraps around to a few bytes, and malloc() returns a single page instead of NULL. calloc() checks its multiplication for overflow, but then passes the product to malloc(), so calloc(SIZE_MAX, 1) returns a single page too. So does realloc(ptr, SIZE_MAX). Such a size is usually a bug in the caller, for instance a length of -1 used as a size_t, and returning a page instead of NULL can turn it into a heap overflow. Fail with ENOMEM when adding the header overflows, as glibc does for sizes this large. Fixes: 0e0ff638400b ("tools/nolibc/stdlib: Implement `malloc()`, `calloc()`, `realloc()` and `free()`") Assisted-by: LLM Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com> Link: https://patch.msgid.link/20260926152414.251214-3-danishkhateeb03@gmail.com Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Diffstat (limited to 'tools/perf/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions