From patchwork Tue Feb 3 10:22:30 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 5211 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 n13AN4Rs030688 for ; Tue, 3 Feb 2009 10:23:04 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 11A22163C41 for ; Tue, 3 Feb 2009 10:22:52 +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.159]) by lists.samba.org (Postfix) with ESMTP id BDFF8163B99 for ; Tue, 3 Feb 2009 10:22:21 +0000 (GMT) Received: by fg-out-1718.google.com with SMTP id 13so805476fge.20 for ; Tue, 03 Feb 2009 02:22:33 -0800 (PST) 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:cc:subject:references:in-reply-to :content-type; bh=N5B9H235biMZHPOEj0tus5TaJpl/ZD+XjZ7r+zBo0HY=; b=CzLesedfmqKXGnWHwNUM6/I4U1QeNM5vEoIZ5rbqeAJU8nDEfrNea36Tl43AsGo013 aqAMZXqzbEgtQSqnMqUVcY9XkVtf0SSIFuNYFU9qqDP3fu0SyyVa3RgN5ObnemlXmw05 HO5cIbi6Vx9CPtj6ojHkTCjlQ9OfP9gfmb3jA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=mZaGke5oQ1XsBFuESdAdY9A2q4HGD6jB1EF+kDTrjP4HLUX7l0FHI8qvybOOeejNe0 HFasPtZqWpZWi80UldS86OUfV6Kyg2KxnWjKDb6ThBFx/eIgY8XI9OO2vkmbg+X7C8T9 sp0knQdF0UrH/BY83hRYioZXtIzwrhyBtXq9I= Received: by 10.86.95.20 with SMTP id s20mr332447fgb.40.1233656553164; Tue, 03 Feb 2009 02:22:33 -0800 (PST) Received: from l102796.int.cboss.ru ([195.245.232.177]) by mx.google.com with ESMTPS id e11sm4548885fga.10.2009.02.03.02.22.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 03 Feb 2009 02:22:32 -0800 (PST) Message-ID: <49881AE6.4030109@gmail.com> Date: Tue, 03 Feb 2009 13:22:30 +0300 From: Igor Mammedov User-Agent: Thunderbird 2.0.0.19 (X11/20081209) MIME-Version: 1.0 To: Steve French References: <9F990792DAA5FF4F96FD0B95C9C44C0BB4F03DCC@ICTS-S-EXC1-CA.luna.kuleuven.be> <4a4634330901301022na22fee2x544c4b39449819a1@mail.gmail.com> <4986C6BC.2000903@gmail.com> <4a4634330902021156y71e61533j7a255aac3fa12ae8@mail.gmail.com> In-Reply-To: <4a4634330902021156y71e61533j7a255aac3fa12ae8@mail.gmail.com> Cc: "linux-cifs-client@lists.samba.org" Subject: [linux-cifs-client] [PATCH] [CIFS] Prevent OOPs when mounting with remote prefixpath 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 Managed to single out the part of DFS root support from a big patch with a little modification. It will report error and fail to mount if perfixpath is on remote server. As well it will not scare people off with a error 'kernel BUG at fs/cifs/cifs_dfs_ref.c:274!'. --------- Fixes OOPs with message 'kernel BUG at fs/cifs/cifs_dfs_ref.c:274!'. Check if prefixpath in accessible while we are still in cifs_mount and fail with reporting a error if we can't access prefixpath (i.e. if prefixpath is located on another server) Best regards, ------------------------- Igor Mammedov, niallain "at" gmail.com >From c61a715cbeee404a1bcc2788090b4d453eb43b8e Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 3 Feb 2009 12:43:56 +0300 Subject: [PATCH] [CIFS] Prevent OOPs when mounting with remote prefixpath. Fix OOPs with message 'kernel BUG at fs/cifs/cifs_dfs_ref.c:274!'. Check if prefixpath in accesible while we are still in cifs_mount and fail with reporting a error if we can't access prefixpath (i.e. if prefixpath is located on another server) Signed-off-by: Igor Mammedov --- fs/cifs/cifsproto.h | 1 + fs/cifs/connect.c | 30 ++++++++++++++++++++++++++++++ fs/cifs/inode.c | 2 +- 3 files changed, 32 insertions(+), 1 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 382ba62..22ff09c 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -42,6 +42,7 @@ extern void _FreeXid(unsigned int); #define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current_fsuid())); #define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__func__,curr_xid,(int)rc));} extern char *build_path_from_dentry(struct dentry *); +extern char *build_path_to_root(struct cifs_sb_info *cifs_sb); extern char *build_wildcard_path_from_dentry(struct dentry *direntry); /* extern void renew_parental_timestamps(struct dentry *direntry);*/ extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *, diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 2209be9..dcffaa9 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2181,6 +2181,24 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info, } int +is_path_accessible(int xid, struct cifsTconInfo *tcon, + struct cifs_sb_info *cifs_sb, const char *full_path) +{ + int rc; + FILE_ALL_INFO *pfindData; + pfindData = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); + if (pfindData == NULL) + return -ENOMEM; + + rc = CIFSSMBQPathInfo(xid, tcon, full_path, pfindData, + 0 /* not legacy */, + cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & + CIFS_MOUNT_MAP_SPECIAL_CHR); + kfree(pfindData); + return rc; +} + +int cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, char *mount_data, const char *devname) { @@ -2190,6 +2208,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, struct cifsSesInfo *pSesInfo = NULL; struct cifsTconInfo *tcon = NULL; struct TCP_Server_Info *srvTcp = NULL; + char *full_path; xid = GetXid(); @@ -2426,6 +2445,17 @@ mount_fail_check: cifs_sb->rsize = min(cifs_sb->rsize, (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)); + + full_path = build_path_to_root(cifs_sb); + if (full_path != NULL) { + rc = is_path_accessible(xid, tcon, cifs_sb, full_path); + kfree(full_path); + if (rc) { + cERROR(1, ("Remote DFS root not supported")); + goto mount_fail_check; + } + } + /* volume_info->password is freed above when existing session found (in which case it is not needed anymore) but when new sesion is created the password ptr is put in the new session structure (in which case the diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index bcf7b51..00c6a3f 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -621,7 +621,7 @@ static const struct inode_operations cifs_ipc_inode_ops = { .lookup = cifs_lookup, }; -static char *build_path_to_root(struct cifs_sb_info *cifs_sb) +char *build_path_to_root(struct cifs_sb_info *cifs_sb) { int pplen = cifs_sb->prepathlen; int dfsplen; -- 1.6.0.2