From owner-freebsd-jail@freebsd.org Sun Nov 29 15:34:00 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 3AEEF4A5693; Sun, 29 Nov 2020 15:34:00 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4CkXTN15Zbz4m7r; Sun, 29 Nov 2020 15:34:00 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 137BD24563; Sun, 29 Nov 2020 15:34:00 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qt1-f181.google.com with SMTP id k4so1821686qtj.10; Sun, 29 Nov 2020 07:34:00 -0800 (PST) X-Gm-Message-State: AOAM5332+zxGyKIYu64w8dxgq8bW6bN+ggzbZb+00g6HGEND69Gwxzqk dqw0FTdFCN4kWGFM0dv31OMZ3HFf3yZKpysi3Gs= X-Google-Smtp-Source: ABdhPJwt4wWA6TB+MdFxhKXGba9zwtDkH4LTSlpJZrGx6P8qjaDA4J65koWLHyQ1WBjROcwNHz3IwSCtkfDXUFAjezw= X-Received: by 2002:ac8:5345:: with SMTP id d5mr17864902qto.60.1606664039506; Sun, 29 Nov 2020 07:33:59 -0800 (PST) MIME-Version: 1.0 References: <06F654BB-B087-4AE5-8599-E5837A85A850@FreeBSD.org> <6BA03DAD-BDCD-4A53-A80A-4B7B476B803C@FreeBSD.org> In-Reply-To: From: Kyle Evans Date: Sun, 29 Nov 2020 09:33:48 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: RFC: Jail privsets To: "Bjoern A. Zeeb" Cc: James Gritton , freebsd-jail , "freebsd-arch@freebsd.org" , trustedbsd-discuss@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Nov 2020 15:34:00 -0000 On Sun, Nov 29, 2020 at 6:51 AM Bjoern A. Zeeb wrote: > > On 28 Nov 2020, at 14:39, Kyle Evans wrote: > > Hi, > > Cc: jamie explicitly as he might have thoughts as well. > > > Yeah, so jail sets are a little tricky, and to be honest I haven't > > really thought about how to cope with common jail sets. The > > complication arises because you have various allow flags that > > typically default to off and turn privileges on, but your common sets > > would have to include them. So, you'd probably end up with: > > > > privset 0: All privs available to the superuser (not considering > > superuser policy just yet) > > privset 1: All privs available to jails (assuming most permissive, all > > allow flags on and assuming a new vnet on VIMAGE systems) > > > > So jails would typically inherit privset 1, but they'd have to mask > > out based on vnet/allow flags out of necessity. Now, that's not > > terrible, but I think we'd have to do a couple more things to reduce > > maintenance burden on folks introducing privs: > > > > 1.) Clearly define a central table that maps pr_flags <-> privs where > > there's a 1:1 mapping (most common, though PRIV_VFS_*MOUNT* are a > > little more complicated) > > 2.) Walk said table when we're defining privs in privset 1 > > 3.) Walk said table when we're determining what to mask out > > > > I suspect the vnet set is large enough that we'd just have a separate > > kernel-internal mask for "vnet privs". In any event, for most people, > > there will be one of three places that you might touch when adding a > > new priv flag or pr_flag mapping to a priv, but it should still be > > obvious what you want: either you want a conditionally added flag, you > > want to influence the default jail policy, or you want to change the > > vnet policy. The latter two scenarios might even be a little easier, > > because you don't need to wade through these gigantic switch > > statements with a lot of cases to determine where you really want it > > to go. > > I think this is all terribly too complicated. > > If we=E2=80=99ll have manageable fine-grained priv system, them retire al= low and > vnet checks for PRIV_* checks and be done with it. If we need new PRIV_* > checks to accomplish that adding PRIV_* is semi-cheap to add. > > The big switch statements in kern_jail.c will go as the applied priv set > will do the right thing already, which means at this point we=E2=80=99d h= ave > a base-system-privset, a classic-jail-privset, a vnet-jail-privset by > default probably. > > If we want to keep allow* in jails we can probably make them compat code > to adjust PRIV_* but I am not sure I=E2=80=99d want jail to still do that= or a > separate priv command (a la cpuset). > > Means jails become simple again and a lot of the complicate logic can > drop out. > Sure- I'm not so sure about vnet, but all of the allow flags could get deprecated in favor of describing the privs available somewhere and letting admin make decisions. I think the vnet set still makes a lot of sense unless you're also proposing that we could just create new vnets if one of those privileges is turned on -- in which case, we'd still have to manage the set, but it wouldn't be used much beyond a hint mask that we need to create a vnet. > >> And yes, that would indeed simplify our jail and network stack (and so= me > >> other) > >> code quite a bit. > >> > >> I=E2=80=99d love this (step-by-step or in whole right away) :-) > >> > > > > :-) > > > > I'm looking to see if I can define a useful abstraction from > > cpuset/domainset that would limit the amount of duplication needed for > > this, then I'll post a v2 to Phabricator. > > There=E2=80=99s probably edge cases in which managing privsets will be a = priv as > well and we=E2=80=99ll probably need multiple cases: one that can still = =E2=80=9Cwiden=E2=80=9D > priv and one that can only copy-and-further-restrict-only. The latter > probably being the default. > True enough.