From 5cbcf1f988f0352f19bd1dee30b73b04f69992a6 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 16 Oct 2019 15:56:01 -0700 Subject: [PATCH] ANDROID: x86/alternatives: Use C int3 selftest but disable KASAN Instead of using inline asm for the int3 selftest (which confuses the Clang's ThinLTO pass), this restores the C function but disables KASAN (and tracing for good measure) to keep the things simple and avoid unexpected side-effects. This attempts to keep the fix from commit ecc606103837 ("x86/alternatives: Fix int3_emulate_call() selftest stack corruption") without using inline asm. Bug: 145210207 Change-Id: Ib4cdfde61473febd867c2329f57ec9a8a5eced2f Signed-off-by: Kees Cook Signed-off-by: Sami Tolvanen --- arch/x86/kernel/alternative.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 2400ad62f330..c5f58615f448 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -628,23 +628,10 @@ extern struct paravirt_patch_site __start_parainstructions[], * * See entry_{32,64}.S for more details. */ - -/* - * We define the int3_magic() function in assembly to control the calling - * convention such that we can 'call' it from assembly. - */ - -extern void int3_magic(unsigned int *ptr); /* defined in asm */ - -asm ( -" .pushsection .init.text, \"ax\", @progbits\n" -" .type int3_magic, @function\n" -"int3_magic:\n" -" movl $1, (%" _ASM_ARG1 ")\n" -" ret\n" -" .size int3_magic, .-int3_magic\n" -" .popsection\n" -); +static void __init __no_sanitize_address notrace int3_magic(unsigned int *ptr) +{ + *ptr = 1; +} extern __initdata unsigned long int3_selftest_ip; /* defined in asm below */