# Re: \[PATCH v15 5/9\] namei: LOOKUP\_IN\_ROOT: chroot-like scoped resolution

- From: Al Viro \<viro@zeniv.linux.org.uk\>
- Date: 2019-11-13 02:03:45 
- List: linux-mips
- Page: https://ratatoskr.run/linux-mips/2019/11/166643
- Thread: https://ratatoskr.run/linux-alpha/2019/11/166181/t.md

```text
On Tue, Nov 05, 2019 at 08:05:49PM +1100, Aleksa Sarai wrote:

> @@ -2277,12 +2277,20 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
>  
>  	nd->m_seq = read_seqbegin(&mount_lock);
>  
> -	/* Figure out the starting path and root (if needed). */
> -	if (*s == '/') {
> +	/* Absolute pathname -- fetch the root. */
> +	if (flags & LOOKUP_IN_ROOT) {
> +		/* With LOOKUP_IN_ROOT, act as a relative path. */
> +		while (*s == '/')
> +			s++;

Er...  Why bother skipping slashes?  I mean, not only link_path_walk()
will skip them just fine, you are actually risking breakage in this:
                if (*s && unlikely(!d_can_lookup(dentry))) {
                        fdput(f);
                        return ERR_PTR(-ENOTDIR);
                }
which is downstream from there with you patch, AFAICS.
```
