* [PATCH] fs: fix is_mnt_ns_file()
@ 2024-12-11 12:11 Miklos Szeredi
2024-12-11 15:36 ` Jeff Layton
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Miklos Szeredi @ 2024-12-11 12:11 UTC (permalink / raw)
To: Christian Brauner; +Cc: linux-fsdevel, stable
Commit 1fa08aece425 ("nsfs: convert to path_from_stashed() helper") reused
nsfs dentry's d_fsdata, which no longer contains a pointer to
proc_ns_operations.
Fix the remaining use in is_mnt_ns_file().
Fixes: 1fa08aece425 ("nsfs: convert to path_from_stashed() helper")
Cc: <stable@vger.kernel.org> # v6.9
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
Came across this while getting the mnt_ns in fsnotify_mark(), tested the
fix in that context. I don't have a test for mainline, though.
fs/namespace.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index 23e81c2a1e3f..6eec7794f707 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2055,9 +2055,15 @@ SYSCALL_DEFINE1(oldumount, char __user *, name)
static bool is_mnt_ns_file(struct dentry *dentry)
{
+ struct ns_common *ns;
+
/* Is this a proxy for a mount namespace? */
- return dentry->d_op == &ns_dentry_operations &&
- dentry->d_fsdata == &mntns_operations;
+ if (dentry->d_op != &ns_dentry_operations)
+ return false;
+
+ ns = d_inode(dentry)->i_private;
+
+ return ns->ops == &mntns_operations;
}
struct ns_common *from_mnt_ns(struct mnt_namespace *mnt)
--
2.47.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: fix is_mnt_ns_file()
2024-12-11 12:11 [PATCH] fs: fix is_mnt_ns_file() Miklos Szeredi
@ 2024-12-11 15:36 ` Jeff Layton
2024-12-11 16:30 ` Al Viro
2024-12-13 12:48 ` Christian Brauner
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2024-12-11 15:36 UTC (permalink / raw)
To: Miklos Szeredi, Christian Brauner; +Cc: linux-fsdevel, stable
On Wed, 2024-12-11 at 13:11 +0100, Miklos Szeredi wrote:
> Commit 1fa08aece425 ("nsfs: convert to path_from_stashed() helper") reused
> nsfs dentry's d_fsdata, which no longer contains a pointer to
> proc_ns_operations.
>
> Fix the remaining use in is_mnt_ns_file().
>
> Fixes: 1fa08aece425 ("nsfs: convert to path_from_stashed() helper")
> Cc: <stable@vger.kernel.org> # v6.9
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> ---
>
> Came across this while getting the mnt_ns in fsnotify_mark(), tested the
> fix in that context. I don't have a test for mainline, though.
>
> fs/namespace.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 23e81c2a1e3f..6eec7794f707 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2055,9 +2055,15 @@ SYSCALL_DEFINE1(oldumount, char __user *, name)
>
> static bool is_mnt_ns_file(struct dentry *dentry)
> {
> + struct ns_common *ns;
> +
> /* Is this a proxy for a mount namespace? */
> - return dentry->d_op == &ns_dentry_operations &&
> - dentry->d_fsdata == &mntns_operations;
> + if (dentry->d_op != &ns_dentry_operations)
> + return false;
> +
> + ns = d_inode(dentry)->i_private;
> +
> + return ns->ops == &mntns_operations;
> }
>
> struct ns_common *from_mnt_ns(struct mnt_namespace *mnt)
Took me a min to figure out how i_private gets set, but this looks
correct.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: fix is_mnt_ns_file()
2024-12-11 12:11 [PATCH] fs: fix is_mnt_ns_file() Miklos Szeredi
2024-12-11 15:36 ` Jeff Layton
@ 2024-12-11 16:30 ` Al Viro
2024-12-13 12:48 ` Christian Brauner
2 siblings, 0 replies; 4+ messages in thread
From: Al Viro @ 2024-12-11 16:30 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: Christian Brauner, linux-fsdevel, stable
On Wed, Dec 11, 2024 at 01:11:17PM +0100, Miklos Szeredi wrote:
> Commit 1fa08aece425 ("nsfs: convert to path_from_stashed() helper") reused
> nsfs dentry's d_fsdata, which no longer contains a pointer to
> proc_ns_operations.
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs: fix is_mnt_ns_file()
2024-12-11 12:11 [PATCH] fs: fix is_mnt_ns_file() Miklos Szeredi
2024-12-11 15:36 ` Jeff Layton
2024-12-11 16:30 ` Al Viro
@ 2024-12-13 12:48 ` Christian Brauner
2 siblings, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2024-12-13 12:48 UTC (permalink / raw)
To: Christian Brauner, Miklos Szeredi; +Cc: linux-fsdevel, stable
On Wed, 11 Dec 2024 13:11:17 +0100, Miklos Szeredi wrote:
> Commit 1fa08aece425 ("nsfs: convert to path_from_stashed() helper") reused
> nsfs dentry's d_fsdata, which no longer contains a pointer to
> proc_ns_operations.
>
> Fix the remaining use in is_mnt_ns_file().
>
>
> [...]
Thanks for fixing that!
---
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] fs: fix is_mnt_ns_file()
https://git.kernel.org/vfs/vfs/c/aa21f333c86c
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-13 12:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11 12:11 [PATCH] fs: fix is_mnt_ns_file() Miklos Szeredi
2024-12-11 15:36 ` Jeff Layton
2024-12-11 16:30 ` Al Viro
2024-12-13 12:48 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox