NetBSD Problem Report #8239
Received: (qmail 4348 invoked from network); 19 Aug 1999 17:08:13 -0000
Message-Id: <199908191707.KAA20097@pc1.whooppee.com>
Date: Thu, 19 Aug 1999 10:07:27 -0700 (PDT)
From: paul@whooppee.com
Reply-To: paul@whooppee.com
To: gnats-bugs@gnats.netbsd.org
Subject: vm problem with fork()
X-Send-Pr-Version: 3.95
>Number: 8239
>Category: kern
>Synopsis: vm problem with fork()
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Aug 19 10:20:01 +0000 1999
>Closed-Date: Sat Aug 21 02:19:29 +0000 1999
>Last-Modified: Sat Aug 21 02:19:45 +0000 1999
>Originator: Paul Goyette
>Release: current as of 8/14/99 (1.4J)<NetBSD-current source date>
>Organization:
-----------------------------------------------------------------------
| Paul Goyette | PGP DSS Key fingerprint: | E-mail addresses: |
| Network Engineer| BCD7 5301 9513 58A6 0DBC | paul@whooppee.com |
| & kernel hacker | 91EB ADB1 A280 3B79 9221 | pgoyette@juniper.net |
-----------------------------------------------------------------------
>Environment:
System: NetBSD pc1.whooppee.com 1.4J NetBSD 1.4J (PC1) #11: Sat Aug 14 08:23:24 PDT 1999 paul@pc1.whooppee.com:/usr/src/sys/arch/i386/compile/PC1 i386
>Description:
Problem observed using the amcheck program (part of the
amanda-server-2.4.1p1 package); not yet reproduced with
simpler example...
Program runs setuid root. Allocates a data structure
using malloc(), and stores a value into the structure
(iti's the fd number returned from a socket() call).
Program then fork()s two new processes. New process 1
erases and frees the data structure allocated by the
parent process. New process 2 attempts to use the value
stored into the data structure, and finds that the socket
fd number is now zero!
Main program then waits for both fork()ed processes to
finish. Inserting printf() in main process shows that it,
too, sees a zero value within the data structure.
>How-To-Repeat:
Install and configure the amanda-server package. Then try
to do a "amcheck <config>" command.
>Fix:
Workaround for amanda's amcheck is to remove the line in
amcheck.c routine start_server_checks() so as not to call
amfree(msg). But this does not fix the underlying kernel
bug.
>Release-Note:
>Audit-Trail:
From: Jason Thorpe <thorpej@nas.nasa.gov>
To: paul@whooppee.com
Cc: gnats-bugs@gnats.netbsd.org, christos@zoulas.com
Subject: Re: kern/8239: vm problem with fork()
Date: Thu, 19 Aug 1999 14:53:36 -0700
On Thu, 19 Aug 1999 10:07:27 -0700 (PDT)
paul@whooppee.com wrote:
> Main program then waits for both fork()ed processes to
> finish. Inserting printf() in main process shows that it,
> too, sees a zero value within the data structure.
Ok, it's pretty obvious (to me, anyhow :-) what the problem is. Please
try the following diff and let me know the results.
-- Jason R. Thorpe <thorpej@nas.nasa.gov>
Index: uvm_aobj.c
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_aobj.c,v
retrieving revision 1.24
diff -c -r1.24 uvm_aobj.c
*** uvm_aobj.c 1999/07/22 22:58:38 1.24
--- uvm_aobj.c 1999/08/19 21:36:05
***************
*** 855,860 ****
--- 855,861 ----
case PGO_CLEANIT|PGO_FREE:
case PGO_CLEANIT|PGO_DEACTIVATE:
case PGO_DEACTIVATE:
+ deactivate_it:
/* skip the page if it's loaned or wired */
if (pp->loan_count != 0 ||
pp->wire_count != 0)
***************
*** 870,875 ****
--- 871,883 ----
continue;
case PGO_FREE:
+ /*
+ * If there are multiple references to
+ * the object, just deactivate the page.
+ */
+ if (uobj->uo_refs > 1)
+ goto deactivate_it;
+
/* XXX skip the page if it's loaned or wired */
if (pp->loan_count != 0 ||
pp->wire_count != 0)
Index: uvm_map.c
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_map.c,v
retrieving revision 1.67
diff -c -r1.67 uvm_map.c
*** uvm_map.c 1999/08/03 00:38:33 1.67
--- uvm_map.c 1999/08/19 21:36:07
***************
*** 2533,2538 ****
--- 2533,2539 ----
case PGO_CLEANIT|PGO_FREE:
case PGO_CLEANIT|PGO_DEACTIVATE:
case PGO_DEACTIVATE:
+ deactivate_it:
/* skip the page if it's loaned or wired */
if (pg->loan_count != 0 ||
pg->wire_count != 0) {
***************
*** 2577,2582 ****
--- 2578,2590 ----
continue;
case PGO_FREE:
+ /*
+ * If there are multiple references to
+ * the amap, just deactivate the page.
+ */
+ if (amap_refs(amap) > 1)
+ goto deactivate_it;
+
/* XXX skip the page if it's wired */
if (pg->wire_count != 0) {
simple_unlock(&anon->an_lock);
From: Paul Goyette <paul@whooppee.com>
To: Jason Thorpe <thorpej@nas.nasa.gov>
Cc: gnats-bugs@gnats.netbsd.org, christos@zoulas.com
Subject: Re: kern/8239: vm problem with fork()
Date: Thu, 19 Aug 1999 21:17:27 -0700 (PDT)
OK, I'll give it a try this weekend.
On Thu, 19 Aug 1999, Jason Thorpe wrote:
> On Thu, 19 Aug 1999 10:07:27 -0700 (PDT)
> paul@whooppee.com wrote:
>
> > Main program then waits for both fork()ed processes to
> > finish. Inserting printf() in main process shows that it,
> > too, sees a zero value within the data structure.
>
> Ok, it's pretty obvious (to me, anyhow :-) what the problem is. Please
> try the following diff and let me know the results.
>
> -- Jason R. Thorpe <thorpej@nas.nasa.gov>
>
> Index: uvm_aobj.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/uvm/uvm_aobj.c,v
> retrieving revision 1.24
> diff -c -r1.24 uvm_aobj.c
> *** uvm_aobj.c 1999/07/22 22:58:38 1.24
> --- uvm_aobj.c 1999/08/19 21:36:05
> ***************
> *** 855,860 ****
> --- 855,861 ----
> case PGO_CLEANIT|PGO_FREE:
> case PGO_CLEANIT|PGO_DEACTIVATE:
> case PGO_DEACTIVATE:
> + deactivate_it:
> /* skip the page if it's loaned or wired */
> if (pp->loan_count != 0 ||
> pp->wire_count != 0)
> ***************
> *** 870,875 ****
> --- 871,883 ----
> continue;
>
> case PGO_FREE:
> + /*
> + * If there are multiple references to
> + * the object, just deactivate the page.
> + */
> + if (uobj->uo_refs > 1)
> + goto deactivate_it;
> +
> /* XXX skip the page if it's loaned or wired */
> if (pp->loan_count != 0 ||
> pp->wire_count != 0)
> Index: uvm_map.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/uvm/uvm_map.c,v
> retrieving revision 1.67
> diff -c -r1.67 uvm_map.c
> *** uvm_map.c 1999/08/03 00:38:33 1.67
> --- uvm_map.c 1999/08/19 21:36:07
> ***************
> *** 2533,2538 ****
> --- 2533,2539 ----
> case PGO_CLEANIT|PGO_FREE:
> case PGO_CLEANIT|PGO_DEACTIVATE:
> case PGO_DEACTIVATE:
> + deactivate_it:
> /* skip the page if it's loaned or wired */
> if (pg->loan_count != 0 ||
> pg->wire_count != 0) {
> ***************
> *** 2577,2582 ****
> --- 2578,2590 ----
> continue;
>
> case PGO_FREE:
> + /*
> + * If there are multiple references to
> + * the amap, just deactivate the page.
> + */
> + if (amap_refs(amap) > 1)
> + goto deactivate_it;
> +
> /* XXX skip the page if it's wired */
> if (pg->wire_count != 0) {
> simple_unlock(&anon->an_lock);
>
-----------------------------------------------------------------------
| Paul Goyette | PGP DSS Key fingerprint: | E-mail addresses: |
| Network Engineer| BCD7 5301 9513 58A6 0DBC | paul@whooppee.com |
| & kernel hacker | 91EB ADB1 A280 3B79 9221 | pgoyette@juniper.net |
-----------------------------------------------------------------------
From: Paul Goyette <paul@whooppee.com>
To: Jason Thorpe <thorpej@nas.nasa.gov>
Cc: gnats-bugs@gnats.netbsd.org, christos@zoulas.com
Subject: Re: kern/8239: vm problem with fork()
Date: Fri, 20 Aug 1999 17:49:49 -0700 (PDT)
Jason,
That patch appears to have fixed the problem. Thanks!
On Thu, 19 Aug 1999, Jason Thorpe wrote:
> On Thu, 19 Aug 1999 10:07:27 -0700 (PDT)
> paul@whooppee.com wrote:
>
> > Main program then waits for both fork()ed processes to
> > finish. Inserting printf() in main process shows that it,
> > too, sees a zero value within the data structure.
>
> Ok, it's pretty obvious (to me, anyhow :-) what the problem is. Please
> try the following diff and let me know the results.
>
> -- Jason R. Thorpe <thorpej@nas.nasa.gov>
>
> Index: uvm_aobj.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/uvm/uvm_aobj.c,v
> retrieving revision 1.24
> diff -c -r1.24 uvm_aobj.c
> *** uvm_aobj.c 1999/07/22 22:58:38 1.24
> --- uvm_aobj.c 1999/08/19 21:36:05
> ***************
> *** 855,860 ****
> --- 855,861 ----
> case PGO_CLEANIT|PGO_FREE:
> case PGO_CLEANIT|PGO_DEACTIVATE:
> case PGO_DEACTIVATE:
> + deactivate_it:
> /* skip the page if it's loaned or wired */
> if (pp->loan_count != 0 ||
> pp->wire_count != 0)
> ***************
> *** 870,875 ****
> --- 871,883 ----
> continue;
>
> case PGO_FREE:
> + /*
> + * If there are multiple references to
> + * the object, just deactivate the page.
> + */
> + if (uobj->uo_refs > 1)
> + goto deactivate_it;
> +
> /* XXX skip the page if it's loaned or wired */
> if (pp->loan_count != 0 ||
> pp->wire_count != 0)
> Index: uvm_map.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/uvm/uvm_map.c,v
> retrieving revision 1.67
> diff -c -r1.67 uvm_map.c
> *** uvm_map.c 1999/08/03 00:38:33 1.67
> --- uvm_map.c 1999/08/19 21:36:07
> ***************
> *** 2533,2538 ****
> --- 2533,2539 ----
> case PGO_CLEANIT|PGO_FREE:
> case PGO_CLEANIT|PGO_DEACTIVATE:
> case PGO_DEACTIVATE:
> + deactivate_it:
> /* skip the page if it's loaned or wired */
> if (pg->loan_count != 0 ||
> pg->wire_count != 0) {
> ***************
> *** 2577,2582 ****
> --- 2578,2590 ----
> continue;
>
> case PGO_FREE:
> + /*
> + * If there are multiple references to
> + * the amap, just deactivate the page.
> + */
> + if (amap_refs(amap) > 1)
> + goto deactivate_it;
> +
> /* XXX skip the page if it's wired */
> if (pg->wire_count != 0) {
> simple_unlock(&anon->an_lock);
>
-----------------------------------------------------------------------
| Paul Goyette | PGP DSS Key fingerprint: | E-mail addresses: |
| Network Engineer| BCD7 5301 9513 58A6 0DBC | paul@whooppee.com |
| & kernel hacker | 91EB ADB1 A280 3B79 9221 | pgoyette@juniper.net |
-----------------------------------------------------------------------
State-Changed-From-To: open->closed
State-Changed-By: thorpej
State-Changed-When: Fri Aug 20 19:19:29 PDT 1999
State-Changed-Why:
Fixed.
From: Jason Thorpe <thorpej@nas.nasa.gov>
To: paul@whooppee.com
Cc: gnats-bugs@gnats.netbsd.org, christos@zoulas.com
Subject: Re: kern/8239: vm problem with fork()
Date: Fri, 20 Aug 1999 19:20:35 -0700
On Fri, 20 Aug 1999 17:49:49 -0700 (PDT)
Paul Goyette <paul@whooppee.com> wrote:
> That patch appears to have fixed the problem. Thanks!
Great, committed!
-- Jason R. Thorpe <thorpej@nas.nasa.gov>
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.