]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
smb: client: fix potential UAF and double free in smb2_open_file()
authorPaulo Alcantara <pc@manguebit.org>
Thu, 5 Feb 2026 16:19:52 +0000 (13:19 -0300)
committerSteve French <stfrench@microsoft.com>
Sun, 8 Feb 2026 23:07:42 +0000 (17:07 -0600)
Zero out @err_iov and @err_buftype before retrying SMB2_open() to
prevent an UAF bug if @data != NULL, otherwise a double free.

Fixes: e3a43633023e ("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>
fs/smb/client/smb2file.c

index 2dd08388ea87331d0c3a8fff03ca5d3c34529494..1f7f284a78449620751eb5f4ef550b04a501b513 100644 (file)
@@ -179,6 +179,8 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
                       &err_buftype);
        if (rc == -EACCES && retry_without_read_attributes) {
                free_rsp_buf(err_buftype, err_iov.iov_base);
+               memset(&err_iov, 0, sizeof(err_iov));
+               err_buftype = CIFS_NO_BUFFER;
                oparms->desired_access &= ~FILE_READ_ATTRIBUTES;
                rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, smb2_data, NULL, &err_iov,
                               &err_buftype);