linux-stable/fs/cifs
Yilu Lin 620b7966d4 CIFS: Fix bug which the return value by asynchronous read is error
commit 97adda8b3a upstream.

This patch is used to fix the bug in collect_uncached_read_data()
that rc is automatically converted from a signed number to an
unsigned number when the CIFS asynchronous read fails.
It will cause ctx->rc is error.

Example:
Share a directory and create a file on the Windows OS.
Mount the directory to the Linux OS using CIFS.
On the CIFS client of the Linux OS, invoke the pread interface to
deliver the read request.

The size of the read length plus offset of the read request is greater
than the maximum file size.

In this case, the CIFS server on the Windows OS returns a failure
message (for example, the return value of
smb2.nt_status is STATUS_INVALID_PARAMETER).

After receiving the response message, the CIFS client parses
smb2.nt_status to STATUS_INVALID_PARAMETER
and converts it to the Linux error code (rdata->result=-22).

Then the CIFS client invokes the collect_uncached_read_data function to
assign the value of rdata->result to rc, that is, rc=rdata->result=-22.

The type of the ctx->total_len variable is unsigned integer,
the type of the rc variable is integer, and the type of
the ctx->rc variable is ssize_t.

Therefore, during the ternary operation, the value of rc is
automatically converted to an unsigned number. The final result is
ctx->rc=4294967274. However, the expected result is ctx->rc=-22.

Signed-off-by: Yilu Lin <linyilu@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
CC: Stable <stable@vger.kernel.org>
Acked-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-24 08:00:40 +02:00
..
asn1.c
cache.c fscache: remove unused ->now_uncached callback 2017-09-06 17:27:26 -07:00
cifs_debug.c smb3: allow stats which track session and share reconnects to be reset 2018-11-13 11:15:09 -08:00
cifs_debug.h lib: update single-char callers of strtobool() 2016-03-17 15:09:34 -07:00
cifs_dfs_ref.c cifs: use correct format characters 2019-04-05 22:31:28 +02:00
cifs_fs_sb.h cifs: Convert to separately allocated bdi 2017-04-20 12:09:55 -06:00
cifs_ioctl.h Enable previous version support 2016-10-13 19:48:11 -05:00
cifs_spnego.c smb3: on kerberos mount if server doesn't specify auth type use krb5 2018-11-13 11:15:09 -08:00
cifs_spnego.h
cifs_unicode.c fs/cifs: don't translate SFM_SLASH (U+F026) to backslash 2018-10-10 08:54:21 +02:00
cifs_unicode.h [SMB3] Remove ifdef since SMB3 (and later) now STRONGLY preferred 2017-07-08 18:57:07 -05:00
cifs_uniupr.h
cifsacl.c cifs: Fix mode output in debugging statements 2020-03-11 18:02:46 +01:00
cifsacl.h cifs: For SMB2 security informaion query, check for minimum sized security descriptor instead of sizeof FileAllInformation class 2018-06-26 08:06:31 +08:00
cifsencrypt.c CIFS: fix sha512 check in cifs_crypto_secmech_release 2018-04-24 09:36:27 +02:00
cifsfs.c cifs: don't dereference smb_file_target before null check 2018-11-27 16:10:46 +01:00
cifsfs.h Update version of cifs module 2017-09-17 23:10:48 -05:00
cifsglob.h cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs 2019-11-10 11:25:19 +01:00
cifspdu.h CIFS: move DFS response parsing out of SMB1 code 2017-03-01 22:26:10 -06:00
cifsproto.h cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs 2019-11-10 11:25:19 +01:00
cifssmb.c CIFS: Fix credits calculations for reads with errors 2019-01-31 08:13:44 +01:00
connect.c cifs: Fix mode output in debugging statements 2020-03-11 18:02:46 +01:00
dir.c cifs_atomic_open(): fix double-put on late allocation failure 2020-03-20 10:54:16 +01:00
dns_resolve.c
dns_resolve.h
export.c
file.c CIFS: Fix bug which the return value by asynchronous read is error 2020-04-24 08:00:40 +02:00
fscache.c
fscache.h
inode.c cifs: don't leak -EAGAIN for stat() during reconnect 2020-03-11 18:03:01 +01:00
ioctl.c [SMB3] Remove ifdef since SMB3 (and later) now STRONGLY preferred 2017-07-08 18:57:07 -05:00
Kconfig cifs: allow disabling insecure dialects in the config 2019-01-26 09:37:07 +01:00
link.c smb3: don't request leases in symlink creation and query 2018-09-05 09:26:33 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
misc.c CIFS: keep FileInfo handle live during oplock break 2019-04-27 09:35:35 +02:00
netmisc.c fs: cifs: mute -Wunused-const-variable message 2019-11-06 12:43:10 +01:00
nterr.c
nterr.h
ntlmssp.h cifs: dynamic allocation of ntlmssp blob 2016-06-23 23:45:07 -05:00
readdir.c cifs: check ntwrk_buf_start for NULL before dereferencing it 2019-02-12 19:46:08 +01:00
rfc1002pdu.h
sess.c cifs: check kmalloc before use 2018-09-05 09:26:33 +02:00
smb1ops.c CIFS: avoid using MID 0xFFFF 2019-10-29 09:17:41 +01:00
smb2file.c cifs: Adjust indentation in smb2_open_file 2020-01-17 19:45:45 +01:00
smb2glob.h CIFS: Separate SMB2 header structure 2017-02-01 16:46:34 -06:00
smb2inode.c smb3: Do not send SMB3 SET_INFO if nothing changed 2018-09-05 09:26:33 +02:00
smb2maperror.c SMB3: retry on STATUS_INSUFFICIENT_RESOURCES instead of failing write 2019-06-25 11:36:54 +08:00
smb2misc.c CIFS: Fix SMB2 oplock break processing 2019-12-17 20:38:49 +01:00
smb2ops.c CIFS: Fix oplock handling for SMB 2.1+ protocols 2019-10-05 12:48:13 +02:00
smb2pdu.c cifs: fail i/o on soft mounts if sessionsetup errors out 2020-02-14 16:32:20 -05:00
smb2pdu.h cifs: fix computation for MAX_SMB2_HDR_SIZE 2019-03-13 14:03:15 -07:00
smb2proto.h CIFS: add sha512 secmech 2018-04-24 09:36:27 +02:00
smb2status.h
smb2transport.c cifs: Fix use after free of a mid_q_entry 2018-07-11 16:29:15 +02:00
smbencrypt.c CIFS: refactor crypto shash/sdesc allocation&free 2018-04-24 09:36:27 +02:00
smberr.h
smbfsctl.h [SMB3] Send durable handle v2 contexts when use of persistent handles required 2015-11-03 09:26:27 -06:00
transport.c CIFS: Do not hide EINTR after sending network packets 2019-01-16 22:07:10 +01:00
winucase.c
xattr.c CIFS: fix max ea value size 2019-10-05 12:48:12 +02:00