Bug 209821 - KASAN: improve x2 memory overhead for kmalloc objects
Summary: KASAN: improve x2 memory overhead for kmalloc objects
Status: RESOLVED CODE_FIX
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Sanitizers (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: MM/Sanitizers virtual assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-22 21:29 UTC by Andrey Konovalov
Modified: 2022-10-18 18:57 UTC (History)
1 user (show)

See Also:
Kernel Version: upstream
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Andrey Konovalov 2020-10-22 21:29:43 UTC
As of [1] kmalloc return value is aligned to the size of the allocation for power-of-two kmalloc caches. As KASAN adds just a few bytes of metadata after each object, this results in x2 memory usage increase for such kmalloc caches.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=59bb47985c1db229ccff8c5deebecd54fc77d2a9
Comment 1 Andrey Konovalov 2022-10-18 18:57:26 UTC
This has been resolved for the Software and Hardware Tag-Based modes by moving stack trace handles from per-object metadata to the stack ring [1].

For Generic KASAN, the additional memory usage caused by the over-alignment of kmalloc objects is not that critical, as it introduces a significant memory overhead anyway.

Thus, this issue is considered resolved.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ca77f290cff1dfa095d71ae16cc7cda8ee6df495

Note You need to log in before you can comment on or make changes to this bug.