From owner-freebsd-jail@freebsd.org Wed May 6 19:04:35 2020 Return-Path: Delivered-To: freebsd-jail@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C19262DD255 for ; Wed, 6 May 2020 19:04:35 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 49HQxv4q3qz43rc for ; Wed, 6 May 2020 19:04:35 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id A350C2DD254; Wed, 6 May 2020 19:04:35 +0000 (UTC) Delivered-To: jail@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A31032DD253 for ; Wed, 6 May 2020 19:04:35 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49HQxv3p6hz43rZ for ; Wed, 6 May 2020 19:04:35 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 718DA2A9BB for ; Wed, 6 May 2020 19:04:35 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qv1-f47.google.com with SMTP id fb4so1362281qvb.7 for ; Wed, 06 May 2020 12:04:35 -0700 (PDT) X-Gm-Message-State: AGi0Pua9OrWKT7805f7QjcgqmFALJVWC9Cj31QT/Io6z+yPFZKvwg6n3 tb0SoPDQMN5fNkUBqrscIq+5ZXpc+r4UhTfOjz8= X-Received: by 2002:a05:6214:28d:: with SMTP id l13mt10622952qvv.181.1588791875024; Wed, 06 May 2020 12:04:35 -0700 (PDT) MIME-Version: 1.0 References: <20200506184923.GT39563@home.opsec.eu> In-Reply-To: From: Kyle Evans Date: Wed, 6 May 2020 14:04:21 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Should killed process deref a jail? Cc: Kurt Jaeger , jail@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 May 2020 19:04:35 -0000 On Wed, May 6, 2020 at 1:55 PM Kyle Evans wrote: > > On Wed, May 6, 2020 at 1:49 PM Kurt Jaeger wrote: > > > > Hi! > > > > > In doing some testing of qemu-user-static recently, I noticed that > > > killing the last process in a non-persist jail doesn't kill off the > > > jail: > > > > > > root@viper:/usr/src# jail -c path=/ command=yes > > > ## ^C out > > > > > > root@viper:/usr/src# jls > > > JID IP Address Hostname Path > > > 181 / > > > > > > root@viper:/usr/src# ps fxJ 181 > > > PID TT STAT TIME COMMAND > > > > > > As a result, I ended up with 82 jails pointed at my armv7 sysroot and > > > much surprise when I checked out `jls`. This vaguely smells like a > > > bug, is this something that should be fixed? > > > > Depends. If the last process held some socket and the socket > > is still in the state LINGER. > > > > See > > > > https://deepix.github.io/2016/10/21/tcprst.html > > > > for more details, after the heading 'What is SO_LINGER?' > > > > You can probably see those sockets with > > > > That'd make sense, but in this case it's actually reproducible with > yes(1), which doesn't open up any sockets or actually use any external > resources other than write()ing to stdout. This turns out to be PEBCAK, as jail(8) will always set persist if there's a command to be run. Sorry for the noise...