KASAN accesses some slab related struct page fields so we need to convert it to struct slab. Some places are a bit simplified thanks to kasan_addr_to_slab() encapsulating the PageSlab flag check through virt_to_slab(). When resolving object address to either a real slab or a large kmalloc, use struct folio as the intermediate type for testing the slab flag to avoid unnecessary implicit compound_head(). [ vbabka@suse.cz: use struct folio, adjust to differences in previous patches ]
Showing the changes to include (1 of 9 files). Show all
Unified · Split
| @@ -9,6 +9,7 @@ · 8 unmodified lines | |||
| 9 | 9 | ||
| 10 | struct kmem_cache; | 10 | struct kmem_cache; |
| 11 | struct page; | 11 | struct page; |
| 12 | struct slab; | ||
| 12 | struct vm_struct; | 13 | struct vm_struct; |
| 13 | struct task_struct; | 14 | struct task_struct; |
| 14 | 15 | ||
| @@ -193,11 +194,11 @@ static __always_inline size_t kasan_metadata_size(struct kmem_cache *cache) · 178 unmodified lines | |||
| 193 | return 0; | 194 | return 0; |
| 194 | } | 195 | } |
| 195 | 196 | ||
| 196 | void __kasan_poison_slab(struct page *page); | 197 | void __kasan_poison_slab(struct slab *slab); |
| 197 | static __always_inline void kasan_poison_slab(struct page *page) | 198 | static __always_inline void kasan_poison_slab(struct slab *slab) |
| 198 | { | 199 | { |
| 199 | if (kasan_enabled()) | 200 | if (kasan_enabled()) |
| 200 | __kasan_poison_slab(page); | 201 | __kasan_poison_slab(slab); |
| 201 | } | 202 | } |
| 202 | 203 | ||
| 203 | void __kasan_unpoison_object_data(struct kmem_cache *cache, void *object); | 204 | void __kasan_unpoison_object_data(struct kmem_cache *cache, void *object); |
| @@ -322,7 +323,7 @@ static inline void kasan_cache_create(struct kmem_cache *cache, · 118 unmodified lines | |||
| 322 | slab_flags_t *flags) {} | 323 | slab_flags_t *flags) {} |
| 323 | static inline void kasan_cache_create_kmalloc(struct kmem_cache *cache) {} | 324 | static inline void kasan_cache_create_kmalloc(struct kmem_cache *cache) {} |
| 324 | static inline size_t kasan_metadata_size(struct kmem_cache *cache) { return 0; } | 325 | static inline size_t kasan_metadata_size(struct kmem_cache *cache) { return 0; } |
| 325 | static inline void kasan_poison_slab(struct page *page) {} | 326 | static inline void kasan_poison_slab(struct slab *slab) {} |
| 326 | static inline void kasan_unpoison_object_data(struct kmem_cache *cache, | 327 | static inline void kasan_unpoison_object_data(struct kmem_cache *cache, |
| 327 | void *object) {} | 328 | void *object) {} |
| 328 | static inline void kasan_poison_object_data(struct kmem_cache *cache, | 329 | static inline void kasan_poison_object_data(struct kmem_cache *cache, |