mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ksmbd: use the resolved share path for the share root
@ 2026-10-26 12:55 Denis Kulikov
  2026-10-27  9:28 ` Namjae Jeon
  0 siblings, 1 reply; 2+ messages in thread
From: Denis Kulikov @ 2026-10-26 12:55 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: Sergey Senozhatsky, Tom Talpey, ChenXiaoSong, Steve French,
	linux-cifs, linux-kernel, Denis Kulikov

If the share path is a mount point and crossmnt is not set (crossmnt = no,
or ksmbd-tools that predate the option), the share root looks empty to
clients: QUERY_DIRECTORY on it returns only "." and "..". Files created
in the root go to the mounted filesystem, but a directory query cannot
find them afterwards, so e.g. "rm" of a file that was just uploaded
fails with STATUS_NO_SUCH_FILE.

An empty name refers to the share root. For it, ksmbd_vfs_path_lookup()
looks up share_conf->path again starting from its parent, and the mount
on the last component is not followed, which gives the directory covered
by the mount. All other names are looked up relative to
share_conf->vfs_path, which was resolved through the mount when the
share was set up.

share_conf->vfs_path already refers to the share root, so return a
reference to it instead of looking the path up again.

Fixes: 74d7970febf7 ("ksmbd: fix racy issue from using ->d_parent and ->d_name")
Signed-off-by: Denis Kulikov <dar1knessx@gmail.com>
---
Tested on x86_64 hardware running v7.3 with this change applied to the
ksmbd module: share on a loop-mounted ext4, crossmnt = no, smbclient.
Without the patch the root lists only "." and ".."; with it all files
are listed and put/ls/rm work. Also tested on current mainline in QEMU.

 fs/smb/server/vfs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 4ee72eda9bc0..1f2bc76f0d09 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -66,12 +66,13 @@ static int ksmbd_vfs_path_lookup(struct ksmbd_share_config *share_conf,
 		if (for_remove)
 			return -EINVAL;
 
-		pathname = share_conf->path;
-		root_share_path = NULL;
-	} else {
-		flags |= LOOKUP_BENEATH;
+		*path = share_conf->vfs_path;
+		path_get(path);
+		return 0;
 	}
 
+	flags |= LOOKUP_BENEATH;
+
 	CLASS(filename_kernel, filename)(pathname);
 	scoped_with_init_fs()
 		err = vfs_path_parent_lookup(filename, flags, path, &last,
-- 
2.56.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ksmbd: use the resolved share path for the share root
  2026-10-26 12:55 [PATCH] ksmbd: use the resolved share path for the share root Denis Kulikov
@ 2026-10-27  9:28 ` Namjae Jeon
  0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2026-10-27  9:28 UTC (permalink / raw)
  To: Denis Kulikov
  Cc: Sergey Senozhatsky, Tom Talpey, ChenXiaoSong, Steve French,
	linux-cifs, linux-kernel

On Mon, Oct 26, 2026 at 9:56 PM Denis Kulikov <dar1knessx@gmail.com> wrote:
>
> If the share path is a mount point and crossmnt is not set (crossmnt = no,
> or ksmbd-tools that predate the option), the share root looks empty to
> clients: QUERY_DIRECTORY on it returns only "." and "..". Files created
> in the root go to the mounted filesystem, but a directory query cannot
> find them afterwards, so e.g. "rm" of a file that was just uploaded
> fails with STATUS_NO_SUCH_FILE.
>
> An empty name refers to the share root. For it, ksmbd_vfs_path_lookup()
> looks up share_conf->path again starting from its parent, and the mount
> on the last component is not followed, which gives the directory covered
> by the mount. All other names are looked up relative to
> share_conf->vfs_path, which was resolved through the mount when the
> share was set up.
>
> share_conf->vfs_path already refers to the share root, so return a
> reference to it instead of looking the path up again.
>
> Fixes: 74d7970febf7 ("ksmbd: fix racy issue from using ->d_parent and ->d_name")
> Signed-off-by: Denis Kulikov <dar1knessx@gmail.com>
Applied it to #ksmbd-for-next.
Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-27  9:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 12:55 [PATCH] ksmbd: use the resolved share path for the share root Denis Kulikov
2026-10-27  9:28 ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®