From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754614AbdCFVHs (ORCPT ); Mon, 6 Mar 2017 16:07:48 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:54877 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754320AbdCFVHA (ORCPT ); Mon, 6 Mar 2017 16:07:00 -0500 Date: Mon, 6 Mar 2017 21:35:00 +0100 From: Peter Zijlstra To: Mark Rutland Cc: Dmitry Vyukov , Andrew Morton , Andrey Ryabinin , Ingo Molnar , kasan-dev , "linux-mm@kvack.org" , LKML , "x86@kernel.org" , will.deacon@arm.com Subject: Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Message-ID: <20170306203500.GR6500@twins.programming.kicks-ass.net> References: <20170306124254.77615-1-dvyukov@google.com> <20170306125851.GL6500@twins.programming.kicks-ass.net> <20170306130107.GK6536@twins.programming.kicks-ass.net> <20170306162018.GC18519@leverpostej> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170306162018.GC18519@leverpostej> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 06, 2017 at 04:20:18PM +0000, Mark Rutland wrote: > > >> So the problem is doing load/stores from asm bits, and GCC > > >> (traditionally) doesn't try and interpret APP asm bits. > > >> > > >> However, could we not write a GCC plugin that does exactly that? > > >> Something that interprets the APP asm bits and generates these KASAN > > >> bits that go with it? > I don't think there's much you'll be able to do within the compiler, > assuming you mean to derive this from the asm block inputs and outputs. Nah, I was thinking about a full asm interpreter. > Those can hide address-generation (e.g. with per-cpu stuff), which the > compiler may erroneously be detected as racing. > > Those may also take fake inputs (e.g. the sp input to arm64's > __my_cpu_offset()) which may confuse matters. > > Parsing the assembly itself will be *extremely* painful due to the way > that's set up for run-time patching. Argh, yah, completely forgot about all that alternative and similar nonsense :/