From: sashiko-bot@kernel.org
To: "Cai Xinchen" <caixinchen1@huawei.com>
Cc: bpf@vger.kernel.org, linux-security-module@vger.kernel.org,
linux-trace-kernel@vger.kernel.org, selinux@vger.kernel.org,
dsterba@suse.cz, "Chuck Lever" <cel@kernel.org>,
"Jeff Layton" <jlayton@kernel.org>,
"Anna Schumaker" <anna@kernel.org>
Subject: Re: [PATCH -next -v4 03/17] fs: pass struct path to xattr helpers
Date: Tue, 17 Nov 2026 14:59:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-219006@kernel.org> (raw)
In-Reply-To: <20261117150542.1169451-4-caixinchen1@huawei.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ksmbd: dotdot mount walk in
ksmbd_populate_dot_dotdot_entries() escapes share_root
- [Low] nfsd: reverse Christmas tree order violated in nfsd_getxattr()
and nfsd_listxattr()
--
commit 659e941625d287aa476faa3056e5fd5cc15c2d66
Author: Cai Xinchen <caixinchen1@huawei.com>
fs: pass struct path to xattr helpers
This commit updates vfs_setxattr(), vfs_getxattr(), vfs_listxattr(),
vfs_removexattr(), and the __vfs_*_locked() helpers along with their
callers in ksmbd, nfsd, overlayfs, cachefiles, ecryptfs, and LSMs to
pass a struct path instead of a struct dentry.
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 1c686b82e70a0..aef4097e9ef37 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
[ ... ]
> @@ -2676,23 +2678,24 @@ __be32
> nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
> void **bufp, int *lenp)
> {
> + struct path path;
> + struct inode *inode;
> + char *buf;
> ssize_t len;
> __be32 err;
> - char *buf;
> - struct inode *inode;
> - struct dentry *dentry;
[ ... ]
> @@ -2749,23 +2752,24 @@ __be32
> nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char **bufp,
> int *lenp)
> {
> + struct path path;
> + struct inode *inode;
> + char *buf;
> ssize_t len;
> __be32 err;
> - char *buf;
> - struct inode *inode;
> - struct dentry *dentry;
[Severity: Low]
This isn't a bug, but NFSD keeps local variable declarations in reverse
Christmas tree order, so struct inode *inode; should come before struct
path path; in both nfsd_getxattr() and nfsd_listxattr().
> diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
> index e7a987af64ba5..a6da27a7d7cbb 100644
> --- a/fs/smb/server/smb_common.c
> +++ b/fs/smb/server/smb_common.c
> @@ -467,37 +467,82 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
> {
> int i, rc = 0;
> struct ksmbd_conn *conn = work->conn;
> - const struct mnt_idmap *idmap = file_mnt_idmap(dir->filp);
> + const struct path *const share_root = &work->tcon->share_conf->vfs_path;
>
> for (i = 0; i < 2; i++) {
> struct kstat kstat;
> struct ksmbd_kstat ksmbd_kstat;
> - struct dentry *dentry;
> + struct path path = dir->filp->f_path;
> + const struct mnt_idmap *idmap;
> + struct dentry *parent;
>
> if (!dir->dot_dotdot[i]) { /* fill dot entry info */
> if (i == 0) {
> d_info->name = ".";
> d_info->name_len = 1;
> - dentry = dget(dir->filp->f_path.dentry);
> + path_get(&path);
> } else {
> d_info->name = "..";
> d_info->name_len = 2;
> - dentry = dget_parent(dir->filp->f_path.dentry);
> + path_get(&path);
> + /*
> + * A ".." entry must not walk above the
> + * share root, so it designates the share
> + * root itself in that case.
> + */
> + if (!path_equal(&path, share_root)) {
> + /*
> + * The parent of a mount root dentry
> + * is not covered by the same mount,
> + * so follow the mount stack up like
> + * a ".." path walk would, to keep
> + * the path valid.
> + */
> + while (path.dentry == path.mnt->mnt_root &&
> + follow_up(&path))
> + ;
> + if (path.dentry == path.mnt->mnt_root) {
> + /*
> + * The mount is detached, for
> + * example after a lazy umount
> + * which the open file pins
> + * down, so the parent would
> + * not be covered by path.mnt:
> + * report the share root
> + * instead, as for any other
> + * ".." above the share root.
> + */
> + path_put(&path);
> + path_get(share_root);
> + path = *share_root;
> + } else {
> + parent = dget_parent(path.dentry);
> + dput(path.dentry);
> + path.dentry = parent;
> + }
> + }
> }
[Severity: Medium]
Can the ".." resolution walk above share_root when a mount is stacked on
top of share_root?
If a submount is mounted on share_root and entered via follow_down() when
KSMBD_SHARE_FLAG_CROSSMNT is enabled, dir->filp->f_path is the submount
root, so the initial path_equal(&path, share_root) check is false.
follow_up(&path) then steps onto share_root, but neither the while loop
nor the dget_parent() branch rechecks path_equal(&path, share_root).
If share_root is itself a mountpoint, the loop continues calling
follow_up(&path) into the parent mount; otherwise the else branch calls
dget_parent(path.dentry) and steps to the parent directory of share_root,
exposing host directory attributes and xattrs outside the share to the
SMB client via ksmbd_vfs_fill_dentry_attrs().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117150542.1169451-1-caixinchen1@huawei.com?part=3
next prev parent reply other threads:[~2026-11-17 14:59 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 15:05 [PATCH -next -v4 00/17] landlock: Add READ_METADATA and WRITE_METADATA access rights Cai Xinchen
2026-11-17 15:05 ` [PATCH -next -v4 01/17] fs: pass struct path to notify_change() Cai Xinchen
2026-11-17 14:48 ` sashiko-bot
2026-11-17 18:30 ` Al Viro
2026-11-17 18:34 ` Al Viro
2026-11-17 15:05 ` [PATCH -next -v4 02/17] LSM: pass struct path to the inode_setsecctx hook Cai Xinchen
2026-11-17 14:43 ` sashiko-bot
2026-11-17 18:43 ` Al Viro
2026-11-18 0:16 ` Al Viro
2026-11-17 15:05 ` [PATCH -next -v4 03/17] fs: pass struct path to xattr helpers Cai Xinchen
2026-11-17 14:59 ` sashiko-bot [this message]
2026-11-17 15:05 ` [PATCH -next -v4 04/17] fs: pass struct path to POSIX ACL helpers Cai Xinchen
2026-11-17 14:45 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 05/17] LSM: pass struct path and struct file to the inode xattr hooks Cai Xinchen
2026-11-17 15:03 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 06/17] LSM: pass struct path and struct file to the inode posix acl hooks Cai Xinchen
2026-11-17 15:07 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 07/17] LSM: pass struct path and struct file to the inode fileattr hooks Cai Xinchen
2026-11-17 14:51 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 08/17] LSM: rename inode_setattr to path_setattr and pass struct path and file Cai Xinchen
2026-11-17 15:11 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 09/17] LSM: rename inode_getattr to path_getattr and pass struct file Cai Xinchen
2026-11-17 15:30 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 10/17] LSM: rename the inode xattr hooks to path_xattr hooks Cai Xinchen
2026-11-17 14:55 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 11/17] LSM: rename the inode posix acl hooks to path_*_acl hooks Cai Xinchen
2026-11-17 14:55 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 12/17] LSM: rename the inode fileattr hooks to path_file_* hooks Cai Xinchen
2026-11-17 15:02 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 13/17] LSM: rename inode_setsecctx to path_setsecctx Cai Xinchen
2026-11-17 14:59 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 14/17] landlock: Add READ_METADATA and WRITE_METADATA access rights Cai Xinchen
2026-11-17 15:49 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 15/17] selftests/landlock: Add tests for metadata " Cai Xinchen
2026-11-17 15:12 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 16/17] samples/landlock: Add metadata rights to sandboxer Cai Xinchen
2026-11-17 15:04 ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 17/17] Documentation: Update landlock doc for metadata rights Cai Xinchen
2026-11-17 15:05 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-219006@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anna@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=caixinchen1@huawei.com \
--cc=cel@kernel.org \
--cc=dsterba@suse.cz \
--cc=jlayton@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.