From nobody@FreeBSD.org  Wed Jul 19 23:19:22 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 6AE8916A4E1
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Jul 2006 23:19:22 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 391DA43D45
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Jul 2006 23:19:22 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k6JNJMV3013858
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Jul 2006 23:19:22 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k6JNJM7Y013857;
	Wed, 19 Jul 2006 23:19:22 GMT
	(envelope-from nobody)
Message-Id: <200607192319.k6JNJM7Y013857@www.freebsd.org>
Date: Wed, 19 Jul 2006 23:19:22 GMT
From: Roberto Lima <roberto@forbrazil.com.br>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] top -s0 causes load excessive
X-Send-Pr-Version: www-2.3

>Number:         100585
>Category:       bin
>Synopsis:       [patch] top(1): top -s0 causes load excessive
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 19 23:20:16 GMT 2006
>Closed-Date:    Thu Sep 25 15:42:27 UTC 2008
>Last-Modified:  Thu Sep 25 15:42:27 UTC 2008
>Originator:     Roberto Lima
>Release:        FreeBSD 6.1
>Organization:
ForBrazil
>Environment:
FreeBSD bsd.forbr.com.br 6.1-STABLE FreeBSD 6.1-STABLE #1: Tue Jun 27 17:20:15 BRT 2006     root@bsd.forbr.com.br:/usr/src/sys/i386/compile/ForBrazil  i386

>Description:
I see that my customers have been using 'top -s0' too many times and this
is overloading in my system.
>How-To-Repeat:
just use 'top -s0' and see the load average going up.
>Fix:
--- top.c.old   Wed Jul 19 19:49:23 2006
+++ top.c       Wed Jul 19 19:49:32 2006
@@ -331,7 +331,7 @@
                break;
 
              case 's':
-               if ((delay = atoi(optarg)) < 0 || (delay == 0 && getuid() != 0))
+               if ((delay = atoi(optarg)) < 1 || (delay == 0 && getuid() != 0))
                {
                    fprintf(stderr,
                        "%s: warning: seconds delay should be positive -- using default\n",
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: Roberto Lima <roberto@forbrazil.com.br>
Cc: freebsd-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org,
        dwmalone@FreeBSD.org
Subject: Re: bin/100585: [PATCH] top -s0 causes load excessive
Date: Mon, 24 Jul 2006 17:14:22 +1000 (EST)

 On Wed, 19 Jul 2006, Roberto Lima wrote:
 
 >> Description:
 > I see that my costumers have been used 'top -s0' too many times and this is overloading in my system.
 >> How-To-Repeat:
 > just use 'top -s0' and see the load average going up.
 >> Fix:
 > --- top.c.old   Wed Jul 19 19:49:23 2006
 > +++ top.c       Wed Jul 19 19:49:32 2006
 > @@ -331,7 +331,7 @@
 >                break;
 >
 >              case 's':
 > -               if ((delay = atoi(optarg)) < 0 || (delay == 0 && getuid() != 0))
 > +               if ((delay = atoi(optarg)) < 1 || (delay == 0 && getuid() != 0))
 
 This would just break the feature that a delay of 0 works for non-root.
 It is already broken for root.  top hasn't used kmem or been setuid
 for a long time so it shouldn't call getuid() here or elsewhere.  Users
 who wish to overload the system can do it in more or less interesting ways
 than with "top -s0", e.g., with "while :; do top 15 | cat; done".
 
 Bruce
State-Changed-From-To: open->closed 
State-Changed-By: edwin 
State-Changed-When: Thu Sep 25 15:42:13 UTC 2008 
State-Changed-Why:  
With the upgrade to 3.8b1 this has been fixed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=100585 
>Unformatted:
