From owner-freebsd-jail@FreeBSD.ORG Mon Apr 22 09:17:16 2013 Return-Path: Delivered-To: freebsd-jail@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 991F1A6F for ; Mon, 22 Apr 2013 09:17:16 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wi0-x229.google.com (mail-wi0-x229.google.com [IPv6:2a00:1450:400c:c05::229]) by mx1.freebsd.org (Postfix) with ESMTP id 340DD1A81 for ; Mon, 22 Apr 2013 09:17:16 +0000 (UTC) Received: by mail-wi0-f169.google.com with SMTP id h11so4216526wiv.4 for ; Mon, 22 Apr 2013 02:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=SsyEMyoiSkPc18ZMCHKPMOAPQ/XVwBuYyFpdp0PIElg=; b=oVf3T2Ax5fKupWC5J1o2zZpsgVCJWeUH9mt+cmqDZR7rR5bljMLnwy5+OeLG7lvRHT fu4SGdngo4PNgo0HIi0aXlbpUfOStI8myC3VLJkOh0pkBqru766K0/nUCn6YPQexde3O pUzQDBByk3AuTdcxiHhx6S+dwG9dZKSNMoOZddeaFMViQeG1ScpROFzaayEs+OocWRTW Ue6512bBNWiTHwPvIebs6WGEfirF22gx22JSHHScjyHWZ0aR8XdpgaLj2rYMvIJaZUca XIOacOzDtwu+vQMMWRZJ+Q2x/uQ62ap01pXtRdijUc1jQSsUFrVYWS/sl+t9tyUD4xA8 c9Yw== X-Received: by 10.180.92.41 with SMTP id cj9mr17952341wib.7.1366622235374; Mon, 22 Apr 2013 02:17:15 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id fp2sm18770065wib.7.2013.04.22.02.17.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 22 Apr 2013 02:17:13 -0700 (PDT) Date: Mon, 22 Apr 2013 11:17:11 +0200 From: Mateusz Guzik To: freebsd-jail@freebsd.org Subject: automatic garbage collection of stuff mounted (etc.) by jailed root Message-ID: <20130422091711.GA3115@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Apr 2013 09:17:16 -0000 Hello, This is something that imho could be done by GSoC student. It is possible to allow jailed root to mount various filesystems. But once all processes are dead, mounts done by jailed root that he didn't clean up are still hanging around. As time passes and more stuff gets jailable we should expect problems like this in different subsystems. So I propose that someone(tm) implements a solution which cleans this stuff during jail destruction. One idea how to do it: implement a list with clean up operations. Using mount example: you add a filesystem to be cleaned up after it is mounted, you delete it after it is unmounted. When the jail is going to die you just traverse the list backwareds and call cleaning functions, in this case unmounting filesystems. Maybe this is is a bad idea in the first place and it is better to take a look at mount tree and traverse that, I don't know, you should investigate. :) Note that the code has to be robust in case of errors (e.g. given fs may not be unmountable because someone from prison0 is inside). Again, the goal is to have jails clean up automatically after anything jailed root was permitted to do. Thoughts? -- Mateusz Guzik