Commit 5a3446d8 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] slab poison checking fix

Spotted by Andries Brouwer.  There's one place where slab is calling
check_poison_obj() but not reporting on any detected failure.

We used to go BUG() in there.  Convert it over to the kinder, gentler
slab_error() regime.
parent cd9ab8c2
...@@ -769,7 +769,7 @@ static void poison_obj(kmem_cache_t *cachep, void *addr, unsigned char val) ...@@ -769,7 +769,7 @@ static void poison_obj(kmem_cache_t *cachep, void *addr, unsigned char val)
*(unsigned char *)(addr+size-1) = POISON_END; *(unsigned char *)(addr+size-1) = POISON_END;
} }
static int check_poison_obj (kmem_cache_t *cachep, void *addr) static void check_poison_obj(kmem_cache_t *cachep, void *addr)
{ {
int size = cachep->objsize; int size = cachep->objsize;
void *end; void *end;
...@@ -779,8 +779,7 @@ static int check_poison_obj (kmem_cache_t *cachep, void *addr) ...@@ -779,8 +779,7 @@ static int check_poison_obj (kmem_cache_t *cachep, void *addr)
} }
end = memchr(addr, POISON_END, size); end = memchr(addr, POISON_END, size);
if (end != (addr+size-1)) if (end != (addr+size-1))
return 1; slab_error(cachep, "object was modified after freeing");
return 0;
} }
#endif #endif
...@@ -1628,8 +1627,7 @@ cache_alloc_debugcheck_after(kmem_cache_t *cachep, ...@@ -1628,8 +1627,7 @@ cache_alloc_debugcheck_after(kmem_cache_t *cachep,
if (!objp) if (!objp)
return objp; return objp;
if (cachep->flags & SLAB_POISON) if (cachep->flags & SLAB_POISON)
if (check_poison_obj(cachep, objp)) check_poison_obj(cachep, objp);
BUG();
if (cachep->flags & SLAB_RED_ZONE) { if (cachep->flags & SLAB_RED_ZONE) {
/* Set alloc red-zone, and check old one. */ /* Set alloc red-zone, and check old one. */
if (xchg((unsigned long *)objp, RED_ACTIVE) != RED_INACTIVE) if (xchg((unsigned long *)objp, RED_ACTIVE) != RED_INACTIVE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment