From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796160342; b=pHbTxfzedLJe5phoRmG23lIAhmslNh/GdA+HKIEIpBu4Ld/i9MJlT2h6f9XVA1Fv3cTu 53xZDCwCJXvr+25WsJPcI/ECbGhOchF4vcOW3JJbLxeiEqCF9ARegI9gYpFkXhzex2Mch 05FliQD6wgEbreB6A4CaAnk4vcAirjscur5dQvb8FP11LlGdjCfcmaxRDqYudBixkwdAx 4Xj1gCTQQdGDqag2abS5K2bmpym8CPuQUR+DMVv8aqyY/apECUuklyA7WG4OzbfCLz5gS NuSFJZ0pENRvbDZH/++71Mvthzs6Q14v9qai0vIApxSuZDbEezM1hhcW5WOQY+znUOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796160342; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type; bh=CajjUWHEqOtlshnu8r51nL8kPaEcOseKQ5hU9v+KmII=; b=KlrQBDiCB2zPO3ECrHCXFlNPSKAktKtYCpnwg53ib+MWJjjV1ZO5BAIiz95SViclbNiB OahtBwKhWVwDcRl3YmaK5tM77Cv+TMlJT9HW1HX1G7Nfn5WZLEmbywb+Z3nckgc1FzAyQ +45Ak7l8vv7pvEid+ZQCEza0bByFlBOxqyEzDrT3IdT9d+DBh7NJbzKocSQr98+ZRtgL5 zpItbXdoUykNuD5+1TtnB97SRDkXr2tcz2IrLKg2OchT/cHMsoEunQrU7Ck3Ezsv1KdLR E+KJYliGbG1QmfDbL3/S9f4Ffbv1Hwnrky08PD7l+nFCwaPgXiafQ+rQ3X/vq6J4mZw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=meBaV2bv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8888606A31A for ; Tue, 1 Dec 2026 21:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=meBaV2bv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D3861F000C1; Tue, 1 Dec 2026 21:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796160342; bh=CajjUWHEqOtlshnu8r51nL8kPaEcOseKQ5hU9v+KmII=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=meBaV2bvrLCnvxtnwhb8BH5A/FV1v6Mnh/Rcy8EoqXI3VX8UXCuHs2oPKQ7ohnr2p BUtghLw/MfJe4Igqyb0suwpcT1wyjF2JLzsAHGEX7jhsDVbuwmvT4LI743Uzq/yZ8j s/DtBDHoDHX9L1418phwgEyFxvwhpmieDYXcCmxrc/6Y/oCPP55WNSi2dk3qYHNGOC 51VAqSJLpvzWzRUrD71/78iapARJ+dabexSidUr9+K6NagYpdq99uFNSiBxxfsU2uX JUzdMv6O4CQbnqnIe2wmC5XLI7HASXr2wbKrhQBaTGFLaUPfaxCseUAQJaUlqKFopC KpucpxzfJaqKQ== From: Thomas Gleixner To: Christian Brauner , Daniel Wade , Ingo Molnar , Peter Zijlstra , Darren Hart Cc: Davidlohr Bueso , Andre Almeida , Sebastian Andrzej Siewior , Kyle Zeng , linux-kernel@vger.kernel.org Subject: Re: [PATCH] futex/pi: Reject owners that have no mm In-Reply-To: <20261201-fotoreporter-fastnacht-siegreich-312e2a63bbba@brauner> References: <20261116132622.34793-1-danjwade95@gmail.com> <87h5gyqv01.ffs@fw13> <20261201-fotoreporter-fastnacht-siegreich-312e2a63bbba@brauner> Date: Tue, 01 Dec 2026 22:25:38 +0100 Message-ID: <87v75cofql.ffs@fw13> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain On Tue, Dec 01 2026 at 21:31, Christian Brauner wrote: > On Mon, Nov 30, 2026 at 03:00:46PM +0100, Thomas Gleixner wrote: >> Why putting this into the pi_lock held region? p->pi_lock protects >> nothing here and the access to p->mm is racy in any case and will >> trigger KCSAN splats. >> >> So the below is sufficient. > > I'm not sure. I found the same bug while working on cleaning up exec > again. Afaict, checking p->mm before the futex state check breaks exit > race handling. But I'm not an expert so double-check. An exiting task > drops its mm after its futex state went to FUTEX_STATE_DEAD: > > do_exit() > -> exit_mm() > -> mm_exit_exec_release() > -> futex_exit_exec_release() > -> futex_cleanup_end() // FUTEX_STATE_DEAD > -> current->mm = NULL > > and it can still be found by its TID until it's reaped. IOW, a task that > has just exited also has no mm, because exit_mm() sets current->mm = > NULL after the futex state went DEAD. So a dead owner hits the new check > and the waiter gets -EPERM which means glibc aborts. So I think this > breaks things. Fair enough. > Checking under pi_lock means a dead task returns at the state check and > never reaches it. Only state OK with no mm gets -EPERM which is a umh > tha that never exec'ed. But that really needs to be spelled out in the change log and comments.