Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4172438ybg; Mon, 21 Oct 2019 05:03:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBFCWsXC9kjOG2PFkY6n1jehX7LWXe/u6FZ844kcoxWLTtqO/WUs0EDD287Yn2/65bHTIK X-Received: by 2002:a17:906:1911:: with SMTP id a17mr21516432eje.14.1571659398190; Mon, 21 Oct 2019 05:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571659398; cv=none; d=google.com; s=arc-20160816; b=f5kvRI5bCGZCoWCZ3uDPNLxZ7U6fL4xIEmITycJ8zIv7darbCokZu9VOC4OJEgUq0n 1kHrhRyI2xumpKmVXIUtlClQDkfBocLLcwZwdqUI/e4acvOkdm8W8kk2JzFpFEaJS8pJ bbaSm/CWzOgXo76TX1vub5LAgeROsllUGmqg5QEe9CMO0Vu45VrOAUAz2L2QDfvyXNGL VK1sWrMGZYkGjruGu7wm1CAOUGZdxE8ATr9wi7WAaulcB7Dicq0cORk5YkNxXMKi4B/M y+W4Vg0xn/3xEDaM5bj+le7Hzvqd4kZ47h36lZkAKYmfOsgmOf6emIdi0vUdd7/ZAqkz dJrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kM1ipbW/NO3Ed+8uSTRI6lzRbVyT5XdIRw7D6wPdv/w=; b=TuPKbiVeJr013k41xgrdqpdm1TvcfC5mAB2GtnkdmaSbBUKwAhUJinZlehr8HYW7Ut xUZyQmtmP9qa2ZUG8Y++DD7WfQ/f2adC9CCIDAiFjBeB+uNjICbZj/X9+NUV7tXmymRJ uId63wmlOvCDSEcN4AGqEZho2neyhyLM/vjBUpa4wywyVx4RevpP1ol7SmZ51z3Ujy3S sWUNe8lgHc/Kor96NzGzdZUGaUaE+jhxQ0BnrQTyQWviTIFoBNyCA7eRvIrR2b4ursSC +O8Sgp5yqXqb3WKi5FQl3YFIAW5uXwbbio9TlzRFxGh9bi9jP2meuqfoTSVGndktEVhL uf9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bFg8OOv+; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h91si10535653edd.270.2019.10.21.05.02.54; Mon, 21 Oct 2019 05:03:18 -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=@redhat.com header.s=mimecast20190719 header.b=bFg8OOv+; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728098AbfJUMAl (ORCPT + 99 others); Mon, 21 Oct 2019 08:00:41 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:48825 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726767AbfJUMAk (ORCPT ); Mon, 21 Oct 2019 08:00:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571659239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kM1ipbW/NO3Ed+8uSTRI6lzRbVyT5XdIRw7D6wPdv/w=; b=bFg8OOv+CASYiqAFat3ZjUx3CZ5hMCZSRwGxP63Shxg+YFD2HU2RheVyYRAxPD/0GVl6+6 xdrbe39NrjxHiNscLNGVnT412qqRaAHoYC1Bvts6W7lNElg0BR8vO367PSZNgVXDMKviYc uVMB+AyHv4xIeeRyhPB7YqQezoHq9P8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-377-Y0FPjqH6PhiULItWA-_CgA-1; Mon, 21 Oct 2019 08:00:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57D682B7; Mon, 21 Oct 2019 12:00:34 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.44]) by smtp.corp.redhat.com (Postfix) with SMTP id 7A48D60CD0; Mon, 21 Oct 2019 12:00:31 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 21 Oct 2019 14:00:33 +0200 (CEST) Date: Mon, 21 Oct 2019 14:00:30 +0200 From: Oleg Nesterov To: Christian Brauner Cc: syzbot , akpm@linux-foundation.org, arnd@arndb.de, christian@brauner.io, deepa.kernel@gmail.com, ebiederm@xmission.com, elver@google.com, guro@fb.com, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, will@kernel.org Subject: Re: KCSAN: data-race in exit_signals / prepare_signal Message-ID: <20191021120029.GA24935@redhat.com> References: <0000000000003b1e8005956939f1@google.com> <20191021111920.frmc3njkha4c3a72@wittgenstein> MIME-Version: 1.0 In-Reply-To: <20191021111920.frmc3njkha4c3a72@wittgenstein> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: Y0FPjqH6PhiULItWA-_CgA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/21, Christian Brauner wrote: > > This traces back to Oleg fixing a race between a group stop and a thread > exiting before it notices that it has a pending signal or is in the middl= e of > do_exit() already, causing group stop to get wacky. > The original commit to fix this race is > commit d12619b5ff56 ("fix group stop with exit race") which took sighand > lock before setting PF_EXITING on the thread. Not really... sig_task_ignored() didn't check task->flags until the recent 33da8e7c81 ("signal: Allow cifs and drbd to receive their terminating signa= ls"). But I think this doesn't matter, see below. > If the race really matters and given how tsk->flags is currently accessed > everywhere the simple fix for now might be: > > diff --git a/kernel/signal.c b/kernel/signal.c > index c4da1ef56fdf..cf61e044c4cc 100644 > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -2819,7 +2819,9 @@ void exit_signals(struct task_struct *tsk) > cgroup_threadgroup_change_begin(tsk); > > if (thread_group_empty(tsk) || signal_group_exit(tsk->signal)) { > + spin_lock_irq(&tsk->sighand->siglock); > tsk->flags |=3D PF_EXITING; > + spin_unlock_irq(&tsk->sighand->siglock); Well, exit_signals() tries to avoid ->siglock in this case.... But this doesn't matter. IIUC the problem is not that exit_signals() sets PF_EXITING, the problem is that it writes to tsk->flags and kasan detects the data race. For example, freezable_schedule() which sets PF_FREEZER_SKIP can equally "race" with sig_task_ignored() or with ANY other code which checks this task's flags. I think this is WONTFIX. Oleg.