From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753794AbbJPKBI (ORCPT ); Fri, 16 Oct 2015 06:01:08 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:39311 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752495AbbJPKBF (ORCPT ); Fri, 16 Oct 2015 06:01:05 -0400 Date: Fri, 16 Oct 2015 12:00:21 +0200 From: Peter Zijlstra To: Andrey Ryabinin Cc: linux-kernel@vger.kernel.org, Ingo Molnar , 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 , "Paul E. McKenney" Subject: Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Message-ID: <20151016100021.GR3816@twins.programming.kicks-ass.net> References: <1444739750-29241-1-git-send-email-aryabinin@virtuozzo.com> <1444988694-26043-1-git-send-email-aryabinin@virtuozzo.com> <1444988694-26043-2-git-send-email-aryabinin@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1444988694-26043-2-git-send-email-aryabinin@virtuozzo.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 16, 2015 at 12:44:53PM +0300, Andrey Ryabinin wrote: > Some code may perform racy by design memory reads. This could be > harmless, yet such code may produce KASAN warnings. > > To hide such accesses from KASAN this patch introduces > READ_ONCE_NOKSAN() macro. KASAN will not check the memory > accessed by READ_ONCE_NOKSAN(). The KernelThreadSanitizer (KTSAN) > is going to ignore it as well. > > This patch creates __read_once_size_noksan() a clone of > __read_once_size(). The only difference between them is > 'no_sanitized_address' attribute appended to '*_nokasan' function. > This attribute tells the compiler that instrumentation of memory > accesses should not be applied to that function. We declare it as > static '__maybe_unsed' because GCC is not capable to inline such > function: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 > > With KASAN=n READ_ONCE_NOKSAN() is just a clone of READ_ONCE(). Would we need a similar annotation for things like mutex_spin_on_owner()'s dereference of owner, or is that considered safe by KASAN? (its not actually safe; as I remember we have a problem with using rcu_read_lock for tasks like that)