mm-kfence-insert-kfence-hooks-for-slub.patch removed from -mm tree
The patch titled
Subject: mm, kfence: insert KFENCE hooks for SLUB
has been removed from the -mm tree. Its filename was
mm-kfence-insert-kfence-hooks-for-slub.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Alexander Potapenko <[email protected]>
Subject: mm, kfence: insert KFENCE hooks for SLUB
Inserts KFENCE hooks into the SLUB allocator.
To pass the originally requested size to KFENCE, add an argument 'orig_size' to slab_alloc*(). The additional argument is required to preserve the requested original size for kmalloc() allocations, which uses size classes (e.g. an allocation of 272 bytes will return an object of size 512). Therefore, kmem_cache::size does not represent the kmalloc-caller's requested size, and we must introduce the argument 'orig_size' to propagate the originally requested size to KFENCE.
Without the originally requested size, we would not be able to detect out-of-bounds accesses for objects placed at the end of a KFENCE object page if that object is not equal to the kmalloc-size class it was bucketed into.
When KFENCE is disabled, there is no additional overhead, since slab_alloc*() functions are __always_inline.
---
include/linux/slub_def.h | 3 + mm/kfence/core.c | 2 + mm/slub.c | 60 ++++++++++++++++++++++++++++--------- 3 files changed, 51 insertions(+), 14 deletions(-)
include/linux/slub_def.h renamed from include/linux/slub_def.h~mm-kfence-insert-kfence-hooks-for-slub +3 -0
@@ -7,6 +7,7 @@* * (C) 2007 SGI, Christoph Lameter */ +#include <linux/kfence.h> #include <linux/kobject.h> #include <linux/reciprocal_div.h>
@@ -185,6 +186,8 @@ static inline unsigned int __obj_to_indestatic inline unsigned int obj_to_index (const struct kmem_cache *cache,const struct page *page,void *obj) { +if (is_kfence_address (obj)) +return 0 ;return __obj_to_index (cache,page_address (page), obj); }
mm/kfence/core.c renamed from mm/kfence/core.c~mm-kfence-insert-kfence-hooks-for-slub +2 -0
@@ -317,6 +317,8 @@ static void *kfence_guarded_alloc(struct/* Set required struct page fields. */ page =virt_to_page (meta->addr); page->slab_cache = cache; +if (IS_ENABLED (CONFIG_SLUB )) + page->objects =1 ;if (IS_ENABLED (CONFIG_SLAB )) page->s_mem = addr;
mm/slub.c renamed from mm/slub.c~mm-kfence-insert-kfence-hooks-for-slub +46 -14
176 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are