When KASAN is configured, make uma_zfree_arg() free items to the per-CPU
free bucket, rather than to the alloc bucket. This means that the item
won't be recycled immediately the next time a thread goes to allocate an
item from that zone on the same CPU. In other words, the item will stay
in a quarantine state longer, which helps make KASAN's use-after-free
detection more reliable.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 74884 Build 71767: arc lint + arc unit
Event Timeline
Looks fine modulo the uz_flags comment and style and history nits.
I'm now wondering if we should just have an __always_inline cache_free_item(..., bool defer) and rely on constant propagation, since it seems the only intended difference is whether to attempt to use the alloc bucket. But maybe it is better to keep the smr/defer path distinct to be more resilient against future accidental changes or dumb compilers.
| sys/vm/uma_core.c | ||
|---|---|---|
| 4618–4629 | So this moved there and back again. Did it need to move at all in the first patch? | |
| 4623–4625 | Style suggestion, would not be vertically longer: if (...) {
/* We will free... */
}
#ifdef KASAN
else if (...Or alternately, I didn't find the original goto construct unclear. | |
| 4627 | You want to use the uz_flags copy, so that we don't have to touch zone yet, otherwise this breaks that optimization with KASAN compiled in. (I haven't checked that UMA_ZONE_NOKASAN makes it into the copy, do check that.) | |
| sys/vm/uma_core.c | ||
|---|---|---|
| 4618–4629 | I suppose not, will fix. | |