From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE5FEC5DF62 for ; Wed, 6 Nov 2019 11:07:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8911D217D7 for ; Wed, 6 Nov 2019 11:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730338AbfKFLHm (ORCPT ); Wed, 6 Nov 2019 06:07:42 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:43948 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbfKFLHl (ORCPT ); Wed, 6 Nov 2019 06:07:41 -0500 Received: from p5b06da22.dip0.t-ipconnect.de ([91.6.218.34] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iSJ9z-00084v-S6; Wed, 06 Nov 2019 12:07:35 +0100 Date: Wed, 6 Nov 2019 12:07:29 +0100 (CET) From: Thomas Gleixner To: Oleg Nesterov cc: Florian Weimer , Shawn Landden , libc-alpha@sourceware.org, linux-api@vger.kernel.org, LKML , Arnd Bergmann , Deepa Dinamani , Andrew Morton , Catalin Marinas , Keith Packard , Peter Zijlstra Subject: Re: handle_exit_race && PF_EXITING In-Reply-To: <20191106103509.GB12575@redhat.com> Message-ID: References: <20191104002909.25783-1-shawn@git.icu> <87woceslfs.fsf@oldenburg2.str.redhat.com> <20191105152728.GA5666@redhat.com> <20191106085529.GA12575@redhat.com> <20191106103509.GB12575@redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 6 Nov 2019, Oleg Nesterov wrote: > On 11/06, Thomas Gleixner wrote: > > > + if (unlikely(p->flags & PF_EXITPIDONE)) { > > > + /* exit_pi_state_list() was already called */ > > > raw_spin_unlock_irq(&p->pi_lock); > > > put_task_struct(p); > > > - return ret; > > > + return -ESRCH; > > > > But, this is incorrect because we'd return -ESRCH to user space while the > > futex value still has the TID of the exiting task set which will > > subsequently cleanout the futex and set the owner died bit. > > Heh. Of course this is not correct. As I said, this patch should be adapted > to the current code. See below. > > > See da791a667536 ("futex: Cure exit race") for example. > > Thomas, I simply can't resist ;) > > I reported this race when I sent this patch in 2015, > > https://lore.kernel.org/lkml/20150205181014.GA20244@redhat.com/ > > but somehow that discussion died with no result. Yes. I was not paying attention for some reason. Don't ask me what happened in Feb. 2015 :) But even if we adapt that patch to the current code it won't solve the -ESRCH issue I described above. > > Guess why that code has more corner case handling than actual > > functionality. :) > > I know why. To confuse me! Of course. As Rusty said: "Futexes are also cursed" Thanks, tglx