Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp335152ybi; Fri, 31 May 2019 02:11:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxN+nJwkodu1Pu37TFzlDSkAY77VFAj6d6oRzyMnmzP4fpRhgBt1BOMUjJAPMoImdaQCTwX X-Received: by 2002:a62:e00e:: with SMTP id f14mr8402511pfh.257.1559293888259; Fri, 31 May 2019 02:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559293888; cv=none; d=google.com; s=arc-20160816; b=0OB1kfecWfyQpF8pWxIrHP7yaF0yV6QjvHXlCZZlZ5Qo8r/ifoLzE36liWYHcBVUmq UdG0WA2kphLAlHihEhHdTwxMe/Bi7wpahhhG7yE0GEehMbjX+am7h5C/rQZoG04+Gu1c NhZzSeOkj9giUKm5ntJ9oOcK+T9dRu/mq7I6ovR3l20vkPZj5Kfm6zx1wx0DFS2yHXxT e4yHvISZ0JfV8FiWT1mIB1sscG2b7OQbYicM07BZeTj4qphLwoJ7l96+RYgklc6vF8GA HzVU440jR+At/TNkfOCxe4BtzXa9lRHlfEgiOVyo3/bCW8JJ44gPsqzAy7LZLNONjByi 6/PA== 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:dkim-signature; bh=1bHe67ZMzZlGf0HYxrOOIqB9sFZ2/e7PsY66nGtu6ZE=; b=G9XSjmnVbcjt5OROBItseD8IEqqyuET0gh1MIjqiJixThqAAa4e2Xy+1P7hx0Nw26p O3mr/MZI0S46v9T0XWDqVySLdS4OgFkyMzAT7OWj2/U6N/xosmCE5Atq4NSNIwbLwHtF eVV5e9HDF4I2QHddvHSShlv+bJL3Qevnmvo2pJ0iikfxJTUN1GXS2PUOAYVWvumbOxin NMh7ueQnQF4TCMQaHgW/I/bnZWBe6DZMGOueB0pkukT+QVfBtZjHi3EVkS3zvu4Wqn/6 erQRO8GJGdRwyRP+pWQEa1dq4KdmCGPJNnUbRjx30wkU2lc6aIpKDJqyJwejEc/hrt00 5mMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=tL1GT6mo; 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 bx8si4976192pjb.79.2019.05.31.02.11.10; Fri, 31 May 2019 02:11:28 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=tL1GT6mo; 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 S1726835AbfEaJIW (ORCPT + 99 others); Fri, 31 May 2019 05:08:22 -0400 Received: from merlin.infradead.org ([205.233.59.134]:58958 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbfEaJIW (ORCPT ); Fri, 31 May 2019 05:08:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1bHe67ZMzZlGf0HYxrOOIqB9sFZ2/e7PsY66nGtu6ZE=; b=tL1GT6mo9h6RdsMJ0+qLgkhZ0 4K8PqgIsUlKZ3DbHJGDLh9Qvaw56cQxJt1ZJruo2VjV6MYzXChvvsUoxPlyypBAy/fdKRrxsQi5wp LFYcB3JXFxnFvCziIdLUddzj5KVKCopIzDeW5TF1/76TBg11NiUtQElkrrSI9jE8BxuwrvEBoYpDz cTLKHbUKOP9x6aFJTf+vs8DnTFPB3JegbLMyFZXmjoUjukCwJSz6Ib129tcLEl+rccbsdxGoGeu8g qeb2dgsdZYXS8X51oicRhWubxj/OEddRi7+bz1zQ12xwg5d2noRj9/pKPsI/tFDwlY9b7X9nJHMvt hMgEBOqmA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWdW7-0003Au-3T; Fri, 31 May 2019 09:08:03 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4630D201B8CFE; Fri, 31 May 2019 11:08:01 +0200 (CEST) Date: Fri, 31 May 2019 11:08:01 +0200 From: Peter Zijlstra To: Andrea Parri Cc: Jann Horn , Oleg Nesterov , "Eric W . Biederman" , Andrew Morton , Kees Cook , David Howells , kernel list , Will Deacon , "Paul E. McKenney" Subject: Re: [PATCH] ptrace: restore smp_rmb() in __ptrace_may_access() Message-ID: <20190531090801.GM2677@hirez.programming.kicks-ass.net> References: <20190529113157.227380-1-jannh@google.com> <20190529162120.GB27659@redhat.com> <20190530103405.GA6392@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190530103405.GA6392@andrea> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 30, 2019 at 12:34:05PM +0200, Andrea Parri wrote: > On Wed, May 29, 2019 at 07:38:46PM +0200, Jann Horn wrote: > > On Wed, May 29, 2019 at 6:21 PM Oleg Nesterov wrote: > > > (I am wondering if smp_acquire__after_ctrl_dep() could be used instead, just to > > > make this code look more confusing) > > > > Uuh, I had no idea that that barrier type exists. The helper isn't > > even explicitly mentioned in Documentation/memory-barriers.rst. I > > don't really want to use dark magic in the middle of ptrace access > > logic... Yeah, it's sorta not documented on purpose. It's too easy to get wrong and we've only used it inside a number of more convenient primitives as an optimzation. I suppose we could add it to the section on control dependencies; just to scare more people :-) > > Anyway, looking at it, I think smp_acquire__after_ctrl_dep() doesn't > > make sense here; quoting the documentation: "A load-load control > > dependency requires a full read memory barrier, not simply a data > > dependency barrier to make it work correctly". IIUC > > smp_acquire__after_ctrl_dep() is for cases in which you would > > otherwise need a full memory barrier - smp_mb() - and you want to be > > able to reduce it to a read barrier. > > It is supposed to be used when you want an ACQUIRE but you only have a > control dependency (so you "augment the dependency" with this barrier). > > FWIW, I do agree on the "dark magic"..., and I'd strongly recommend to > not use this barrier (or, at least, to use it with high suspicion). Right, so the purpose of the barrier is to upgrade a LOAD->STORE order (as provided by the ctrl-dep) to a LOAD->{LOAD,STORE} order as would be provided by load-acquire.