You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
mm: page_alloc: add kasan hooks on alloc and free paths
Add kernel address sanitizer hooks to mark allocated page's addresses as accessible in corresponding shadow region. Mark freed pages as inaccessible. Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Konstantin Serebryany <kcc@google.com> Cc: Dmitry Chernenkov <dmitryc@google.com> Signed-off-by: Andrey Konovalov <adech.fo@gmail.com> Cc: Yuri Gribov <tetra2005@gmail.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Cc: Sasha Levin <sasha.levin@oracle.com> Cc: Christoph Lameter <cl@linux.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
ef7f0d6a6c
commit
b8c73fc249
@@ -254,6 +254,20 @@ static __always_inline void check_memory_region(unsigned long addr,
|
||||
kasan_report(addr, size, write, _RET_IP_);
|
||||
}
|
||||
|
||||
void kasan_alloc_pages(struct page *page, unsigned int order)
|
||||
{
|
||||
if (likely(!PageHighMem(page)))
|
||||
kasan_unpoison_shadow(page_address(page), PAGE_SIZE << order);
|
||||
}
|
||||
|
||||
void kasan_free_pages(struct page *page, unsigned int order)
|
||||
{
|
||||
if (likely(!PageHighMem(page)))
|
||||
kasan_poison_shadow(page_address(page),
|
||||
PAGE_SIZE << order,
|
||||
KASAN_FREE_PAGE);
|
||||
}
|
||||
|
||||
#define DEFINE_ASAN_LOAD_STORE(size) \
|
||||
void __asan_load##size(unsigned long addr) \
|
||||
{ \
|
||||
|
||||
Reference in New Issue
Block a user