On Sat, May 08, 2021 at 01:39:45PM -0700, Linus Torvalds wrote: > +static inline int prepend_entries(struct prepend_buffer *b, const struct path *path, const struct path *root, struct mount *mnt) If anything, s/path/dentry/, since vfsmnt here will be equal to &mnt->mnt all along. > +{ > + struct dentry *dentry = path->dentry; > + struct vfsmount *vfsmnt = path->mnt; > + > + while (dentry != root->dentry || vfsmnt != root->mnt) { > + int error; > + struct dentry * parent; > + > + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { > + struct mount *parent = READ_ONCE(mnt->mnt_parent); > + struct mnt_namespace *mnt_ns; > + > + /* Escaped? */ > + if (dentry != vfsmnt->mnt_root) > + return 3; > + > + /* Global root? */ > + if (mnt != parent) { > + dentry = READ_ONCE(mnt->mnt_mountpoint); > + mnt = parent; > + vfsmnt = &mnt->mnt; > + continue; > + } > + mnt_ns = READ_ONCE(mnt->mnt_ns); > + /* open-coded is_mounted() to use local mnt_ns */ > + if (!IS_ERR_OR_NULL(mnt_ns) && !is_anon_ns(mnt_ns)) > + return 1; // absolute root > + > + return 2; // detached or not attached yet > + break; ? > + } > + parent = dentry->d_parent; > + prefetch(parent); > + error = prepend_name(b, &dentry->d_name); > + if (error) > + break; return error, surely? > + dentry = parent; > + } > + return 0; > +} FWIW, if we go that way, I would make that while (dentry != root->dentry || &mnt->mnt != root->mnt) { int error; struct dentry *parent = READ_ONCE(dentry->d_parent); if (unlikely(dentry == mnt->mnt.mnt_root)) { struct mount *m = READ_ONCE(mnt->mnt_parent); /* Global root? */ if (unlikely(mnt == m) { struct mnt_namespace *mnt_ns; mnt_ns = READ_ONCE(mnt->mnt_ns); /* open-coded is_mounted() to use local mnt_ns */ if (!IS_ERR_OR_NULL(mnt_ns) && !is_anon_ns(mnt_ns)) return 1; // absolute root else return 2; // detached or not attached yet } // cross into whatever it's mounted on dentry = READ_ONCE(mnt->mnt_mountpoint); mnt = m; continue; } /* Escaped? */ if (unlikely(dentry == parent)) return 3; prefetch(parent); error = prepend_name(b, &dentry->d_name); if (error) return error; dentry = parent; } return 0;