Commit 073e80ec authored by Paulo Alcantara's avatar Paulo Alcantara Committed by sanglipeng
Browse files

smb: client: fix potential NULL deref in parse_dfs_referrals()

stable inclusion
from stable-v5.10.204
commit 12467ad3f3d4f5321c1052cd978846e552a5847d
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9J4PL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=12467ad3f3d4f5321c1052cd978846e552a5847d



--------------------------------

[ 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: 9d49640a ("CIFS: implement get_dfs_refer for SMB2+")
Cc: stable@vger.kernel.org
Reported-by: default avatarRobert Morris <rtm@csail.mit.edu>
Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 4a31bb53
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2767,6 +2767,8 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
				(char **)&dfs_rsp, &dfs_rsp_size);
	} while (rc == -EAGAIN);

	if (!rc && !dfs_rsp)
		rc = -EIO;
	if (rc) {
		if ((rc != -ENOENT) && (rc != -EOPNOTSUPP))
			cifs_tcon_dbg(VFS, "ioctl error in %s rc=%d\n", __func__, rc);