Skip to contentSkip to conversation

Patch "x86/kasan: Fix boot with KASAN=y and PROFILE_ANNOTATED_BRANCHES=y" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Mar 20, 2017

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

x86/kasan: Fix boot with KASAN=y and PROFILE_ANNOTATED_BRANCHES=y

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
x86-kasan-fix-boot-with-kasan-y-and-profile_annotated_branches-y.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From be3606ff739d1c1be36389f8737c577ad87e1f57 Mon Sep 17 00:00:00 2001

From: Andrey Ryabinin <[email protected]>
Date: Mon, 13 Mar 2017 19:33:37 +0300
Subject: x86/kasan: Fix boot with KASAN=y and PROFILE_ANNOTATED_BRANCHES=y

From: Andrey Ryabinin <[email protected]>

commit be3606ff739d1c1be36389f8737c577ad87e1f57 upstream.

The kernel doesn't boot with both PROFILE_ANNOTATED_BRANCHES=y and KASAN=y options selected. With branch profiling enabled we end up calling ftrace_likely_update() before kasan_early_init(). ftrace_likely_update() is built with KASAN instrumentation, so calling it before kasan has been initialized leads to crash.

Use DISABLE_BRANCH_PROFILING define to make sure that we don't call ftrace_likely_update() from early code before kasan_early_init().

---
 arch/x86/kernel/head64.c    |    1 +
 arch/x86/mm/kasan_init_64.c |    1 +
 2 files changed, 2 insertions(+)
arch/x86/kernel/head64.c +1 -0
@@ -4,6 +4,7 @@
  *  Copyright (C) 2000 Andrea Arcangeli <[email protected]> SuSE
  */
 
+#define DISABLE_BRANCH_PROFILING
 #include <linux/init.h>
 #include <linux/linkage.h>
 #include <linux/types.h>
arch/x86/mm/kasan_init_64.c +1 -0
@@ -1,3 +1,4 @@
+#define DISABLE_BRANCH_PROFILING
 #define pr_fmt(fmt) "kasan: " fmt
 #include <linux/bootmem.h>
 #include <linux/kasan.h>

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/x86-kasan-fix-boot-with-kasan-y-and-profile_annotated_branches-y.patch