Re: [PATCH v2] kasan: Disable branch tracing for core runtime

From: Marco Elver
Date: Sat May 23 2020 - 05:12:25 EST


On Sat, 23 May 2020 at 01:42, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, 22 May 2020 09:52:07 +0200 Marco Elver <elver@xxxxxxxxxx> wrote:
>
> > During early boot, while KASAN is not yet initialized, it is possible to
> > enter reporting code-path and end up in kasan_report(). While
> > uninitialized, the branch there prevents generating any reports,
> > however, under certain circumstances when branches are being traced
> > (TRACE_BRANCH_PROFILING), we may recurse deep enough to cause kernel
> > reboots without warning.
> >
> > To prevent similar issues in future, we should disable branch tracing
> > for the core runtime.
> >
> > Link: 20200517011732.GE24705@shao2-debian/">https://lore.kernel.org/lkml/20200517011732.GE24705@shao2-debian/
> > Reported-by: kernel test robot <rong.a.chen@xxxxxxxxx>
> > Signed-off-by: Marco Elver <elver@xxxxxxxxxx>
>
> I assume this affects 5.6 and perhaps earlier kernels?
>
> I also assume that a cc:stable is appropriate for this fix?

Yes, it does. On the other hand, the workaround is simple enough
(disable any kind of branch profiling).

Note, the patch won't cleanly apply to 5.6 and early without this:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a16c09edc58982d56c49ab577fdcdf830fbc3a5

Thanks,
-- Marco