Commit 49bd49f9 authored by Shyam Prasad N's avatar Shyam Prasad N Committed by Steve French
Browse files

cifs: send workstation name during ntlmssp session setup



During the ntlmssp session setup (authenticate phases)
send the client workstation info. This can make debugging easier on
servers.

Signed-off-by: default avatarShyam Prasad N <sprasad@microsoft.com>
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Reviewed-by: default avatarEnzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent c9f1c19c
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/mempool.h>
#include <linux/mempool.h>
#include <linux/workqueue.h>
#include <linux/workqueue.h>
#include <linux/utsname.h>
#include "cifs_fs_sb.h"
#include "cifs_fs_sb.h"
#include "cifsacl.h"
#include "cifsacl.h"
#include <crypto/internal/hash.h>
#include <crypto/internal/hash.h>
@@ -99,6 +100,8 @@
#define XATTR_DOS_ATTRIB "user.DOSATTRIB"
#define XATTR_DOS_ATTRIB "user.DOSATTRIB"
#endif
#endif


#define CIFS_MAX_WORKSTATION_LEN  (__NEW_UTS_LEN + 1)  /* reasonable max for client */

/*
/*
 * CIFS vfs client Status information (based on what we know.)
 * CIFS vfs client Status information (based on what we know.)
 */
 */
@@ -909,6 +912,7 @@ struct cifs_ses {
				   and after mount option parsing we fill it */
				   and after mount option parsing we fill it */
	char *domainName;
	char *domainName;
	char *password;
	char *password;
	char *workstation_name;
	struct session_key auth_key;
	struct session_key auth_key;
	struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */
	struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */
	enum securityEnum sectype; /* what security flavor was specified? */
	enum securityEnum sectype; /* what security flavor was specified? */
+6 −0
Original line number Original line Diff line number Diff line
@@ -1948,6 +1948,12 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
		if (!ses->domainName)
		if (!ses->domainName)
			goto get_ses_fail;
			goto get_ses_fail;
	}
	}
	if (ctx->workstation_name) {
		ses->workstation_name = kstrdup(ctx->workstation_name,
						GFP_KERNEL);
		if (!ses->workstation_name)
			goto get_ses_fail;
	}
	if (ctx->domainauto)
	if (ctx->domainauto)
		ses->domainAuto = ctx->domainauto;
		ses->domainAuto = ctx->domainauto;
	ses->cred_uid = ctx->cred_uid;
	ses->cred_uid = ctx->cred_uid;
+31 −3
Original line number Original line Diff line number Diff line
@@ -309,6 +309,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
	new_ctx->username = NULL;
	new_ctx->username = NULL;
	new_ctx->password = NULL;
	new_ctx->password = NULL;
	new_ctx->domainname = NULL;
	new_ctx->domainname = NULL;
	new_ctx->workstation_name = NULL;
	new_ctx->UNC = NULL;
	new_ctx->UNC = NULL;
	new_ctx->source = NULL;
	new_ctx->source = NULL;
	new_ctx->iocharset = NULL;
	new_ctx->iocharset = NULL;
@@ -323,6 +324,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
	DUP_CTX_STR(UNC);
	DUP_CTX_STR(UNC);
	DUP_CTX_STR(source);
	DUP_CTX_STR(source);
	DUP_CTX_STR(domainname);
	DUP_CTX_STR(domainname);
	DUP_CTX_STR(workstation_name);
	DUP_CTX_STR(nodename);
	DUP_CTX_STR(nodename);
	DUP_CTX_STR(iocharset);
	DUP_CTX_STR(iocharset);


