mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] slab: ensure cache_alloc_refill terminates
@ 2007-02-19  8:22 Pekka J Enberg
  2007-02-19  8:48 ` KAMEZAWA Hiroyuki
  2007-02-20  5:05 ` Christoph Lameter
  0 siblings, 2 replies; 8+ messages in thread
From: Pekka J Enberg @ 2007-02-19  8:22 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, mcr, clameter

From: Pekka Enberg <penberg@cs.helsinki.fi>

If slab->inuse is corrupted, cache_alloc_refill can enter an infinite
loop as detailed by Michael Richardson in the following post:
<http://lkml.org/lkml/2007/2/16/292>.

This patch adds a BUG_ON for the case where a slab in partial or free
list has no available objects for allocation to ensure
cache_alloc_refill terminates.

Cc: Michael Richardson <mcr@sandelman.ca>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 mm/slab.c |    8 ++++++++
 1 file changed, 8 insertions(+)

Index: 2.6/mm/slab.c
===================================================================
--- 2.6.orig/mm/slab.c	2007-02-19 09:58:28.000000000 +0200
+++ 2.6/mm/slab.c	2007-02-19 10:19:20.000000000 +0200
@@ -2987,6 +2987,14 @@
 		slabp = list_entry(entry, struct slab, list);
 		check_slabp(cachep, slabp);
 		check_spinlock_acquired(cachep);
+
+		/*
+		 * The slab was either on partial or free list so
+		 * there must be at least one object available for
+		 * allocation.
+		 */
+		BUG_ON(slabp->inuse >= cachep->num);
+
 		while (slabp->inuse < cachep->num && batchcount--) {
 			STATS_INC_ALLOCED(cachep);
 			STATS_INC_ACTIVE(cachep);

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH] slab: ensure cache_alloc_refill terminates
@ 2007-02-21  8:30 Pekka J Enberg
  2007-02-21 17:51 ` Christoph Lameter
  0 siblings, 1 reply; 8+ messages in thread
From: Pekka J Enberg @ 2007-02-21  8:30 UTC (permalink / raw)
  To: akpm; +Cc: mcr, clameter, linux-kernel

From: Pekka Enberg <penberg@cs.helsinki.fi>

If slab->inuse is corrupted, cache_alloc_refill can enter an infinite
loop as detailed by Michael Richardson in the following post:
<http://lkml.org/lkml/2007/2/16/292>. This adds a BUG_ON to catch
those cases.

Cc: Michael Richardson <mcr@sandelman.ca>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 mm/slab.c |    8 ++++++++
 1 file changed, 8 insertions(+)

Index: 2.6/mm/slab.c
===================================================================
--- 2.6.orig/mm/slab.c	2007-02-19 15:15:17.000000000 +0200
+++ 2.6/mm/slab.c	2007-02-20 08:39:26.000000000 +0200
@@ -2987,6 +2987,14 @@
 		slabp = list_entry(entry, struct slab, list);
 		check_slabp(cachep, slabp);
 		check_spinlock_acquired(cachep);
+
+		/*
+		 * The slab was either on partial or free list so
+		 * there must be at least one object available for
+		 * allocation.
+		 */
+		BUG_ON(slabp->inuse < 0 || slabp->inuse >= cachep->num);
+
 		while (slabp->inuse < cachep->num && batchcount--) {
 			STATS_INC_ALLOCED(cachep);
 			STATS_INC_ACTIVE(cachep);

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-02-21 18:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19  8:22 [PATCH] slab: ensure cache_alloc_refill terminates Pekka J Enberg
2007-02-19  8:48 ` KAMEZAWA Hiroyuki
2007-02-19  8:58   ` Pekka J Enberg
2007-02-20  5:05 ` Christoph Lameter
2007-02-21  8:30 Pekka J Enberg
2007-02-21 17:51 ` Christoph Lameter
2007-02-21 18:22   ` Pekka Enberg
2007-02-21 18:28     ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®