From: Peter Zijlstra Subject: Re: [PATCH 3/3] asm-generic, x86: Add bitops instrumentation for KASAN Date: Wed, 29 May 2019 14:01:18 +0200 Message-ID: <20190529120118.GQ2623@hirez.programming.kicks-ass.net> References: <20190528163258.260144-1-elver@google.com> <20190528163258.260144-3-elver@google.com> <20190528165036.GC28492@lakrids.cambridge.arm.com> <20190529100116.GM2623@hirez.programming.kicks-ass.net> <20190529103010.GP2623@hirez.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: David Laight Cc: 'Dmitry Vyukov' , Marco Elver , Mark Rutland , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , the arch/x86 maintainers , Arnd Bergmann , Josh Poimboeuf , "open list:DOCUMENTATION" , LKML , linux-arch , kasan-dev List-Id: linux-arch.vger.kernel.org On Wed, May 29, 2019 at 11:20:56AM +0000, David Laight wrote: > From: Dmitry Vyukov > > Sent: 29 May 2019 11:57 > > Interesting. Does an address passed to bitops also should be aligned, > > or alignment is supposed to be handled by bitops themselves? > > The bitops are defined on 'long []' and it is expected to be aligned. > Any code that casts the argument is likely to be broken on big-endian. > I did a quick grep a few weeks ago and found some very dubious code. > Not all the casts seemed to be on code that was LE only (although > I didn't try to find out what the casts were from). > > The alignment trap on x86 could be avoided by only ever requesting 32bit > cycles - and assuming the buffer is always 32bit aligned (eg int []). > But on BE passing an 'int []' is just so wrong .... Right, but as argued elsewhere, I feel we should clean up the dubious code instead of enabling it.