Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5728797ybp; Tue, 8 Oct 2019 07:27:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGk5AhSozb7KwMjkBk7Q+IRLY2mySwZ6PS65XKJ6oESozTEqJjP6+r86FJgf2u8m1NF+AC X-Received: by 2002:a17:906:699:: with SMTP id u25mr28772030ejb.250.1570544876119; Tue, 08 Oct 2019 07:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570544876; cv=none; d=google.com; s=arc-20160816; b=thzaJcJJW37lkrXcQMGlztSr66EKWyZUC5SgoKHcH8yQcRmBt3Wk2o0eQgeOrS+MgL yiVNd69JsQQsquvr2iYOU0h9CeCDPjmmn7sgoF9bnLlCZsIgZq00GKemQFju2endEFtG nkZ/iexQYufan2XbYOLcUgpzBdKX6/D6V1tN24ryH887RLZXRfmjqcTS/sGxsW7xDmma B+sHK5qrTPINIrbhPgbSQzvM6brp6hKvn5E/Z4aKvCHNHXn/pRo/t/F6ha65VEeGQvxT 1c61y41yimkmOitm4zQkt8alzU55PQLjrlQKRMs89su6BznF9TN+j3W4Hd96wJ91j3Zn LkIQ== 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=ac0sXZKMHyYhQ+ZkqWghDlw28diDOjKnf3qOchUcnUs=; b=NLmjdqK3roBCkjhcs132zGUN6TC7Mh41aHFe6OTCPyIG2XqOxtE1myMGJ76CVMCwuk RSnfT2oenPS21PXIKGuo9/AOZn392vDULzj/B8cNM5q0gxULypf8/cKwIqkJbEegSWOH uuh9gki6AC+AOI42Hd9lUPn54aORyDaESDIrA7DMPq9zYViXxWlC3Wr8qbJufMbmLxUb nb73vwLnOnw8UVbDXMiEhpndq1tVvTsk0WQzqgyMAtR9j5DlksD96QFmUDvgqYdy19a4 stPuNGI5RsupoQG2OselAIkBz4qN2QYd/znPvblykoEs8jeMRULHegQoJGRw3hgDudd+ wDuQ== 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 x19si8781270eje.336.2019.10.08.07.27.32; Tue, 08 Oct 2019 07:27:56 -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 S1727051AbfJHOYU (ORCPT + 99 others); Tue, 8 Oct 2019 10:24:20 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57079 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbfJHOYU (ORCPT ); Tue, 8 Oct 2019 10:24:20 -0400 Received: from p2e585ebf.dip0.t-ipconnect.de ([46.88.94.191] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iHqPP-0007Ee-SD; Tue, 08 Oct 2019 14:24:15 +0000 Date: Tue, 8 Oct 2019 16:24:14 +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: <20191008142413.h5kczta7jo4ado6u@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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191008142035.GA13564@andrea.guest.corp.microsoft.com> 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 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. Christian