From nobody@FreeBSD.ORG Mon Nov 15 00:05:46 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 8E46B14C97; Mon, 15 Nov 1999 00:05:46 -0800 (PST)
Message-Id: <19991115080546.8E46B14C97@hub.freebsd.org>
Date: Mon, 15 Nov 1999 00:05:46 -0800 (PST)
From: dlowe@pootpoot.com
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: portmap bug (when run with -v flag)
X-Send-Pr-Version: www-1.0

>Number:         14895
>Category:       misc
>Synopsis:       portmap bug (when run with -v flag)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 15 00:10:01 PST 1999
>Closed-Date:    Fri Jan 18 08:14:39 PST 2002
>Last-Modified:  Fri Jan 18 08:14:42 PST 2002
>Originator:     J. David Lowe
>Release:        3.0-RELEASE
>Organization:
pootpoot
>Environment:
FreeBSD bertha.pootpoot.com 3.0-RELEASE FreeBSD 3.0-RELEASE #3: Sun Oct 31 16:21:08 PST 1999     dlowe@bertha.pootpoot.com:/usr/src/sys/compile/BERTHA  i386
>Description:
Under certain circumstances, portmap forks endlessly.  This was also
reported in PR misc/12607, but mistakenly listed as a ypbind() bug.

Here's the set of things that cause this problem:

portmap actually fork()s before calling getrpcbynumber() and syslog(),
to log.  Thus the main portmap process can answer requests while a
child writes log output.

When portmap is run with the -v flag, it logs every incoming request.

Under certain circumstances, getrpcent(), called several times by
getrpcbynumber(), will call _yp_check(), which in turn may call
ypbind(), which in turn talks to portmap.

Doh!

portmap eventually fills up the process table with logging children.
>How-To-Repeat:
/etc/rc.conf:

nisdomainname="FOO"
nis_server_enable="YES"

portmap_enable="YES"
portmap_flags="-v"

You'll need to go into single user mode in order to get the machine
back, since rc can't seem to finish with a full process table.
>Fix:
This is a workaround patch to pmap_check.c, not very nice because it
removes one level of verbosity from the supposedly more verbose output
of portmap -v.  However, it should prevent this from happening, and it
illustrates the problem area.  As a simpler workaround, don't run
portmap with the -v flag, or don't run NIS.  Neither solution is
perfect.  This patch is against "$Id: pmap_check.c,v 1.3 1997/10/09
07:17:11 charnier Exp $"


