linux/mm/kasan
Andrey Konovalov a3fe7cdf02 kasan: fix krealloc handling for tag-based mode
Right now tag-based KASAN can retag the memory that is reallocated via
krealloc and return a differently tagged pointer even if the same slab
object gets used and no reallocated technically happens.

There are a few issues with this approach.  One is that krealloc callers
can't rely on comparing the return value with the passed argument to
check whether reallocation happened.  Another is that if a caller knows
that no reallocation happened, that it can access object memory through
the old pointer, which leads to false positives.  Look at
nf_ct_ext_add() to see an example.

Fix this by keeping the same tag if the memory don't actually gets
reallocated during krealloc.

Link: http://lkml.kernel.org/r/bb2a71d17ed072bcc528cbee46fcbd71a6da3be4.1546540962.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-08 17:15:11 -08:00
..
Makefile kasan: split out generic_report.c from report.c 2018-12-28 12:11:43 -08:00
common.c kasan: fix krealloc handling for tag-based mode 2019-01-08 17:15:11 -08:00
generic.c kasan: add SPDX-License-Identifier mark to source files 2018-12-28 12:11:44 -08:00
generic_report.c kasan: add SPDX-License-Identifier mark to source files 2018-12-28 12:11:44 -08:00
init.c mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
kasan.h kasan: add hooks implementation for tag-based mode 2018-12-28 12:11:44 -08:00
quarantine.c mm: convert totalram_pages and totalhigh_pages variables to atomic 2018-12-28 12:11:47 -08:00
report.c kasan: add SPDX-License-Identifier mark to source files 2018-12-28 12:11:44 -08:00
tags.c kasan: add SPDX-License-Identifier mark to source files 2018-12-28 12:11:44 -08:00
tags_report.c kasan: add SPDX-License-Identifier mark to source files 2018-12-28 12:11:44 -08:00