[PATCH] VFS: Ensure LOOKUP_CONTINUE flag is preserved by link_path_walk()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 When walking a path, the LOOKUP_CONTINUE flag is used by some filesystems
 (for instance NFS) in order to determine whether or not it is looking up
 the last component of the path. It this is the case, it may have to look
 at the intent information in order to perform various tasks such as atomic
 open.

 A problem currently occurs when link_path_walk() hits a symlink. In this
 case LOOKUP_CONTINUE may be cleared prematurely when we hit the end of the
 path passed by __vfs_follow_link() (i.e. the end of the symlink path)
 rather than when we hit the end of the path passed by the user.

 The solution is to have link_path_walk() clear LOOKUP_CONTINUE if and only
 if that flag was unset when we entered the function.

 Signed-off-by: Trond Myklebust <[email protected]>
---

 fs/namei.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 4acdac0..e1195f4 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -790,7 +790,7 @@ static fastcall int __link_path_walk(con
 
 	inode = nd->dentry->d_inode;
 	if (nd->depth)
-		lookup_flags = LOOKUP_FOLLOW;
+		lookup_flags = LOOKUP_FOLLOW | (nd->flags & LOOKUP_CONTINUE);
 
 	/* At this point we know we have a real path component. */
 	for(;;) {
@@ -885,7 +885,8 @@ static fastcall int __link_path_walk(con
 last_with_slashes:
 		lookup_flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
 last_component:
-		nd->flags &= ~LOOKUP_CONTINUE;
+		/* Clear LOOKUP_CONTINUE iff it was previously unset */
+		nd->flags &= lookup_flags | ~LOOKUP_CONTINUE;
 		if (lookup_flags & LOOKUP_PARENT)
 			goto lookup_parent;
 		if (this.name[0] == '.') switch (this.len) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux