Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1250452

[PATCH v5 2/2] x86/mm: Silence KASAN warnings in get_wchan()

From Andrey Ryabinin <aryabinin@virtuozzo.com>
Newsgroups linux.kernel
Subject [PATCH v5 2/2] x86/mm: Silence KASAN warnings in get_wchan()
Date 2015-10-19 10:40 +0200
Message-ID <qle93-7rs-11@gated-at.bofh.it> (permalink)
References <qj721-6Fq-17@gated-at.bofh.it> <qle93-7rs-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Reported-by: Sasha Levin <sasha.levin@oracle.com>
---
 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;
 }
-- 
2.4.9

--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/2] Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-13 14:50 +0200
  [PATCH v3 0/2] Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-13 17:30 +0200
    [PATCH v3 1/2] Provide READ_ONCE_NOCHECK() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-13 17:40 +0200
      [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK  () tip-bot for Andrey Ryabinin <tipbot@zytor.com> - 2015-10-14 17:40 +0200
        Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 17:50 +0200
          Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:00 +0200
            Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:10 +0200
              Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Peter Zijlstra <peterz@infradead.org> - 2015-10-14 18:20 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:20 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Andy Lutomirski <luto@amacapital.net> - 2015-10-14 18:30 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Peter Zijlstra <peterz@infradead.org> - 2015-10-14 18:40 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Ingo Molnar <mingo@kernel.org> - 2015-10-14 19:50 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Andy Lutomirski <luto@amacapital.net> - 2015-10-14 20:00 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Peter Zijlstra <peterz@infradead.org> - 2015-10-14 18:30 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:40 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Peter Zijlstra <peterz@infradead.org> - 2015-10-14 19:00 +0200
              Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 18:30 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:40 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 19:10 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 19:30 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 19:40 +0200
            Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 18:10 +0200
            Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK  () Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-14 18:20 +0200
              Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:40 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 19:10 +0200
      linux-next: build problems (Was: [PATCH v3 1/2] Provide  READ_ONCE_NOCHECK()) Stephen Rothwell <sfr@canb.auug.org.au> - 2015-10-15 11:20 +0200
        Re: linux-next: build problems (Was: [PATCH v3 1/2] Provide  READ_ONCE_NOCHECK()) Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-15 12:10 +0200
        [PATCH] compiler, READ_ONCE: Fix build failure with some older GCC Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-15 12:30 +0200
          Re: [PATCH] compiler, READ_ONCE: Fix build failure with some older  GCC Ingo Molnar <mingo@kernel.org> - 2015-10-15 13:40 +0200
    [PATCH v3 2/2] x86/process: Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-13 17:40 +0200
      [tip:locking/urgent] x86/mm: Silence KASAN warnings in get_wchan(  ) tip-bot for Andrey Ryabinin <tipbot@zytor.com> - 2015-10-14 17:40 +0200
  [PATCH v4 2/2] x86/mm: Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 11:50 +0200
  [PATCH v4 0/2] Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 11:50 +0200
    [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 11:50 +0200
      Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Peter Zijlstra <peterz@infradead.org> - 2015-10-16 12:10 +0200
        Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 13:00 +0200
          Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Peter Zijlstra <peterz@infradead.org> - 2015-10-16 13:10 +0200
      Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Borislav Petkov <bp@alien8.de> - 2015-10-16 12:40 +0200
        Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 14:00 +0200
          Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Ingo Molnar <mingo@kernel.org> - 2015-10-18 09:30 +0200
        Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-16 18:10 +0200
    [PATCH v4 0/2] Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 11:50 +0200
  [PATCH v5 2/2] x86/mm: Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-19 10:40 +0200
    [tip:x86/urgent] x86/mm, kasan:   Silence KASAN warnings in get_wchan() tip-bot for Andrey Ryabinin <tipbot@zytor.com> - 2015-10-20 11:50 +0200
  [PATCH v5 0/2] Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-19 10:40 +0200
    [PATCH v5 1/2] compiler, atomics: Provide READ_ONCE_NOCHECK() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-19 10:40 +0200
      [tip:x86/urgent] compiler, atomics, kasan:   Provide READ_ONCE_NOCHECK() tip-bot for Andrey Ryabinin <tipbot@zytor.com> - 2015-10-20 11:50 +0200

csiph-web