mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 21:03:32 +00:00
cifs: prevent use-after-free by freeing the cfile later
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: 76894f3e2f
("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>
This commit is contained in:
parent
f0b6a834a8
commit
33f736187d
1 changed files with 3 additions and 3 deletions
|
@ -398,9 +398,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
|
||||||
rsp_iov);
|
rsp_iov);
|
||||||
|
|
||||||
finished:
|
finished:
|
||||||
if (cfile)
|
|
||||||
cifsFileInfo_put(cfile);
|
|
||||||
|
|
||||||
SMB2_open_free(&rqst[0]);
|
SMB2_open_free(&rqst[0]);
|
||||||
if (rc == -EREMCHG) {
|
if (rc == -EREMCHG) {
|
||||||
pr_warn_once("server share %s deleted\n", tcon->tree_name);
|
pr_warn_once("server share %s deleted\n", tcon->tree_name);
|
||||||
|
@ -529,6 +526,9 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfile)
|
||||||
|
cifsFileInfo_put(cfile);
|
||||||
|
|
||||||
if (rc && err_iov && err_buftype) {
|
if (rc && err_iov && err_buftype) {
|
||||||
memcpy(err_iov, rsp_iov, 3 * sizeof(*err_iov));
|
memcpy(err_iov, rsp_iov, 3 * sizeof(*err_iov));
|
||||||
memcpy(err_buftype, resp_buftype, 3 * sizeof(*err_buftype));
|
memcpy(err_buftype, resp_buftype, 3 * sizeof(*err_buftype));
|
||||||
|
|
Loading…
Reference in a new issue