]> git.baikalelectronics.ru Git - kernel.git/commit
page_pool: mask the page->signature before the checking
authorYunsheng Lin <linyunsheng@huawei.com>
Fri, 6 Aug 2021 01:39:07 +0000 (09:39 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 Aug 2021 09:03:02 +0000 (10:03 +0100)
commit6fe6fd0f3c2a64b6ac3cdd8f7c8e7617964908c9
tree90e700c7c4e93410acc9dd0141324467edff945a
parent2a523c9a9573a18dab65dc2aafbc5c01ef27d651
page_pool: mask the page->signature before the checking

As mentioned in commit 8a20ff88f4b8 ("mm: add a signature in
struct page"):
"The page->signature field is aliased to page->lru.next and
page->compound_head."

And as the comment in page_is_pfmemalloc():
"lru.next has bit 1 set if the page is allocated from the
pfmemalloc reserves. Callers may simply overwrite it if they
do not need to preserve that information."

The page->signature is OR’ed with PP_SIGNATURE when a page is
allocated in page pool, see __page_pool_alloc_pages_slow(),
and page->signature is checked directly with PP_SIGNATURE in
page_pool_return_skb_page(), which might cause resoure leaking
problem for a page from page pool if bit 1 of lru.next is set
for a pfmemalloc page. What happens here is that the original
pp->signature is OR'ed with PP_SIGNATURE after the allocation
in order to preserve any existing bits(such as the bit 1, used
to indicate a pfmemalloc page), so when those bits are present,
those page is not considered to be from page pool and the DMA
mapping of those pages will be left stale.

As bit 0 is for page->compound_head, So mask both bit 0/1 before
the checking in page_pool_return_skb_page(). And we will return
those pfmemalloc pages back to the page allocator after cleaning
up the DMA mapping.

Fixes: 1592101ea54b ("page_pool: Allow drivers to hint on SKB recycling")
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/page_pool.c