Skip to content

Commit 62b5e81

Browse files
committed
smb: client: Handle kstrdup failures for passwords
JIRA: https://issues.redhat.com/browse/RHEL-65939 CVE: CVE-2024-50120 commit 9a5dd61 Author: Henrique Carvalho <[email protected]> Date: Tue Oct 22 15:21:26 2024 -0300 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: c1eb537 ("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]> Signed-off-by: Paulo Alcantara <[email protected]>
1 parent c84085f commit 62b5e81

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/smb/client/fs_context.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,15 @@ static int smb3_reconfigure(struct fs_context *fc)
918918
else {
919919
kfree_sensitive(ses->password);
920920
ses->password = kstrdup(ctx->password, GFP_KERNEL);
921+
if (!ses->password)
922+
return -ENOMEM;
921923
kfree_sensitive(ses->password2);
922924
ses->password2 = kstrdup(ctx->password2, GFP_KERNEL);
925+
if (!ses->password2) {
926+
kfree_sensitive(ses->password);
927+
ses->password = NULL;
928+
return -ENOMEM;
929+
}
923930
}
924931
STEAL_STRING(cifs_sb, ctx, domainname);
925932
STEAL_STRING(cifs_sb, ctx, nodename);

0 commit comments

Comments
 (0)