Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4063911pxj; Tue, 8 Jun 2021 05:45:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvawV1gvAeMglpi883whYFBZSLhC4owfkUl5qN/DEzTkhTOM6MRbjecmbKrUubjpZz7t4i X-Received: by 2002:a17:906:b88e:: with SMTP id hb14mr15988758ejb.396.1623156346856; Tue, 08 Jun 2021 05:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623156346; cv=none; d=google.com; s=arc-20160816; b=dxkZdsJA7Y+BxuaXbe4a2os8KHc/AM0AWqgd6tshpVwGaofwiT+G5CCOxOJbBh+P/s aWTtbUgxRxDk1OxGcF4w3dNJk1acU1RWTGZvJQNJpiQ+qB/9jfslhUukXRNV789p+4zb ilLZbcH7fL/bRRXMw0LGmjIrylf2E0ziOiPJAcuHt52Hp/4/aRSew5OhdEIeupLl/rTJ 02TG9KpBBrmQlXsA7a2Nn3gJRY2imNuHOuW4dl3kXXFn5txy/ksjEPizykvomGLh9sl/ SwP/4TOSX/fKl0qetgsTlHs1mGW/ql2993QTz+VyCqIggwfpJMKayAfQ2PaQjkegjCz/ N6bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7VLTtXLbh6Qtn2WQYVl9hQuEkTiFNcPDiyzdOswnQ+0=; b=WHvvsZ0uTdKSQBraD9K28LFx2S/+hmXIZCZsdejpIiiA2JVzPpqCNkXwupFw0l7b0U waDQ4qVJYQjWhIK5JAtGTDSkKQVboSvHUYdxRO7VbMF1pDQssk/D3eVDbjxwgCzk2G7H luj/qutmZXG0CigKFPMjRtjDjNNSzVUOYfLkKVG92bd5jAz7DwKLollETu2M6U0t1B1i gMGn5WA/VysAN/1ouFIHWq8qQVeK/HyEY1hWAvUEYStlNeaVcBHFpAMpNMVKj2Scis4m guzClXmLD0hMFr3hYEBXsLX0TY2hDL8sGL+hM/4GHGJCg74jJu+Jkn6n++25dRsX/ZC4 X+6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xMYpznH6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si2975719edw.522.2021.06.08.05.45.22; Tue, 08 Jun 2021 05:45:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xMYpznH6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232649AbhFHMnv (ORCPT + 99 others); Tue, 8 Jun 2021 08:43:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:44212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232570AbhFHMnu (ORCPT ); Tue, 8 Jun 2021 08:43:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 860996023E; Tue, 8 Jun 2021 12:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623156108; bh=I/9UjWyXkJ418fvvcVmVgnBgL8SqzouPAlgJ5NltetU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xMYpznH6b6aI8a+h4qyaS9D+TGDXsNNUFsLJK1gB3VxS5nuwJDG0z1xtz47tu+mpx JIC4b1xAUbSvLD7R9of+EdElzeUwvgKKCsqSXhTjx3GWlBq3GBXC/kdHghiaafVlC+ Mdbfph8/sCTVveGu5QNce48Qy8Y3tMu3vQKxICDA= Date: Tue, 8 Jun 2021 14:41:45 +0200 From: Greg Kroah-Hartman To: "Enrico Weigelt, metux IT consult" Cc: Christian Brauner , containers@lists.linux.dev, "linux-kernel@vger.kernel.org" Subject: Re: device namespaces Message-ID: References: <20210608123050.zde5lwmovjr4yhiy@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210608123050.zde5lwmovjr4yhiy@wittgenstein> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 08, 2021 at 02:30:50PM +0200, Christian Brauner wrote: > On Tue, Jun 08, 2021 at 11:38:16AM +0200, Enrico Weigelt, metux IT consult wrote: > > Hello folks, > > > > > > I'm going to implement device namespaces, where containers can get an > > entirely different view of the devices in the machine (usually just a > > specific subset, but possibly additional virtual devices). > > > > For start I'd like to add a simple mapping of dev maj/min (leaving aside > > sysfs, udev, etc). An important requirement for me is that the parent ns > > can choose to delegate devices from those it full access too (child > > namespaces can do the same to their childs), and the assignment can > > change (for simplicity ignoring the case of removing devices that are > > already opened by some process - haven't decided yet whether they should > > be forcefully closed or whether keeping them open is a valid use case). > > > > The big question for me now is how exactly to do the table maintenance > > from userland. We already have entries in /proc//ns/*. I'm thinking > > about using them as command channel, like this: > > > > * new child namespaces are created with empty mapping > > * mapping manipulation is done by just writing commands to the ns file > > * access is only granted if the writing process itself is in the > > parent's device ns and has CAP_SYS_ADMIN (or maybe their could be some > > admin user for the ns ? or the 'root' of the corresponding user_ns ?) > > * if the caller has some restrictions on some particular device, these > > are automatically added (eg. if you're restricted to readonly, you > > can't give rw to the child ns). > > > > Is this a good way to go ? Or what would be a better one ? > > Ccing Greg. Without adressing specific problems, I should warn you that > this idea is not new and the plan is unlikely to go anywhere. Especially > not without support from Greg. Hah, yeah, this is a non-starter. Enrico, what real problem are you trying to solve by doing this? And have you tried anything with this yet? We almost never talk about "proposals" without seeing real code as it's pointless to discuss things when you haven't even proven that it can work. So let's see code before even talking about this... And as Christian points out, you can do this today without any kernel changes, so to think you need to modify the kernel means that you haven't even tried this at all? greg k-h