smb3: enumerating snapshots was leaving part of the data off end
authorSteve French <stfrench@microsoft.com>
Thu, 9 Aug 2018 19:33:12 +0000 (14:33 -0500)
committerSteve French <stfrench@microsoft.com>
Fri, 10 Aug 2018 02:20:01 +0000 (21:20 -0500)
commite02789a53d71334b067ad72eee5d4e88a0158083
tree01cf76e9fd5a7a732257db28b522fb9d7aae8702
parent730928c8f4be88e9d6a027a16b1e8fa9c59fc077
smb3: enumerating snapshots was leaving part of the data off end

When enumerating snapshots, the last few bytes of the final
snapshot could be left off since we were miscalculating the
length returned (leaving off the sizeof struct SRV_SNAPSHOT_ARRAY)
See MS-SMB2 section 2.2.32.2. In addition fixup the length used
to allow smaller buffer to be passed in, in order to allow
returning the size of the whole snapshot array more easily.

Sample userspace output with a kernel patched with this
(mounted to a Windows volume with two snapshots).
Before this patch, the second snapshot would be missing a
few bytes at the end.

~/cifs-2.6# ~/enum-snapshots /mnt/file
press enter to issue the ioctl to retrieve snapshot information ...

size of snapshot array = 102
Num snapshots: 2 Num returned: 2 Array Size: 102

Snapshot 0:@GMT-2018.06.30-19.34.17
Snapshot 1:@GMT-2018.06.30-19.33.37

CC: Stable <stable@vger.kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
fs/cifs/smb2ops.c