Page MenuHomeFreeBSD

malloc: Add state transitions for KASAN
ClosedPublic

Authored by markj on Mar 27 2021, 11:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 11 2024, 8:02 AM
Unknown Object (File)
Nov 11 2024, 7:07 AM
Unknown Object (File)
Oct 31 2024, 11:01 PM
Unknown Object (File)
Oct 31 2024, 1:02 PM
Unknown Object (File)
Oct 31 2024, 12:48 PM
Unknown Object (File)
Oct 31 2024, 7:59 AM
Unknown Object (File)
Oct 17 2024, 1:42 PM
Unknown Object (File)
Oct 17 2024, 1:42 PM
Subscribers

Details

Summary


- Reuse some REDZONE bits to keep track of the requested and allocated
sizes, and use that to provide red zones.
- As in UMA, disable memory trashing to avoid unnecessary CPU overhead.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

andrew added inline comments.
sys/kern/kern_malloc.c
611

Is this #ifdef needed?

912

Does this address space become invalid via another means in both of these paths?

1024

This doesn't look right

markj added inline comments.
sys/kern/kern_malloc.c
912

For UMA, the region will immediately be marked invalid, so this call isn't really accomplishing anything. Note that in zfree() it is required since we are zeroing the entire allocation, including the redzone.

For kmem_*, the region will be marked valid (for future users of the KVA) and unmapped. I think I added this kasan_mark() call before adding state transitions to kmem_*, so I marked the region valid here. Again, it is not necessary now, but is still needed in the zfree() case.

1024

Oops, indeed...

markj marked an inline comment as done.
  • Drop unneeded ifdef.
  • Fix a harmless bug in the realloc() modification.
  • Drop unintended vm_kern.c diff.
This revision was not accepted when it landed; it landed in state Needs Review.Apr 13 2021, 9:43 PM
This revision was automatically updated to reflect the committed changes.