Skip to content
/ linux Public

Commit 7425453

Browse files
pcacjrSasha Levin
authored andcommitted
smb: client: fix potential UAF and double free in smb2_open_file()
[ Upstream commit ebbbc4b ] Zero out @err_iov and @err_buftype before retrying SMB2_open() to prevent an UAF bug if @DaTa != NULL, otherwise a double free. Fixes: e3a4363 ("smb/client: fix memory leak in smb2_open_file()") Reported-by: David Howells <dhowells@redhat.com> Closes: https://lore.kernel.org/r/2892312.1770306653@warthog.procyon.org.uk Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Reviewed-by: David Howells <dhowells@redhat.com> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Cc: linux-cifs@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e3d1fd0 commit 7425453

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/smb/client/smb2file.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32
123123
&err_buftype);
124124
if (rc == -EACCES && retry_without_read_attributes) {
125125
free_rsp_buf(err_buftype, err_iov.iov_base);
126+
memset(&err_iov, 0, sizeof(err_iov));
127+
err_buftype = CIFS_NO_BUFFER;
126128
oparms->desired_access &= ~FILE_READ_ATTRIBUTES;
127129
rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, smb2_data, NULL, &err_iov,
128130
&err_buftype);

0 commit comments

Comments
 (0)