From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.156 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795996202; b=gjvtoZz4UCov9VJeh2leYOazAKcoiPGMOK9DPeGO5innbuqJobBcrTFIE6aG35VDN6fD aHnUYpeKSSjmrbbRWuY06NHh9/qDasQ07vqbf8YRg1vblAwcNz3fUvJGCX2MNKCbauch9 u8m4kWzWmUetwG+iuiOHFl1dnFwh+9B+RNjYn9Jg5/LOx32tBC6y2Ic2jJe1w+zRx8enJ lJy5mU11Qic8s4k3RrL6V2KeEkX6eAvN444K24s+KyqHsTDHWVLkBCUpWSLRv3rnaGHaG nVqfP64LhGr6pKYK/vfB3u+ssvm2pBL4WClpRHrPks415qcw6VezjagtSSVMFmz93/A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795996202; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=dIpL4r1UBYpBMjjyYcTcAM+3ffAk7M5AShaRWOIzg4M=; b=MOtUmTQrL8R0pLm7QalSKpy47mC1DM7StgCia08ps9gkM/TavSSpQZ4iQLdIvMdqi928 M8bBVbLKbdyQxB/BK6dZRPwOyOREzOP5FxCzrb/PoNwVxnVZxutgoq/xPxABKsCS0klxC yBu7XVPwwqGa2g0y1ohyXfJji8wc1mY4qP2lumhZRyxK5NrrXkSBXlY2LVOC/mARNez9o tAWgtlogBN2Cdiwud6vVQ8t+l0szYF39hOSL4u3WE3rCIG289oQon3auUrwchRdFgODJ2 L8CXIT636SDeKvQppKmb6m8WW3Voo3/8V2BAk23YB+jUy6CytTnmqlD1BjlaZfIzXaA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=joshtriplett.org; spf=pass smtp.mailfrom=joshtriplett.org; dkim=pass header.d=joshtriplett.org header.i=@joshtriplett.org header.a=rsa-sha256 header.s=fm3 header.b=MkWxEooU; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=e3DS4urt; arc=none smtp.remote-ip=202.12.124.156 Received: from fhigh-b5-smtp.messagingengine.com (fhigh-b5-smtp.messagingengine.com [202.12.124.156]) (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 77F2D606A31C for ; Sun, 29 Nov 2026 23:50:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 77F2D606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joshtriplett.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=joshtriplett.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=joshtriplett.org header.i=@joshtriplett.org header.a=rsa-sha256 header.s=fm3 header.b=MkWxEooU; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=e3DS4urt Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 06E207A0330 for ; Sun, 29 Nov 2026 18:50:01 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sun, 29 Nov 2026 18:50:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= joshtriplett.org; h=cc:cc:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1795996199; x=1796082599; bh=dIpL4r1UBYpBMjjyYcTcAM+3ffAk7M5AShaRWOIzg4M=; b= MkWxEooUJkx07WLjOogern74hcyYIexFBXWP/eEcInTQYxz78WMHhb3KqzKGVvxz 8RkVKL2lXejt7V0F9FZk2zCxC9gGgTqc6ukJHdoYs1WdwGG99O4sYcdSi3On5M1W C42A4+B4ulmhFhTZLSPZNZ/Q4Ab9lS5coI/8kioqP2+Dc9J5lX5ZurnjLvx05QnQ MuAnjAgGViHKqjRqt8w0O8++jzA2fWEhI2i3B/y2vLl0n3egj4881GM8w+6jr11x wEc0DIdHc1ZJxT/qU5gRbiRXblqsKv/WJn9LHIcNglt6lfPn5lJ2yVRBl4L8GJpm w34VvwVX9DToCkSPU6rFuA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1795996199; x=1796082599; bh=dIpL4r1UBYpBMjjyYcTcAM+3ffAk7M5ASha RWOIzg4M=; b=e3DS4urtmIdLdyFd3s2C57al67zccOluqcz1sP1esz2b6ZsVb4B BkHyFDvwBfgvFJ8EgLg3JGzj5hrtQzUDLMlAjAJ7WidJcpbmNM7FO2gq55lD89gf Ze9JNuLit/NbA5dPxQuGRusbk/PJyHt/BCJ6BFhBV7o0nJ8ZZLcTPaZSMq1Uwx6G vs78i2P95zEU5b7csDzmFzpCZcglKumf0ERp42sQvVmiitsqYTZlaVzwsWZPAkFs mBQXKJrr6Zul9s2eIg6ZEGVJPp2hqW0WIAEw3zWBo5VCGB3eol2iurkcgTzNLpHT xCKlzRf1bfKHxR5QwPVFWKsCdyeBPdRO/Qw== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=joshtriplett.org a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1795996199; d=joshtriplett.org; mf=PGpvc2hAam9zaHRyaXBsZXR0Lm9yZz4=; rt=PGxpbnV4LWtzZWxmdGVzdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:ks2IkUBO1TSe3mtmHfUROr23lDVrOf2Q8AIuzf4zqnzAS6N ebNQGnVw+uKbAomLWPyer+Kr4Df9apV5wJc/AHHJvHRPyXaP2HIjyZWlistRkXCC zrVk0SoBiFj7BVKlcCenbHyurdmWEjnE28LEvOxDknt+6Ao6Fke/S4KKIZ88cqa5 7hRj878yOWh84VBaiLVSolO4QyYYMvPiyftdDEO14WMKAhB7bD2MiMsfvONcdsID jvsykrq51Ng9OFc2L6qnh0xdAN/Ax6NoHExXBHj6ejmKj8ICWg6zxZJ0wsZhumW9 T5W9evr6Ejwv5v1CKR30K0YcaAXfheJLViawpaA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:jhQ1GDIn6cb6ai1yVG+UFSj1pCtog1Zu9YhNrGwyeCU=:gw0YkQgLIIRRknGKtYKk7oTlw2U2PQoKY4nMrWsjJb8=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEc9e55/8yAdcBjoA4Amau8vfvOrYqfoAwShvA9SWwp2lqfNbvio0uc2XWTs5XTU5 mqVlBiSTGpQol1ZIuwCnIB0vAG/ysaWVhRO4QUofCxEM6rKf6JTxdxdbdTF4akryTFdO3R 0H4mCZ2om9Ikz20DTZz2QgGDLkQFR6+lgqWS9BI0SEUTYkARzFEjWKiMCgHfsCXbY0S4NA 7QRc/5pXBl3PeP1Djz00AIRr4hcfQIQ/kp1FBucK2jYyaTLBc+j9q+P5InHOpb6/w3IePk cKIV0piRPvt9/xv93N0Yok55nJFLbV/PVgho0S044dEYY7m3W4n+WvAxpupZZoMgTo6cOD G9Xxsir+g0dFBgJ+cOZ8zmvLcwFWW1kWueSorUiDYmet5Psgfrzk5K+lXRryFxKZoY88QY ycNvzWZswNpFNFYl6X/DPAq7MVO0f57h42TBial/ow8gmqaF2Yyw8aWolMxERc2SpU5xSR RMHLth/jo7ITppQQkXHt+m5a7KmO3PnezdHHXUAfmlzWuPDTCwQmVG84xr6kMQU6dy6nlA dsJZdY2eetI5vyGEt2UBfwthY3JkSBV3okqhq4Wf0gHuTKXYvEBAO1glosvHVvU7tHOumY buFO+fdX2FfNlqoWQSmB8bpyZpGIoP8LfTVlPxBvvj295J97aDqYyfJTRoTA X-ME-Proxy: Feedback-ID: i83e94755:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Nov 2026 18:49:58 -0500 (EST) Date: Sun, 29 Nov 2026 15:49:58 -0800 From: Josh Triplett To: David Carlier Cc: Christian Brauner , Shuah Khan , Oleg Nesterov , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [RFC PATCH 0/2] pidfd: add PIDFD_GETFD_NO_SELF Message-ID: References: <20261129212732.805592-1-devnexen@gmail.com> X-Mailing-List: linux-kselftest@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; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261129212732.805592-1-devnexen@gmail.com> On Sun, Nov 29, 2026 at 09:27:30PM +0000, David Carlier wrote: > pidfd_getfd() on a task that shares the caller's fd table duplicates one > of the caller's own descriptors. This is the only case that forces a > pidfd_getfd() wrapper in the Rust standard library to be unsafe [1]. > > Add PIDFD_GETFD_NO_SELF, which makes pidfd_getfd() fail with ELOOP when > the target shares the caller's fd table: the caller, its threads, or a > CLONE_FILES task that has not unshared. The check is on the fd table > rather than the thread group. A tgid comparison in userspace misses > CLONE_FILES, and kcmp(KCMP_FILES) depends on CONFIG_KCMP. > > ELOOP is open to change. It only has to differ from EINVAL so that > userspace can tell an old kernel from a refused target. > > Suggested by Josh Triplett. Thank you. This looks reasonable to me, and I don't think it's otherwise possible race-free in userspace without kcmp. The other option would be to *only* reject a pidfd that refers to the current process, and allow one referring to another process that happens to share the fd table. However, I think the behavior in this patch series is more useful. Reviewed-by: Josh Triplett > [1] https://github.com/rust-lang/libs-team/issues/939