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 546666B0074 for ; Mon, 6 Oct 2014 12:01:21 -0400 (EDT) Received: by mail-pa0-f54.google.com with SMTP id ey11so5437337pad.41 for ; Mon, 06 Oct 2014 09:01:20 -0700 (PDT) Received: from mailout3.w1.samsung.com (mailout3.w1.samsung.com. [210.118.77.13]) by mx.google.com with ESMTPS id n4si10984534pdc.79.2014.10.06.09.01.19 for (version=TLSv1 cipher=RC4-MD5 bits=128/128); Mon, 06 Oct 2014 09:01:19 -0700 (PDT) Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ND100BJG5YX4U80@mailout3.w1.samsung.com> for linux-mm@kvack.org; Mon, 06 Oct 2014 17:04:09 +0100 (BST) From: Andrey Ryabinin Subject: [PATCH v4 03/13] x86_64: load_percpu_segment: read irq_stack_union.gs_base before load_segment Date: Mon, 06 Oct 2014 19:53:57 +0400 Message-id: <1412610847-27671-4-git-send-email-a.ryabinin@samsung.com> In-reply-to: <1412610847-27671-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1412610847-27671-1-git-send-email-a.ryabinin@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: linux-kernel@vger.kernel.org Cc: Andrey Ryabinin , Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Andrew Morton , Dave Hansen , Andi Kleen , Vegard Nossum , "H. Peter Anvin" , Dave Jones , x86@kernel.org, linux-mm@kvack.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 ea51f2c..8d9a3c6 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