ksmbd: fix incorrect handling of iterate_dir
authorNamjae Jeon <linkinjeon@kernel.org>
Fri, 9 Sep 2022 08:43:53 +0000 (17:43 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Oct 2022 08:12:57 +0000 (10:12 +0200)
commit20bc6d23f7f67c1122349080e00f490024d8f37a
treec9a7e4ac6198ece9847b6ec3137deeaa6f34c911
parent3c8cfcaa2d9a2424005261bbcb5283831c38a05a
ksmbd: fix incorrect handling of iterate_dir

[ Upstream commit 88541cb414b7a2450c45fc9c131b37b5753b7679 ]

if iterate_dir() returns non-negative value, caller has to treat it
as normal and check there is any error while populating dentry
information. ksmbd doesn't have to do anything because ksmbd already
checks too small OutputBufferLength to store one file information.

And because ctx->pos is set to file->f_pos when iterative_dir is called,
remove restart_ctx(). And if iterate_dir() return -EIO, which mean
directory entry is corrupted, return STATUS_FILE_CORRUPT_ERROR error
response.

This patch fixes some failure of SMB2_QUERY_DIRECTORY, which happens when
ntfs3 is local filesystem.

Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ksmbd/smb2pdu.c