Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2870877imu; Fri, 23 Nov 2018 16:25:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/VcqoKwKSIqzLSRPnfrhEUtj8bF3oBK+ztOSJv5VaV8C8KB1CTsu8FBoY5iHeRccDF/kI/J X-Received: by 2002:a63:1f4e:: with SMTP id q14mr15444622pgm.88.1543019133018; Fri, 23 Nov 2018 16:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543019132; cv=none; d=google.com; s=arc-20160816; b=cT5mCOrKN0l2VX1rc3lKz3holcjVrDNgLaUxlzpVlf1yphNFDrd96/8Hg+KaS1iuNl s22LB2Y6jn+0voIimYbich7fzTCp4Nj3HtHumIigUoTxQIutz3zqqisZbMGbJMVKIMKM aYkcZg7u0C6evbVeRSm8rDfYsU3fJ5AglFx55v1IiBF/0B3KsH7nOV0+w3TseDhwE4/f 67EOEei6CbqYJLwly7KtymtnEceLQfC0mqDBfo4xt8kSjKx8TZneWp7wtH1plBCeZ139 9YHTDjvq1ejk4lejNfc9gh/JFOBGf69TlX2uk1VAhWUJv5EJzzGAvQEzQeVRo90SV7zj pPeA== 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=hUuTUv+s2G7K7h9qC0GrCi8WkD6WoUB4IZbeVWgDQNg=; b=Px3CE3fm0DL9ymyyh23WXamuSq5Oa9ROOpzK/h/2/LsZGP+zNUs6GivqSA6R52QSx8 JrHfheCdxUFrcWZHYW6zZUjjxXwdpI+ksZcF573H8YbXobju+HClMw8sIi4Ew+1E6tEe awkHzmaw7i++wIKnlSimqx2Q2AbaLK7zdg9Z9l6tSumIeIYnxUwHv74pRXoKmXBUDQNs Vom0YtW83hRE1RdWGtCPj0VSGc2rvKJLVhdbVlr0IY/QsKv7tEPpY6YAjFBEz1r4gbF3 k4eoVm1CM1myFkFpQHyQ0adluiom4uytjZzYlgj1wLYM/oEu/9wzmSo+Yksgu3hrQrt+ Y0xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=DrZu+84s; 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 1-v6si57600610plv.205.2018.11.23.16.25.19; Fri, 23 Nov 2018 16:25:32 -0800 (PST) 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=pass header.i=@amarulasolutions.com header.s=google header.b=DrZu+84s; 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 S2405817AbeKWCZ3 (ORCPT + 99 others); Thu, 22 Nov 2018 21:25:29 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:41733 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728825AbeKWCZ3 (ORCPT ); Thu, 22 Nov 2018 21:25:29 -0500 Received: by mail-ed1-f65.google.com with SMTP id z28so8050927edi.8 for ; Thu, 22 Nov 2018 07:45:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hUuTUv+s2G7K7h9qC0GrCi8WkD6WoUB4IZbeVWgDQNg=; b=DrZu+84s6rzVOB+IHZ0V3NtYJvcBcxzGQ+tkFanJJ2N1igEh1N+9Du3DrAnulFhUzx Mm5WwNlYcyP9VlTQ+tjsL9+3xieAtsC1Ccy6mRRzJzZrXMOnHkCUAljaxLf4Ux7yp9sZ zLjb2Z5e49jm1Fy09dO0/ZO0ssHqj6ggNzMzA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=hUuTUv+s2G7K7h9qC0GrCi8WkD6WoUB4IZbeVWgDQNg=; b=o5oD9wAnZfFyknvs2JDrwC3lc35Mp7kPFSQ2A7gRzXHmkr0Zi7pHhv4TiTtYi1hSu4 bfpFp023+aFk/WiNwaro7XVO+xERd2LNv5CN61rHmQP+mWyxDZ/K4G3EmDL3fWhDFMhm BneD5E6Mrya0EqzgahCyuHs4kcLKBNzz0UDJf+KFft16Feyk1Gyt0CU6oS39yjtpS1+8 Z9Gyy4u8ZkoneLq3yAeyjtT8KrM9781Vy0E+WW0VfzY2knckwLcd2xIb2+7ue1GlbnoU QaFuQWAipaMrCZ6amQgpqVlKMHpcaOMgr6V32LAITc6B2Te8TaaxTwRT11MfRwxLaEAV DvRg== X-Gm-Message-State: AGRZ1gJhOvLuFgtYojvuJGbrt0gjOU/ufFXmnHsNR3TKdI4JJ3rxwE51 ql0WFff/HSRC/cEht2yIye+J5g== X-Received: by 2002:a17:906:2cd3:: with SMTP id r19-v6mr8489968ejr.38.1542901533862; Thu, 22 Nov 2018 07:45:33 -0800 (PST) Received: from andrea (85.100.broadband17.iol.cz. [109.80.100.85]) by smtp.gmail.com with ESMTPSA id x58sm13104893edm.10.2018.11.22.07.45.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Nov 2018 07:45:33 -0800 (PST) Date: Thu, 22 Nov 2018 16:45:27 +0100 From: Andrea Parri To: Oleg Nesterov Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [Question] smp_wmb() in prepare_uprobe() Message-ID: <20181122154526.GA14616@andrea> References: <20181121224124.GB4016@andrea> <20181122123655.GD28270@redhat.com> <20181122134400.GA10327@andrea> <20181122150524.GF28270@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181122150524.GF28270@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 22, 2018 at 04:05:24PM +0100, Oleg Nesterov wrote: > On 11/22, Andrea Parri wrote: > > > > > See 142b18ddc81439acda4bc4231b291e99fe67d507 ("uprobes: Fix handle_swbp() > > > vs unregister() + register() race") and the comment above this rmb(). > > > > Mmh..., at first glance, this suggests me that the above set_bit() and > > test_bit() to/from uprobe->flags are among these memory accesses. But > > this doesn't make sense to me: these accesses do not "alternate" (i.e., > > they both appear after the corresponding barrier..); instead I'd expect > > something like (on top of the above diff): > > > > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c > > index 2d29977522017..a75b9a08dee54 100644 > > --- a/kernel/events/uprobes.c > > +++ b/kernel/events/uprobes.c > > @@ -2178,10 +2178,18 @@ static void handle_swbp(struct pt_regs *regs) > > * After we hit the bp, _unregister + _register can install the > > * new and not-yet-analyzed uprobe at the same address, restart. > > */ > > - smp_rmb(); /* pairs with the smp_wmb() in prepare_uprobe() */ > > if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags))) > > goto out; > > > > + /* > > + * Pairs with the smp_wmb() in prepare_uprobe(). > > + * > > + * Guarantees that if we see the UPROBE_COPY_INSN bit set, then > > + * we must (can) also see the stores to &uprobe->arch performed > > + * by prepare_uprobe() (say). > > + */ > > + smp_rmb(); > > OOPS, you are right! Thanks. Thank you for the clarification; I'll send a patch with the fix shortly. Andrea > > Oleg. >