aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrique Carvalho <[email protected]>2024-10-22 15:21:26 -0300
committerSteve French <[email protected]>2024-10-23 07:42:22 -0500
commit9a5dd61151399ad5a5d69aad28ab164734c1e3bc (patch)
treefe31f832e4eb4f9582ef9922319188d01239cead
parent42f7652d3eb527d03665b09edac47f85fb600924 (diff)
smb: client: Handle kstrdup failures for passwords
In smb3_reconfigure(), after duplicating ctx->password and ctx->password2 with kstrdup(), we need to check for allocation failures. If ses->password allocation fails, return -ENOMEM. If ses->password2 allocation fails, free ses->password, set it to NULL, and return -ENOMEM. Fixes: c1eb537bf456 ("cifs: allow changing password during remount") Reviewed-by: David Howells <[email protected] Signed-off-by: Haoxiang Li <[email protected]> Signed-off-by: Henrique Carvalho <[email protected]> Signed-off-by: Steve French <[email protected]>
-rw-r--r--fs/smb/client/fs_context.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 28c4e576d460..5c5a52019efa 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -920,8 +920,15 @@ static int smb3_reconfigure(struct fs_context *fc)
else {
kfree_sensitive(ses->password);
ses->password = kstrdup(ctx->password, GFP_KERNEL);
+ if (!ses->password)
+ return -ENOMEM;
kfree_sensitive(ses->password2);
ses->password2 = kstrdup(ctx->password2, GFP_KERNEL);
+ if (!ses->password2) {
+ kfree_sensitive(ses->password);
+ ses->password = NULL;
+ return -ENOMEM;
+ }
}
STEAL_STRING(cifs_sb, ctx, domainname);
STEAL_STRING(cifs_sb, ctx, nodename);