SMB3: fix readpage for large swap cache
authorSteve French <stfrench@microsoft.com>
Fri, 23 Jul 2021 23:35:15 +0000 (18:35 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Aug 2021 10:46:45 +0000 (12:46 +0200)
commitbfc8e67c60b911ee5605c1234fcb58239e5c20de
treed979cdb27dc734a4dec015ab903ef7f1646cc124
parentbe561c0154dca82c3e399648bfe1b21b717af144
SMB3: fix readpage for large swap cache

commit f2a26a3cff27dfa456fef386fe5df56dcb4b47b6 upstream.

readpage was calculating the offset of the page incorrectly
for the case of large swapcaches.

    loff_t offset = (loff_t)page->index << PAGE_SHIFT;

As pointed out by Matthew Wilcox, this needs to use
page_file_offset() to calculate the offset instead.
Pages coming from the swap cache have page->index set
to their index within the swapcache, not within the backing
file.  For a sufficiently large swapcache, we could have
overlapping values of page->index within the same backing file.

Suggested by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: <stable@vger.kernel.org> # v5.7+
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/file.c