]> git.baikalelectronics.ru Git - kernel.git/commit
CIFS: Fix use after free of file info structures
authorPavel Shilovsky <pshilov@microsoft.com>
Wed, 23 Oct 2019 22:37:19 +0000 (15:37 -0700)
committerSteve French <stfrench@microsoft.com>
Fri, 25 Oct 2019 02:32:35 +0000 (21:32 -0500)
commit831bbf1b374e6c60a59645d25d339a2ad616da39
treec66e3fc9f7fb3181082d2982b1f5db7278ba8ad7
parent276f2a70e795f71f8a12561018193ce4e9e9f2bb
CIFS: Fix use after free of file info structures

Currently the code assumes that if a file info entry belongs
to lists of open file handles of an inode and a tcon then
it has non-zero reference. The recent changes broke that
assumption when putting the last reference of the file info.
There may be a situation when a file is being deleted but
nothing prevents another thread to reference it again
and start using it. This happens because we do not hold
the inode list lock while checking the number of references
of the file info structure. Fix this by doing the proper
locking when doing the check.

Fixes: 15e30fc2ae8eb ("cifs: add spinlock for the openFileList to cifsInodeInfo")
Fixes: 5b9039fc16d89 ("cifs: use cifsInodeInfo->open_file_lock while iterating to avoid a panic")
Cc: Stable <stable@vger.kernel.org>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/file.c