diff options
| author | Feng Tang <feng.tang@intel.com> | 2024-09-11 14:45:31 +0800 |
|---|---|---|
| committer | Vlastimil Babka <vbabka@suse.cz> | 2024-10-29 10:43:23 +0100 |
| commit | fb5eda0dfe2256b468fc4e95207a4df88457274f (patch) | |
| tree | baf6e79edd6c08dd02fd3f985507a5b1323397f5 /mm/slab.h | |
| parent | 704573851b51808b45dae2d62059d1d8189138a2 (diff) | |
| download | tip-fb5eda0dfe2256b468fc4e95207a4df88457274f.tar.gz | |
mm/kasan: Don't store metadata inside kmalloc object when slub_debug_orig_size is on
For a kmalloc object, when both kasan and slub redzone sanity check
are enabled, they could both manipulate its data space like storing
kasan free meta data and setting up kmalloc redzone, and may affect
accuracy of that object's 'orig_size'.
As an accurate 'orig_size' will be needed by some function like
krealloc() soon, save kasan's free meta data in slub's metadata area
instead of inside object when 'orig_size' is enabled.
This will make it easier to maintain/understand the code. Size wise,
when these two options are both enabled, the slub meta data space is
already huge, and this just slightly increase the overall size.
Signed-off-by: Feng Tang <feng.tang@intel.com>
Acked-by: Andrey Konovalov <andreyknvl@gmail.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Diffstat (limited to 'mm/slab.h')
| -rw-r--r-- | mm/slab.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/slab.h b/mm/slab.h index 6c6fe6d630ce3d..2985670194857e 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -695,6 +695,12 @@ void __kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct slab *slab) void __check_heap_object(const void *ptr, unsigned long n, const struct slab *slab, bool to_user); +static inline bool slub_debug_orig_size(struct kmem_cache *s) +{ + return (kmem_cache_debug_flags(s, SLAB_STORE_USER) && + (s->flags & SLAB_KMALLOC)); +} + #ifdef CONFIG_SLUB_DEBUG void skip_orig_size_check(struct kmem_cache *s, const void *object); #endif |
