]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: fix potential NULL deref in parse_dfs_referrals()
authorPaulo Alcantara <pc@manguebit.com>
Wed, 6 Dec 2023 00:49:29 +0000 (21:49 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Dec 2023 17:36:50 +0000 (18:36 +0100)
[ Upstream commit 92414333eb375ed64f4ae92d34d579e826936480 ]

If server returned no data for FSCTL_DFS_GET_REFERRALS, @dfs_rsp will
remain NULL and then parse_dfs_referrals() will dereference it.

Fix this by returning -EIO when no output data is returned.

Besides, we can't fix it in SMB2_ioctl() as some FSCTLs are allowed to
return no data as per MS-SMB2 2.2.32.

Fixes: 9d49640a21bf ("CIFS: implement get_dfs_refer for SMB2+")
Cc: stable@vger.kernel.org
Reported-by: Robert Morris <rtm@csail.mit.edu>
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/smb2ops.c

index d8ce079ba9091ac37802653a501bc8b10187f3be..7c2ecbb17f542790da33001e77ae69a4edb8afab 100644 (file)
@@ -2926,6 +2926,8 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
                usleep_range(512, 2048);
        } while (++retry_count < 5);
 
+       if (!rc && !dfs_rsp)
+               rc = -EIO;
        if (rc) {
                if (!is_retryable_error(rc) && rc != -ENOENT && rc != -EOPNOTSUPP)
                        cifs_tcon_dbg(VFS, "%s: ioctl error: rc=%d\n", __func__, rc);