mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-06 03:45:24 -04:00
FROMGIT: mm/slab: rerform init_on_free earlier
Currently in CONFIG_SLAB init_on_free happens too late, and heap objects go to the heap quarantine not being erased. Lets move init_on_free clearing before calling kasan_slab_free(). In that case heap quarantine will store erased objects, similarly to CONFIG_SLUB=y behavior. Link: https://lkml.kernel.org/r/20201210183729.1261524-1-alex.popov@linux.com Signed-off-by: Alexander Popov <alex.popov@linux.com> Reviewed-by: Alexander Potapenko <glider@google.com> Acked-by: David Rientjes <rientjes@google.com> Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Bug: 177201466 (cherry picked from commit a32d654db543843a5ffb248feaec1a909718addd https://github.com/hnaz/linux-mm v5.11-rc4-mmots-2021-01-21-20-10) Test: CONFIG_KFENCE_KUNIT_TEST=y passes on Cuttlefish Signed-off-by: Alexander Potapenko <glider@google.com> Change-Id: I2bf5e70c1524619526efd792bbdd959b813af1e4
This commit is contained in:
parent
b5c9938cb4
commit
40edd642cb
1 changed files with 3 additions and 2 deletions
|
|
@ -3425,6 +3425,9 @@ free_done:
|
|||
static __always_inline void __cache_free(struct kmem_cache *cachep, void *objp,
|
||||
unsigned long caller)
|
||||
{
|
||||
if (unlikely(slab_want_init_on_free(cachep)))
|
||||
memset(objp, 0, cachep->object_size);
|
||||
|
||||
/* Put the object into the quarantine, don't touch it for now. */
|
||||
if (kasan_slab_free(cachep, objp, _RET_IP_))
|
||||
return;
|
||||
|
|
@ -3438,8 +3441,6 @@ void ___cache_free(struct kmem_cache *cachep, void *objp,
|
|||
struct array_cache *ac = cpu_cache_get(cachep);
|
||||
|
||||
check_irq_off();
|
||||
if (unlikely(slab_want_init_on_free(cachep)))
|
||||
memset(objp, 0, cachep->object_size);
|
||||
kmemleak_free_recursive(objp, cachep->flags);
|
||||
objp = cache_free_debugcheck(cachep, objp, caller);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue