Commit 9ccecae8 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: we do not allow changing username/password/unc/... during remount

Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent d6a78783
...@@ -493,7 +493,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root) ...@@ -493,7 +493,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
if (tcon->no_lease) if (tcon->no_lease)
seq_puts(s, ",nolease"); seq_puts(s, ",nolease");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) if (cifs_sb->ctx->multiuser)
seq_puts(s, ",multiuser"); seq_puts(s, ",multiuser");
else if (tcon->ses->user_name) else if (tcon->ses->user_name)
seq_show_option(s, "username", tcon->ses->user_name); seq_show_option(s, "username", tcon->ses->user_name);
......
...@@ -632,10 +632,51 @@ static int smb3_verify_reconfigure_ctx(struct smb3_fs_context *new_ctx, ...@@ -632,10 +632,51 @@ static int smb3_verify_reconfigure_ctx(struct smb3_fs_context *new_ctx,
cifs_dbg(VFS, "can not change sec during remount\n"); cifs_dbg(VFS, "can not change sec during remount\n");
return -EINVAL; return -EINVAL;
} }
if (new_ctx->multiuser != old_ctx->multiuser) {
cifs_dbg(VFS, "can not change multiuser during remount\n");
return -EINVAL;
}
if (new_ctx->UNC &&
(!old_ctx->UNC || strcmp(new_ctx->UNC, old_ctx->UNC))) {
cifs_dbg(VFS, "can not change UNC during remount\n");
return -EINVAL;
}
if (new_ctx->username &&
(!old_ctx->username || strcmp(new_ctx->username, old_ctx->username))) {
cifs_dbg(VFS, "can not change username during remount\n");
return -EINVAL;
}
if (new_ctx->password &&
(!old_ctx->password || strcmp(new_ctx->password, old_ctx->password))) {
cifs_dbg(VFS, "can not change password during remount\n");
return -EINVAL;
}
if (new_ctx->domainname &&
(!old_ctx->domainname || strcmp(new_ctx->domainname, old_ctx->domainname))) {
cifs_dbg(VFS, "can not change domainname during remount\n");
return -EINVAL;
}
if (new_ctx->nodename &&
(!old_ctx->nodename || strcmp(new_ctx->nodename, old_ctx->nodename))) {
cifs_dbg(VFS, "can not change nodename during remount\n");
return -EINVAL;
}
if (new_ctx->iocharset &&
(!old_ctx->iocharset || strcmp(new_ctx->iocharset, old_ctx->iocharset))) {
cifs_dbg(VFS, "can not change iocharset during remount\n");
return -EINVAL;
}
return 0; return 0;
} }
#define STEAL_STRING(cifs_sb, ctx, field) \
do { \
kfree(ctx->field); \
ctx->field = cifs_sb->ctx->field; \
cifs_sb->ctx->field = NULL; \
} while (0)
static int smb3_reconfigure(struct fs_context *fc) static int smb3_reconfigure(struct fs_context *fc)
{ {
struct smb3_fs_context *ctx = smb3_fc2context(fc); struct smb3_fs_context *ctx = smb3_fc2context(fc);
...@@ -648,10 +689,16 @@ static int smb3_reconfigure(struct fs_context *fc) ...@@ -648,10 +689,16 @@ static int smb3_reconfigure(struct fs_context *fc)
return rc; return rc;
/* /*
* Steal the UNC from the old and to be destroyed context. * We can not change UNC/username/password/domainname/nodename/iocharset
* during reconnect so ignore what we have in the new context and
* just use what we already have in cifs_sb->ctx.
*/ */
ctx->UNC = cifs_sb->ctx->UNC; STEAL_STRING(cifs_sb, ctx, UNC);
cifs_sb->ctx->UNC = NULL; STEAL_STRING(cifs_sb, ctx, username);
STEAL_STRING(cifs_sb, ctx, password);
STEAL_STRING(cifs_sb, ctx, domainname);
STEAL_STRING(cifs_sb, ctx, nodename);
STEAL_STRING(cifs_sb, ctx, iocharset);
smb3_cleanup_fs_context_contents(cifs_sb->ctx); smb3_cleanup_fs_context_contents(cifs_sb->ctx);
rc = smb3_fs_context_dup(cifs_sb->ctx, ctx); rc = smb3_fs_context_dup(cifs_sb->ctx, ctx);
......
...@@ -149,7 +149,6 @@ struct smb3_fs_context { ...@@ -149,7 +149,6 @@ struct smb3_fs_context {
bool uid_specified; bool uid_specified;
bool gid_specified; bool gid_specified;
bool sloppy; bool sloppy;
char *nodename;
bool got_ip; bool got_ip;
bool got_version; bool got_version;
bool got_rsize; bool got_rsize;
...@@ -161,6 +160,7 @@ struct smb3_fs_context { ...@@ -161,6 +160,7 @@ struct smb3_fs_context {
char *password; char *password;
char *domainname; char *domainname;
char *UNC; char *UNC;
char *nodename;
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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment