From patchwork Tue Apr 21 15:37:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 19210 Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3LFc8mp004815 for ; Tue, 21 Apr 2009 15:38:08 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id AAC0E163BE6 for ; Tue, 21 Apr 2009 15:37:46 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.8 tests=AWL,BAYES_00, DNS_FROM_RFC_POST,SPF_PASS autolearn=no version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.153]) by lists.samba.org (Postfix) with ESMTP id 950F6163B99 for ; Tue, 21 Apr 2009 15:37:26 +0000 (GMT) Received: by fg-out-1718.google.com with SMTP id e12so438861fga.20 for ; Tue, 21 Apr 2009 08:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=F2k8J97kl5CBP3XQcddqUBzIQhoGwF1gDkw92fUMVWQ=; b=s9eJRdr2m+gvowlH22EnpJMjsWX6U2+3DlrFUuJtduyKSvhfZYOwPIDH9cL/H/sY4V qlhjv3s8Ek8LR7lmq6hNxTXkh4u5Ecmu2L9slWs5vNhk3w3let2wis6NLHJ8Ln15+mih qUX9KNBKOYrqlE3tf0DWgu/SDYzDXlgYosOXQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=Jqy2mmYMUS9vO2AI+bv+Y3pCzuM1whwgr9oA3Igvu4gzZZxiWYjWJCQUOqZ8zPS3GN K0gx1CR4fCxz6ogkQwJAP0xBOYlfv8G5XfjcOiAA5KsZ+VZML2czVuzV8Y3GFDihvzTb NHclYZW2I0cXQArZMar/3b8ugaMUQBS6idagQ= Received: by 10.86.36.17 with SMTP id j17mr4668399fgj.38.1240328266201; Tue, 21 Apr 2009 08:37:46 -0700 (PDT) Received: from l102796.int.cboss.ru ([195.245.232.177]) by mx.google.com with ESMTPS id 12sm5558798fgg.7.2009.04.21.08.37.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 21 Apr 2009 08:37:45 -0700 (PDT) Message-ID: <49EDE847.9000209@gmail.com> Date: Tue, 21 Apr 2009 19:37:43 +0400 From: Igor Mammedov User-Agent: Thunderbird 2.0.0.21 (X11/20090302) MIME-Version: 1.0 To: Steve French , "linux-cifs-client@lists.samba.org" Subject: [linux-cifs-client] [PATCH] [CIFS] Added loop check when mounting DFS tree. X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Errors-To: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org I'm sorry for delay, a promised patch is attached. Acked-by: Jeff Layton >From c473c8f71ebcb1db11573545106d4f9b49fa7418 Mon Sep 17 00:00:00 2001 From: Igor Mammedov 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 --- 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 #include #include +#include #include #include #include @@ -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