From patchwork Sun Dec 15 23:20:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ruffell X-Patchwork-Id: 1210033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47bgPY4HHTz9sPn; Mon, 16 Dec 2019 10:20:49 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1igdBt-0002C3-QG; Sun, 15 Dec 2019 23:20:45 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1igdBs-0002BG-AA for kernel-team@lists.ubuntu.com; Sun, 15 Dec 2019 23:20:44 +0000 Received: from mail-pl1-f199.google.com ([209.85.214.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1igdBr-0001mA-R2 for kernel-team@lists.ubuntu.com; Sun, 15 Dec 2019 23:20:44 +0000 Received: by mail-pl1-f199.google.com with SMTP id t3so4561823plz.3 for ; Sun, 15 Dec 2019 15:20:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cSNrvGMxjipbYKtt34bKD6GI0+aSw8MHkDHszyE3+zc=; b=oQjsAKGwSGGb0Z9LXa/n31MQZji8dBvobx+6PqrIsr9+Cs+peqQMMsAJpEL5s4eQbX tffd9FLh35S3bHlH9iZO10UBTnFEqyRsaDMgEbfK3xnL0M7OCcX1P4T/d/F67Lx+JYiG a8/9LaHN2nVSVyVsQmfb0LJfyqbdYtpShknYIzTZh9dTbG62BJ3ZNswm9sLF2tnpasri VJVOHAn7ndw7GS4zHzXzfP0MSMBSe1XO6YS9TLYQUptxdQg+ypy5tqxhypazvSTlarE/ MqWdPCSpL+9E+wfN8vFA00PMuHz8O0M7lC7DCwHX2xfcxs0Vl5Yl+72YtF6H10877HbL cYVg== X-Gm-Message-State: APjAAAWEj8T9kYwVFofMNfoHo55T1NudGRwLOh4l5P9/yh6z9o5J6sBx lxjA05lt1HmyLZAWcPHGqHMPzE2o1UeFt8SLwoBo973KGp1xKlMU6Qf0BWzaFPU+WJ5FnClgULZ +O6QkoE/BWbbnH9FNo4H1eqcYq5Vy7RzBV8EvxBL9BQ== X-Received: by 2002:a17:90a:218c:: with SMTP id q12mr15111269pjc.0.1576452042302; Sun, 15 Dec 2019 15:20:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxLDKDrGMIguTvWKFgpSnuihh2Hpi5UfCpcIGrHsucPVU1wdRVrt7ea3j1AidvYtDICVZa0Fw== X-Received: by 2002:a17:90a:218c:: with SMTP id q12mr15111249pjc.0.1576452041984; Sun, 15 Dec 2019 15:20:41 -0800 (PST) Received: from localhost.localdomain (222-154-99-146-fibre.sparkbb.co.nz. [222.154.99.146]) by smtp.gmail.com with ESMTPSA id 11sm6572327pfz.25.2019.12.15.15.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Dec 2019 15:20:41 -0800 (PST) From: Matthew Ruffell To: kernel-team@lists.ubuntu.com Subject: [SRU][D][E][F][PATCH 1/1] cifs: Fix retrieval of DFS referrals in cifs_mount() Date: Mon, 16 Dec 2019 12:20:33 +1300 Message-Id: <20191215232033.12353-2-matthew.ruffell@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191215232033.12353-1-matthew.ruffell@canonical.com> References: <20191215232033.12353-1-matthew.ruffell@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "Paulo Alcantara (SUSE)" BugLink: https://bugs.launchpad.net/bugs/1854887 Make sure that DFS referrals are sent to newly resolved root targets as in a multi tier DFS setup. Signed-off-by: Paulo Alcantara (SUSE) Link: https://lkml.kernel.org/r/05aa2995-e85e-0ff4-d003-5bb08bd17a22@canonical.com Cc: stable@vger.kernel.org Tested-by: Matthew Ruffell Signed-off-by: Steve French (cherry picked from commit 5bb30a4dd60e2a10a4de9932daff23e503f1dd2b) Signed-off-by: Matthew Ruffell --- fs/cifs/connect.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index c4b457f2e4f8..122ffabb81ab 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -4588,6 +4588,17 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol, } #ifdef CONFIG_CIFS_DFS_UPCALL +static inline void set_root_tcon(struct cifs_sb_info *cifs_sb, + struct cifs_tcon *tcon, + struct cifs_tcon **root) +{ + spin_lock(&cifs_tcp_ses_lock); + tcon->tc_count++; + tcon->remap = cifs_remap(cifs_sb); + spin_unlock(&cifs_tcp_ses_lock); + *root = tcon; +} + int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol) { int rc = 0; @@ -4681,18 +4692,10 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol) /* Cache out resolved root server */ (void)dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb), root_path + 1, NULL, NULL); - /* - * Save root tcon for additional DFS requests to update or create a new - * DFS cache entry, or even perform DFS failover. - */ - spin_lock(&cifs_tcp_ses_lock); - tcon->tc_count++; - tcon->dfs_path = root_path; + kfree(root_path); root_path = NULL; - tcon->remap = cifs_remap(cifs_sb); - spin_unlock(&cifs_tcp_ses_lock); - root_tcon = tcon; + set_root_tcon(cifs_sb, tcon, &root_tcon); for (count = 1; ;) { if (!rc && tcon) { @@ -4729,6 +4732,15 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol) mount_put_conns(cifs_sb, xid, server, ses, tcon); rc = mount_get_conns(vol, cifs_sb, &xid, &server, &ses, &tcon); + /* + * Ensure that DFS referrals go through new root server. + */ + if (!rc && tcon && + (tcon->share_flags & (SHI1005_FLAGS_DFS | + SHI1005_FLAGS_DFS_ROOT))) { + cifs_put_tcon(root_tcon); + set_root_tcon(cifs_sb, tcon, &root_tcon); + } } if (rc) { if (rc == -EACCES || rc == -EOPNOTSUPP)