Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5721469ybp; Tue, 8 Oct 2019 07:21:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkQYUyP1ulkrlQWUDSlRkzkVd9CwocN08ZeyLzduy3YiZ+sG7n8riL9Uog2/K54vQyjgB3 X-Received: by 2002:aa7:c614:: with SMTP id h20mr33520475edq.209.1570544507527; Tue, 08 Oct 2019 07:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570544507; cv=none; d=google.com; s=arc-20160816; b=ebYnhHAOjrKOqm2P+Kr7ksJna0avwepYhkhImHZXY2MQ+beqERUJNeu8Va5NUkG2yI VSQ1GRrtFO1ewl/rLzdZaKJJHxZJi/5zBKHRo/Pvn6Ao7bR0PVj+VtGesg+2zFZjrOnL aRmk4c8JaUmTZvrLG2UaBLCoCErCvrEBuHMvHSrpf5rBS3I/NmMNVk1uMis7gEB3vQ20 vjtH6cCMDB0bK1QKpTMYKgJMROjcRGdQe3wWGXzC0kkxSyg7NtBifMZBc61i9SekCzUN xCAitPd2k+0so6QSYjOJ+CsQYmefCY2C0gnFJPugITAqmm9iCH5YOHjkCoVTqbmJU0as G+tQ== 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=jGk4MWMZkTAIeXYuDbRwhGcphWqWu107D+eHL9NFn3g=; b=aIwruK8/ny5DKI+GCuaDSmfgCaK4gWIywRnCtfLydYDIrcc4YG4f+Wcsx3D02Nixwc 26jXvfaueAgyRoZWPe2mTz07bdCZsPg/Rd4cdcDkpfIPd4KnFQuIo+E1g1P5zlufBjsq Tk/reJS9Kodvsa3BBIZsk54rdU06Aq2XsIihZEycNVg3nRZiWR1bBOfLavFhJ1dZh8Io ByROrOTvmna8mo71xM9EpbLYVsrfm63WOlUQ3Gmes/DMhvxRhBqT54sgDbT1nutK7wYc +V4Tes3eWUHpOEjgFIBOa10Cf3biWCqJNvFuj8DAHdfCVda8dPq9hTSnKLbjFR9QoeLW x/sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=InzhK1nL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si8837853eju.269.2019.10.08.07.21.24; Tue, 08 Oct 2019 07:21:47 -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=pass header.i=@gmail.com header.s=20161025 header.b=InzhK1nL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726254AbfJHOUp (ORCPT + 99 others); Tue, 8 Oct 2019 10:20:45 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35228 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbfJHOUp (ORCPT ); Tue, 8 Oct 2019 10:20:45 -0400 Received: by mail-wr1-f65.google.com with SMTP id v8so19655761wrt.2; Tue, 08 Oct 2019 07:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=jGk4MWMZkTAIeXYuDbRwhGcphWqWu107D+eHL9NFn3g=; b=InzhK1nLbMGYUei3X0D3rLlwU60tfmfvgVRQZsqB8Deg7Cy0csosomUPXmqTj+imVy igtXMAV2IAjGFF6u02l/cBsCagUB52DbTrK+x9bWKKQgwEa26XNK+Eos7HG5+8w8HDIf 693w/nnvyf5+kBpYlOb4qE2Ym/oRQ0047SAUGNcfDTc7JQp3GmPMWM8H9a0JY1l89Fyi 4CqHxOTZ5dLogj5/VuPRdrCWEkNNNuTleBH5mEL89x0uuXbu/+BNsGmhirPKvthjUbEI ZaSVCG0ZCn8GzBvLQWUQU9qzjTtHh0A/otWE4V97kbUjH6AE//wHnRsl6VQ3queneAb6 vh4Q== 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=jGk4MWMZkTAIeXYuDbRwhGcphWqWu107D+eHL9NFn3g=; b=L2JrkF7baKuwpl3jqmIKMn/80CE5ZqQylS7KClh270R9kTe3lw3r3LE6AI7p00BrBY pFEHtNNfggtUzb4vNf3ronUna+BY/0H+CaVV6N8ZA2eox5E4U9i2+IZblu4qDHJ7egKj z+z9a2Ae6g7g2jbM4Bs/UfTVB7IRJvhvIHTI3EVcp7Woe+zebELxpOjOTyCPWMmz5G2I PEOngH/AsXY1nA8OfML+6eDtgWQ9DDM+O1QHsMtqqMMlN6MkHQiIi1IxVMosjpIcmCy7 Xm8XjQoTdKDy6yBU6bFxgbYMXfkniUDfu6OqLcSHRPQYlUOxHj2damLCqV3q/K2d/LcP 9+3w== X-Gm-Message-State: APjAAAX/7VTf7qmw3U7R74lCQTihP8L6iGHeF21Dj4b/ENbnnCQdErkn EHS14R/s4AvSXqjc0KW2xZI= X-Received: by 2002:a5d:6a90:: with SMTP id s16mr27268223wru.284.1570544441329; Tue, 08 Oct 2019 07:20:41 -0700 (PDT) Received: from andrea.guest.corp.microsoft.com (userh394.uk.uudial.com. [194.69.102.21]) by smtp.gmail.com with ESMTPSA id h7sm19467307wrs.15.2019.10.08.07.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 07:20:40 -0700 (PDT) Date: Tue, 8 Oct 2019 16:20:35 +0200 From: Andrea Parri To: Dmitry Vyukov Cc: Christian Brauner , bsingharora@gmail.com, Marco Elver , LKML , syzbot , syzkaller-bugs , stable Subject: Re: [PATCH v2] taskstats: fix data-race Message-ID: <20191008142035.GA13564@andrea.guest.corp.microsoft.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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? Andrea