diff mbox

[linux-cifs-client,CIFS] Added loop check when mounting DFS tree.

Message ID 49EDE847.9000209@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Igor Mammedov April 21, 2009, 3:37 p.m. UTC
I'm sorry for delay,
a promised patch is attached.

Comments

Jeff Layton April 30, 2009, 3:10 p.m. UTC | #1
On Tue, 21 Apr 2009 19:37:43 +0400
Igor Mammedov <niallain@gmail.com> wrote:

> I'm sorry for delay,
> a promised patch is attached.
> 
> -- 
> 
> Best regards,
> 
> -------------------------
> Igor Mammedov,
> niallain "at" gmail.com
> 
> 
> 
> 

Acked-by: Jeff Layton <jlayton@redhat.com>
Steve French April 30, 2009, 5:30 p.m. UTC | #2
Both are now merged.  Thanks Igor for good work again.

commit 5c2503a8e339fbc82f49d5706c5a4ad650dd9711
Author: Igor Mammedov <niallain@gmail.com>
Date:   Tue Apr 21 19:31:05 2009 +0400

    Added loop check when mounting DFS tree.

    Added loop check when mounting DFS tree. mount will fail with
    ELOOP if referral walks exceed MAX_NESTED_LINK count.

    Signed-off-by: Igor Mammedov <niallain@gmail.com>
    Acked-by: Jeff Layton <jlayton@redhat.com>
    Signed-off-by: Steve French <sfrench@us.ibm.com>

commit 1af28ceb923d04357733642a3dbc4497da4db1c2
Author: Igor Mammedov <niallain@gmail.com>
Date:   Tue Mar 17 19:00:30 2009 +0300

    Enable dfs submounts to handle remote referrals.

    Having remote dfs root support in cifs_mount, we can
    afford to pass into it UNC that is remote.

    Signed-off-by: Igor Mammedov <niallain@gmail.com>
    Acked-by: Jeff Layton <jlayton@redhat.com>
    Signed-off-by: Steve French <sfrench@us.ibm.com>


On Thu, Apr 30, 2009 at 10:10 AM, Jeff Layton <jlayton@poochiereds.net> wrote:
> On Tue, 21 Apr 2009 19:37:43 +0400
> Igor Mammedov <niallain@gmail.com> wrote:
>
>> I'm sorry for delay,
>> a promised patch is attached.
>>
>> --
>>
>> Best regards,
>>
>> -------------------------
>> Igor Mammedov,
>> niallain "at" gmail.com
>>
>>
>>
>>
>
> Acked-by: Jeff Layton <jlayton@redhat.com>
>
diff mbox

Patch

>From c473c8f71ebcb1db11573545106d4f9b49fa7418 Mon Sep 17 00:00:00 2001
From: Igor Mammedov <niallain@gmail.com>
Date: Tue, 21 Apr 2009 19:31:05 +0400
Subject: [PATCH] [CIFS] Added loop check when mounting DFS tree.

Added loop check when mounting DFS tree. mount will fail with
ELOOP if referral walks exceed MAX_NESTED_LINK count.

Signed-off-by: Igor Mammedov <niallain@gmail.com>
---
 fs/cifs/connect.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index bacdef1..387f3f0 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -32,6 +32,7 @@ 
 #include <linux/kthread.h>
 #include <linux/pagevec.h>
 #include <linux/freezer.h>
+#include <linux/namei.h>
 #include <asm/uaccess.h>
 #include <asm/processor.h>
 #include <net/ipv6.h>
@@ -2278,6 +2279,7 @@  cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
 #ifdef CONFIG_CIFS_DFS_UPCALL
 	struct dfs_info3_param *referrals = NULL;
 	unsigned int num_referrals = 0;
+	int referral_walks_count = 0;
 try_mount_again:
 #endif
 	full_path = NULL;
@@ -2525,6 +2527,16 @@  remote_path_check:
 	/* get referral if needed */
 	if (rc == -EREMOTE) {
 #ifdef CONFIG_CIFS_DFS_UPCALL
+		if (referral_walks_count > MAX_NESTED_LINKS) {
+			/*
+			 * BB: when we implement proper loop detection,
+			 *     we will remove this check. But now we need it
+			 *     to prevent an indefinite loop if 'DFS tree' is
+			 *     misconfigured (i.e. has loops).
+			 */
+			rc = -ELOOP;
+			goto mount_fail_check;
+		}
 		/* convert forward to back slashes in prepath here if needed */
 		if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) == 0)
 			convert_delimiter(cifs_sb->prepath,
@@ -2558,6 +2570,7 @@  remote_path_check:
 			cleanup_volume_info(&volume_info);
 			FreeXid(xid);
 			kfree(full_path);
+			referral_walks_count++;
 			goto try_mount_again;
 		}
 #else /* No DFS support, return error on mount */
-- 
1.6.0.2