mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
UPSTREAM: kasan, mm: fix conflicts with init_on_alloc/free
[ Upstream commitce5716c618] A few places where SLUB accesses object's data or metadata were missed in a previous patch. This leads to false positives with hardware tag-based KASAN when bulk allocations are used with init_on_alloc/free. Fix the false-positives by resetting pointer tags during these accesses. (The kasan_reset_tag call is removed from slab_alloc_node, as it's added into maybe_wipe_obj_freeptr.) Link: https://linux-review.googlesource.com/id/I50dd32838a666e173fe06c3c5c766f2c36aae901 Link: https://lkml.kernel.org/r/093428b5d2ca8b507f4a79f92f9929b35f7fada7.1610731872.git.andreyknvl@google.com Fixes:aa1ef4d7b3("kasan, mm: reset tags when accessing metadata") Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Reported-by: Dmitry Vyukov <dvyukov@google.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com> Cc: Alexander Potapenko <glider@google.com> Cc: Marco Elver <elver@google.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Peter Collingbourne <pcc@google.com> Cc: Evgenii Stepanov <eugenis@google.com> Cc: Branislav Rankov <Branislav.Rankov@arm.com> Cc: Kevin Brodsky <kevin.brodsky@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Bug: 172318110 Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Change-Id: I48c4d12a10e92e3e6a4bcd1c3a72c5903bfdbc71
This commit is contained in:
committed by
Alistair Delva
parent
5ec78398b3
commit
5c96cfe8b9
@@ -2794,7 +2794,8 @@ static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s,
|
||||
void *obj)
|
||||
{
|
||||
if (unlikely(slab_want_init_on_free(s)) && obj)
|
||||
memset((void *)((char *)obj + s->offset), 0, sizeof(void *));
|
||||
memset((void *)((char *)kasan_reset_tag(obj) + s->offset),
|
||||
0, sizeof(void *));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2886,7 +2887,7 @@ redo:
|
||||
stat(s, ALLOC_FASTPATH);
|
||||
}
|
||||
|
||||
maybe_wipe_obj_freeptr(s, kasan_reset_tag(object));
|
||||
maybe_wipe_obj_freeptr(s, object);
|
||||
|
||||
if (unlikely(slab_want_init_on_alloc(gfpflags, s)) && object)
|
||||
memset(kasan_reset_tag(object), 0, s->object_size);
|
||||
@@ -3332,7 +3333,7 @@ int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size,
|
||||
int j;
|
||||
|
||||
for (j = 0; j < i; j++)
|
||||
memset(p[j], 0, s->object_size);
|
||||
memset(kasan_reset_tag(p[j]), 0, s->object_size);
|
||||
}
|
||||
|
||||
/* memcg and kmem_cache debug support */
|
||||
|
||||
Reference in New Issue
Block a user