From 39b92caa8ad07e218b29427363b584f1dd59e9bc Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 10 Mar 2003 19:54:41 -0800 Subject: [PATCH] [PATCH] fix kmem_cache_size() for new slab poisoning The new slab poisoning code broke kmem_cache_size(), it now returns a too large size as the poisoning area after the object is includes. XFS's kmem_zone_zalloc thus overwrites exactly that area and triggers the new checks everytime such an object is freed again. I don't recommend using XFS on BK-current without this patch applied :) --- mm/slab.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index bd7871f4aee9e..db8c96c499479 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2041,11 +2041,16 @@ kfree_percpu(const void *objp) unsigned int kmem_cache_size(kmem_cache_t *cachep) { + unsigned int objlen = cachep->objsize; + #if DEBUG if (cachep->flags & SLAB_RED_ZONE) - return (cachep->objsize - 2*BYTES_PER_WORD); + objlen -= 2*BYTES_PER_WORD; + if (cachep->flags & SLAB_STORE_USER) + objlen -= BYTES_PER_WORD; #endif - return cachep->objsize; + + return objlen; } kmem_cache_t * kmem_find_general_cachep (size_t size, int gfpflags) -- 2.53.0