aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPetar Penkov <ppenkov@google.com>2017-08-29 14:20:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-09-20 23:27:48 -0400
commita90bcb86ae700c12432446c4aa1819e7b8e172ec (patch)
treef172eb5b81e958457422d74e66587bf0071ddebe /lib
parent2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e (diff)
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: 72e809ed81ed ("iov_iter: sanity checks for copy to/from page primitives") Signed-off-by: Petar Penkov <ppenkov@google.com> CC: Al Viro <viro@zeniv.linux.org.uk> CC: Eric Dumazet <edumazet@google.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'lib')
-rw-r--r--lib/iov_iter.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 52c8dd6d8e82..1c1c06ddc20a 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -687,8 +687,10 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache);
687 687
688static inline bool page_copy_sane(struct page *page, size_t offset, size_t n) 688static inline bool page_copy_sane(struct page *page, size_t offset, size_t n)
689{ 689{
690 size_t v = n + offset; 690 struct page *head = compound_head(page);
691 if (likely(n <= v && v <= (PAGE_SIZE << compound_order(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))))
692 return true; 694 return true;
693 WARN_ON(1); 695 WARN_ON(1);
694 return false; 696 return false;