Skip to content

Commit f7d27c3

Browse files
aryabininIngo Molnar
authored andcommitted
x86/mm, kasan: Silence KASAN warnings in get_wchan()
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 <sasha.levin@oracle.com> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andrey Konovalov <andreyknvl@google.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Kostya Serebryany <kcc@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wolfram Gloger <wmglo@dent.med.uni-muenchen.de> Cc: kasan-dev <kasan-dev@googlegroups.com> Link: http://lkml.kernel.org/r/1445243838-17763-3-git-send-email-aryabinin@virtuozzo.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent d976441 commit f7d27c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/x86/kernel/process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,14 @@ unsigned long get_wchan(struct task_struct *p)
550550
if (sp < bottom || sp > top)
551551
return 0;
552552

553-
fp = READ_ONCE(*(unsigned long *)sp);
553+
fp = READ_ONCE_NOCHECK(*(unsigned long *)sp);
554554
do {
555555
if (fp < bottom || fp > top)
556556
return 0;
557-
ip = READ_ONCE(*(unsigned long *)(fp + sizeof(unsigned long)));
557+
ip = READ_ONCE_NOCHECK(*(unsigned long *)(fp + sizeof(unsigned long)));
558558
if (!in_sched_functions(ip))
559559
return ip;
560-
fp = READ_ONCE(*(unsigned long *)fp);
560+
fp = READ_ONCE_NOCHECK(*(unsigned long *)fp);
561561
} while (count++ < 16 && p->state != TASK_RUNNING);
562562
return 0;
563563
}

0 commit comments

Comments
 (0)