Re: Jails that keep hanging around

From: Melvyn Sopacua <freebsd-current_at_webteckies.org>
Date: Tue, 17 Feb 2004 00:32:15 +0100
On Sunday 15 February 2004 19:18, Robert Watson wrote:
> On Sun, 15 Feb 2004, Melvyn Sopacua wrote:
> > I have yet to figure out what triggers the bug, but I end up with
> > 'running' jails, without any processes. So I thought I'd create 'jld' to
> > remove a jail. However - prison_find isn't exported to userland.
> > Probably for good reason.
>
> Jails are reference-counted objects hung off of process credentials, which
> are also reference-counted objects.  So a jail can't evaporate until the
> last credential referencing that object also evaporates.

Would you take the patch below? I'm not sure it should be in jls(8) output, 
but at least it helps tracking down issues like this.
I've tested this patch on this laptop and see no problems with it.

-- 
Melvyn

=======================================================
FreeBSD sarevok.chello.nl 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Mon Feb 16 
19:59:52 CET 2004     
root_at_sarevok.webteckies.org:/usr/obj/usr/src/sys/SAREVOK_NOAPM_NODEBUG  i386
=======================================================


Index: sys/sys/jail.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/jail.h,v
retrieving revision 1.19
diff -u -r1.19 jail.h
--- sys/sys/jail.h	23 Jan 2004 20:44:26 -0000	1.19
+++ sys/sys/jail.h	16 Feb 2004 23:20:00 -0000
_at__at_ -26,6 +26,7 _at__at_
 	char		 pr_path[MAXPATHLEN];
 	char 		 pr_host[MAXHOSTNAMELEN];
 	u_int32_t	 pr_ip;
+	int              pr_refcount;
 };
 #define	XPRISON_VERSION	1
 
Index: sys/kern/kern_jail.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_jail.c,v
retrieving revision 1.35
diff -u -r1.35 kern_jail.c
--- sys/kern/kern_jail.c	23 Jan 2004 20:44:26 -0000	1.35
+++ sys/kern/kern_jail.c	16 Feb 2004 23:20:01 -0000
_at__at_ -449,6 +449,7 _at__at_
 		strlcpy(xp->pr_path, pr->pr_path, sizeof(xp->pr_path));
 		strlcpy(xp->pr_host, pr->pr_host, sizeof(xp->pr_host));
 		xp->pr_ip = pr->pr_ip;
+		xp->pr_refcount = pr->pr_ref;
 		mtx_unlock(&pr->pr_mtx);
 		xp++;
 	}
Index: usr.sbin/jls/jls.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/jls/jls.c,v
retrieving revision 1.3
diff -u -r1.3 jls.c
--- usr.sbin/jls/jls.c	22 Apr 2003 13:24:56 -0000	1.3
+++ usr.sbin/jls/jls.c	16 Feb 2004 23:20:01 -0000
_at__at_ -65,11 +65,12 _at__at_
 	    xp->pr_version != XPRISON_VERSION)
 		errx(1, "Kernel and userland out of sync");
 
-	printf("   JID  IP Address      Hostname                      Path\n");
+	printf("   JID    Ref IP Address      Hostname                      
Path\n");
 	for (i = 0; i < len / sizeof(*xp); i++) {
 		in.s_addr = ntohl(xp->pr_ip);
-		printf("%6d  %-15.15s %-29.29s %.74s\n",
-		    xp->pr_id, inet_ntoa(in), xp->pr_host, xp->pr_path);
+		printf("%6d %6d %-15.15s %-29.29s %.74s\n",
+		    xp->pr_id, xp->pr_refcount, inet_ntoa(in),
+		    xp->pr_host, xp->pr_path);
 		xp++;
 	}
 	free(sxp);

Received on Mon Feb 16 2004 - 14:51:01 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:43 UTC