Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp810976ybp; Wed, 9 Oct 2019 04:43:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7kyuEL23AAQIZIoHgGBfnbEFnByIAttCN5FPAoAMseNLxQfXmAlV/qUoOdl9dS7jdUGAq X-Received: by 2002:a17:906:4748:: with SMTP id j8mr2380077ejs.210.1570621407630; Wed, 09 Oct 2019 04:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570621407; cv=none; d=google.com; s=arc-20160816; b=f4MuAHBtNO5LUzJtMgR4hH4rJrjWV/s/wGIy+Tsno6aRAyPVv0deIDqy8eFxD8LHVR pqFmlKS+A4oViBPEf8WluhJd0oRXU4lKiC3XU21af87Sz83aTe9O98slA+NzjyWUEeny NXGMtcJVp693O8ruweOuEbCBDTjYpWQgJ/0BJXijt2emcJ7M6VmLIglUW4KWb9j47mmN 2nTAxzlsZ1NJAVNeU0ZH82Ac5p9PqxrKbT4Vo6aqQSnmd401EnKPTEWa9jO4PkxhKvyq OFUlcImmDXJC2Xa/Ah39Hx+gA75s4LCbsRFGB/aodkRMBxENwIT0FB0CLUC7xoxqBnPk dYEQ== 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=8MuRLyNNWl0Sj1g0uU7kynhX2aCGolOyaYv8YY/SHRk=; b=nDOeAQj/Y9GD7/JTW3WOZ1ddyixWulThTvpGYHv7ZdSBka+bsqIyb+g6mhE+ym6acy f5un0aEUu/FJhsKteB1MlDMHRPAIyrFBOora5lcELWoShILQIJZgX9iCFbFB+xIjtZ3c 9xu2Kn/GRsw10vDBO5uRzbXcT4OqcQOzaAC6wUXWdxkDagxDbH3W9GVf0JGXY2ymbd7f XmEDH7gfgeE8Q9sOuipzY6BZ7K/Y0IVY1qGmXNYjQip3PUymTTrCim4LdD7GV7uID3io B3CkBlROeJ6Gs8Si1jWTayMXGcukIsdnRwUdI2qfRrUP6wb+G3bKfJFad0fMWIsgEnip hSqA== 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 h17si923632ejt.173.2019.10.09.04.43.03; Wed, 09 Oct 2019 04:43:27 -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 S1730888AbfJILko (ORCPT + 99 others); Wed, 9 Oct 2019 07:40:44 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:58708 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbfJILko (ORCPT ); Wed, 9 Oct 2019 07:40:44 -0400 Received: from [79.140.115.128] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iIAKg-0000Lg-97; Wed, 09 Oct 2019 11:40:42 +0000 Date: Wed, 9 Oct 2019 13:40:41 +0200 From: Christian Brauner To: parri.andrea@gmail.com Cc: bsingharora@gmail.com, dvyukov@google.com, elver@google.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, syzbot+c5d03165a1bd1dead0c1@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com Subject: Re: [PATCH] taskstats: fix data-race Message-ID: <20191009114040.tqbbdxmkvvt6mia5@wittgenstein> References: <20191008154418.GA16972@andrea> <20191009113134.5171-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191009113134.5171-1-christian.brauner@ubuntu.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 Wed, Oct 09, 2019 at 01:31:34PM +0200, Christian Brauner wrote: > When assiging and testing taskstats in taskstats_exit() there's a race > when writing and reading sig->stats when a thread-group with more than > one thread exits: > > cpu0: > thread catches fatal signal and whole thread-group gets taken down > do_exit() > do_group_exit() > taskstats_exit() > taskstats_tgid_alloc() > The tasks reads sig->stats without holding sighand lock seeing garbage. > > cpu1: > task calls exit_group() > do_exit() > do_group_exit() > taskstats_exit() > taskstats_tgid_alloc() > The task takes sighand lock and assigns new stats to sig->stats. > > Fix this by using smp_load_acquire() and smp_store_release(). > > Reported-by: syzbot+c5d03165a1bd1dead0c1@syzkaller.appspotmail.com > Fixes: 34ec12349c8a ("taskstats: cleanup ->signal->stats allocation") > Cc: stable@vger.kernel.org > Signed-off-by: Christian Brauner > Reviewed-by: Dmitry Vyukov _sigh_, let me resend since i fcked this one up. Christian