android_kernel_oneplus_msm8998/fs/cifs
Dave Wysochanski ad56882f0c cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs
[ Upstream commit d46b0da7a33dd8c99d969834f682267a45444ab3 ]

There's a deadlock that is possible and can easily be seen with
a test where multiple readers open/read/close of the same file
and a disruption occurs causing reconnect.  The deadlock is due
a reader thread inside cifs_strict_readv calling down_read and
obtaining lock_sem, and then after reconnect inside
cifs_reopen_file calling down_read a second time.  If in
between the two down_read calls, a down_write comes from
another process, deadlock occurs.

        CPU0                    CPU1
        ----                    ----
cifs_strict_readv()
 down_read(&cifsi->lock_sem);
                               _cifsFileInfo_put
                                  OR
                               cifs_new_fileinfo
                                down_write(&cifsi->lock_sem);
cifs_reopen_file()
 down_read(&cifsi->lock_sem);

Fix the above by changing all down_write(lock_sem) calls to
down_write_trylock(lock_sem)/msleep() loop, which in turn
makes the second down_read call benign since it will never
block behind the writer while holding lock_sem.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Suggested-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed--by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-10 11:21:10 +01:00
..
asn1.c
cache.c
cifs_debug.c smb3: allow stats which track session and share reconnects to be reset 2018-11-21 09:27:35 +01:00
cifs_debug.h lib: update single-char callers of strtobool() 2016-10-28 03:01:30 -04:00
cifs_dfs_ref.c cifs: use correct format characters 2019-04-27 09:33:49 +02:00
cifs_fs_sb.h
cifs_ioctl.h
cifs_spnego.c smb3: on kerberos mount if server doesn't specify auth type use krb5 2018-11-21 09:27:35 +01:00
cifs_spnego.h
cifs_unicode.c fs/cifs: don't translate SFM_SLASH (U+F026) to backslash 2018-10-10 08:52:11 +02:00
cifs_unicode.h CIFS: add misssing SFM mapping for doublequote 2017-05-20 14:27:01 +02:00
cifs_uniupr.h
cifsacl.c
cifsacl.h
cifsencrypt.c CIFS: zero sensitive data when freeing 2018-02-16 20:09:39 +01:00
cifsfs.c SMB3: GUIDs should be constructed as random but valid uuids 2016-10-28 03:01:32 -04:00
cifsfs.h
cifsglob.h cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs 2019-11-10 11:21:10 +01:00
cifspdu.h
cifsproto.h cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs 2019-11-10 11:21:10 +01:00
cifssmb.c fs/cifs: suppress a string overflow warning 2018-10-10 08:52:12 +02:00
connect.c cifs: Use kzfree() to zero out the password 2019-09-21 07:12:51 +02:00
dir.c CIFS: Force reval dentry if LOOKUP_REVAL flag is set 2019-10-17 13:41:03 -07:00
dns_resolve.c
dns_resolve.h
export.c
file.c cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs 2019-11-10 11:21:10 +01:00
fscache.c
fscache.h
inode.c CIFS: Force revalidate inode when dentry is stale 2019-10-17 13:41:05 -07:00
ioctl.c cifs: fix CIFS_IOC_GET_MNT_INFO oops 2017-05-20 14:27:01 +02:00
Kconfig Revert "cifs: In Kconfig CONFIG_CIFS_POSIX needs depends on legacy (insecure cifs)" 2019-02-20 10:13:20 +01:00
link.c smb3: don't request leases in symlink creation and query 2018-09-05 09:18:37 +02:00
Makefile
misc.c cifs: read overflow in is_valid_oplock_break() 2018-10-10 08:52:12 +02:00
netmisc.c fs: cifs: mute -Wunused-const-variable message 2019-11-06 12:09:14 +01:00
nterr.c
nterr.h
ntlmssp.h
readdir.c cifs: check ntwrk_buf_start for NULL before dereferencing it 2019-02-20 10:13:13 +01:00
rfc1002pdu.h
sess.c cifs: check kmalloc before use 2018-09-05 09:18:37 +02:00
smb1ops.c CIFS: avoid using MID 0xFFFF 2019-10-29 09:13:30 +01:00
smb2file.c cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs 2019-11-10 11:21:10 +01:00
smb2glob.h cifs: Limit the overall credit acquired 2016-10-28 03:01:32 -04:00
smb2inode.c smb3: Do not send SMB3 SET_INFO if nothing changed 2018-09-05 09:18:37 +02:00
smb2maperror.c SMB3: retry on STATUS_INSUFFICIENT_RESOURCES instead of failing write 2019-07-10 09:56:34 +02:00
smb2misc.c cifs: check if SMB2 PDU size has been padded and suppress the warning 2018-09-15 09:40:37 +02:00
smb2ops.c CIFS: Fix oplock handling for SMB 2.1+ protocols 2019-10-05 12:27:55 +02:00
smb2pdu.c smb3: send CAP_DFS capability during session setup 2019-08-25 10:52:54 +02:00
smb2pdu.h cifs: fix computation for MAX_SMB2_HDR_SIZE 2019-03-23 08:44:26 +01:00
smb2proto.h Handle mismatched open calls 2017-05-08 07:46:01 +02:00
smb2status.h
smb2transport.c Handle mismatched open calls 2017-05-08 07:46:01 +02:00
smbencrypt.c
smberr.h
smbfsctl.h
transport.c CIFS: Do not hide EINTR after sending network packets 2019-01-16 22:16:10 +01:00
winucase.c
xattr.c