cifs: change confusing field serverName (to ip_addr)
authorSteve French <stfrench@microsoft.com>
Sun, 21 Feb 2021 01:24:11 +0000 (19:24 -0600)
committerSteve French <stfrench@microsoft.com>
Tue, 23 Feb 2021 03:20:43 +0000 (21:20 -0600)
ses->serverName is not the server name, but the string form
of the ip address of the server.  Change the name to ip_addr
to avoid confusion (and fix the array length to match
maximum length of ipv6 address).

Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifs_debug.c
fs/cifs/cifsencrypt.c
fs/cifs/cifsglob.h
fs/cifs/connect.c
fs/cifs/file.c
fs/cifs/sess.c

index 370cc88a3d02e687c7618f8215883f6b7c88859a..1048180f4722618056a8cf652e7b2c940fba7534 100644 (file)
@@ -395,7 +395,7 @@ skip_rdma:
                                (ses->serverOS == NULL) ||
                                (ses->serverNOS == NULL)) {
                                seq_printf(m, "\n\t%d) Name: %s Uses: %d Capability: 0x%x\tSession Status: %d ",
-                                       i, ses->serverName, ses->ses_count,
+                                       i, ses->ip_addr, ses->ses_count,
                                        ses->capabilities, ses->status);
                                if (ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST)
                                        seq_printf(m, "Guest ");
@@ -406,7 +406,7 @@ skip_rdma:
                                    "\n\t%d) Name: %s  Domain: %s Uses: %d OS: %s "
                                    "\n\tNOS: %s\tCapability: 0x%x"
                                        "\n\tSMB session status: %d ",
-                               i, ses->serverName, ses->serverDomain,
+                               i, ses->ip_addr, ses->serverDomain,
                                ses->ses_count, ses->serverOS, ses->serverNOS,
                                ses->capabilities, ses->status);
                        }
index 51d53e4bdf6b18cfc96f5be75ad1287db2bfe9a6..b8f1ff9a83f3051b7431fa810adde093d2df1b16 100644 (file)
@@ -568,15 +568,15 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
                        return rc;
                }
        } else {
-               /* We use ses->serverName if no domain name available */
-               len = strlen(ses->serverName);
+               /* We use ses->ip_addr if no domain name available */
+               len = strlen(ses->ip_addr);
 
                server = kmalloc(2 + (len * 2), GFP_KERNEL);
                if (server == NULL) {
                        rc = -ENOMEM;
                        return rc;
                }
-               len = cifs_strtoUTF16((__le16 *)server, ses->serverName, len,
+               len = cifs_strtoUTF16((__le16 *)server, ses->ip_addr, len,
                                        nls_cp);
                rc =
                crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
index 0aa2c3c871c92911a2d4a85c6247cb2a49ce668f..fb904236f07f3f4f4eb43bb5c3d56bdd9289ee28 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/in.h>
 #include <linux/in6.h>
+#include <linux/inet.h>
 #include <linux/slab.h>
 #include <linux/mempool.h>
 #include <linux/workqueue.h>
@@ -902,7 +903,7 @@ struct cifs_ses {
        kuid_t linux_uid;       /* overriding owner of files on the mount */
        kuid_t cred_uid;        /* owner of credentials */
        unsigned int capabilities;
-       char serverName[SERVER_NAME_LEN_WITH_NULL];
+       char ip_addr[INET6_ADDRSTRLEN + 1]; /* Max ipv6 (or v4) addr string len */
        char *user_name;        /* must not be null except during init of sess
                                   and after mount option parsing we fill it */
        char *domainName;
index b3102a86fd8195e7afdd36ae895449b55af23f78..139e306305dfb73b3bd7610b6262b839085d4340 100644 (file)
@@ -1841,9 +1841,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
        /* new SMB session uses our server ref */
        ses->server = server;
        if (server->dstaddr.ss_family == AF_INET6)
-               sprintf(ses->serverName, "%pI6", &addr6->sin6_addr);
+               sprintf(ses->ip_addr, "%pI6", &addr6->sin6_addr);
        else
-               sprintf(ses->serverName, "%pI4", &addr->sin_addr);
+               sprintf(ses->ip_addr, "%pI4", &addr->sin_addr);
 
        if (ctx->username) {
                ses->user_name = kstrdup(ctx->username, GFP_KERNEL);
index 6d001905c8e51af170559f67b26609af5fb48afc..26de4329d16158363b054e38464a13b19cb4d6d0 100644 (file)
@@ -580,7 +580,7 @@ int cifs_open(struct inode *inode, struct file *file)
                } else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
                        if (tcon->ses->serverNOS)
                                cifs_dbg(VFS, "server %s of type %s returned unexpected error on SMB posix open, disabling posix open support. Check if server update available.\n",
-                                        tcon->ses->serverName,
+                                        tcon->ses->ip_addr,
                                         tcon->ses->serverNOS);
                        tcon->broken_posix_open = true;
                } else if ((rc != -EIO) && (rc != -EREMOTE) &&
index 213465718fa89d7005e01f05bd718157b9540af2..183a3a868d7b90946a9cc9f9b1a2fcac05ae3d45 100644 (file)
@@ -218,7 +218,7 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
 
        /* UNC and paths */
        /* XXX: Use ses->server->hostname? */
-       sprintf(unc, unc_fmt, ses->serverName);
+       sprintf(unc, unc_fmt, ses->ip_addr);
        ctx.UNC = unc;
        ctx.prepath = "";