提交 a90bcb86 编写于 作者: P Petar Penkov 提交者: Al Viro

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: 72e809ed ("iov_iter: sanity checks for copy to/from page
primitives")
Signed-off-by: NPetar Penkov <ppenkov@google.com>
CC: Al Viro <viro@zeniv.linux.org.uk>
CC: Eric Dumazet <edumazet@google.com>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 2bd6bf03
...@@ -687,8 +687,10 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache); ...@@ -687,8 +687,10 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache);
static inline bool page_copy_sane(struct page *page, size_t offset, size_t n) static inline bool page_copy_sane(struct page *page, size_t offset, size_t n)
{ {
size_t v = n + offset; struct page *head = compound_head(page);
if (likely(n <= v && v <= (PAGE_SIZE << compound_order(page)))) size_t v = n + offset + page_address(page) - page_address(head);
if (likely(n <= v && v <= (PAGE_SIZE << compound_order(head))))
return true; return true;
WARN_ON(1); WARN_ON(1);
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册