]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/slub: free KFENCE objects in slab_free_hook()
authorVlastimil Babka <vbabka@suse.cz>
Tue, 14 Nov 2023 21:12:47 +0000 (22:12 +0100)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 21 Nov 2023 18:03:21 +0000 (13:03 -0500)
commit19412067642b3e16f3ad08f700c8cc06a7f39e31
tree2575f8fb22b736438379db9ad9a8c25a1300f017
parent826484413b608f7133b09fcbec64ebdedef521a8
mm/slub: free KFENCE objects in slab_free_hook()

When freeing an object that was allocated from KFENCE, we do that in the
slowpath __slab_free(), relying on the fact that KFENCE "slab" cannot be
the cpu slab, so the fastpath has to fallback to the slowpath.

This optimization doesn't help much though, because is_kfence_address()
is checked earlier anyway during the free hook processing or detached
freelist building. Thus we can simplify the code by making the
slab_free_hook() free the KFENCE object immediately, similarly to KASAN
quarantine.

In slab_free_hook() we can place kfence_free() above init processing, as
callers have been making sure to set init to false for KFENCE objects.
This simplifies slab_free(). This places it also above kasan_slab_free()
which is ok as that skips KFENCE objects anyway.

While at it also determine the init value in slab_free_freelist_hook()
outside of the loop.

This change will also make introducing per cpu array caches easier.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c