cifs: prevent use-after-free by freeing the cfile later
authorShyam Prasad N <sprasad@microsoft.com>
Thu, 22 Jun 2023 18:16:03 +0000 (18:16 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jul 2023 14:21:44 +0000 (16:21 +0200)
commit4fe07d55a5461e66a55fbefb57f85ff0facea32b
tree072628a935f0bd55dbf1de9da5a21612e45c33a7
parente28d7a3f4bc5e9ed72984952c2ff449254b1dda0
cifs: prevent use-after-free by freeing the cfile later

[ Upstream commit 33f736187d08f6bc822117629f263b97d3df4165 ]

In smb2_compound_op we have a possible use-after-free
which can cause hard to debug problems later on.

This was revealed during stress testing with KASAN enabled
kernel. Fixing it by moving the cfile free call to
a few lines below, after the usage.

Fixes: 76894f3e2f71 ("cifs: improve symlink handling for smb2+")
Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/client/smb2inode.c