From patchwork Tue Aug 6 16:02:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13755091 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4191F13A26F for ; Tue, 6 Aug 2024 16:02:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960160; cv=none; b=UhoxJ9xDqSU2vkRNw/twBt+09aqvU70w5/N0vt4TPXU7q92m5R0LkJFZRKQwRLnp4G9sl7Gv9VnqbmftFRHHhaby3MusHVR8tLlVyyua8TU6ZFrYr1j/cZO4R+b0a/xC0ARHOSEJo7hX5uZYQ9F0jyUbJr2scf29DHffrOP3OY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960160; c=relaxed/simple; bh=nX8jly5hivqhxcp7i0sBoUlkkwyN6k1tpHVLGLWWs90=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IOrixifEgfpDdruqb7JO5eCM9viflsQSWU/hKmeejihSkI1nKcQigwtHAmAoLfY587uK0GWy0YM4zV2c0lZzVcQ4X6Vnz6iNUUTXtV9PgYFrs9H+P3MXAMhjT8btCXGWdv/aEocOjYu7ZENoP9Tnx8kH5j5ZM+M8Co4Rg/LPVWQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ybamsc2n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ybamsc2n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69133C4AF0E; Tue, 6 Aug 2024 16:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722960159; bh=nX8jly5hivqhxcp7i0sBoUlkkwyN6k1tpHVLGLWWs90=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ybamsc2nHcWycUxS3VfPP4bOVMMFJPGCSSNIVYHIUc9Byx74vnbhHbl7EP6EPL9rX G5ry3P40LidLB58lwyLpwBW2iaYU5ptsz0dax7YBisred384xIRnHnriIQgO3KUb9R UtQhKxa1svRxzgFPdDKuZoRG69v5Su2iK9N/fLgRjoQhP8CYrRUX5UPAQQfeh0nsKa dhK3Asg+clsQJRVP+8bQkfaDu1SRmzEWwz2zEt6WaSf5S7u6tuPrSTXedK1B4wdk1h QTB8Plp9zc86X6QD+hSsL/WfAcON8SJrbHnaP9CSOE0CwI/nIot5WlFtYhI8TKcW5P fEOV0wI9bDEdQ== From: Christian Brauner Date: Tue, 06 Aug 2024 18:02:27 +0200 Subject: [PATCH RFC 1/6] proc: proc_readfd() -> proc_fd_iterate_shared() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-work-procfs-v1-1-fb04e1d09f0c@kernel.org> References: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> In-Reply-To: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> To: Linus Torvalds , linux-fsdevel@vger.kernel.org Cc: Alexander Viro , Jan Kara , Aleksa Sarai , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=880; i=brauner@kernel.org; h=from:subject:message-id; bh=nX8jly5hivqhxcp7i0sBoUlkkwyN6k1tpHVLGLWWs90=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRt8pRW2PF9+kP+IAWjv6fYLlTetimddqRs0U9ZNevw/ vmKs/Z87yhlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZiI5BdGhu9F1h5yLVItmWGH qu7yMyxdtjW4TeFalqyP76vFcSxn+RgZHte8W702i6Wa13q/eb7FBFMOiSV7X1/qLtsiKuNqunE nFwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Give the method to iterate through the fd directory a better name. Signed-off-by: Christian Brauner --- fs/proc/fd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/fd.c b/fs/proc/fd.c index 586bbc84ca04..41bc75d5060c 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c @@ -312,14 +312,14 @@ static int proc_readfd_count(struct inode *inode, loff_t *count) return 0; } -static int proc_readfd(struct file *file, struct dir_context *ctx) +static int proc_fd_iterate_shared(struct file *file, struct dir_context *ctx) { return proc_readfd_common(file, ctx, proc_fd_instantiate); } const struct file_operations proc_fd_operations = { .read = generic_read_dir, - .iterate_shared = proc_readfd, + .iterate_shared = proc_fd_iterate_shared, .llseek = generic_file_llseek, }; From patchwork Tue Aug 6 16:02:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13755092 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2898B4CB5B for ; Tue, 6 Aug 2024 16:02:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960162; cv=none; b=lwhR111O7YfWDar3ROUeHymD1n/fonqdzq2h8yTlL5qwzQsAya2Iua5N76niil07prfqPiS8z44OvWykO0lMZDAJbKgHP4+tx/8lkF4j9PQNxMwC1UoH5GN2C3/rVmd6lipdN/JXxZldqEo2IxhcSzTEcoNfRGqp0nJqTVtNqew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960162; c=relaxed/simple; bh=5Hspo1wRi7bgaz5mDUcuHrEK9HemY9nNPtcpwLwfDMw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mrgMacD+u0PfbWZNqbf9FTMjlJ/xAM6ldlFOyPYziEJFEJKzRW/nGWmjfs1U9W/tcjYi00hGgeOvNYRZ0zBbGleKybS/k80nr1q0EAC4D/NA49ozU174shHqMCTlIstE9W+iTNUOA0okNVXY+jz9c+LKaNrJOrXa+0Eok+VgLVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BZIZeCRX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BZIZeCRX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BED5C4AF0C; Tue, 6 Aug 2024 16:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722960161; bh=5Hspo1wRi7bgaz5mDUcuHrEK9HemY9nNPtcpwLwfDMw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BZIZeCRXW2F2okTSJk/92J5mdHWqHR3gkgOvDRiya+lwwPfQxD2B9SJrYeAccG/nI m2v2ZOSXjFESptzma4r+k+TZIZv31ZPL7EJ9EDEaLUd4m1flH38eKut5p6wcq0gj8R NSGNLDq3yXFb9a4QtGxD43NnisNMRYy6tZ79pKnMbqLdIMxPHYH1bI8QHA6wQ1ScYR 744rITnQXXuHQz+4Hd62Rsliaa59b74sNTYEB+1PZjKNGXAtgGIeokfg6Gc+Gi//E8 dToTt7zDPil/wtlExOM9mnSXj1/by26QpW7Vj6hp4iTe9W//82UHts0+UzCCdTwNu0 8yuv+fFjmtfag== From: Christian Brauner Date: Tue, 06 Aug 2024 18:02:28 +0200 Subject: [PATCH RFC 2/6] proc: proc_readfdinfo() -> proc_fdinfo_iterate_shared() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-work-procfs-v1-2-fb04e1d09f0c@kernel.org> References: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> In-Reply-To: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> To: Linus Torvalds , linux-fsdevel@vger.kernel.org Cc: Alexander Viro , Jan Kara , Aleksa Sarai , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1063; i=brauner@kernel.org; h=from:subject:message-id; bh=5Hspo1wRi7bgaz5mDUcuHrEK9HemY9nNPtcpwLwfDMw=; b=kA0DAAoWkcYbwGV43KIByyZiAGaySRuhJxemDHuA4tpKDax94UUdfkej7Opob9fG1NvdI3ZlZ 4h1BAAWCgAdFiEEQIc0Vx6nDHizMmkokcYbwGV43KIFAmaySRsACgkQkcYbwGV43KIdOQD/Vdkq PRnEn6t06ri50vJjGGdoHiQOJdEcAb+gnIGdKkEA/0pQCUSbrKCCIlf9qt6YGrArYhLMU9VCvgF GfDiWkQAL X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Give the method to iterate through the fdinfo directory a better name. Signed-off-by: Christian Brauner --- fs/proc/fd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/fd.c b/fs/proc/fd.c index 41bc75d5060c..ab243caf1b71 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c @@ -407,7 +407,7 @@ proc_lookupfdinfo(struct inode *dir, struct dentry *dentry, unsigned int flags) return proc_lookupfd_common(dir, dentry, proc_fdinfo_instantiate); } -static int proc_readfdinfo(struct file *file, struct dir_context *ctx) +static int proc_fdinfo_iterate_shared(struct file *file, struct dir_context *ctx) { return proc_readfd_common(file, ctx, proc_fdinfo_instantiate); @@ -421,6 +421,6 @@ const struct inode_operations proc_fdinfo_inode_operations = { const struct file_operations proc_fdinfo_operations = { .read = generic_read_dir, - .iterate_shared = proc_readfdinfo, + .iterate_shared = proc_fdinfo_iterate_shared, .llseek = generic_file_llseek, }; From patchwork Tue Aug 6 16:02:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13755093 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C6A94CB5B for ; Tue, 6 Aug 2024 16:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960164; cv=none; b=az5273tU5BP4zKl36IWT4FAorcsjg3JvcdXBcAdIPpwCU5PgbMKB8fkFilSNslM3TVOWvwvn5Pd/D/Ln+k970c6sTavDNDtemfn9k/BvSf3uwkUYxiCuLeZrPMEZQj3inzS4LNSyX6voOzRCQ4Q45q6zilVscv8v+2OXzeJc7jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960164; c=relaxed/simple; bh=VHvhBLO4JEFn16lq6IhxF5u65kdur9fh5dxgwtDLXBo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ULUU/bzVSyXtrMfZU3JbNexqxQRtwezDOjm0Ec2ErMfzfr0KYNUxw0dN0RRXFH52nCBBmYznuLVMR51CijHcJSpCplRtc5zFICqLsnLgNwy5mOYvBC83xt/oK3l+c6TuTD45yV+cIvC9Nv/XXglE05/hua8suSSS8QQXm/9L1tI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U43s6sub; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U43s6sub" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E98FC4AF0C; Tue, 6 Aug 2024 16:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722960163; bh=VHvhBLO4JEFn16lq6IhxF5u65kdur9fh5dxgwtDLXBo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=U43s6subiJRrT+q/RDMa9h/p2blVEfI0m8riGwAolkJu92pfPeSpJhEDvVJaETgCZ k0Y6omDYlcg8mTCz0wWVwy2pBbRUGItHeH4Xdy6p3uefiFGUx3hArNtnHB+Y+PejmK /Up5ux9XSWr11WVZsgpShUSp0LyTG6DlrDei0D2io9eD5uZYoNCS8ewE85UWfAYTx3 kEIm0f9xB0p8fGYNAqqNXF5Jgclb8Q8p84+yhV34eDHv9DVRF7yN50YnPc7JzklKuw 2wQJ5WNIwTaUy9evGcwOQfjryvi0tvt1Ts8eyWj3NMlinBhzGxjBrneg1S+/wn+i9H 4zL4GbRI+S/1w== From: Christian Brauner Date: Tue, 06 Aug 2024 18:02:29 +0200 Subject: [PATCH RFC 3/6] proc: add proc_splice_unmountable() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-work-procfs-v1-3-fb04e1d09f0c@kernel.org> References: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> In-Reply-To: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> To: Linus Torvalds , linux-fsdevel@vger.kernel.org Cc: Alexander Viro , Jan Kara , Aleksa Sarai , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1020; i=brauner@kernel.org; h=from:subject:message-id; bh=VHvhBLO4JEFn16lq6IhxF5u65kdur9fh5dxgwtDLXBo=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRt8pQ+9jb+qorERyu/a4xTdJWfnW/vNRRpc/+xsIXrb 5PMrL+lHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABMRM2NkeH8iYUk5D9/umMSu zZsua29P3VEhEM+k/fRhy4uQzYdMdjL8d4xPU7ZReO24PiHpmdiVnm/bmW7nnXps2VI/seMDt0k uAwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Add a tiny procfs helper to splice a dentry that cannot be mounted upon. Signed-off-by: Christian Brauner --- fs/proc/internal.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/proc/internal.h b/fs/proc/internal.h index a8a8576d8592..9e3f25e4c188 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -349,3 +349,16 @@ static inline void pde_force_lookup(struct proc_dir_entry *pde) /* /proc/net/ entries can be changed under us by setns(CLONE_NEWNET) */ pde->proc_dops = &proc_net_dentry_ops; } + +/* + * Add a new procfs dentry that can't serve as a mountpoint. That should + * encompass anything that is ephemeral and can just disappear while the + * process is still around. + */ +static inline struct dentry *proc_splice_unmountable(struct inode *inode, + struct dentry *dentry, const struct dentry_operations *d_ops) +{ + d_set_d_op(dentry, d_ops); + dont_mount(dentry); + return d_splice_alias(inode, dentry); +} From patchwork Tue Aug 6 16:02:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13755094 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 015B9C144 for ; Tue, 6 Aug 2024 16:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960166; cv=none; b=OSPi+5X0aY96QAEH0fIOnfCl36gde5kz+0SgOB+GsO/RoGT3Adiydg/kP9xmqL/FNr1D3dOiTL1fKj3pZYFM4bGzAEudALn+dIt9DMoi9HLYxoNwP/xx4ScN75tnMjpUPxtCNdSVp5sCICxf9xiB6WwgIaZyg+ZCvr7RzCGUofs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960166; c=relaxed/simple; bh=CMJvcPk73Yhg2hvF422QDgsQzhpQCQjSVQtUQYVkiag=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bqqQ2xNKl1kB9WtgEcmB0+d3BYlHkgyEppf0FzZtXtOvtqN5cd5cqprl2EVaTFxhR4eChD3zqqy9N7Nfk9NT5/YYdXgzeeezaP7pb/P4M1n7FNMEnUZnO/9mO0w4k8IF1/myMq8ya2NBWa7WYKr2913Lzo0WTf+5FNaSAc83YuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RysdK8l4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RysdK8l4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29AD2C4AF0D; Tue, 6 Aug 2024 16:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722960165; bh=CMJvcPk73Yhg2hvF422QDgsQzhpQCQjSVQtUQYVkiag=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RysdK8l4pzrthO4n10U02fpkI+LOzXDXPEkLAOuNwauUERL2USxN7PXCnFj4dzMPg Y+qu6Nje12QbGRztTHWji0cPqXMBuQU2/cb8kxkqeL77DyBO3vLXZPvD1PhfoboueN 0L8404RG+auQ+XZERo04eZsalRvIedmZd9b08cQa2RAV3AcRSYFpIeYRnPsPhYSoIP CIwyGjLaZUx7Jo2mhVXXFvnIqytVBX5r0FA0pNqyD1tO78DeCCdiuRvlpYnS7RT6f5 KgiGNfYgdo7P+WqHqwsP6ZhLks0JHmlpp0wUftw7hCuo7h39GjL+jBaGwtnUIUp3zk mpE24lMfwIogw== From: Christian Brauner Date: Tue, 06 Aug 2024 18:02:30 +0200 Subject: [PATCH RFC 4/6] proc: block mounting on top of /proc//map_files/* Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-work-procfs-v1-4-fb04e1d09f0c@kernel.org> References: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> In-Reply-To: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> To: Linus Torvalds , linux-fsdevel@vger.kernel.org Cc: Alexander Viro , Jan Kara , Aleksa Sarai , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1008; i=brauner@kernel.org; h=from:subject:message-id; bh=CMJvcPk73Yhg2hvF422QDgsQzhpQCQjSVQtUQYVkiag=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRt8pSewHNAIvM8H5fPesbS5M7cuJDZV2O0PMW77Hde3 SoVzP6so5SFQYyLQVZMkcWh3SRcbjlPxWajTA2YOaxMIEMYuDgFYCLmXowMRxmCbp+0nng1++3s C39Sb78r7+mLMEmK/yHr3bVQa/onXob/kQt49nVf3bE6eLFxpc3bBQuCE0NLbCSDNs4LDf+4I+w eFwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Entries under /proc//map_files/* are ephemeral and may go away before the process dies. As such allowing them to be used as mount points creates the ability to leak mounts that linger until the process dies with no ability to unmount them until then. Don't allow using them as mountpoints. Signed-off-by: Christian Brauner --- fs/proc/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 72a1acd03675..fce3d377b826 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2276,8 +2276,8 @@ proc_map_files_instantiate(struct dentry *dentry, inode->i_op = &proc_map_files_link_inode_operations; inode->i_size = 64; - d_set_d_op(dentry, &tid_map_files_dentry_operations); - return d_splice_alias(inode, dentry); + return proc_splice_unmountable(inode, dentry, + &tid_map_files_dentry_operations); } static struct dentry *proc_map_files_lookup(struct inode *dir, From patchwork Tue Aug 6 16:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13755095 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF94128382 for ; Tue, 6 Aug 2024 16:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960167; cv=none; b=Jx0mG8rC++a5iVkWdxYNJqT7MgskzzhicD7+zL/hraka8bSHTi3CO1gcd6ZOQ1dIkrxR3Bb7eargRBrXHi/n9Lp8xypQEw5ShDQUqvqujKCR1TbL2tbgpKiKwBnoJKwHCsqgasPiq5Cy+c//YRAoqJ2OuGOdPIzaUcKiZygrUuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960167; c=relaxed/simple; bh=mGE09MY53cVyBZDTv5xs8m17LFOvUXS/Bx6Bgx9K2uM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OX4rDH/Njz1r+wy+W86OFJBPh1okjIyphL4mypBmQACtO90zwZ5nJ08LLKhk3RkkokHnj1A78kTnVQ2qZIcNa0Wx/OpukEGMO/fYXKF8s0zERA1MGDOv4yYpJx4FhPP/oKvw3OV0Jm56omKVYLgoOBy0QYc/EIvmFPbeg7qmdqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Izy16J70; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Izy16J70" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F14D0C4AF13; Tue, 6 Aug 2024 16:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722960167; bh=mGE09MY53cVyBZDTv5xs8m17LFOvUXS/Bx6Bgx9K2uM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Izy16J70e00QhZLDiNRn1JQKGtb0D9WZQHBwDCe9XSVoGsMaDRqMyBfFKXMu0sNvE kwS1UVB2OszOYTfQr4cPKnIN6AoYI4nqGTcwJ2+KsvLa83j8S40ZKSxGDq/XTynIH7 39pcOYiTNIr2c8ax2oM63zNJf055VBWPtRNafq3kT/LAby5Vn9tFeRqtZe3BXjoicp 7KT68eAR4oI/wLRxwW0FG/3k3u4Hu1CFLw1J0Nndw0foytOAly7bJOqudh9zmflDBC wMOEqhzDxssSqFYcrlM3QCQuqrYyM76E4bMkGzIJzeCQOor8FRE7U2pMcOc3GagMU2 uWZeen7r0Jfhw== From: Christian Brauner Date: Tue, 06 Aug 2024 18:02:31 +0200 Subject: [PATCH RFC 5/6] proc: block mounting on top of /proc//fd/* Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-work-procfs-v1-5-fb04e1d09f0c@kernel.org> References: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> In-Reply-To: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> To: Linus Torvalds , linux-fsdevel@vger.kernel.org Cc: Alexander Viro , Jan Kara , Aleksa Sarai , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=999; i=brauner@kernel.org; h=from:subject:message-id; bh=mGE09MY53cVyBZDTv5xs8m17LFOvUXS/Bx6Bgx9K2uM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRt8pT+UVVh4pv2sih5VnaTs1Grsrym7LW+uUuK2Vhq7 7k02Lt2lLIwiHExyIopsji0m4TLLeep2GyUqQEzh5UJZAgDF6cATGSvB8P/uoeb3p5p3sj1eO4H Hd6Ai4skOO6+LQvcnSjX993FJ3L3IUaGN+IqN25MmWjGNmXH/fXtHsLaf2+cYO6WZdSumv3a6uE CXgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Entries under /proc//fd/* are ephemeral and may go away before the process dies. As such allowing them to be used as mount points creates the ability to leak mounts that linger until the process dies with no ability to unmount them until then. Don't allow using them as mountpoints. Signed-off-by: Christian Brauner --- fs/proc/fd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/fd.c b/fs/proc/fd.c index ab243caf1b71..f6b7344b9b2e 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c @@ -220,8 +220,8 @@ static struct dentry *proc_fd_instantiate(struct dentry *dentry, ei->op.proc_get_link = proc_fd_link; tid_fd_update_inode(task, inode, data->mode); - d_set_d_op(dentry, &tid_fd_dentry_operations); - return d_splice_alias(inode, dentry); + return proc_splice_unmountable(inode, dentry, + &tid_fd_dentry_operations); } static struct dentry *proc_lookupfd_common(struct inode *dir, From patchwork Tue Aug 6 16:02:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13755096 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C028F28382 for ; Tue, 6 Aug 2024 16:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960169; cv=none; b=BYi/4ISBj4zU3oDsa0X7DgI6VrGgmeoHImopaW7EhYAWT17CGuS5YKBOP/n3bdwLeokTQGGB64wsqqUtkkfNiPGRsNwzzajj7ddQzl8hyWmCCKyQSMjNnPbpox0StINBOO0h84OFOoQgCcYlGGmeiR7mPX2fmjIphsVv8QnM2g8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722960169; c=relaxed/simple; bh=PCqgiUtrfFNRs8S6V6oi9qOM8cvc8rx8luFKBcBqD+Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WR7M9rmaY/5f5F6WwKbcmqQGuXTwNfwyaYIR60Totq0NSjb0mOEKraLrDqdoVMjUhoODouReM9ha/jnoBvBQSP48NEOCOyTKluGEKHpobIM+lyn8JMYZrFRxsxlFKmyA07nMzx3tmsMISpQLbZ6imSmf7oqIZ5jbx1hs+x3g+ao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N+0BNnj4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N+0BNnj4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8AD8C32786; Tue, 6 Aug 2024 16:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722960169; bh=PCqgiUtrfFNRs8S6V6oi9qOM8cvc8rx8luFKBcBqD+Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=N+0BNnj4AlQcuMM0nuK6L2f7jR/u2ZUrTj7bUKuNpiRsiKZcFK/rJ16Pr+Y4hXFIq ZTuqQ7J+7dbgVtwzb0i1YV2CD9qnurKzcr/5i3LA85/5A6UcftPMqcOgDC9Ln6s+nV 89A+8rdbSCeRwM11mdivi/5YiOpEEFUfbJuizCMjxCTVxDazSwhlifHocVB2puzozQ t6XrE/Oley635VzE09j7VP6CWrd5ijA1CkJDXjg+Dfirln9/dPrvilYu9gvJfl+zaV PZzoIjXc+JreWk3HQxsTEM9mVqtGQwg2owl1GNnMBZQnPsiDICba3mzEIwu7PRI0bz ER2TkLBcsbTyQ== From: Christian Brauner Date: Tue, 06 Aug 2024 18:02:32 +0200 Subject: [PATCH RFC 6/6] proc: block mounting on top of /proc//fdinfo/* Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240806-work-procfs-v1-6-fb04e1d09f0c@kernel.org> References: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> In-Reply-To: <20240806-work-procfs-v1-0-fb04e1d09f0c@kernel.org> To: Linus Torvalds , linux-fsdevel@vger.kernel.org Cc: Alexander Viro , Jan Kara , Aleksa Sarai , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=967; i=brauner@kernel.org; h=from:subject:message-id; bh=PCqgiUtrfFNRs8S6V6oi9qOM8cvc8rx8luFKBcBqD+Y=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRt8pSev1Bm2wzXQ0vUbzZtCZXquVTu0djz+1ZMVvenM 2ViwVLfO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACZiuZyRYfO28Nsz/eN53fvm yRo/+qWY8YmBT2mf5eSHHFFGDWFcCxgZFjKKrir3ZNJmfbioueds5YLrH0TSz19ftnGm4ZQ99yM L2AE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Entries under /proc//fdinfo/* are ephemeral and may go away before the process dies. As such allowing them to be used as mount points creates the ability to leak mounts that linger until the process dies with no ability to unmount them until then. Don't allow using them as mountpoints. Signed-off-by: Christian Brauner --- fs/proc/fd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/fd.c b/fs/proc/fd.c index f6b7344b9b2e..e9ac955ca9f3 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c @@ -397,8 +397,8 @@ static struct dentry *proc_fdinfo_instantiate(struct dentry *dentry, inode->i_fop = &proc_fdinfo_file_operations; tid_fd_update_inode(task, inode, 0); - d_set_d_op(dentry, &tid_fd_dentry_operations); - return d_splice_alias(inode, dentry); + return proc_splice_unmountable(inode, dentry, + &tid_fd_dentry_operations); } static struct dentry *