Skip to content

Commit

Permalink
fs: namei: Allow follow_down() to uncover auto mounts
Browse files Browse the repository at this point in the history
This function is only used by NFSD to cross mount points.
If a mount point is of type auto mount, follow_down() will
not uncover it. Add LOOKUP_AUTOMOUNT to the lookup flags
to have ->d_automount() called when NFSD walks down the
mount tree.

Signed-off-by: Richard Weinberger <[email protected]>
Reviewed-by: Ian Kent <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
Acked-by: Al Viro <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
  • Loading branch information
richardweinberger authored and chucklever committed Feb 20, 2023
1 parent 50f5fda commit e1f1985
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1458,11 +1458,11 @@ EXPORT_SYMBOL(follow_down_one);
* point, the filesystem owning that dentry may be queried as to whether the
* caller is permitted to proceed or not.
*/
int follow_down(struct path *path)
int follow_down(struct path *path, unsigned int flags)
{
struct vfsmount *mnt = path->mnt;
bool jumped;
int ret = traverse_mounts(path, &jumped, NULL, 0);
int ret = traverse_mounts(path, &jumped, NULL, flags);

if (path->mnt != mnt)
mntput(mnt);
Expand Down Expand Up @@ -2864,7 +2864,7 @@ int path_pts(struct path *path)

path->dentry = child;
dput(parent);
follow_down(path);
follow_down(path, 0);
return 0;
}
#endif
Expand Down
6 changes: 5 additions & 1 deletion fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
struct dentry *dentry = *dpp;
struct path path = {.mnt = mntget(exp->ex_path.mnt),
.dentry = dget(dentry)};
unsigned int follow_flags = 0;
int err = 0;

err = follow_down(&path);
if (exp->ex_flags & NFSEXP_CROSSMOUNT)
follow_flags = LOOKUP_AUTOMOUNT;

err = follow_down(&path, follow_flags);
if (err < 0)
goto out;
if (path.mnt == exp->ex_path.mnt && path.dentry == dentry &&
Expand Down
2 changes: 1 addition & 1 deletion include/linux/namei.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct dentry *lookup_one_positive_unlocked(struct user_namespace *mnt_userns,
struct dentry *base, int len);

extern int follow_down_one(struct path *);
extern int follow_down(struct path *);
extern int follow_down(struct path *path, unsigned int flags);
extern int follow_up(struct path *);

extern struct dentry *lock_rename(struct dentry *, struct dentry *);
Expand Down

0 comments on commit e1f1985

Please sign in to comment.