From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by kanga.kvack.org (Postfix) with ESMTP id 761936B00C9 for ; Mon, 24 Nov 2014 13:02:43 -0500 (EST) Received: by mail-pa0-f54.google.com with SMTP id fb1so10028941pad.27 for ; Mon, 24 Nov 2014 10:02:43 -0800 (PST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com. [210.118.77.11]) by mx.google.com with ESMTPS id ml2si22620337pab.144.2014.11.24.10.02.38 for (version=TLSv1 cipher=RC4-MD5 bits=128/128); Mon, 24 Nov 2014 10:02:39 -0800 (PST) Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFK00KMW294XF00@mailout1.w1.samsung.com> for linux-mm@kvack.org; Mon, 24 Nov 2014 18:05:29 +0000 (GMT) From: Andrey Ryabinin Subject: [PATCH v7 02/12] x86_64: load_percpu_segment: read irq_stack_union.gs_base before load_segment Date: Mon, 24 Nov 2014 21:02:15 +0300 Message-id: <1416852146-9781-3-git-send-email-a.ryabinin@samsung.com> In-reply-to: <1416852146-9781-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1416852146-9781-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 8779d63..97f56f6 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.3 -- 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