Anon Sricharoenchai wrote:
> I have tested the "fork" and so called "copy-on-write" operation by
> invoking the following command (as a normal user, not superuser).

> perl -e '$| = 1; sub s1() { system("free -t | tail -1") } s1(); for ($i =
> 0; $i<10_000_000; $i++) { $a[$i] = 0 } s1(); if (\!fork()) { s1(); for ($i
> = 0; $i<scalar(@a); $i+=300) { $a[$i] = 0 } s1() } else { wait() }'

> First of all, suppose that my machine has 300M of free memory.
> Then I allocate array of 10,000,000 integer elements, that will eat
> memory about 200M.  Now, the amount of free memory is 100M.
> Then I fork() 1 time, and let the child process to write on the allocated
> array to force the "copy-on-write" operation.
> But the free memory is not enough to "copy-on-write" the whole of
> allocated array.  So, the system will run out of memory and crash.
> And I can't find any method to recover my system without reseting the
> hardware.

> How can I protect this crash ?

User quotas. You will axe the child process but keep the rest of your system
intact. This also works (on ext2 partitions at least) against fill-up-the-disk
attacks.

-- 
We are sorry, but the number you have dialed is imaginary. 
Please rotate your phone 90 degrees and try again. -- David Grabiner

Reply via email to