linux-stable/fs/cifs
Yilu Lin 9bc0225895 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-17 10:48:48 +02:00
..
asn1.c treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00
cache.c cifs: use 64-bit timestamps for fscache 2018-08-07 14:15:41 -05:00
cifs_debug.c cifs: Don't display RDMA transport on reconnect 2019-12-21 10:57:33 +01:00
cifs_debug.h cifs: add server argument to the dump_detail method 2018-05-27 17:56:35 -05:00
cifs_dfs_ref.c cifs: use correct format characters 2019-04-05 22:32:59 +02:00
cifs_fs_sb.h cifs: Properly handle auto disabling of serverino option 2019-09-16 08:22:17 +02:00
cifs_ioctl.h
cifs_spnego.c smb3: on kerberos mount if server doesn't specify auth type use krb5 2018-11-13 11:08:48 -08:00
cifs_spnego.h
cifs_unicode.c fs/cifs: don't translate SFM_SLASH (U+F026) to backslash 2018-09-02 23:21:42 -05: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-05 16:42:15 +01:00
cifsacl.h cifs: For SMB2 security informaion query, check for minimum sized security descriptor instead of sizeof FileAllInformation class 2018-06-04 19:19:24 -05:00
cifsencrypt.c cifs: Make sure all data pages are signed correctly 2018-08-07 14:15:41 -05:00
cifsfs.c smb3: allow disabling requesting leases 2019-10-05 13:10:08 +02:00
cifsfs.h cifs: update internal module version number for cifs.ko to 2.12 2018-08-23 15:11:10 -05:00
cifsglob.h cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs 2019-11-10 11:27:34 +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:27:34 +01:00
cifssmb.c CIFS: Respect SMB2 hdr preamble size in read responses 2019-11-06 13:05:35 +01:00
connect.c cifs: Fix mode output in debugging statements 2020-03-05 16:42:15 +01:00
dir.c cifs_atomic_open(): fix double-put on late allocation failure 2020-03-18 07:14:21 +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-17 10:48:48 +02:00
fscache.c cifs: use 64-bit timestamps for fscache 2018-08-07 14:15:41 -05:00
fscache.h cifs: use 64-bit timestamps for fscache 2018-08-07 14:15:41 -05:00
inode.c cifs: don't leak -EAGAIN for stat() during reconnect 2020-03-11 14:14:57 +01:00
ioctl.c [SMB3] Remove ifdef since SMB3 (and later) now STRONGLY preferred 2017-07-08 18:57:07 -05:00
Kconfig cifs: In Kconfig CONFIG_CIFS_POSIX needs depends on legacy (insecure cifs) 2018-12-21 14:15:23 +01:00
link.c smb3: don't request leases in symlink creation and query 2018-08-07 14:15:57 -05:00
Makefile smb3: Add ftrace tracepoints for improved SMB3 debugging 2018-05-27 17:56:35 -05:00
misc.c cifs: Properly handle auto disabling of serverino option 2019-09-16 08:22:17 +02:00
netmisc.c fs: cifs: mute -Wunused-const-variable message 2019-11-06 13:05:51 +01:00
nterr.c
nterr.h
ntlmssp.h
readdir.c cifs: check ntwrk_buf_start for NULL before dereferencing it 2019-02-12 19:47:17 +01:00
rfc1002pdu.h
sess.c cifs: check kmalloc before use 2018-08-23 15:10:49 -05:00
smb1ops.c CIFS: avoid using MID 0xFFFF 2019-10-29 09:20:01 +01:00
smb2file.c cifs: Adjust indentation in smb2_open_file 2020-01-17 19:47:01 +01:00
smb2glob.h cifs: remove struct smb2_hdr 2018-06-01 09:14:30 -05:00
smb2inode.c smb3: Do not send SMB3 SET_INFO if nothing changed 2018-08-07 14:30:59 -05:00
smb2maperror.c SMB3: retry on STATUS_INSUFFICIENT_RESOURCES instead of failing write 2019-06-25 11:36:01 +08:00
smb2misc.c cifs: Fix memory allocation in __smb2_handle_cancelled_cmd() 2020-02-01 09:37:04 +00:00
smb2ops.c CIFS: Respect SMB2 hdr preamble size in read responses 2019-11-06 13:05:35 +01:00
smb2pdu.c cifs: log warning message (once) if out of disk space 2020-02-24 08:34:53 +01:00
smb2pdu.h SMB3: Fix persistent handles reconnect 2019-11-12 19:20:42 +01:00
smb2proto.h CIFS: Close open handle after interrupted close 2019-12-21 10:57:35 +01:00
smb2status.h
smb2transport.c CIFS: Do not skip SMB2 message IDs on send failures 2019-03-23 20:09:56 +01:00
smbdirect.c cifs: smbd: Return -EINVAL when the number of iovs exceeds SMBDIRECT_MAX_SGE 2019-12-21 10:57:32 +01:00
smbdirect.h cifs: smbd: take an array of reqeusts when sending upper layer data 2019-09-16 08:22:13 +02:00
smbencrypt.c CIFS: refactor crypto shash/sdesc allocation&free 2018-04-01 20:24:39 -05:00
smberr.h
smbfsctl.h
trace.c smb3: Add ftrace tracepoints for improved SMB3 debugging 2018-05-27 17:56:35 -05:00
trace.h smb3: add tracepoint for slow responses 2018-08-07 14:28:01 -05:00
transport.c cifs: smbd: Return -EAGAIN when transport is reconnecting 2019-12-21 10:57:31 +01:00
winucase.c
xattr.c CIFS: fix max ea value size 2019-10-05 13:10:12 +02:00