Skip to content

Commit 53b776c

Browse files
committed
netfs: Miscellaneous fixes
Fix some miscellaneous things in the new netfs lib[1]: (1) The kerneldoc for netfs_readpage() shouldn't say netfs_page(). (2) netfs_readpage() can get an integer overflow on 32-bit when it multiplies page_index(page) by PAGE_SIZE. It should use page_file_offset() instead. (3) netfs_write_begin() should use page_offset() to avoid the same overflow. Note that netfs_readpage() needs to use page_file_offset() rather than page_offset() as it may see swap-over-NFS. Reported-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: David Howells <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Link: https://lore.kernel.org/r/161789062190.6155.12711584466338493050.stgit@warthog.procyon.org.uk/ [1]
1 parent 3d14ec1 commit 53b776c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/netfs/read_helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ void netfs_readahead(struct readahead_control *ractl,
933933
EXPORT_SYMBOL(netfs_readahead);
934934

935935
/**
936-
* netfs_page - Helper to manage a readpage request
936+
* netfs_readpage - Helper to manage a readpage request
937937
* @file: The file to read from
938938
* @page: The page to read
939939
* @ops: The network filesystem's operations for the helper to use
@@ -968,7 +968,7 @@ int netfs_readpage(struct file *file,
968968
return -ENOMEM;
969969
}
970970
rreq->mapping = page_file_mapping(page);
971-
rreq->start = page_index(page) * PAGE_SIZE;
971+
rreq->start = page_file_offset(page);
972972
rreq->len = thp_size(page);
973973

974974
if (ops->begin_cache_operation) {
@@ -1106,7 +1106,7 @@ int netfs_write_begin(struct file *file, struct address_space *mapping,
11061106
if (!rreq)
11071107
goto error;
11081108
rreq->mapping = page->mapping;
1109-
rreq->start = page->index * PAGE_SIZE;
1109+
rreq->start = page_offset(page);
11101110
rreq->len = thp_size(page);
11111111
rreq->no_unlock_page = page->index;
11121112
__set_bit(NETFS_RREQ_NO_UNLOCK_PAGE, &rreq->flags);

0 commit comments

Comments
 (0)