From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by kanga.kvack.org (Postfix) with ESMTP id D241B900014 for ; Mon, 27 Oct 2014 12:47:43 -0400 (EDT) Received: by mail-pd0-f171.google.com with SMTP id r10so5999161pdi.16 for ; Mon, 27 Oct 2014 09:47:43 -0700 (PDT) Received: from mailout4.w1.samsung.com (mailout4.w1.samsung.com. [210.118.77.14]) by mx.google.com with ESMTPS id cq3si10832751pbb.193.2014.10.27.09.47.42 for (version=TLSv1 cipher=RC4-MD5 bits=128/128); Mon, 27 Oct 2014 09:47:42 -0700 (PDT) Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE400AIY442SSA0@mailout4.w1.samsung.com> for linux-mm@kvack.org; Mon, 27 Oct 2014 16:50:26 +0000 (GMT) From: Andrey Ryabinin Subject: [PATCH v5 03/12] x86_64: load_percpu_segment: read irq_stack_union.gs_base before load_segment Date: Mon, 27 Oct 2014 19:46:50 +0300 Message-id: <1414428419-17860-4-git-send-email-a.ryabinin@samsung.com> In-reply-to: <1414428419-17860-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1414428419-17860-1-git-send-email-a.ryabinin@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Andrey Ryabinin , Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Dave Hansen , Andi Kleen , Vegard Nossum , "H. Peter Anvin" , Dave Jones , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar Reading irq_stack_union.gs_base after load_segment creates troubles for kasan. Compiler inserts __asan_load in between load_segment and wrmsrl. If kernel built with stackprotector this will result in boot failure because __asan_load has stackprotector. To avoid this irq_stack_union.gs_base stored to temporary variable before load_segment, so __asan_load will be called before load_segment(). There are two alternative ways to fix this: a) Add __attribute__((no_sanitize_address)) to load_percpu_segment(), which tells compiler to not instrument this function. However this will result in build failure with CONFIG_KASAN=y and CONFIG_OPTIMIZE_INLINING=y. b) Add -fno-stack-protector for mm/kasan/kasan.c Signed-off-by: Andrey Ryabinin --- arch/x86/kernel/cpu/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 4b4f78c..ee5c286 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -389,8 +389,10 @@ void load_percpu_segment(int cpu) #ifdef CONFIG_X86_32 loadsegment(fs, __KERNEL_PERCPU); #else + void *gs_base = per_cpu(irq_stack_union.gs_base, cpu); + loadsegment(gs, 0); - wrmsrl(MSR_GS_BASE, (unsigned long)per_cpu(irq_stack_union.gs_base, cpu)); + wrmsrl(MSR_GS_BASE, (unsigned long)gs_base); #endif load_stack_canary_segment(); } -- 2.1.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org