Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp930556ybp; Wed, 9 Oct 2019 06:28:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwO88lipBoJewDxBEdjEIxjsIZ3b8GB0XyvaWUbDCrJUOeagZzjgdtbebM5cj0EIh1/DCaS X-Received: by 2002:a17:906:704:: with SMTP id y4mr2787646ejb.259.1570627730379; Wed, 09 Oct 2019 06:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570627730; cv=none; d=google.com; s=arc-20160816; b=V/qjR6cp6SK6PStEhuYzVvO8Du5MuODLUa+8VKthgj8bkU2K1gpP+xoLMiJem/cw8h aNsb03+M5p9ULulPYN3Qaf/jtDrXGJyjL6llcXeL3nRs7y99HNXt3jryU96sA6L9Q2xq Mq/K9jBYl6so/aGP4LkFlO0p2tm2iAKEsggNd/ro0bRr6ctUJJuAArgKz8P7TsW/qlgg SF2hnCFp/A3jjF/CbxNmA3oioDLM+RyifcE/nouc0C6YHMhoHYtd+xI5mwlmOR1f/xzw qE9S36AYduEkCxwBFHHUUBoSMDH0NgSP/PxxwVJTxUUMUrFlZiU+2USdG7MrmePA/+2v BgLQ== 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:to :from:date; bh=BrrjI4eOYHnTzWoDS+TQiTHmReDkKlBBzSmpun+et64=; b=K151yejB9oxYM2HfRw0QsePhyIueJgcvwDNx16xereLBpSUnIzOstXWqAmej5ico0M WNS3bdkqRP57ddnORHRlfXBWO/Qf+EL/t+8BWYjHOsPZPwPDBnkCNOeYFCODGAtR9Ufz 6dCMb2NvxEgUTnJATRrKus9dnaP02HAbZntCBT6wDvacxzsg8aE2SP12ZHMJKM2Vorfk /EjXcFeYuiiOPk/uXYPt+hOzrE3WL5DAszXbyAU1qC6t6lrG78bc04gT2GUo26IZwPnO 3MK1ZiQSCwYyd/+dLCSzBb7YD/tqSGfa2ySP0USFxn62AMCmToJJ6smIb/jsQZem3X+R 5eZg== 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 p43si1331365edc.368.2019.10.09.06.28.27; Wed, 09 Oct 2019 06:28:50 -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 S1731193AbfJIN0U (ORCPT + 99 others); Wed, 9 Oct 2019 09:26:20 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:33186 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731083AbfJIN0U (ORCPT ); Wed, 9 Oct 2019 09:26:20 -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 1iIBys-0007l0-8m; Wed, 09 Oct 2019 13:26:18 +0000 Date: Wed, 9 Oct 2019 15:26:17 +0200 From: Christian Brauner To: bsingharora@gmail.com, dvyukov@google.com, elver@google.com, linux-kernel@vger.kernel.org, parri.andrea@gmail.com, stable@vger.kernel.org, syzbot+c5d03165a1bd1dead0c1@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com Subject: Re: [PATCH v5] taskstats: fix data-race Message-ID: <20191009132616.at3yspm6y3mzp5wg@wittgenstein> References: <20191009113134.5171-1-christian.brauner@ubuntu.com> <20191009114809.8643-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191009114809.8643-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:48:09PM +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 Applied to: https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=taskstats_syzbot Merged into: https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=fixes Targeting v5.4-rc3. Thanks! Christian