Skip to content

Commit c966813

Browse files
committed
Merge tag 'slab-for-6.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab
Pull slab fix from Vlastimil Babka: - Fix mempool poisoning order>0 pages with CONFIG_HIGHMEM (Vlastimil Babka) * tag 'slab-for-6.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab: mm/mempool: fix poisoning order>0 pages with HIGHMEM
2 parents 07e09c3 + ec33b59 commit c966813

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

mm/mempool.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,20 @@ static void check_element(mempool_t *pool, void *element)
6868
} else if (pool->free == mempool_free_pages) {
6969
/* Mempools backed by page allocator */
7070
int order = (int)(long)pool->pool_data;
71-
void *addr = kmap_local_page((struct page *)element);
7271

73-
__check_element(pool, addr, 1UL << (PAGE_SHIFT + order));
74-
kunmap_local(addr);
72+
#ifdef CONFIG_HIGHMEM
73+
for (int i = 0; i < (1 << order); i++) {
74+
struct page *page = (struct page *)element;
75+
void *addr = kmap_local_page(page + i);
76+
77+
__check_element(pool, addr, PAGE_SIZE);
78+
kunmap_local(addr);
79+
}
80+
#else
81+
void *addr = page_address((struct page *)element);
82+
83+
__check_element(pool, addr, PAGE_SIZE << order);
84+
#endif
7585
}
7686
}
7787

@@ -97,10 +107,20 @@ static void poison_element(mempool_t *pool, void *element)
97107
} else if (pool->alloc == mempool_alloc_pages) {
98108
/* Mempools backed by page allocator */
99109
int order = (int)(long)pool->pool_data;
100-
void *addr = kmap_local_page((struct page *)element);
101110

102-
__poison_element(addr, 1UL << (PAGE_SHIFT + order));
103-
kunmap_local(addr);
111+
#ifdef CONFIG_HIGHMEM
112+
for (int i = 0; i < (1 << order); i++) {
113+
struct page *page = (struct page *)element;
114+
void *addr = kmap_local_page(page + i);
115+
116+
__poison_element(addr, PAGE_SIZE);
117+
kunmap_local(addr);
118+
}
119+
#else
120+
void *addr = page_address((struct page *)element);
121+
122+
__poison_element(addr, PAGE_SIZE << order);
123+
#endif
104124
}
105125
}
106126
#else /* CONFIG_SLUB_DEBUG_ON */

0 commit comments

Comments
 (0)