Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is possible to protect from forkbomb?

I do not want that user different from root can to kill my machine with a forkbomb

share|improve this question

migrated from stackoverflow.com Feb 3 '11 at 12:01

This question came from our site for professional and enthusiast programmers.

2  
I pasted your title into Google; the first hit answers your question. –  Marcelo Cantos Feb 3 '11 at 11:35
1  
You are right. I have tried to search with google in my language only –  Ritardi Giuseppe Feb 3 '11 at 11:40
2  
@Marcelo: Please don't leave such comments‌​. –  Dennis Williamson Feb 3 '11 at 15:53
    
@Dennis: Why not? It's a basic question that has very good answers all over the web that aren't at all difficult to find. –  Marcelo Cantos Feb 4 '11 at 4:48
    
@Marcelo: My comment has a link with a good discussion of the reasons. If nothing else, we want this to be the destination that Google leads to. Stack Exchange is not only about getting Person A's question answered; it's also about Persons B-ZZZ who come along after. –  Dennis Williamson Feb 4 '11 at 5:14

3 Answers 3

You can set a user-specific process limit with setrlimit() on Linux systems. If you are using Ubuntu, for example, you can change the limit in /etc/security/limits.conf

share|improve this answer

In Ubuntu (or any other distro that has PAM module pam_limits enabled) you can limit the amount of processes a user can have. You can do this by editing /etc/security/limits.conf.

For example to limit the amount (20 procs as a maximum) of processes user "foo" and group "bar" you would add

foo    hard    nproc   20
@bar   hard    nproc   20

You can also do this by ulimit or setrlimit.

share|improve this answer

In addition to the other two answers (vtorhonen and hrnt), that refer to system-wide limits, I add that under bash you can limit the number of processes using the builtin ulimit:

ulimit -u N

where N is the number of processes that can be spawned using this shell.

This might be effective for you because you place the limitation only for the malicious user.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.