]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cifs: fix a sign extension bug
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 21 Sep 2021 20:33:35 +0000 (23:33 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Sep 2021 08:09:24 +0000 (10:09 +0200)
commitd140ccb140c2b082bd2fd61a0b444bcb4d2e6b43
tree821eb62429438371bbace620125458ec6b51e152
parent1c1062c5cf215c960373c75acb96dc601714ed88
cifs: fix a sign extension bug

[ Upstream commit e946d3c887a9dc33aa82a349c6284f4a084163f4 ]

The problem is the mismatched types between "ctx->total_len" which is
an unsigned int, "rc" which is an int, and "ctx->rc" which is a
ssize_t.  The code does:

ctx->rc = (rc == 0) ? ctx->total_len : rc;

We want "ctx->rc" to store the negative "rc" error code.  But what
happens is that "rc" is type promoted to a high unsigned int and
'ctx->rc" will store the high positive value instead of a negative
value.

The fix is to change "rc" from an int to a ssize_t.

Fixes: c610c4b619e5 ("CIFS: Add asynchronous write support through kernel AIO")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/file.c