Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3792415imm; Mon, 25 Jun 2018 04:49:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIqrra27gIlZF5QE6dQg/7+duIrwOxb6SNZtzebm25FYIYCE3acwv6DQsbDWsNcPxXcVkG+ X-Received: by 2002:a17:902:7888:: with SMTP id q8-v6mr12191375pll.79.1529927376921; Mon, 25 Jun 2018 04:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529927376; cv=none; d=google.com; s=arc-20160816; b=GWGCrm1pibzXkWof07ShJ8SVF8YPKUKMDannG7gSvAND86qiyhg13xAZ/0F678r/OR cx+dyJKOLF4oNlN1h49A0dCXentFKyjvCSd6+eGIq6V6pDw+we11n5NdDR1logkBd5LW cR7JVfuFL8/C/WXXs/LJnk4t0rpAUk3UdDTwrIdtjxTMb3I47rpi2/Fdnio5GAAIinc3 H0jP5HA3Q+N2MzzzFV59OUaRcmWp9UnqP1+vo3wSGEd+C68Huqe/cGEVZcSndAN34kDX LPoKuVTvQKD96zBov39dSrEv3sPxD/733aGog/yiRXH1Neg6DM28Al0GsGM9K5oVdMkd IePw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Ae1OJBriDj8TNyLK2zwrtkmdAh+QAULADbIU/nVCG64=; b=pkqO/uAgxLUTsLmfh23SGwQZ54u6sYT/S+eV6o8MhaidJh+PwUs9PfOJWW8MrF2xv7 8NmsQEiQEZ3G5u0NZbaTcdCFxIwYCFYgiCbiwEYY8V/ixQADqEgffykCphulAa51CQEP Hg3SFfaJm7iqXV6O9gqYsa2NeeKh1iqAwyBcRmvY4neOoJ6gyYswVQPEtjTvROmEqM7f j/dlUFuvmHPDKlCYQNGSsaNVcHFSpXak5xANamAEKWJfvtaY/2HrKi/+Exi68PGnHIOn +d5562dG/CngfUq4bgmqJNrLhjBFexqKTLB0IW886PpOsCvMLje3RAinJxWfJry35bMx XxGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8-v6si518008pgq.432.2018.06.25.04.49.22; Mon, 25 Jun 2018 04:49:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932819AbeFYLsh (ORCPT + 99 others); Mon, 25 Jun 2018 07:48:37 -0400 Received: from foss.arm.com ([217.140.101.70]:55356 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932211AbeFYLse (ORCPT ); Mon, 25 Jun 2018 07:48:34 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4C7A618A; Mon, 25 Jun 2018 04:48:33 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1AB2E3F59C; Mon, 25 Jun 2018 04:48:31 -0700 (PDT) Date: Mon, 25 Jun 2018 12:48:20 +0100 From: Mark Rutland To: Andrea Parri Cc: linux-kernel@vger.kernel.org, will.deacon@arm.com, peterz@infradead.org, boqun.feng@gmail.com, Dmitry Vyukov Subject: Re: [PATCHv2 03/11] atomics: simplify cmpxchg() instrumentation Message-ID: <20180625114820.zhrhcyy4s47n4r5e@lakrids.cambridge.arm.com> References: <20180625105952.3756-1-mark.rutland@arm.com> <20180625105952.3756-4-mark.rutland@arm.com> <20180625113803.GA13628@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180625113803.GA13628@andrea> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 25, 2018 at 01:38:03PM +0200, Andrea Parri wrote: > On Mon, Jun 25, 2018 at 11:59:44AM +0100, Mark Rutland wrote: > > Currently we define some fairly verbose wrappers for the cmpxchg() > > family so that we can pass a pointer and size into kasan_check_write(). > > > > The wrapper duplicate the size-switching logic necessary in arch code, > > and only work for scalar types. On some architectures, (cmp)xchg are > > used on non-scalar types, and thus the instrumented wrappers need to be > > able to handle this. > > > > We could take the type-punning logic form {READ,WRITE}_ONCE(), but this > > makes the wrappers even more verbose, and requires several local > > variables in the macros. > > > > Instead, let's simplify the wrappers into simple macros which: > > > > * snapshot the pointer into a single local variable, called __ai_ptr to > > avoid conflicts with variables in the scope of the caller. > > > > * call kasan_check_read() on __ai_ptr. > > Maybe I'm misreading the diff: aren't you calling kasan_check_write()? Sorry, yes -- I'll update the commit message. > (not sure if it makes a difference in this case/for KTSan, but CMPXCHG > does not necessarily perform a write...) For KASAN, it shouldn't matter -- it'll only be used to report whether the access was a read or write, and it's fine to say that it's a potential write. KTSAN's not yet upstream, so I'll leave that detail to Dmitry. Thanks, Mark.