On Tue, Oct 31, 2023 at 10:46 AM Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
There is also an aspect of memory consumption. KASAN headers increase
the size of every heap object. So we tried to keep them as compact as
possible. At some point CPU numbers and timestamps (IIRC) were already
part of the header, but we removed them to shrink the header to 16
bytes.
Do you think it is worth using the extra bytes to record more
information? If this is a user-configurable feature.
If it's user-configurable, then it is OK.
FWIW, Generic KASAN already stores the auxiliary stack handles in the
redzone, so the size of the redzone header is 24 bytes. Perhaps, we
should hide them under a config as well.
However, the increase of the redzone header size will only affect
small kmalloc allocations (<= 16 bytes, as kmalloc allocations are
aligned to the size of the object and the redzone is thus as big as
the object anyway) and small non-kmalloc slab allocations (<= 64
bytes, for which optimal_redzone returns 16). So I don't think adding
new fields to the redzone will increase the memory usage by much. But
this needs to be tested to make sure.