From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932307AbbJMNte (ORCPT ); Tue, 13 Oct 2015 09:49:34 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:33140 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932142AbbJMNt2 (ORCPT ); Tue, 13 Oct 2015 09:49:28 -0400 Date: Tue, 13 Oct 2015 15:48:59 +0200 From: Ingo Molnar To: Andrey Ryabinin Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org, Andrew Morton , Andy Lutomirski , Andrey Konovalov , Kostya Serebryany , Alexander Potapenko , kasan-dev , Borislav Petkov , Denys Vlasenko , Andi Kleen , Dmitry Vyukov , Sasha Levin , Wolfram Gloger Subject: Re: [PATCH v2 2/2] x86/process: Silence KASAN warnings in get_wchan() Message-ID: <20151013134859.GB8843@gmail.com> References: <1444739750-29241-1-git-send-email-aryabinin@virtuozzo.com> <1444739750-29241-3-git-send-email-aryabinin@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1444739750-29241-3-git-send-email-aryabinin@virtuozzo.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Andrey Ryabinin wrote: > get_wchan() is racy by design, it may access volatile stack > of running task, thus it may access redzone in a stack frame > and cause KASAN to warn about this. > > Use READ_ONCE_NOCHECK() to silence these warnings. > > Reported-by: Sasha Levin > Signed-off-by: Andrey Ryabinin > --- > arch/x86/kernel/process.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c > index 39e585a..e28db18 100644 > --- a/arch/x86/kernel/process.c > +++ b/arch/x86/kernel/process.c > @@ -550,14 +550,14 @@ unsigned long get_wchan(struct task_struct *p) > if (sp < bottom || sp > top) > return 0; > > - fp = READ_ONCE(*(unsigned long *)sp); > + fp = READ_ONCE_NOCHECK(*(unsigned long *)sp); > do { > if (fp < bottom || fp > top) > return 0; > - ip = READ_ONCE(*(unsigned long *)(fp + sizeof(unsigned long))); > + ip = READ_ONCE_NOCHECK(*(unsigned long *)(fp + sizeof(unsigned long))); > if (!in_sched_functions(ip)) > return ip; > - fp = READ_ONCE(*(unsigned long *)fp); > + fp = READ_ONCE_NOCHECK(*(unsigned long *)fp); > } while (count++ < 16 && p->state != TASK_RUNNING); > return 0; > } Hm, exactly how is the 'red zone' defined? Is this about the current task mostly, or when doing get_wchan() on other tasks? Thanks, Ingo