android_kernel_samsung_univ.../fs/cifs
Paulo Alcantara 6ee6f1787e cifs: Fix infinite loop when using hard mount option
commit 7ffbe65578b44fafdef577a360eb0583929f7c6e upstream.

For every request we send, whether it is SMB1 or SMB2+, we attempt to
reconnect tcon (cifs_reconnect_tcon or smb2_reconnect) before carrying
out the request.

So, while server->tcpStatus != CifsNeedReconnect, we wait for the
reconnection to succeed on wait_event_interruptible_timeout(). If it
returns, that means that either the condition was evaluated to true, or
timeout elapsed, or it was interrupted by a signal.

Since we're not handling the case where the process woke up due to a
received signal (-ERESTARTSYS), the next call to
wait_event_interruptible_timeout() will _always_ fail and we end up
looping forever inside either cifs_reconnect_tcon() or smb2_reconnect().

Here's an example of how to trigger that:

$ mount.cifs //foo/share /mnt/test -o
username=foo,password=foo,vers=1.0,hard

(break connection to server before executing bellow cmd)
$ stat -f /mnt/test & sleep 140
[1] 2511

$ ps -aux -q 2511
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      2511  0.0  0.0  12892  1008 pts/0    S    12:24   0:00 stat -f
/mnt/test

$ kill -9 2511

(wait for a while; process is stuck in the kernel)
$ ps -aux -q 2511
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      2511 83.2  0.0  12892  1008 pts/0    R    12:24  30:01 stat -f
/mnt/test

By using 'hard' mount point means that cifs.ko will keep retrying
indefinitely, however we must allow the process to be killed otherwise
it would hang the system.

Signed-off-by: Paulo Alcantara <palcantara@suse.de>
Cc: stable@vger.kernel.org
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-11 16:03:48 +02:00
..
asn1.c
cache.c
cifs_debug.c Display number of credits available 2016-10-28 03:01:32 -04:00
cifs_debug.h
cifs_dfs_ref.c
cifs_fs_sb.h
cifs_ioctl.h
cifs_spnego.c
cifs_spnego.h
cifs_unicode.c CIFS: add misssing SFM mapping for doublequote 2017-05-20 14:27:01 +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: Reconnect expired SMB sessions 2017-10-18 09:20:40 +02:00
cifspdu.h
cifsproto.h CIFS: Fix a possible memory corruption during reconnect 2017-01-06 11:16:15 +01:00
cifssmb.c cifs: Fix infinite loop when using hard mount option 2018-07-11 16:03:48 +02:00
connect.c CIFS: zero sensitive data when freeing 2018-02-16 20:09:39 +01:00
dir.c cifs: do not allow creating sockets except with SMB1 posix exensions 2018-04-29 07:50:01 +02:00
dns_resolve.c
dns_resolve.h
export.c
file.c CIFS: silence lockdep splat in cifs_relock_file() 2018-04-13 19:50:03 +02:00
fscache.c
fscache.h
inode.c
ioctl.c cifs: fix CIFS_IOC_GET_MNT_INFO oops 2017-05-20 14:27:01 +02:00
Kconfig
link.c
Makefile
misc.c CIFS: zero sensitive data when freeing 2018-02-16 20:09:39 +01:00
netmisc.c cifs: small underflow in cnvrtDosUnixTm() 2018-03-24 10:58:46 +01:00
nterr.c
nterr.h
ntlmssp.h
readdir.c cifs: initialize file_info_lock 2017-02-09 08:02:45 +01:00
rfc1002pdu.h
sess.c CIFS: Enable encryption during session setup phase 2018-03-24 10:58:40 +01:00
smb1ops.c CIFS: Improve readdir verbosity 2017-06-29 12:48:51 +02:00
smb2file.c CIFS: Fix a possible memory corruption in push locks 2017-01-06 11:16:16 +01:00
smb2glob.h cifs: Limit the overall credit acquired 2016-10-28 03:01:32 -04:00
smb2inode.c Do not send SMB3 SET_INFO request if nothing is changing 2016-10-28 03:01:33 -04:00
smb2maperror.c
smb2misc.c Handle mismatched open calls 2017-05-08 07:46:01 +02:00
smb2ops.c CIFS: Reconnect expired SMB sessions 2017-10-18 09:20:40 +02:00
smb2pdu.c cifs: Fix infinite loop when using hard mount option 2018-07-11 16:03:48 +02:00
smb2pdu.h CIFS: Fix maximum SMB2 header size 2017-09-07 08:34:09 +02: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 Handle mismatched open calls 2017-05-08 07:46:01 +02:00
winucase.c
xattr.c