Skip to content

Commit 7640131

Browse files
MJDSystorvalds
authored andcommitted
mm/mempool: avoid KASAN marking mempool poison checks as use-after-free
When removing an element from the mempool, mark it as unpoisoned in KASAN before verifying its contents for SLUB/SLAB debugging. Otherwise KASAN will flag the reads checking the element use-after-free writes as use-after-free reads. Signed-off-by: Matthew Dawson <matthew@mjdsystems.ca> Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2a4fb27 commit 7640131

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/mempool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ static void *remove_element(mempool_t *pool)
135135
void *element = pool->elements[--pool->curr_nr];
136136

137137
BUG_ON(pool->curr_nr < 0);
138-
check_element(pool, element);
139138
kasan_unpoison_element(pool, element);
139+
check_element(pool, element);
140140
return element;
141141
}
142142

0 commit comments

Comments
 (0)