From owner-freebsd-jail@freebsd.org Thu May 7 04:25:53 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 BA67B2EC9B0 for ; Thu, 7 May 2020 04:25:53 +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 49HgPY2qNyz4nDS for ; Thu, 7 May 2020 04:25:53 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 609222EC9AF; Thu, 7 May 2020 04:25:53 +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 605B72EC9AE for ; Thu, 7 May 2020 04:25:53 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 49HgPY1y04z4nDR for ; Thu, 7 May 2020 04:25:53 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 3155A2ED41 for ; Thu, 7 May 2020 04:25:53 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qt1-f179.google.com with SMTP id g16so3638478qtp.11 for ; Wed, 06 May 2020 21:25:53 -0700 (PDT) X-Gm-Message-State: AGi0Puadx2EwScpzMp8tuZmfd9EXwvnX3mYAcoEw+qVa0cJm3wTVU+2W GEh66tiABNh0DD8fCqAj04SUPaaAvPZV/MdY0u4= X-Google-Smtp-Source: APiQypIin1QXveSlCyxlGGykWlHstM4xVS67ET/elzx/9mOJBjr9lxLy0IYj8nWUF7PhU4w9oWOriPTdPRssABW1MIE= X-Received: by 2002:ac8:4e0f:: with SMTP id c15mr11448349qtw.211.1588825552604; Wed, 06 May 2020 21:25:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Kyle Evans Date: Wed, 6 May 2020 23:25:41 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Should killed process deref a jail? Cc: 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: Thu, 07 May 2020 04:25:53 -0000 On Wed, May 6, 2020 at 1:42 PM Kyle Evans 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? > I wrote a small utility to workaround this behavior: https://git.kevans.dev/kevans/quickjail I hope to quickly deprecate it with this review or something similar, if it seems reasonable: https://reviews.freebsd.org/D24745 -> my problem is entirely centered around sending ^C to the jail command= that's hanging, which sends SIGINT to the entire foreground process group, thus killing jail(8) in the process and preventing the cleanup that should happen when the command terminates. I think it's perhaps reasonable to just ignore SIGINT and let the child deal with it or terminate to let jail(8) cleanup afterwards. Perhaps the surface area in that review that's ignoring SIGINT (read: the whole thing) is too large, but this is an exercise left up to someone way more familiar with jail than I am. Thanks, Kyle Evans