08 Nov 2008 @ 3:13 PM 
 

Typed LS and system crashed

 

Our college is know forĀ  open source software support.There are few geeks out there who like to play with Linux and open source software’s . Once durin our OS and Networking Lab , a friend of mine typed LS command ( ls is a basic command in Linux to list directory contents) and his system froze, which usually never happens.As i told u before there r geeks out there who like to play, has aliased the command to execute a fork bomb.

Now wat this fork bomb.
:(){ :|:& };:

Does this look like a command ? yes it is and is called a fork bomb.
i did a small research in that .This wat i understood from that command

:(){ :|:& };:

- function name of our newly defined function
- parentheses declare a function
- block begins
- call self recursively
- open a pipe to another process
- call self recursively
- fork
- block ends
- end function declaration
- runs the function

as there is a saying necessity is mother of all invention.I was wondering how to protect from it .Its not that harmful ,just a reboot will do the job.Still there will be something in it.Google around found abt a ulimit command , ofcourse next is man ulimit (once my senior said rtfm to me :D ,from that day i changed)

ulimit -a
All current limits are reported.

its output for my system is like this

nikil@nikil-laptop:~$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 24563
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 24563
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited;

forking actually creates a new process.From that we can get the solution if we r able to limit the number of process for a system ,then system will not crash.
now the next step is how to limit the number of process.From above i have a maximum user processes is 24563. i need to reset to small number. there is a configuration file /etc/security/limits.conf
Contains complete details in that ,after reading i edited the file as

*               hard    nproc           100

100 processes should be enough ,now running the fork bomb now
will generate errors, but u will not need a reboot

finally if u want to try the LS command check out this page

http://vivtech.blogspot.com/2008/08/fork-bomb-deployment.html

Tags Tags: ,
Categories: GNU/Linux
Posted By: borngold
 

Responses to this post » (None)

 


Comments are open. Feel free to leave a comment below.


 Comment Meta:
RSS Feed for comments
TrackBack URI
 

Leave A Comment ...

 

 XHTML:
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
\/ More Options ...
Not Logged In.
  • Role »
  • Posts »
  • Comments »
Change Theme...
  • VoidVoid (Default)
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LiteLightweight