Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp441954ybx; Wed, 6 Nov 2019 03:09:01 -0800 (PST) X-Google-Smtp-Source: APXvYqwsilzE/v0RrL2sT9bIRClCdTHNLVGp95Q8YilNavnnkf9v7Bvfqqj1Y9+Xie7ZfrLqqxJp X-Received: by 2002:a05:6402:783:: with SMTP id d3mr1899971edy.180.1573038541662; Wed, 06 Nov 2019 03:09:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573038541; cv=none; d=google.com; s=arc-20160816; b=jaWwieqZp29vI7jxuxCTGXt6dhJstRc9r0PxuFT31cneO7EAnaXbfpCse1LaMOfQfr 1xxcOJQjSAfujOjmrEZj4Xjjm0aqvqxWsB77bPbpGZUe1JNmoHNzX45pv4xAZEhSiXW3 ZQII1PLOBhhQGo7ob0irxSaE3JL4/SHeEPCogIh8F5bREfLmEqFKt5AxBlvc6ZWWBo4W ZcritqKuZ+H0YTbXzsb05zZSiW5WtIjfFnULTwADv+03ZsPB5E7aA1H3macmUccX0Bec X587sYH65uC+ChqwHlwOu9ZLaw5Ap7zimjL7n8jfPd842VyOE+cn9UOyrm4NSsRUFv/A 01OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=NOdbwc7p0Q3E3u+bsOAHa9kmMyUPZpDqBKCU0/NEfms=; b=EPL9o7k6QPlKw+6+cQOZuyvZXXsQGAzRaQFANXGEkmQtNcfliwyMQxOwde4CqhV7kG SrtZe1EuVhJvnlQneU2Lx4qzsH9YvEugEzU4yRICk7BiVYe12bGSluXgOj6IGOldSg5G Rw6DSApSk2gG8E/PkiicmKJT1hV/EyiEXbR7caxqQPOl1lGX2RpUeZYVJ+kzwSq34vIq kDaHy7h66+LU7zES9rtJC0JyuBpNhIkQRdcZaLtBOZf7vGQvX9NScj12yWv6dk29Vz2/ WN7zfRF21Ipwun3+EaWBn0Iy9usylM317aFLXVD+VtoMG1Pqj2YhQpXGwaegDoQ+jUru QWUA== 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 bs2si1210768edb.354.2019.11.06.03.08.32; Wed, 06 Nov 2019 03:09:01 -0800 (PST) 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 S1730178AbfKFLHm (ORCPT + 99 others); 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