cifs: Don't replace dentries for dfs mounts
Subsystems (2)
PATCH 1/1 cifs: Don't replace dentries for dfs mounts
Doing a readdir on a dfs root can result in the dentries for directories with a dfs share mounted being replaced by new dentries for objects returned by the readdir call. These new dentries on shares mounted with unix extenstions show up as symlinks pointing to the dfs share.
# mount -t cifs -o sec=none //vm140-31/dfsroot cifs # stat cifs/testlink/testfile; ls -l cifs File: ‘cifs/testlink/testfile’ Size: 0 Blocks: 0 IO Block: 16384 regular empty file Device: 27h/39d Inode: 130120 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2015-03-31 13:55:50.106018200 +0100 Modify: 2015-03-31 13:55:50.106018200 +0100 Change: 2015-03-31 13:55:50.106018200 +0100 Birth: - total 0 drwxr-xr-x 2 root root 0 Mar 31 13:54 testdir lrwxrwxrwx 1 root root 19 Mar 24 14:25 testlink -> \vm140-31\test
In the example above, the stat command mounts the dfs share at cifs/testlink. The subsequent ls on the dfsroot directory replaces the dentry for testlink with a symlink.
In the earlier code, the d_invalidate command returned an -EBUSY error when attempting to invalidate directories. This stopped the code from replacing the directories with symlinks returned by the readdir call. Changes were recently made to the d_invalidate() command so that it no longer returns an error code. This results in the directory with the mounted dfs share being replaced by a symlink which denotes a dfs share.
--- fs/cifs/readdir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/readdir.c +2 -0
@@ -90,6 +90,8 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,if (dentry) { inode = dentry->d_inode;if (inode) { +if (d_mountpoint (dentry)) + goto out;/* * If we're generating inode numbers, then we don't * want to clobber the existing one with the one that
Signature · 1 line
2.1.0
A message that is not in the archive (sent off-list or not yet received): 1427982695-29891-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Jeff Layton
Reviewed-byQuoted 42 lines · On Thu, 2 Apr 2015 14:51:35 +0100 Sachin Prabhu…
Doing a readdir on a dfs root can result in the dentries for directories with a dfs share mounted being replaced by new dentries for objects returned by the readdir call. These new dentries on shares mounted with unix extenstions show up as symlinks pointing to the dfs share.
# mount -t cifs -o sec=none //vm140-31/dfsroot cifs # stat cifs/testlink/testfile; ls -l cifs File: ‘cifs/testlink/testfile’ Size: 0 Blocks: 0 IO Block: 16384 regular empty file Device: 27h/39d Inode: 130120 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2015-03-31 13:55:50.106018200 +0100 Modify: 2015-03-31 13:55:50.106018200 +0100 Change: 2015-03-31 13:55:50.106018200 +0100 Birth: - total 0 drwxr-xr-x 2 root root 0 Mar 31 13:54 testdir lrwxrwxrwx 1 root root 19 Mar 24 14:25 testlink -> \vm140-31\testIn the example above, the stat command mounts the dfs share at cifs/testlink. The subsequent ls on the dfsroot directory replaces the dentry for testlink with a symlink.
In the earlier code, the
d_invalidatecommand returned an-EBUSYerror when attempting to invalidate directories. This stopped the code from replacing the directories with symlinks returned by the readdir call. Changes were recently made to thed_invalidate()command so that it no longer returns an error code. This results in the directory with the mounted dfs share being replaced by a symlink which denotes a dfs share.Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/readdir.c | 2 ++ 1 file changed, 2 insertions(+)fs/cifs/readdir.c +0
-0
fs/cifs/readdir.c cifs_prime_dcache(struct dentry *parent, struct qstr *name, · line 97
Quoted 8 lines
fs/cifs/readdir.c +2
-0@@ -90,6 +90,8 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,if (dentry) { inode = dentry->d_inode;if (inode) { +if (d_mountpoint (dentry)) + goto out;/* * If we're generating inode numbers, then we don't * want to clobber the existing one with the one that
Looks right.
A message that is not in the archive (sent off-list or not yet received): 20150403081406.1f8323d1-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Looks reasonable but fails on SMB3 - we need to fix lines 133 and 134 of smb2pdu.c as well
Quoted 62 lines · Jeff Layton
Quoted 42 lines · On Thu, 2 Apr 2015 14:51:35 +0100 Sachin Prabhu…
Doing a readdir on a dfs root can result in the dentries for directories with a dfs share mounted being replaced by new dentries for objects returned by the readdir call. These new dentries on shares mounted with unix extenstions show up as symlinks pointing to the dfs share.
# mount -t cifs -o sec=none //vm140-31/dfsroot cifs # stat cifs/testlink/testfile; ls -l cifs File: ‘cifs/testlink/testfile’ Size: 0 Blocks: 0 IO Block: 16384 regular empty file Device: 27h/39d Inode: 130120 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2015-03-31 13:55:50.106018200 +0100 Modify: 2015-03-31 13:55:50.106018200 +0100 Change: 2015-03-31 13:55:50.106018200 +0100 Birth: - total 0 drwxr-xr-x 2 root root 0 Mar 31 13:54 testdir lrwxrwxrwx 1 root root 19 Mar 24 14:25 testlink -> \vm140-31\testIn the example above, the stat command mounts the dfs share at cifs/testlink. The subsequent ls on the dfsroot directory replaces the dentry for testlink with a symlink.
In the earlier code, the
d_invalidatecommand returned an-EBUSYerror when attempting to invalidate directories. This stopped the code from replacing the directories with symlinks returned by the readdir call. Changes were recently made to thed_invalidate()command so that it no longer returns an error code. This results in the directory with the mounted dfs share being replaced by a symlink which denotes a dfs share.Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/readdir.c | 2 ++ 1 file changed, 2 insertions(+)fs/cifs/readdir.c +0
-0fs/cifs/readdir.c cifs_prime_dcache(struct dentry *parent, struct qstr *name, · line 97
Quoted 8 lines
fs/cifs/readdir.c +2
-0@@ -90,6 +90,8 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,if (dentry) { inode = dentry->d_inode;if (inode) { +if (d_mountpoint (dentry)) + goto out;/* * If we're generating inode numbers, then we don't * want to clobber the existing one with the one that Looks right.
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): CAH2r5mt1JHCsnmTQmOgT5gSozig=UAreT=zqjuqDMsLtciqVJw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 2 lines · Steve French
Looks reasonable but fails on SMB3 - we need to fix lines 133 and 134 of
smb2pdu.cas well
Hello Steve,
I am not sure I understand how these lines are involved. The patch fixes behaviour for readdir where the lookup data doesn't contain any information indicating that the directory leads to a DFS lookup.
Sachin Prabhu
Quoted 67 lines · Jeff Layton
Quoted 62 lines
Quoted 42 lines · On Thu, 2 Apr 2015 14:51:35 +0100 Sachin Prabhu…
Doing a readdir on a dfs root can result in the dentries for directories with a dfs share mounted being replaced by new dentries for objects returned by the readdir call. These new dentries on shares mounted with unix extenstions show up as symlinks pointing to the dfs share.
# mount -t cifs -o sec=none //vm140-31/dfsroot cifs # stat cifs/testlink/testfile; ls -l cifs File: ‘cifs/testlink/testfile’ Size: 0 Blocks: 0 IO Block: 16384 regular empty file Device: 27h/39d Inode: 130120 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2015-03-31 13:55:50.106018200 +0100 Modify: 2015-03-31 13:55:50.106018200 +0100 Change: 2015-03-31 13:55:50.106018200 +0100 Birth: - total 0 drwxr-xr-x 2 root root 0 Mar 31 13:54 testdir lrwxrwxrwx 1 root root 19 Mar 24 14:25 testlink -> \vm140-31\testIn the example above, the stat command mounts the dfs share at cifs/testlink. The subsequent ls on the dfsroot directory replaces the dentry for testlink with a symlink.
In the earlier code, the
d_invalidatecommand returned an-EBUSYerror when attempting to invalidate directories. This stopped the code from replacing the directories with symlinks returned by the readdir call. Changes were recently made to thed_invalidate()command so that it no longer returns an error code. This results in the directory with the mounted dfs share being replaced by a symlink which denotes a dfs share.Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/readdir.c | 2 ++ 1 file changed, 2 insertions(+)fs/cifs/readdir.c +0
-0fs/cifs/readdir.c cifs_prime_dcache(struct dentry *parent, struct qstr *name, · line 97
Quoted 8 lines
fs/cifs/readdir.c +2
-0@@ -90,6 +90,8 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,if (dentry) { inode = dentry->d_inode;if (inode) { +if (d_mountpoint (dentry)) + goto out;/* * If we're generating inode numbers, then we don't * want to clobber the existing one with the one that Looks right.
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Sachin Prabhu
Quoted 2 lines · Steve French
Looks reasonable but fails on SMB3 - we need to fix lines 133 and 134 of
smb2pdu.cas wellHello Steve,
I am not sure I understand how these lines are involved. The patch fixes behaviour for readdir where the lookup data doesn't contain any information indicating that the directory leads to a DFS lookup.
I already merged your patch and don't see a problem with those lines - but was just noting that I could only test it on cifs - we can't test it in the more important use cases (SMB2.1, SMB3) due to what I pointed out in the earlier note.
Signature · 3 lines
Thanks, Steve