mm, kasan: account for object redzone in SLUB's nearest_obj()
[cascardo/linux.git] / include / linux / slub_def.h
index d1faa01..cf501cf 100644 (file)
@@ -99,6 +99,11 @@ struct kmem_cache {
         */
        int remote_node_defrag_ratio;
 #endif
+
+#ifdef CONFIG_SLAB_FREELIST_RANDOM
+       unsigned int *random_seq;
+#endif
+
        struct kmem_cache_node *node[MAX_NUMNODES];
 };
 
@@ -114,15 +119,17 @@ static inline void sysfs_slab_remove(struct kmem_cache *s)
 void object_err(struct kmem_cache *s, struct page *page,
                u8 *object, char *reason);
 
+void *fixup_red_left(struct kmem_cache *s, void *p);
+
 static inline void *nearest_obj(struct kmem_cache *cache, struct page *page,
                                void *x) {
        void *object = x - (x - page_address(page)) % cache->size;
        void *last_object = page_address(page) +
                (page->objects - 1) * cache->size;
-       if (unlikely(object > last_object))
-               return last_object;
-       else
-               return object;
+       void *result = (unlikely(object > last_object)) ? last_object : object;
+
+       result = fixup_red_left(cache, result);
+       return result;
 }
 
 #endif /* _LINUX_SLUB_DEF_H */