Re: Q: memory management

Peter Horton (pdh@berserk.demon.co.uk)
Wed, 3 Jun 1998 19:00:51 +0100 (BST)


On Tue, 2 Jun 1998, Andrea Arcangeli wrote:

> On Tue, 2 Jun 1998, Peter Horton wrote:
>
> >The machine didn't thrash at all. It quickly filled up all memory, and
> >then all the swap. Then it locked. What does the kernel do when it needs a
> >page, and all of the pages (including swap) are used ? I kinda assumed
> >that it would just kill the process ...
>
> Could you try to write the shorter exploit that locks your machine and
> post it here (or to me if it will result over some kbyte of size)?
>
> To know if your machine is locked at hardware level you can easily press
> ALT+SCROLL-LOCK and report if it print something on the _console_ (don' t
> do that under X).
>
> Andrea[s] Arcangeli
>

This is the code. Not much too it.

The machine doesn't lock up as the virtual console switching is still
working, but all processes seem to stop. After a couple of minutes like
this SHIFT+SCROLL-LOCK reports approx 140KB of free pages. The machine
doesn't seem to want to come out of this state, even if I leave if for 15
minutes.

-----------------------------------------------------------

#include <stdio.h>
#include <unistd.h>

#define ONE_MB (1 << 20)
#define PAGE (0x1000)

char *b[0x1000];

int main(int argc, char *argv[])
{
int i, j;

i = -1;
do
{
b[++i] = sbrk(ONE_MB);
}
while(b[i] != (char *) -1);

printf("allocated %dMB\n", i);

while(i--)
{
for(j = 0; j < ONE_MB; j += PAGE)
{
b[i][j] = 0xaa;
}
printf(".");
fflush(stdout);
}
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu