public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Dane Mutters <dmutters@gmail.com>,
	Martin Olsson <mnemo@minimum.se>,
	linux-kernel@vger.kernel.org
Subject: Re: Is it possible to give the user the option to cancel forkbombs?
Date: Sat, 17 Nov 2007 14:36:10 +0100	[thread overview]
Message-ID: <p737ikhat9x.fsf@bingen.suse.de> (raw)
In-Reply-To: <20071117103922.12f3823b@the-village.bc.nu> (Alan Cox's message of "Sat\, 17 Nov 2007 10\:39\:22 +0000")

Alan Cox <alan@lxorguk.ukuu.org.uk> writes:

>> > I would like to see something done about this, with Ubuntu as popular as
>> > it is, even as a server in some cases.  Is there a way that in the
>> > future, one could simply download a package or click a box or something
>> > and have a limit set, like the links suggest?  That would make things
>> > just "that much" more convenient for system administrators (and might
>> > help them/us to remember to set these limits, too...).
>> 
>> If you don't know which limits to set and need a package for them, your
>> job title should not be system administrator.
>
> Thats a very arrogant viewpoint. I don't have to be a TV engineer to use
> my television.
>
> Distributions should be providing sensible defaults out of the box. The
> kernel already provides them the mechanisms.

If you mean ulimits -- the current ulimits are not very useful imho.   Or 
at least not for handling the general resource resumption problem. They
work in some limited circumstances for well known special purpose workloads,
but not more. 

I don't know why people here always claiming they are (have they ever
tried to use them on your desktop in general?).

The equation to limit resources is something like:

MAX_PROCESSES_PER_UID*(MAX_MEM_PER_PROCESS+MAX_FD_PER_PROCESS+...)=TOTAL_RESOURCES_UID

To get an effective limit you either need MAX_PROCESSES or MAX_MEM to unusable
low numbers breaking a lot of applications. And you cannot generally predict 
in advance if the workload will need high MAX_MEM or high MAX_PROCESSES
or a combination of both.

That is why distributions usually don't set them. Or at least not for
in a setup to protect the system fully because that is not possible.

e.g. SUSE supports a optional default limit that sets the max memory
per process to below the available memory, but the user can still
easily circumvent that by starting multiple processes.

And I'm not really talking about a general bean counter for all kernel
objects here, just the "ordinary easy resources" like processes and virtual
memory.

Pretty much all the per process limits would need to be per uid to be really
useful in general. I'm hoping that we'll get some of that out of the recent
container work. e.g. if there was a "max mem per uid" then you could actually
set it to a sensible value. Even better than max mem per uid would be probably
"max total memory used as fraction of the system" or something like that --
that would also handle things like memory hotplug etc. well. Probably
would also need to be separated into swap space and real memory; at least
as long as the Linux swap algorithms are so slow.

Regarding the fork bomb problem: 

the uid cgroup scheduler that went in recently should already help a little,
although to be really effective against fork bombs for a desktop user you
would probably need multiple cgroups per uid (so e.g. that the window
manager is also protected against other processes running on the same
uid and you can then still kill the nasty processes from it).

That is why I didn't like hardcoding the uid in the scheduler too much.

-Andi

  reply	other threads:[~2007-11-17 13:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-17  5:51 Is it possible to give the user the option to cancel forkbombs? Martin Olsson
2007-11-16 21:31 ` Alan Cox
2007-11-17  7:04   ` Martin Olsson
2007-11-16 23:46     ` Alan Cox
2007-11-17  6:45     ` Dane Mutters
2007-11-17  7:44       ` Peter Zijlstra
2007-11-17 10:39         ` Alan Cox
2007-11-17 13:36           ` Andi Kleen [this message]
2007-11-17 15:28             ` Herbert Xu
2007-11-17 17:42         ` Martin Olsson
2007-11-17 10:03           ` Peter Zijlstra
2007-11-17 15:53           ` Diego Calleja
2007-11-17 17:55             ` Dane Mutters
2007-11-23  7:34               ` Radoslaw Szkodzinski
2007-11-22  0:05     ` (``-_-´´) -- Fernando
2007-11-22 12:03       ` David Newall
2007-11-16 21:38 ` Diego Calleja

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=p737ikhat9x.fsf@bingen.suse.de \
    --to=andi@firstfloor.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dmutters@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mnemo@minimum.se \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox