Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3875381ybi; Fri, 19 Jul 2019 10:33:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWNwdu4P04qofNUfH7ysfP/03pgmvuHpzXSYmYogEbenUEwuOe0vjt+62NFW76+TQtog1T X-Received: by 2002:a17:90a:9dca:: with SMTP id x10mr59611076pjv.100.1563557588449; Fri, 19 Jul 2019 10:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563557588; cv=none; d=google.com; s=arc-20160816; b=tru9UqCgenwl4G1ye4ab/ai/7KKFQLdYX4tmR5ETU7xeEsGQl5QHraWo6aNNkmAe3B BbpwMVLsnzlhA84zWcVv2t/YDxBg2u0w0NwuUY0Clh2T88AA9y8pkzbsSMc7D14q/dBY bUZq5ZqR1dQEXYJAdv8oDCDm4I87tstPDI12TyTXTeMK/tBo5UxR6BY0bcyDDQIVkdOC /WA8GTKZZpdmrXZ/+aMO4EvXbUB1tGpVzUdF6OdvXAClH5z+Hs5R3DZUCazB3goQ7h3n IwjHDwqueVJdUvexERDgMxhY7QFH7Q2bu5yf3SZWm5jZyig7ztN5B8dHAa3Nu9j/Z6E9 EcNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:dkim-signature; bh=W6Id2apSO0w+oDefY5998IEGsU/bQYe3SdY14bHlNAI=; b=oTRVjkj0NLi8KlFoZmDHMoNnS9mwsMWuLOpiXFyQP2YVgeq9piaWvk4auxWAEQBRfX I9Q3ffkb0Rs6Ss+uwojmHtMGpbU9nTS91HPG6LdLVjAlPMZMhrMVZDDHfRpBRFLI3QU3 +DNpH+B6ox73GpXeqZrMAJnk7TdKSK1p0fCJHXKKEvZUJmAgADW5JuNNsHzE8nYygxWt s8TDRd/1zuYM7ZQJ6xaaZ41HllkqDe/q9fi2oqOvPdppXXE8xyMafIsYQ41k2A3gd3mI jui7dn69L5+jRmQsD/QV/MMTGvv2dmM8hqjE1AmyvmA9YfLTuoeGPYKLmEU5aPi8x+H9 DmJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@brauner.io header.s=google header.b=J0SvgNFh; 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 j36si928971plb.77.2019.07.19.10.32.53; Fri, 19 Jul 2019 10:33:08 -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=fail header.i=@brauner.io header.s=google header.b=J0SvgNFh; 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 S1730396AbfGSQxy (ORCPT + 99 others); Fri, 19 Jul 2019 12:53:54 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:43238 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727717AbfGSQxy (ORCPT ); Fri, 19 Jul 2019 12:53:54 -0400 Received: by mail-ot1-f65.google.com with SMTP id j11so9180828otp.10 for ; Fri, 19 Jul 2019 09:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:cc:from:message-id; bh=W6Id2apSO0w+oDefY5998IEGsU/bQYe3SdY14bHlNAI=; b=J0SvgNFhOGDy8g8QY/w1QwAYPSBe0785So5Ef8PCu0eG8fvW2Yjspbp76HCDseoPYy xAzoRaSj4CtH8k348QGLoBdiSQztIyUZS/QYzoJ4oRK9LFmWkaknioQt0cXmVRw2eG2h qqkc1PHLXNZxR5d2Fu2MCzeK2ANmvicuaZtcr+NEd54BQZc41C/Ik64X1VUjhgpCnXum OwZ1399Rwg0XjnxV6mgn0o48sUN8dHUtW6y9fVW6MHMxnwycBG2FUk0Q0rwr8OZUkbKh uETwqhcw7Dy2RjgoK3D0PTH6WDPW/IE9Axo1YvGTt5595OXwWiqskQvIrPu5sysvRekU MnhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:cc:from :message-id; bh=W6Id2apSO0w+oDefY5998IEGsU/bQYe3SdY14bHlNAI=; b=czZn2aSyqkaQKcS8oxIr2rnoAsn9yrH1/nbyHAZbuBtAYvrLsoeVDWW7rO1leMNCLE rPFTAXGeNPQStxqhn9b1HtDdj9P1OsCwYiM9Vu4g2btUQObhq53rNxrwniEhph0Mut9i MQwhOwY+bU7l8rqnKgTwzhhypnT+P/wsyIVK/Y5RSl/y3noKgXY/ptSvAtOKdae3YDib 06HRxMviq3CgmPra1Ykri5w8nhr2KztwCxaMGK33DQncFix9WfVN0zSb+NHyqwhhploK JJtcfvPT8mx4vd2LN+KWfBE/eoDTM/mV4EqI8bQJ6u2ayFfH3V5zKKnca4TlDkV9uiaq AAsw== X-Gm-Message-State: APjAAAUkE5dgpPigU96CdvwRX4uJ1CbIAyMo4DU+hADljHVDQ+FQNmYF 8Ed9Nm8lbkr1vP2Wp5ik1oI= X-Received: by 2002:a9d:4c8b:: with SMTP id m11mr17441400otf.293.1563555233209; Fri, 19 Jul 2019 09:53:53 -0700 (PDT) Received: from [26.82.125.95] ([208.54.86.221]) by smtp.gmail.com with ESMTPSA id b2sm10783966otf.48.2019.07.19.09.53.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jul 2019 09:53:52 -0700 (PDT) Date: Fri, 19 Jul 2019 18:53:46 +0200 User-Agent: K-9 Mail for Android In-Reply-To: References: <20190717172100.261204-1-joel@joelfernandes.org> <20190719161404.GA24170@redhat.com> <20190719162726.u5fi5k3tqove6hgn@brauner.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH RFC v1] pidfd: fix a race in setting exit_state for pidfd polling To: Joel Fernandes CC: Oleg Nesterov , "Joel Fernandes (Google)" , LKML , Suren Baghdasaryan , "Cc: Android Kernel" , Andrea Arcangeli , Andrew Morton , "Eric W. Biederman" , Tejun Heo From: Christian Brauner Message-ID: <28DEE709-0BD6-4915-B9AB-0ACCC7C02111@brauner.io> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On July 19, 2019 6:51:20 PM GMT+02:00, Joel Fernandes = wrote: >On Fri, Jul 19, 2019 at 12:27 PM Christian Brauner > wrote: >> >> On Fri, Jul 19, 2019 at 06:14:05PM +0200, Oleg Nesterov wrote: >> > it seems that I missed something else=2E=2E=2E >> > >> > On 07/17, Joel Fernandes (Google) wrote: >> > > >> > > @@ -1156,10 +1157,11 @@ static int wait_task_zombie(struct >wait_opts *wo, struct task_struct *p) >> > > ptrace_unlink(p); >> > > >> > > /* If parent wants a zombie, don't release it now */ >> > > - state =3D EXIT_ZOMBIE; >> > > + p->exit_state =3D EXIT_ZOMBIE; >> > > if (do_notify_parent(p, p->exit_signal)) >> > > - state =3D EXIT_DEAD; >> > > - p->exit_state =3D state; >> > > + p->exit_state =3D EXIT_DEAD; >> > > + >> > > + state =3D p->exit_state; >> > > write_unlock_irq(&tasklist_lock); >> > >> > why do you think we also need to change wait_task_zombie() ? >> > >> > pidfd_poll() only needs the exit_state !=3D 0 check, we know that it >> > is not zero at this point=2E Why do we need to change exit_state >before >> > do_notify_parent() ? >> >> Oh, because of?: >> >> /* >> * Move the task's state to DEAD/TRACE, only one thread can >do this=2E >> */ >> state =3D (ptrace_reparented(p) && thread_group_leader(p)) ? >> EXIT_TRACE : EXIT_DEAD; >> if (cmpxchg(&p->exit_state, EXIT_ZOMBIE, state) !=3D >EXIT_ZOMBIE) >> return 0; >> >> So exit_state will definitely be set in this scenario=2E Good point=2E >> > >Agreed=2E Christian, do you mind dropping this hunk from the patch or do >you want me to resend the patch with the hunk dropped? Yeah, no problem=2E :)