Bug 23740

Summary: kernel DoS tha could be executed by any user
Product: Base System Reporter: iasenkk <iasenkk>
Component: kernAssignee: silby
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description iasenkk 2000-12-22 01:20:01 UTC
int main()
{
     while(1) fork();
     return(1);
}
it produces kernel panic (kernel resources exhausted)

Fix: 

just report for now
How-To-Repeat: int main()
{
     while(1) fork();
     return(1);
}
compile and run
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2000-12-22 09:19:45 UTC
State Changed
From-To: open->closed

Yet Another Fork Bomb PR.
Comment 2 des 2000-12-22 09:20:56 UTC
iasenkk@hotmail.com writes:
> int main()
> {
>      while(1) fork();
>      return(1);
> }
> it produces kernel panic (kernel resources exhausted)

That's what resource limits are for. 'man login.conf'.

DES
-- 
Dag-Erling Smorgrav - des@ofug.org
Comment 3 iasenkk 2000-12-22 09:45:27 UTC
I don't think that is the way it should be done (login.conf)
The kernel shoul have its own protection ! Even agains super user. He
can do something wrong and it will break up the whole system. I mean it
because the kernel in one of my experiments coulnd not even reboot . It
said "panic" and that was all no syncing no auto reboot !
Comment 4 iasenkk 2000-12-22 09:59:35 UTC
Addon :)

I think that the kernel should not execute "panic" but to manage some
how with the problem.
And also I think it's not just fork problem , but "memory allocation" or
"user limits check" problem.
Comment 5 Peter Pentchev 2000-12-22 10:08:46 UTC
On Fri, Dec 22, 2000 at 02:00:01AM -0800, Charlie Root wrote:
> The following reply was made to PR kern/23740; it has been noted by GNATS.
> 
> From: Charlie Root <iasenkk@hotmail.com>
> To: freebsd-gnats-submit@FreeBSD.org, iasenkk@hotmail.com
> Cc:  
> Subject: Re: kern/23740: kernel DoS tha could be executed by any user
> Date: Fri, 22 Dec 2000 11:59:35 +0200
> 
>  Addon :)
>  
>  I think that the kernel should not execute "panic" but to manage some
>  how with the problem.
>  And also I think it's not just fork problem , but "memory allocation" or
>  "user limits check" problem.

Uhm - "user limits check" problem?  Right on!  So you think the kernel
should enforce some kind of limits - you're exactly right.  There should
be a way to tell it what to do, what limits to impose on what users,
now wouldn't that be a nice idea!  Uh.. wait.. it already does that..
man 5 login.conf :)

How exactly do you expect the kernel to know which limits to impose
on what users 'by itself'?  login.conf *is* the way to tell it.

G'luck,
Peter

-- 
Hey, out there - is it *you* reading me, or is it someone else?
Comment 6 iasenkk 2000-12-22 10:31:54 UTC
OK for user limits let it be so , but memory allocation ?
And FreeBSD 4.0 doesn't do it that way (just table is full or some
thing) and nothing more
no panic no lockups that could beak up your file system.
Comment 7 Peter Pentchev freebsd_committer freebsd_triage 2000-12-26 11:13:42 UTC
State Changed
From-To: closed->analyzed

As several people pointed out, this *is* a problem - a resource shortage 
should not cause a kernel panic.  I have so far traced it to the good old 
maxusers=128 problem; I'll do some more tests to isolate a minimal test 
case, and then unleash this PR unto the unsuspecting world. 

(I hereby officially proclaim my lack of life - just like Michael C. Wu 
(keichii) described himself in a posting to -arch, I analyzed this issue 
between 1 and 5am in the cold winter morning of Dec 25..)
Comment 8 alex freebsd_committer freebsd_triage 2001-05-29 13:35:37 UTC
Responsible Changed
From-To: freebsd-bugs->roam

roam was working on this one
Comment 9 silby freebsd_committer freebsd_triage 2002-02-12 07:53:58 UTC
Responsible Changed
From-To: roam->silby

I have this almost tackled, an effective fix will appear in the tree soon.
Comment 10 silby freebsd_committer freebsd_triage 2002-03-07 04:52:55 UTC
State Changed
From-To: analyzed->closed

The base problem here was that with a large maxproc value, 
processes will cause all kmaps to be exhausted and a panic 
will ensue. 

One simple way to avoid this problem is to keep maxusers <= 
the MB of ram in your system.  As people may exceed this setting 
for other reasons, I have added changes so that maxproc 
will not be allowed to grow large enough to cause panics.