Message ID | 20211222160405.3174438-2-ryandbair@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | cifs: fix workstation_name for multiuser mounts | expand |
Ryan Bair <ryandbair@gmail.com> writes: > Set workstation_name from the master_tcon for multiuser mounts. > > Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name. > > Signed-off-by: Ryan Bair <ryandbair@gmail.com> > --- > fs/cifs/connect.c | 13 +++++++++++++ > fs/cifs/sess.c | 6 +++++- > 2 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c > index 1060164b984a..cefd0e9623ba 100644 > --- a/fs/cifs/connect.c > +++ b/fs/cifs/connect.c Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Steve, could you pick this up? Please also add the following tags: Fixes: 49bd49f983b5 ("cifs: send workstation name during ntlmssp session setup") Cc: stable@vger.kernel.org # 5.16 Thanks.
Missed this email thread during the holidays - will test it out later this week. On Fri, Dec 24, 2021 at 5:07 AM Ryan Bair <ryandbair@gmail.com> wrote: > > Set workstation_name from the master_tcon for multiuser mounts. > > Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name. > > Signed-off-by: Ryan Bair <ryandbair@gmail.com> > --- > fs/cifs/connect.c | 13 +++++++++++++ > fs/cifs/sess.c | 6 +++++- > 2 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c > index 1060164b984a..cefd0e9623ba 100644 > --- a/fs/cifs/connect.c > +++ b/fs/cifs/connect.c > @@ -1945,6 +1945,19 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses) > } > } > > + ctx->workstation_name = kstrdup(ses->workstation_name, GFP_KERNEL); > + if (!ctx->workstation_name) { > + cifs_dbg(FYI, "Unable to allocate memory for workstation_name\n"); > + rc = -ENOMEM; > + kfree(ctx->username); > + ctx->username = NULL; > + kfree_sensitive(ctx->password); > + ctx->password = NULL; > + kfree(ctx->domainname); > + ctx->domainname = NULL; > + goto out_key_put; > + } > + > out_key_put: > up_read(&key->sem); > key_put(key); > diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c > index 035dc3e245dc..42133939f35d 100644 > --- a/fs/cifs/sess.c > +++ b/fs/cifs/sess.c > @@ -675,7 +675,11 @@ static int size_of_ntlmssp_blob(struct cifs_ses *ses, int base_size) > else > sz += sizeof(__le16); > > - sz += sizeof(__le16) * strnlen(ses->workstation_name, CIFS_MAX_WORKSTATION_LEN); > + if (ses->workstation_name) > + sz += sizeof(__le16) * strnlen(ses->workstation_name, > + CIFS_MAX_WORKSTATION_LEN); > + else > + sz += sizeof(__le16); > > return sz; > } > -- > 2.33.1 >
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 1060164b984a..cefd0e9623ba 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1945,6 +1945,19 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses) } } + ctx->workstation_name = kstrdup(ses->workstation_name, GFP_KERNEL); + if (!ctx->workstation_name) { + cifs_dbg(FYI, "Unable to allocate memory for workstation_name\n"); + rc = -ENOMEM; + kfree(ctx->username); + ctx->username = NULL; + kfree_sensitive(ctx->password); + ctx->password = NULL; + kfree(ctx->domainname); + ctx->domainname = NULL; + goto out_key_put; + } + out_key_put: up_read(&key->sem); key_put(key); diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 035dc3e245dc..42133939f35d 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -675,7 +675,11 @@ static int size_of_ntlmssp_blob(struct cifs_ses *ses, int base_size) else sz += sizeof(__le16); - sz += sizeof(__le16) * strnlen(ses->workstation_name, CIFS_MAX_WORKSTATION_LEN); + if (ses->workstation_name) + sz += sizeof(__le16) * strnlen(ses->workstation_name, + CIFS_MAX_WORKSTATION_LEN); + else + sz += sizeof(__le16); return sz; }
Set workstation_name from the master_tcon for multiuser mounts. Just in case, protect size_of_ntlmssp_blob against a NULL workstation_name. Signed-off-by: Ryan Bair <ryandbair@gmail.com> --- fs/cifs/connect.c | 13 +++++++++++++ fs/cifs/sess.c | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-)