*** pmap_check.c.original       Sun Nov 14 23:36:54 1999
--- pmap_check.c        Sun Nov 14 23:42:07 1999
***************
*** 242,248 ****
  
        if (prognum == 0) {
            progname = "";
!       } else if ((rpc = getrpcbynumber((int) prognum))) {
            progname = rpc->r_name;
        } else {
            sprintf(progname = progbuf, "%lu", prognum);
--- 242,250 ----
  
        if (prognum == 0) {
            progname = "";
!         /*  Ironically, it's not safe to call getrpcbynumber() when
!          *  verboselog is true, resulting in less verbose logs. */
!       } else if ((! verboselog) && ((rpc = getrpcbynumber((int) prognum)))) {
            progname = rpc->r_name;
        } else {
            sprintf(progname = progbuf, "%lu", prognum);

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: mike 
State-Changed-When: Fri Jul 20 20:04:20 PDT 2001 
State-Changed-Why:  

Does this problem still occur in newer versions of FreeBSD, 
such as 4.3-RELEASE? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=14895 

From: Mike Barcroft <mike@FreeBSD.org>
To: David Lowe <dlowe@pootpoot.com>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/14895: portmap bug (when run with -v flag)
Date: Mon, 23 Jul 2001 20:42:34 -0400

 On Mon, Jul 23, 2001 at 03:11:31PM -0700, David Lowe wrote:
 > Mike -
 > 
 > The latest version I have installed is 4.2-RELEASE, and the problem is
 > still exactly the same and easy to duplicate, and the original patch I
 > supplied (though not a great solution) still applies and fixes the
 > problem, for some definition of fixes...
 
 Would you mind trying a newer version?  PR: misc/12607, which you
 reference in this PR, says it was fixed shortly after 4.2-RELEASE.
 
 Best regards,
 Mike Barcroft

From: David Lowe <dlowe@pootpoot.com>
To: Mike Barcroft <mike@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/14895: portmap bug (when run with -v flag)
Date: Mon, 23 Jul 2001 17:45:40 -0700 (PDT)

 Mike -
 
 I really don't have any machines more recent than 4.2-RELEASE to play with
 at the moment.  It's very predictable and easy to duplicate, if you have
 access to such a machine.
 
 I am building a new machine within the next month or so, so I will test it
 again once it's done if you are unable to do so.
 
 misc/12607 doesn't mention (in the fix) whether they explicitly ran
 portmap with the -v flag in testing, nor does it explain *why* the bug
 would go away under post-4.2.  So I suspect that it's just that nobody has
 tried it, but would be happy to be proven wrong.
 
 : : : J. David Lowe :: dlowe@pootpoot.com :: http://pootpoot.com : : :
 ::            "Oh the morning sun in all its glory                  ::
 :              Greets the day with hope and comfort too              :
 :              And you fill my life with laughter"                   :
 ::                        -Van Morrison, "Have I told you Lately"   ::
  :: fingerprint: 79 1D 66 9F 35 A1 2D ED   81 98 26 E1 F8 D5 3F 29 ::
 
 On Mon, 23 Jul 2001, Mike Barcroft wrote:
 
 > On Mon, Jul 23, 2001 at 03:11:31PM -0700, David Lowe wrote:
 > > Mike -
 > > 
 > > The latest version I have installed is 4.2-RELEASE, and the problem is
 > > still exactly the same and easy to duplicate, and the original patch I
 > > supplied (though not a great solution) still applies and fixes the
 > > problem, for some definition of fixes...
 > 
 > Would you mind trying a newer version?  PR: misc/12607, which you
 > reference in this PR, says it was fixed shortly after 4.2-RELEASE.
 > 
 > Best regards,
 > Mike Barcroft
 > 
 
 
 

From: Mike Barcroft <mike@FreeBSD.org>
To: David Lowe <dlowe@pootpoot.com>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/14895: portmap bug (when run with -v flag)
Date: Wed, 25 Jul 2001 23:35:31 -0400

 On Mon, Jul 23, 2001 at 05:45:40PM -0700, David Lowe wrote:
 > Mike -
 > 
 > I really don't have any machines more recent than 4.2-RELEASE to play with
 > at the moment.  It's very predictable and easy to duplicate, if you have
 > access to such a machine.
 > 
 > I am building a new machine within the next month or so, so I will test it
 > again once it's done if you are unable to do so.
 > 
 > misc/12607 doesn't mention (in the fix) whether they explicitly ran
 > portmap with the -v flag in testing, nor does it explain *why* the bug
 > would go away under post-4.2.  So I suspect that it's just that nobody has
 > tried it, but would be happy to be proven wrong.
 
 I don't have a 4.3-RELEASE or 4.3-STABLE box available for testing
 this, and 5.0-CURRENT seems to be using a new mechanism for RPC which
 doesn't exhibit this behaviour.
 
 Best regards,
 Mike Barcroft
State-Changed-From-To: feedback->closed 
State-Changed-By: sheldonh 
State-Changed-When: Fri Jan 18 08:14:39 PST 2002 
State-Changed-Why:  
Automatic feedback timeout.  If additional feedback that warrants 
the re-opening of this PR is available but not included in the 
audit trail, please include the feedback in a reply to this message 
(preserving the Subject line) and ask that the PR be re-opened. 

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