Skip to content

Commit a90bcb8

Browse files
Petar PenkovAl Viro
authored andcommitted
iov_iter: fix page_copy_sane for compound pages
Issue is that if the data crosses a page boundary inside a compound page, this check will incorrectly trigger a WARN_ON. To fix this, compute the order using the head of the compound page and adjust the offset to be relative to that head. Fixes: 72e809e ("iov_iter: sanity checks for copy to/from page primitives") Signed-off-by: Petar Penkov <[email protected]> CC: Al Viro <[email protected]> CC: Eric Dumazet <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 2bd6bf0 commit a90bcb8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/iov_iter.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,10 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache);
687687

688688
static inline bool page_copy_sane(struct page *page, size_t offset, size_t n)
689689
{
690-
size_t v = n + offset;
691-
if (likely(n <= v && v <= (PAGE_SIZE << compound_order(page))))
690+
struct page *head = compound_head(page);
691+
size_t v = n + offset + page_address(page) - page_address(head);
692+
693+
if (likely(n <= v && v <= (PAGE_SIZE << compound_order(head))))
692694
return true;
693695
WARN_ON(1);
694696
return false;

0 commit comments

Comments
 (0)