[lkml]   [2020]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC][PATCHSET] sanitized pathwalk machinery (v2)
On Tue, Feb 25, 2020 at 01:24:57AM +0000, Al Viro wrote:

> Incidentally, another inconsistency is LOOKUP_BENEATH treatment in case
> when we have walked out of the subtree by way of e.g. procfs symlink and
> then ran into .. in the absolute root (that's
> if (!follow_up(&nd->path))
> break;
> in follow_dotdot()). Shouldn't that give the same reaction as ..
> in root (EXDEV on LOOKUP_BENEATH, that is)? It doesn't...
> Another one is about LOOKUP_NO_XDEV again: suppose you have process'
> root directly overmounted and cwd in the root of whatever's overmounting
> it. Resolution of .. will stay in cwd - we have no parent within the
> chroot jail we are in, so we move to whatever's overmounting that root.
> Which is the original location. Should we fail on LOOKUP_NO_XDEV here?
> Plain .. in the root of chroot jail (not overmounted by anything) does
> *not*...

FWIW, my preference would be the following (for non-RCU case; RCU
one is similar)

if (path_equal(&nd->path, &nd->root))
return NULL;
if (nd->path.dentry != nd->path.mnt->mnt_root)
return dget_parent(nd->path.dentry);
m = real_mount(nd->path.mnt);
while (mnt_has_parent(m)) {
d = m->mnt_mountpoint;
m = m->mnt_parent;
if (&m->mnt == nd->root.mnt && d == nd->root.path) // root
if (m->mnt_root != d) {
if (unlikely(nd->flags & LOOKUP_NO_XDEV)) {
return ERR_PTR(-EXDEV);
nd->path.mnt = &m->mnt;
nd->path.dentry = d;
nd->inode = d->d_inode;
return dget_parent(d);
return NULL;

with follow_dotdot() doing
parent = get_parent(nd);
if (unlikely(IS_ERR(parent)))
return PTR_ERR(parent);
if (unlikely(!parent)) { .. in root is a rare case
bugger off if LOOKUP_BENEATH
parent = dget(nd->path.dentry);
} else if (unlikely(!path_connected(nd->path.mnt, parent))) {
return -ENOENT;
nd->path.dentry = parent;

... with the last part replaced with
step_into(nd, WALK_NOFOLLOW, dentry, NULL, 0);
later in this series, with similar in RCU case (only there we would want
inode and seq supplied, as usual, so it would be get_parent_rcu(nd, &inode,

 \ /
  Last update: 2020-02-25 03:04    [W:0.463 / U:1.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site