linux-stable/mm/kasan
Andrey Konovalov 3f41b60938 kasan: fix random seed generation for tag-based mode
There are two issues with assigning random percpu seeds right now:

1. We use for_each_possible_cpu() to iterate over cpus, but cpumask is
   not set up yet at the moment of kasan_init(), and thus we only set
   the seed for cpu #0.

2. A call to get_random_u32() always returns the same number and produces
   a message in dmesg, since the random subsystem is not yet initialized.

Fix 1 by calling kasan_init_tags() after cpumask is set up.

Fix 2 by using get_cycles() instead of get_random_u32(). This gives us
lower quality random numbers, but it's good enough, as KASAN is meant to
be used as a debugging tool and not a mitigation.

Link: http://lkml.kernel.org/r/1f815cc914b61f3516ed4cc9bfd9eeca9bd5d9de.1550677973.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-02-21 09:01:00 -08:00
..
Makefile kasan: mark file common so ftrace doesn't trace it 2019-02-01 15:46:23 -08:00
common.c kasan: fix assigning tags twice 2019-02-21 09:01:00 -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: fix random seed generation for tag-based mode 2019-02-21 09:01:00 -08:00
tags_report.c kasan: add SPDX-License-Identifier mark to source files 2018-12-28 12:11:44 -08:00