From patchwork Mon Aug 1 12:32:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Aur=C3=A9lien_Aptel?= X-Patchwork-Id: 9254359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F8746075F for ; Mon, 1 Aug 2016 12:32:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FC54284A3 for ; Mon, 1 Aug 2016 12:32:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 746AC284A7; Mon, 1 Aug 2016 12:32:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE6AE284A3 for ; Mon, 1 Aug 2016 12:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753352AbcHAMcW (ORCPT ); Mon, 1 Aug 2016 08:32:22 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:47953 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752342AbcHAMcV (ORCPT ); Mon, 1 Aug 2016 08:32:21 -0400 Received: from nwb-ext-pat.microfocus.com ([10.120.13.103]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Mon, 01 Aug 2016 14:32:19 +0200 Received: from aaptelpc (nwb-a10-snat.microfocus.com [10.120.13.202]) by nwb-ext-pat.microfocus.com with ESMTP (TLS encrypted); Mon, 01 Aug 2016 13:32:09 +0100 Date: Mon, 1 Aug 2016 14:32:04 +0200 From: =?UTF-8?B?QXVyw6lsaWVu?= Aptel To: linux-cifs@vger.kernel.org Subject: Re: [PATCH] Add full_path_type arg to cifs_build_path_to_root() Message-ID: <20160801143204.7377b5a4@aaptelpc> In-Reply-To: <20160420181634.1a9ed866@aaptelpc> References: <20160420181634.1a9ed866@aaptelpc> Organization: SUSE X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.28; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 20 Apr 2016 18:16:34 +0200 Aurélien Aptel wrote: > There are 2 ways to fix this: > - never prefix an UNC path, even when using a DFS link i.e. remove all > code dealing with DFS from cifs_build_path_to_root) > - add a new arg to decide the behaviour of cifs_build_path_to_root(). We have 2 customers reporting a bug involving this problem internally at SUSE. I'm letting you know the first solution (patch attached) will be in the next update of SUSE (SLE) kernels. From df54ca09437a11438e1ec880c80c92e93ba98d71 Mon Sep 17 00:00:00 2001 From: Aurelien Aptel Date: Tue, 26 Apr 2016 17:59:06 +0200 Subject: [PATCH] fs/cifs: remove DFS handling from cifs_build_path_to_root() This function is called from: - cifs_mount() - cifs_get_root() The later expects a full path from the root, even in the presence of a DFS link. e.g. in the case of a DFS link like //A/shareA/link -> //B/shareB/sub/dir/ When doing a "cd link", cifs_get_root() was getting "//B/shareB//sub/dir" Instead of "/sub/dir" Resulting in sh: cd: link: No such file or directory Thanks to Josef Cejka for finding the bug&fix. Reported-by: Fons Jongh Signed-off-by: Aurelien Aptel --- fs/cifs/dir.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index fb0903f..05f7480 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -49,31 +49,16 @@ char * cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon) { - int pplen = vol->prepath ? strlen(vol->prepath) + 1 : 0; - int dfsplen; + int pplen = vol->prepath ? strlen(vol->prepath) : 0; char *full_path = NULL; - /* if no prefix path, simply set path to the root of share to "" */ - if (pplen == 0) { - full_path = kzalloc(1, GFP_KERNEL); - return full_path; - } - - if (tcon->Flags & SMB_SHARE_IS_IN_DFS) - dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1); - else - dfsplen = 0; - - full_path = kmalloc(dfsplen + pplen + 1, GFP_KERNEL); + full_path = kmalloc(pplen + 1, GFP_KERNEL); if (full_path == NULL) return full_path; - if (dfsplen) - strncpy(full_path, tcon->treeName, dfsplen); - full_path[dfsplen] = CIFS_DIR_SEP(cifs_sb); - strncpy(full_path + dfsplen + 1, vol->prepath, pplen); + strncpy(full_path, vol->prepath, pplen); convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb)); - full_path[dfsplen + pplen] = 0; /* add trailing null */ + full_path[pplen] = 0; /* add trailing null */ return full_path; } -- 2.1.4