Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4061515ybp; Mon, 7 Oct 2019 02:32:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDxjS6LV6F7bMx7wIF9SrjrnONSlNuP06OVM4YB/liWX7k1fBMXDAaoktaRKlQWdmNd3ke X-Received: by 2002:a17:906:22c1:: with SMTP id q1mr15397515eja.325.1570440773703; Mon, 07 Oct 2019 02:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570440773; cv=none; d=google.com; s=arc-20160816; b=uF7Uhw8uMKdl4BZojZlEHPD1G/gQcsma+FIt3iskvVfpVo3Ay9ZZuzcfiLGQoOSExX daPEeOm8uAU+ZN8Yku3X2h8hoOSImrT6hA5oVtrxHuuZTG/INl1g/kDX4WnO0dKpIhI7 xdP4uawDkNMsXLCFckfLNEt4YqGKA/uM72V71U16VL6B2hC3IP7/FzbNDmD00aeloSUx UYldLZlFMCst8XqePHIuEQWYJXYPgajLK1B+v2fJNJpDzUHhdukNgT3hRTXa+oxAN5P8 4LXhXZZ1lesxSEq8NKCVbIZMjWQEurWVq2FekS9xTMUTdSWzSvyUZeXbi5DoJ0dGE/LO d08A== 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=b24R/2l0dgRbFZr4CIpoGBu8iJL5qn9ve2DlNUJ/zK4=; b=Gi7ATtsTfGcZ4SouQd7sPehk/KAXEzYwhT+xJ49UPRpefXg8ByQ0edxo3R43TKFOI2 wP+HpGwGtBdx0WQVr4XVAoTDntjdNs93FH8J8sEfuF+hEgRKi6/vb47LoMoroHrkS7/k 5HrMFSyTD9F+wpsOVt8weAtiPw0BNvM/L60xi8d1Yz/G+Z9Gg9Y4zJvR41CcJHPwywoX 70fDRT/rETZacnAl9szDmoRfJkoYAYxwZCJG88AkACUnGt4Btc6XQPiIjkEAHz5Rj6yk oTlX6tqom+Qs43g2VnvhET6mEOLfAA0c9ZgJHSrxhYKcZxSf+WCM6JWke1hrfyws1WM9 WsLg== 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 p18si7304162ejn.370.2019.10.07.02.32.30; Mon, 07 Oct 2019 02:32:53 -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 S1727272AbfJGJ3c (ORCPT + 99 others); Mon, 7 Oct 2019 05:29:32 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:41340 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbfJGJ3c (ORCPT ); Mon, 7 Oct 2019 05:29:32 -0400 Received: from [185.66.195.251] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iHPKb-00065g-SJ; Mon, 07 Oct 2019 09:29:29 +0000 Date: Mon, 7 Oct 2019 11:29:28 +0200 From: Christian Brauner To: Dmitry Vyukov Cc: bsingharora@gmail.com, Marco Elver , LKML , syzbot , syzkaller-bugs Subject: Re: [PATCH] taskstats: fix data-race Message-ID: <20191007092927.qpfs553g7oow3qs7@wittgenstein> References: <20191005112806.13960-1-christian.brauner@ubuntu.com> <20191006235216.7483-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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 09:31:16AM +0200, Dmitry Vyukov wrote: > On Mon, Oct 7, 2019 at 1:52 AM 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 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 READ_ONCE() and smp_store_release(). > > > > Reported-by: syzbot+c5d03165a1bd1dead0c1@syzkaller.appspotmail.com > > Cc: Dmitry Vyukov > > Signed-off-by: Christian Brauner > > --- > > /* v1 */ > > Link: https://lore.kernel.org/r/20191005112806.13960-1-christian.brauner@ubuntu.com > > > > /* v2 */ > > - Dmitry Vyukov , Marco Elver : > > - fix the original double-checked locking using memory barriers > > --- > > kernel/taskstats.c | 19 ++++++++++--------- > > 1 file changed, 10 insertions(+), 9 deletions(-) > > Reviewed-by: Dmitry Vyukov Applied to: https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=fixes Should show up in linux-next tomorrow. Targeting v5.4-rc3. Cced stable. Christian