Skip to content

Commit cb6d5aa

Browse files
GoodLuck612smfrench
authored andcommitted
cifs: Fix memory and information leak in smb3_reconfigure()
In smb3_reconfigure(), if smb3_sync_session_ctx_passwords() fails, the function returns immediately without freeing and erasing the newly allocated new_password and new_password2. This causes both a memory leak and a potential information leak. Fix this by calling kfree_sensitive() on both password buffers before returning in this error case. Fixes: 0f0e357 ("cifs: during remount, make sure passwords are in sync") Signed-off-by: Zilin Guan <zilin@seu.edu.cn> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 9448598 commit cb6d5aa

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/smb/client/fs_context.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,8 @@ static int smb3_reconfigure(struct fs_context *fc)
11391139
rc = smb3_sync_session_ctx_passwords(cifs_sb, ses);
11401140
if (rc) {
11411141
mutex_unlock(&ses->session_mutex);
1142+
kfree_sensitive(new_password);
1143+
kfree_sensitive(new_password2);
11421144
return rc;
11431145
}
11441146

0 commit comments

Comments
 (0)