Why can't I crash my system with a fork bomb?

Plancton

Recently I've been digging up information about processes in GNU/Linux and I met the infamous fork bomb :

:(){ : | :& }; :

Theoretically, it is supposed to duplicate itself infinitely until the system runs out of resources...

However, I've tried testing both on a CLI Debian and a GUI Mint distro, and it doesn't seem to impact much the system. Yes there are tons of processes that are created, and after a while I read in console messages like :

bash: fork: Resource temporarily unavailable

bash: fork: retry: No child processes

But after some time, all the processes just get killed and everything goes back to normal. I've read that the ulimit set a maximum amount of process per user, but I can't seem to be able to raise it really far.

What are the system protections against a fork-bomb? Why doesn't it replicate itself until everything freezes or at least lags a lot? Is there a way to really crash a system with a fork bomb?

Hkoof

You probably have a Linux distro that uses systemd.

Systemd creates a cgroup for each user, and all processes of a user belong to the same cgroup.

Cgroups is a Linux mechanism to set limits on system resources like max number of processes, CPU cycles, RAM usage, etc. This is a different, more modern, layer of resource limiting than ulimit (which uses the getrlimit() syscall).

If you run systemctl status user-<uid>.slice (which represents the user's cgroup), you can see the current and maximum number of tasks (processes and threads) that is allowed within that cgroup.

$ systemctl status user-$UID.slice
● user-22001.slice - User Slice of UID 22001
   Loaded: loaded
  Drop-In: /usr/lib/systemd/system/user-.slice.d
           └─10-defaults.conf
   Active: active since Mon 2018-09-10 17:36:35 EEST; 1 weeks 3 days ago
    Tasks: 17 (limit: 10267)
   Memory: 616.7M

By default, the maximum number of tasks that systemd will allow for each user is 33% of the "system-wide maximum" (sysctl kernel.threads-max); this usually amounts to ~10,000 tasks. If you want to change this limit:

  • In systemd v239 and later, the user default is set via TasksMax= in:

    /usr/lib/systemd/system/user-.slice.d/10-defaults.conf
    

    To adjust the limit for a specific user (which will be applied immediately as well as stored in /etc/systemd/system.control), run:

    systemctl [--runtime] set-property user-<uid>.slice TasksMax=<value>
    

    The usual mechanisms of overriding a unit's settings (such as systemctl edit) can be used here as well, but they will require a reboot. For example, if you want to change the limit for every user, you could create /etc/systemd/system/user-.slice.d/15-limits.conf.

  • In systemd v238 and earlier, the user default is set via UserTasksMax= in /etc/systemd/logind.conf. Changing the value generally requires a reboot.

More info about this:

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I find why system can not run my application?

分類Dev

My spawning system doesn't work and I dont know why

分類Dev

Why can't I change system time to less than 1970?

分類Dev

Why can't I pass in system properties to elasticsearch on windows

分類Dev

Why can't I select cells in my WPF datagrid?

分類Dev

Why can't I use my column alias in WHERE clause?

分類Dev

Why can't I extend my desktop 12.04 in KDE?

分類Dev

Why can't I see remote video in my WebRTC app?

分類Dev

Why can't I open my txt file in Ubuntu?

分類Dev

Why can't I download my package through packagist?

分類Dev

Why can't I access my objects member variable?

分類Dev

Why is my javascript function not being invoked for simple MVC tutorial? Why can't I debug either?

分類Dev

Why I can't permanently remove these environment variables into an Ubuntu 18.04 system?

分類Dev

How can I fork a PPA

分類Dev

Why can't I copy a large number of files to my USB flash drive?

分類Dev

Why can't I match the last part of my regular expression in python?

分類Dev

Why can't I add static files in my django project when other static files are available in sources?

分類Dev

Why can't I define my variable with bracket notation in Angular 2

分類Dev

Why can't I put more then one dot in my JS calc

分類Dev

Why I can't use my classes from Models folder in Global.asax.cs?

分類Dev

Why, I can't update my react app hosted on Digital Ocean?

分類Dev

Why can't I access my JavaScript array by index outside of the d3 then function?

分類Dev

Why can't I find my express code at AWS EB'S EC2 instance?

分類Dev

Why can't I add the newtonsoft.Json.dll ref to my project?

分類Dev

Why can't I set a static IP address for my Linux box?

分類Dev

Why can't I see my USB drive during Windows 7 installation?

分類Dev

Why can't I access my private variable inside a function in PHP?

分類Dev

Why can't I parse the html result returned by my MVC partial view?

分類Dev

why I can't access my 3rd level CoreData data in swift?

Related 関連記事

  1. 1

    How can I find why system can not run my application?

  2. 2

    My spawning system doesn't work and I dont know why

  3. 3

    Why can't I change system time to less than 1970?

  4. 4

    Why can't I pass in system properties to elasticsearch on windows

  5. 5

    Why can't I select cells in my WPF datagrid?

  6. 6

    Why can't I use my column alias in WHERE clause?

  7. 7

    Why can't I extend my desktop 12.04 in KDE?

  8. 8

    Why can't I see remote video in my WebRTC app?

  9. 9

    Why can't I open my txt file in Ubuntu?

  10. 10

    Why can't I download my package through packagist?

  11. 11

    Why can't I access my objects member variable?

  12. 12

    Why is my javascript function not being invoked for simple MVC tutorial? Why can't I debug either?

  13. 13

    Why I can't permanently remove these environment variables into an Ubuntu 18.04 system?

  14. 14

    How can I fork a PPA

  15. 15

    Why can't I copy a large number of files to my USB flash drive?

  16. 16

    Why can't I match the last part of my regular expression in python?

  17. 17

    Why can't I add static files in my django project when other static files are available in sources?

  18. 18

    Why can't I define my variable with bracket notation in Angular 2

  19. 19

    Why can't I put more then one dot in my JS calc

  20. 20

    Why I can't use my classes from Models folder in Global.asax.cs?

  21. 21

    Why, I can't update my react app hosted on Digital Ocean?

  22. 22

    Why can't I access my JavaScript array by index outside of the d3 then function?

  23. 23

    Why can't I find my express code at AWS EB'S EC2 instance?

  24. 24

    Why can't I add the newtonsoft.Json.dll ref to my project?

  25. 25

    Why can't I set a static IP address for my Linux box?

  26. 26

    Why can't I see my USB drive during Windows 7 installation?

  27. 27

    Why can't I access my private variable inside a function in PHP?

  28. 28

    Why can't I parse the html result returned by my MVC partial view?

  29. 29

    why I can't access my 3rd level CoreData data in swift?

ホットタグ

アーカイブ