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)
Jan 12 2024, 2:43 AM
Unknown Object (File)
Nov 28 2023, 12:21 AM
Unknown Object (File)
Nov 27 2023, 5:17 PM
Unknown Object (File)
Oct 7 2023, 2:46 AM
Unknown Object (File)
Aug 27 2023, 2:40 PM
Unknown Object (File)
Aug 27 2023, 1:07 PM
Unknown Object (File)
Aug 27 2023, 1:06 PM
Unknown Object (File)
Aug 27 2023, 1:04 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.