From patchwork Thu May 27 14:49:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1484686 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=) 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 4FrW1M4gCBz9sTD; Fri, 28 May 2021 00:49:27 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lmHK8-0005ex-Ro; Thu, 27 May 2021 14:49:24 +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 1lmHK5-0005dm-M7 for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:49:21 +0000 Received: from mail-pj1-f71.google.com ([209.85.216.71]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lmHK5-0004UB-EO for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:49:21 +0000 Received: by mail-pj1-f71.google.com with SMTP id a11-20020a17090a70cbb029015d3e996884so2736244pjm.4 for ; Thu, 27 May 2021 07:49:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vOrnr2gXWixDQhJLNxDAxbBegeYlY4lAIzvNY2xCtZY=; b=cdtshh1a9+ATLQ7Ur0lAbl/vB4+0WNz4aKfqvMdSxY7jnKlXlt6s6Q+c6QZumha4Gg pNsV5dYvM0eldy7coEGeqijrSUGvsA47IP3RbGEyEuItF9mGTvQfptVLDfmbUb1uKcWM 85klTNV7QE27BIvesGuz8Ig/NEYqnvFcFUrIakftnp6Gm0FYvTVQvOPf0YhOjaIxV/2b x5cJVJZQJK1kRVOA8hVOxTw3SIcUV1StOUzrVdZOYQtLtLooH3di/toVcQxbTYsNHRCV VingpaSsKKqIvjKW4Zo9d7/Wd0ZUTjihkVIxTHWFbx1qKyrgX6XPoC9/1YJB04MMGoWH 8s3w== X-Gm-Message-State: AOAM533XElU8p6bVjVpqOGqALota/v1CNaWBd/LcjN8KvSh8x63sqR1W ISX2CTdX+7WaYV1FRDnme79v4G1XLVhxnL9EN4NAN/YcFoWmt7+ATIA351KRF3kaQB9G1Vn/8Wh klM75ceGC16Fp58FVwSqCnYlNbzirlFTzn8EV/ycpkA== X-Received: by 2002:a63:ee12:: with SMTP id e18mr4092345pgi.73.1622126959885; Thu, 27 May 2021 07:49:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPwYLOfd2v19ARd7iTd2CrbEVFBKabLphOCGa22/83J5BKv8G/0na/2j/Sv9Vv+Z/a717QXQ== X-Received: by 2002:a63:ee12:: with SMTP id e18mr4092328pgi.73.1622126959697; Thu, 27 May 2021 07:49:19 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id x1sm2058074pjk.37.2021.05.27.07.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 07:49:19 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/4] cifs: rename reconn_inval_dfs_target() Date: Thu, 27 May 2021 08:49:12 -0600 Message-Id: <20210527144915.17079-2-tim.gardner@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210527144915.17079-1-tim.gardner@canonical.com> References: <20210527144915.17079-1-tim.gardner@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Paulo Alcantara BugLink: https://bugs.launchpad.net/bugs/1929831 This function has nothing to do with *invalidation* but setting up the next target server from a cached referral. Rename it to reconn_set_next_dfs_target(). While at it, get rid of some meaningless checks. Signed-off-by: Paulo Alcantara (SUSE) Reviewed-by: Aurelien Aptel Signed-off-by: Steve French (backported from commit 7d397a034d5c45528c7bdf7fc3752c4793029cce) [rtg minor context adjustmnent] Signed-off-by: Tim Gardner --- fs/cifs/connect.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index ab9eeb5ff8e57..1746aadf85ef4 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -435,15 +435,14 @@ static inline void put_tcp_super(struct super_block *sb) cifs_sb_deactive(sb); } -static void reconn_inval_dfs_target(struct TCP_Server_Info *server, - struct cifs_sb_info *cifs_sb, - struct dfs_cache_tgt_list *tgt_list, - struct dfs_cache_tgt_iterator **tgt_it) +static void reconn_set_next_dfs_target(struct TCP_Server_Info *server, + struct cifs_sb_info *cifs_sb, + struct dfs_cache_tgt_list *tgt_list, + struct dfs_cache_tgt_iterator **tgt_it) { const char *name; - if (!cifs_sb || !cifs_sb->origin_fullpath || !tgt_list || - !server->nr_targets) + if (!cifs_sb || !cifs_sb->origin_fullpath) return; if (!*tgt_it) { @@ -620,7 +619,7 @@ cifs_reconnect(struct TCP_Server_Info *server) * feature is disabled, then we will retry last server we * connected to before. */ - reconn_inval_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); + reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); #endif rc = reconn_set_ipaddr(server); if (rc) { From patchwork Thu May 27 14:49:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1484687 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=) 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 4FrW1Q1Bh6z9sTD; Fri, 28 May 2021 00:49:30 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lmHKB-0005g8-4G; Thu, 27 May 2021 14:49:27 +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 1lmHK6-0005eO-Pk for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:49:22 +0000 Received: from mail-pl1-f198.google.com ([209.85.214.198]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lmHK6-0004UP-Hp for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:49:22 +0000 Received: by mail-pl1-f198.google.com with SMTP id t2-20020a170902b202b02900ec9b8c34b6so68299plr.15 for ; Thu, 27 May 2021 07:49:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5Pme5tf1/zTbEJiFKXrFBqpgYSIetKwi/6QIeERlAXQ=; b=sS7yfURlc6sTcveRhbgfl6mJKhvJvGWYxaadnf6XpRVZMyJCVOaYp5JwOco3j0ueaw 0utUJBrPaIKMzMNrVIvtyQFFl/HtSAATqTa+6lYqYGK01YrzZRMI0LGP8341rMjNpGBM /JmCk8YIcWqBZ/riKsMoMt5PZCPkL1kNiuo6KD8OIBIyYrSPbZ2ZniZ8gS70BLANlDMP DwKFGRe4CNv6bMbugWqaNABnp/lFI9ccqj4x6v1GnO4AjFZciatVXYFNa1389QZRp19y TiHx6yDFEOwgZA7LXuvAkqaQcDfJ+cAvEu2+R+fBlqgWBmj5Y1rWDA1o2B94SGnV9r30 FmRw== X-Gm-Message-State: AOAM530wQgh/saoej/QgcnpxkflsG7rOdob+b6KZ8dFeQhtvNVRPClIo hrmNh6Lqr3UzacxF8akyxWvLgqZ3f3A/RAAFZxUMwpi7S0osr+klsInjoYo3ipKb8WqBbZ4c97M iFIrSc7FpJm863f6grc77lwgtov5GBcZZz7UJeLu1QQ== X-Received: by 2002:a17:902:8505:b029:ec:b451:71cd with SMTP id bj5-20020a1709028505b02900ecb45171cdmr3667464plb.23.1622126960871; Thu, 27 May 2021 07:49:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf50wlSVHkB3d0n0fXsHTqD9zUuaDdTlL1ZsJ/KCvRvc+jOzcsGRm0ZVzsO8xh+QLoCCPI9Q== X-Received: by 2002:a17:902:8505:b029:ec:b451:71cd with SMTP id bj5-20020a1709028505b02900ecb45171cdmr3667449plb.23.1622126960648; Thu, 27 May 2021 07:49:20 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id x1sm2058074pjk.37.2021.05.27.07.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 07:49:20 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/4] cifs: Simplify reconnect code when dfs upcall is enabled Date: Thu, 27 May 2021 08:49:13 -0600 Message-Id: <20210527144915.17079-3-tim.gardner@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210527144915.17079-1-tim.gardner@canonical.com> References: <20210527144915.17079-1-tim.gardner@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Samuel Cabrero BugLink: https://bugs.launchpad.net/bugs/1929831 Some witness notifications, like client move, tell the client to reconnect to a specific IP address. In this situation the DFS failover code path has to be skipped so clean up as much as possible the cifs_reconnect() code. Signed-off-by: Samuel Cabrero Reviewed-by: Aurelien Aptel Signed-off-by: Steve French (backported from commit 7d6535b720421d58886d5590ffc3617d359aa871) [rtg - minor context adjustment] Signed-off-by: Tim Gardner --- fs/cifs/connect.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 1746aadf85ef4..e096751a73873 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -344,7 +344,7 @@ static char *extract_hostname(const char *unc); * This should be called with server->srv_mutex held. */ #ifdef CONFIG_CIFS_DFS_UPCALL -static int reconn_set_ipaddr(struct TCP_Server_Info *server) +static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) { int rc; int len; @@ -379,12 +379,6 @@ static int reconn_set_ipaddr(struct TCP_Server_Info *server) return !rc ? -1 : 0; } -#else -static inline int reconn_set_ipaddr(struct TCP_Server_Info *server) -{ - return 0; -} -#endif #ifdef CONFIG_CIFS_DFS_UPCALL struct super_cb_data { @@ -441,6 +435,7 @@ static void reconn_set_next_dfs_target(struct TCP_Server_Info *server, struct dfs_cache_tgt_iterator **tgt_it) { const char *name; + int rc; if (!cifs_sb || !cifs_sb->origin_fullpath) return; @@ -465,6 +460,12 @@ static void reconn_set_next_dfs_target(struct TCP_Server_Info *server, "%s: failed to extract hostname from target: %ld\n", __func__, PTR_ERR(server->hostname)); } + + rc = reconn_set_ipaddr_from_hostname(server); + if (rc) { + cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n", + __func__, rc); + } } static inline int reconn_setup_dfs_targets(struct cifs_sb_info *cifs_sb, @@ -621,11 +622,6 @@ cifs_reconnect(struct TCP_Server_Info *server) */ reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); #endif - rc = reconn_set_ipaddr(server); - if (rc) { - cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n", - __func__, rc); - } if (cifs_rdma_enabled(server)) rc = smbd_reconnect(server); From patchwork Thu May 27 14:49:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1484688 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=) 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 4FrW1S2gLnz9sWD; Fri, 28 May 2021 00:49:32 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lmHKC-0005hj-Kn; Thu, 27 May 2021 14:49:28 +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 1lmHK7-0005ei-Uj for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:49:23 +0000 Received: from mail-pf1-f200.google.com ([209.85.210.200]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lmHK7-0004UW-Ex for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:49:23 +0000 Received: by mail-pf1-f200.google.com with SMTP id l199-20020a6288d00000b02902db317806d5so566399pfd.18 for ; Thu, 27 May 2021 07:49:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CauJndK54q8jq2eH2CUXEiq/GbAnR0gE739VYKyD4KA=; b=YfCttLsIGuyK5TTk/cMMQ6Rg2FJZ4v80szqpapY8fijUAX/cXYzEkZfRnrqCVwyQog /uqSRTp/q2zfebZ0rpf3iRIUzMGzKYFZV1heI4G9DEioIRE7UK2WbKmaMrqL18/Q+P8z AK48/sg8fDJPuN9WxHWpxVkPD1fTG/+iAGCAuz0lzHeWkey+pqrX2WZ8Cnm33nGAdNHX Q7SkToib/8lKS4Y5cQLzob+89BKPQcNrdOMW6G8daeWq0nN8OJ7zenHMSNpXl4hg3mHV lw6Fm5tJgrGgj21mhKeJwmVRXclEHf/sNNh8SQ09CjwkcmkTf8o0pNyHRpXaCAAf3S41 SWhw== X-Gm-Message-State: AOAM531Vfi9XnKFAHrqnnXEWlTK/AG5z2hJs1oEAkfKU2Q1zpa4ZQilO E9WUF+R7HikhPR+bkBxlWIe87HWdMWS8fsKVzwC0RJuzErWopAWsjMLf5HLuFToVqDqdqlBmYSE Y7GwuYKXXMGp+heQASwVFrOaH5M5Edc24g6Sf20h5kA== X-Received: by 2002:aa7:98c5:0:b029:2e9:4382:fa03 with SMTP id e5-20020aa798c50000b02902e94382fa03mr2522211pfm.38.1622126961885; Thu, 27 May 2021 07:49:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzduFxHAELDKeIr0PcOoNxyI+HxU8uMbaTwo6DcFPfcEiH60Exj6FCzGCbV3/Pmpk8y5ZW6zw== X-Received: by 2002:aa7:98c5:0:b029:2e9:4382:fa03 with SMTP id e5-20020aa798c50000b02902e94382fa03mr2522193pfm.38.1622126961654; Thu, 27 May 2021 07:49:21 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id x1sm2058074pjk.37.2021.05.27.07.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 07:49:21 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/4] cifs: Avoid error pointer dereference Date: Thu, 27 May 2021 08:49:14 -0600 Message-Id: <20210527144915.17079-4-tim.gardner@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210527144915.17079-1-tim.gardner@canonical.com> References: <20210527144915.17079-1-tim.gardner@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Samuel Cabrero BugLink: https://bugs.launchpad.net/bugs/1929831 The patch 7d6535b72042: "cifs: Simplify reconnect code when dfs upcall is enabled" leads to the following static checker warning: fs/cifs/connect.c:160 reconn_set_next_dfs_target() error: 'server->hostname' dereferencing possible ERR_PTR() Avoid dereferencing the error pointer by early returning on error condition. Reported-by: Dan Carpenter Signed-off-by: Samuel Cabrero Signed-off-by: Steve French (cherry picked from commit 0bf1bafb17df03fbd0e8b9a086c39e6f24af7193) Signed-off-by: Tim Gardner --- fs/cifs/connect.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e096751a73873..505c88221b28f 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -459,6 +459,7 @@ static void reconn_set_next_dfs_target(struct TCP_Server_Info *server, cifs_dbg(FYI, "%s: failed to extract hostname from target: %ld\n", __func__, PTR_ERR(server->hostname)); + return; } rc = reconn_set_ipaddr_from_hostname(server); From patchwork Thu May 27 14:49:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1484689 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=) 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 4FrW1T6fKVz9sWQ; Fri, 28 May 2021 00:49:33 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1lmHKD-0005iI-71; Thu, 27 May 2021 14:49:29 +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 1lmHK9-0005fI-Aq for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:49:25 +0000 Received: from mail-pj1-f69.google.com ([209.85.216.69]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lmHK8-0004Uy-VR for kernel-team@lists.ubuntu.com; Thu, 27 May 2021 14:49:25 +0000 Received: by mail-pj1-f69.google.com with SMTP id l2-20020a17090a0702b02901603ba65800so1213036pjl.6 for ; Thu, 27 May 2021 07:49:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WzlIVubQWms82CCw3kkL8FJq//D0IDrsJH8mptgg16Y=; b=NF3jL+URUD4Nb25TC4gHg2KAohLd7Au6dMB2gqFzmJYm4DUcfpU/joDZHFF/ivzXWE YhPfaYqV+d5K9Q0vrYURpfSWrvZ8snoQlZztd3UgCAoJH5tCHM2AxtdphbJo7Cetv+Uv Tr9WgzDw8SFIrySTE86rRo4PyIcUKvQ3th9unN9bDmzxXVMGiQ5ppuJntBReGgCoj3ke XPyAzcHODeQXWIQgPg9wQlx2m5c3j6IZontR10NaX2f7ZLekt8eGhfV/FGsSfea4/UgE JjaJShuqEYVfBea+eTmk+8Tqr3LowtFQpR92u29OI/VGWS41tFcOqfoEzN+gerEuttQy b1Sg== X-Gm-Message-State: AOAM533ZF9g3AavkaUS6Z9Wp3kN3GHVqvpkD8Tasqocmzt2Ik/PXpdL4 qHLLiifZjyc+I1z1nvqQFWHCF8tRK2adepZv/n37YwUq5NgfoncmtfykucDaSFkGHwWHIxivygB VF/InmNv5dYomtDrFvq2VcpgaVpuX3Wcon1OL7mGdUg== X-Received: by 2002:a62:bd19:0:b029:2db:9bd7:edf0 with SMTP id a25-20020a62bd190000b02902db9bd7edf0mr4076434pff.40.1622126963045; Thu, 27 May 2021 07:49:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeAuQiSDuTZD68pvoqpnoXdbGFzkhi9s7wrV4JDm6comCDoDMqGPJLc9/Jbdf0F7Bj/gEvzQ== X-Received: by 2002:a62:bd19:0:b029:2db:9bd7:edf0 with SMTP id a25-20020a62bd190000b02902db9bd7edf0mr4076417pff.40.1622126962816; Thu, 27 May 2021 07:49:22 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id x1sm2058074pjk.37.2021.05.27.07.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 07:49:22 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/4] cifs: On cifs_reconnect, resolve the hostname again. Date: Thu, 27 May 2021 08:49:15 -0600 Message-Id: <20210527144915.17079-5-tim.gardner@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210527144915.17079-1-tim.gardner@canonical.com> References: <20210527144915.17079-1-tim.gardner@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shyam Prasad N BugLink: https://bugs.launchpad.net/bugs/1929831 On cifs_reconnect, make sure that DNS resolution happens again. It could be the cause of connection to go dead in the first place. This also contains the fix for a build issue identified by Intel bot. Reported-by: kernel test robot Signed-off-by: Shyam Prasad N Reviewed-by: Paulo Alcantara (SUSE) Reviewed-by: Pavel Shilovsky CC: # 5.11+ Signed-off-by: Steve French (backported from commit 4e456b30f78c429b183db420e23b26cde7e03a78) [rtg - context adjustment] Signed-off-by: Tim Gardner --- fs/cifs/Kconfig | 3 +-- fs/cifs/Makefile | 5 +++-- fs/cifs/connect.c | 27 ++++++++++++++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/fs/cifs/Kconfig b/fs/cifs/Kconfig index 22cf04fb32d35..16e2d2ef96bb0 100644 --- a/fs/cifs/Kconfig +++ b/fs/cifs/Kconfig @@ -18,6 +18,7 @@ config CIFS select CRYPTO_AES select CRYPTO_LIB_DES select KEYS + select DNS_RESOLVER help This is the client VFS module for the SMB3 family of NAS protocols, (including support for the most recent, most secure dialect SMB3.1.1) @@ -112,7 +113,6 @@ config CIFS_WEAK_PW_HASH config CIFS_UPCALL bool "Kerberos/SPNEGO advanced session setup" depends on CIFS - select DNS_RESOLVER help Enables an upcall mechanism for CIFS which accesses userspace helper utilities to provide SPNEGO packaged (RFC 4178) Kerberos tickets @@ -179,7 +179,6 @@ config CIFS_DEBUG_DUMP_KEYS config CIFS_DFS_UPCALL bool "DFS feature support" depends on CIFS - select DNS_RESOLVER help Distributed File System (DFS) support is used to access shares transparently in an enterprise name space, even if the share diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile index 51bae9340842f..523fc419af8ad 100644 --- a/fs/cifs/Makefile +++ b/fs/cifs/Makefile @@ -10,13 +10,14 @@ cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \ cifs_unicode.o nterr.o cifsencrypt.o \ readdir.o ioctl.o sess.o export.o smb1ops.o winucase.o \ smb2ops.o smb2maperror.o smb2transport.o \ - smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o + smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o \ + dns_resolve.o cifs-$(CONFIG_CIFS_XATTR) += xattr.o cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o -cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o dfs_cache.o +cifs-$(CONFIG_CIFS_DFS_UPCALL) += cifs_dfs_ref.o dfs_cache.o cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 505c88221b28f..50e3f069847fb 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -343,7 +343,6 @@ static char *extract_hostname(const char *unc); * * This should be called with server->srv_mutex held. */ -#ifdef CONFIG_CIFS_DFS_UPCALL static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server) { int rc; @@ -616,12 +615,26 @@ cifs_reconnect(struct TCP_Server_Info *server) mutex_lock(&server->srv_mutex); #ifdef CONFIG_CIFS_DFS_UPCALL - /* - * Set up next DFS target server (if any) for reconnect. If DFS - * feature is disabled, then we will retry last server we - * connected to before. - */ - reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); + if (cifs_sb && cifs_sb->origin_fullpath) + /* + * Set up next DFS target server (if any) for reconnect. If DFS + * feature is disabled, then we will retry last server we + * connected to before. + */ + reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it); + else { +#endif + /* + * Resolve the hostname again to make sure that IP address is up-to-date. + */ + rc = reconn_set_ipaddr_from_hostname(server); + if (rc) { + cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n", + __func__, rc); + } + +#ifdef CONFIG_CIFS_DFS_UPCALL + } #endif if (cifs_rdma_enabled(server))