@@ -720,6 +722,11 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,
		cifs_errorf(fc, "can not change domainname during remount\n");
		cifs_errorf(fc, "can not change domainname during remount\n");
		return -EINVAL;
		return -EINVAL;
	}
	}
	if (new_ctx->workstation_name &&
	    (!old_ctx->workstation_name || strcmp(new_ctx->workstation_name, old_ctx->workstation_name))) {
		cifs_errorf(fc, "can not change workstation_name during remount\n");
		return -EINVAL;
	}
	if (new_ctx->nodename &&
	if (new_ctx->nodename &&
	    (!old_ctx->nodename || strcmp(new_ctx->nodename, old_ctx->nodename))) {
	    (!old_ctx->nodename || strcmp(new_ctx->nodename, old_ctx->nodename))) {
		cifs_errorf(fc, "can not change nodename during remount\n");
		cifs_errorf(fc, "can not change nodename during remount\n");
@@ -753,7 +760,8 @@ static int smb3_reconfigure(struct fs_context *fc)
		return rc;
		return rc;


	/*
	/*
	 * We can not change UNC/username/password/domainname/nodename/iocharset
	 * We can not change UNC/username/password/domainname/
	 * workstation_name/nodename/iocharset
	 * during reconnect so ignore what we have in the new context and
	 * during reconnect so ignore what we have in the new context and
	 * just use what we already have in cifs_sb->ctx.
	 * just use what we already have in cifs_sb->ctx.
	 */
	 */
@@ -762,6 +770,7 @@ static int smb3_reconfigure(struct fs_context *fc)
	STEAL_STRING(cifs_sb, ctx, username);
	STEAL_STRING(cifs_sb, ctx, username);
	STEAL_STRING(cifs_sb, ctx, password);
	STEAL_STRING(cifs_sb, ctx, password);
	STEAL_STRING(cifs_sb, ctx, domainname);
	STEAL_STRING(cifs_sb, ctx, domainname);
	STEAL_STRING(cifs_sb, ctx, workstation_name);
	STEAL_STRING(cifs_sb, ctx, nodename);
	STEAL_STRING(cifs_sb, ctx, nodename);
	STEAL_STRING(cifs_sb, ctx, iocharset);
	STEAL_STRING(cifs_sb, ctx, iocharset);


@@ -1414,13 +1423,22 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,


int smb3_init_fs_context(struct fs_context *fc)
int smb3_init_fs_context(struct fs_context *fc)
{
{
	int rc;
	struct smb3_fs_context *ctx;
	struct smb3_fs_context *ctx;
	char *nodename = utsname()->nodename;
	char *nodename = utsname()->nodename;
	int i;
	int i;


	ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
	ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
	if (unlikely(!ctx))
	if (unlikely(!ctx)) {
		return -ENOMEM;
		rc = -ENOMEM;
		goto err_exit;
	}

	ctx->workstation_name = kstrdup(nodename, GFP_KERNEL);
	if (unlikely(!ctx->workstation_name)) {
		rc = -ENOMEM;
		goto err_exit;
	}


	/*
	/*
	 * does not have to be perfect mapping since field is
	 * does not have to be perfect mapping since field is
@@ -1493,6 +1511,14 @@ int smb3_init_fs_context(struct fs_context *fc)
	fc->fs_private = ctx;
	fc->fs_private = ctx;
	fc->ops = &smb3_fs_context_ops;
	fc->ops = &smb3_fs_context_ops;
	return 0;
	return 0;

err_exit:
	if (ctx) {
		kfree(ctx->workstation_name);
		kfree(ctx);
	}

	return rc;
}
}


void
void
@@ -1518,6 +1544,8 @@ smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx)
	ctx->source = NULL;
	ctx->source = NULL;
	kfree(ctx->domainname);
	kfree(ctx->domainname);
	ctx->domainname = NULL;
	ctx->domainname = NULL;
	kfree(ctx->workstation_name);
	ctx->workstation_name = NULL;
	kfree(ctx->nodename);
	kfree(ctx->nodename);
	ctx->nodename = NULL;
	ctx->nodename = NULL;
	kfree(ctx->iocharset);
	kfree(ctx->iocharset);
+1 −0
Original line number Original line Diff line number Diff line
@@ -170,6 +170,7 @@ struct smb3_fs_context {
	char *server_hostname;
	char *server_hostname;
	char *UNC;
	char *UNC;
	char *nodename;
	char *nodename;
	char *workstation_name;
	char *iocharset;  /* local code page for mapping to and from Unicode */
	char *iocharset;  /* local code page for mapping to and from Unicode */
	char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
	char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
	char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
	char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
+1 −0
Original line number Original line Diff line number Diff line
@@ -94,6 +94,7 @@ sesInfoFree(struct cifs_ses *buf_to_free)
	kfree_sensitive(buf_to_free->password);
	kfree_sensitive(buf_to_free->password);
	kfree(buf_to_free->user_name);
	kfree(buf_to_free->user_name);
	kfree(buf_to_free->domainName);
	kfree(buf_to_free->domainName);
	kfree(buf_to_free->workstation_name);
	kfree_sensitive(buf_to_free->auth_key.response);
	kfree_sensitive(buf_to_free->auth_key.response);
	kfree(buf_to_free->iface_list);
	kfree(buf_to_free->iface_list);
	kfree_sensitive(buf_to_free);
	kfree_sensitive(buf_to_free);
Loading