Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5810817ybp; Tue, 8 Oct 2019 08:38:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIbNDFnV5/Y8Sv6nDCkb3xUao9eA1PAy1x6h3FIGWa0PJTSpGiNLzYBDJy/VwKSijeITRr X-Received: by 2002:a50:9fce:: with SMTP id c72mr2875330edf.166.1570549116492; Tue, 08 Oct 2019 08:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570549116; cv=none; d=google.com; s=arc-20160816; b=r3BJIpE47ldROG84e5A3q6qCFmo0irNFh2f4UhVS3xSPVxyKXnrUCIKt8vgiWYHag7 EouU+0fjHGAbin4RmC3RKpQ79UOjkvw1mIeD1efWNoLiYV0Wi8CUIxk+D5bqQVwNFOr2 B5FU8tEMkAGzbrrNhGJ7wLKwU/amFs0pOxa0MPkrnnwW7mGg9vp8laxIMlfNiXtLwBVE XyUetkevtT46lWXIaZt5ZbagGtQ0bdvesTDMUhUAAxOzZFKrncbtmffeq4VVGMNjD/dm 4ZoRixpGPg5abm+16VbCX+EX4qc0AhQ/AjDpXeQfjcZOdONopMReBNDuhnWE9XLM8AVm Xwtg== 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; bh=uG9GvQVWJ8wmIRWU1XR0j/+1kzjqaM9qGYoBX7JI3vU=; b=tpwNuJDip6vho2/tpWbIXvW+14co7L0ADoTTwLZy5F5SO8WlcTkXFcyILS/jcxraKR P2OkSPZM+PvrwcGglZ3LFZf2u0QsMOHbPcUa0WUv/ducQv1zSqPJqWlel6itU2M7beeA vLVM5v/0MYwBXeaXP/SHUqwp0l4rugy5Xkg76J96Uf79AEegzbOjUWcGxdgB5q4GlJmG XPDW8+kjFZJn6ikyBgN+FQEDbQWNGxzpE60N6YI3HYYefw4o3JITJ3spJo6qz3kBnFJV z88RixxQPohgsKWjSjiTcrIdXhXmG8aaYAQYLzdtEjO0Uu/RVuZmrkg1lXi3y2h4sREe QXxw== 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 q4si8894606eji.152.2019.10.08.08.38.12; Tue, 08 Oct 2019 08:38: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 S1726839AbfJHPfl (ORCPT + 99 others); Tue, 8 Oct 2019 11:35:41 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:60722 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfJHPfk (ORCPT ); Tue, 8 Oct 2019 11:35:40 -0400 Received: from [213.220.153.21] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iHrWS-0004tt-B1; Tue, 08 Oct 2019 15:35:36 +0000 Date: Tue, 8 Oct 2019 17:35:35 +0200 From: Christian Brauner To: Andrea Parri Cc: Dmitry Vyukov , bsingharora@gmail.com, Marco Elver , LKML , syzbot , syzkaller-bugs , stable Subject: Re: [PATCH v2] taskstats: fix data-race Message-ID: <20191008153533.r43qyvasfqahmq6f@wittgenstein> References: <20191007104039.GA16085@andrea.guest.corp.microsoft.com> <20191007110117.1096-1-christian.brauner@ubuntu.com> <20191007131804.GA19242@andrea.guest.corp.microsoft.com> <20191007141432.GA22083@andrea.guest.corp.microsoft.com> <20191008142035.GA13564@andrea.guest.corp.microsoft.com> <20191008142413.h5kczta7jo4ado6u@wittgenstein> <20191008152659.GA16065@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191008152659.GA16065@andrea> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 08, 2019 at 05:26:59PM +0200, Andrea Parri wrote: > On Tue, Oct 08, 2019 at 04:24:14PM +0200, Christian Brauner wrote: > > On Tue, Oct 08, 2019 at 04:20:35PM +0200, Andrea Parri wrote: > > > On Mon, Oct 07, 2019 at 04:18:26PM +0200, Dmitry Vyukov wrote: > > > > On Mon, Oct 7, 2019 at 4:14 PM Andrea Parri wrote: > > > > > > > > > > > > > static struct taskstats *taskstats_tgid_alloc(struct task_struct *tsk) > > > > > > > > { > > > > > > > > struct signal_struct *sig = tsk->signal; > > > > > > > > - struct taskstats *stats; > > > > > > > > + struct taskstats *stats_new, *stats; > > > > > > > > > > > > > > > > - if (sig->stats || thread_group_empty(tsk)) > > > > > > > > - goto ret; > > > > > > > > + /* Pairs with smp_store_release() below. */ > > > > > > > > + stats = READ_ONCE(sig->stats); > > > > > > > > > > > > > > This pairing suggests that the READ_ONCE() is heading an address > > > > > > > dependency, but I fail to identify it: what is the target memory > > > > > > > access of such a (putative) dependency? > > > > > > > > > > > > I would assume callers of this function access *stats. So the > > > > > > dependency is between loading stats and accessing *stats. > > > > > > > > > > AFAICT, the only caller of the function in 5.4-rc2 is taskstats_exit(), > > > > > which 'casts' the return value to a boolean (so I really don't see how > > > > > any address dependency could be carried over/relied upon here). > > > > > > > > This does not make sense. > > > > > > > > But later taskstats_exit does: > > > > > > > > memcpy(stats, tsk->signal->stats, sizeof(*stats)); > > > > > > > > Perhaps it's supposed to use stats returned by taskstats_tgid_alloc? > > > > > > Seems reasonable to me. If so, replacing the READ_ONCE() in question > > > with an smp_load_acquire() might be the solution. Thoughts? > > > > I've done that already in my tree yesterday. I can resend for another > > review if you'd prefer. > > Oh nice! No need to resend of course. ;D FWIW, I can check it if you > let me know the particular branch/commit (guessing that's somewhere in > git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git, yes?). Oh ups, yeah of course :) https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=taskstats_syzbot Thanks! Christian