diff -uNr modutils-2.3.21/insmod/modprobe.c modutils-2.3.21.SuSE/insmod/modprobe.c --- modutils-2.3.21/insmod/modprobe.c Tue Nov 21 10:10:54 2000 +++ modutils-2.3.21.SuSE/insmod/modprobe.c Wed Nov 29 00:39:54 2000 @@ -363,6 +363,9 @@ return desc; } +/* KG, 2000-11-29: Limit recursion in build_stack() */ +#define BSTACKRECMAX 128 +static int bstackrecurs = 0; /* * Create a linked list of the stack of modules needed in the kernel * in order to satisfy a request for "name" @@ -395,6 +398,15 @@ if (rev && strcmp(rev->kname, desc->kname) == 0) return 0; + if (++bstackrecurs > BSTACKRECMAX) { + fprintf (stderr, "modprobe: Too deep recursion in module dependencies!\n"); + fprintf (stderr, "modprobe: Circular dependency?"); + for (lp = *stack; lp; lp = lp->next) + fprintf (stderr, " %s", lp->item.d->kname); + fprintf (stderr, "\n"); + abort (); + } + /* * Get the modules that this one should pull in * according to modules.conf ("above") @@ -414,7 +426,7 @@ rev ? rev : desc, MODE_ABOVE, 1); if (r < 0) - return r; + { bstackrecurs--; return r; } } } } @@ -424,7 +436,7 @@ if (strcmp(desc->kname, lp->item.d->kname) == 0) { /* Avoid infinite loops ("above") */ if (rev && rev == lp->item.d) - return 0; + { bstackrecurs--; return 0; } /* else */ /* Remove the entry, it is in the wrong place */ if (prev) @@ -452,7 +464,7 @@ dir, rev, MODE_BELOW, 1)) < 0) - return r; + { bstackrecurs--; return r; } } } } @@ -465,10 +477,10 @@ for (nod = desc->nod->dep; nod; nod = nod->next) { if ((r = build_stack(stack, nod->key, nod->str, dir, rev, MODE_NORMAL, 0)) < 0) - return r; + { bstackrecurs--; return r; } } - return 0; + bstackrecurs--; return 0; } /* For debugging */