Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755032AbaKYMmn (ORCPT ); Tue, 25 Nov 2014 07:42:43 -0500 Received: from mail-ob0-f174.google.com ([209.85.214.174]:49100 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754956AbaKYMmR (ORCPT ); Tue, 25 Nov 2014 07:42:17 -0500 MIME-Version: 1.0 In-Reply-To: <1416852146-9781-3-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> <1416852146-9781-3-git-send-email-a.ryabinin@samsung.com> From: Dmitry Chernenkov Date: Tue, 25 Nov 2014 16:41:56 +0400 Message-ID: Subject: Re: [PATCH v7 02/12] x86_64: load_percpu_segment: read irq_stack_union.gs_base before load_segment To: Andrey Ryabinin Cc: Andrew Morton , Dmitry Vyukov , Konstantin Serebryany , 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" , LKML , Thomas Gleixner , Ingo Molnar Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org LGTM On Mon, Nov 24, 2014 at 9:02 PM, Andrey Ryabinin wrote: > 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/