Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752865AbdLKQbR (ORCPT ); Mon, 11 Dec 2017 11:31:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35922 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728AbdLKQbO (ORCPT ); Mon, 11 Dec 2017 11:31:14 -0500 Message-ID: <1513009857.6310.337.camel@redhat.com> Subject: Re: RFC(v2): Audit Kernel Container IDs From: Eric Paris To: Casey Schaufler , =?ISO-8859-1?Q?Micka=EBl_Sala=FCn?= , Richard Guy Briggs , cgroups@vger.kernel.org, Linux Containers , Linux API , Linux Audit , Linux FS Devel , Linux Kernel , Linux Network Development Cc: mszeredi@redhat.com, "Eric W. Biederman" , Simo Sorce , jlayton@redhat.com, "Carlos O'Donell" , David Howells , Al Viro , Andy Lutomirski , Eric Paris , trondmy@primarydata.com, Michael Kerrisk Date: Mon, 11 Dec 2017 11:30:57 -0500 In-Reply-To: References: <20171012141359.saqdtnodwmbz33b2@madcap2.tricolour.ca> <75b7d6a6-42ba-2dff-1836-1091c7c024e7@schaufler-ca.com> <7ebca85a-425c-2b95-9a5f-59d81707339e@digikod.net> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 11 Dec 2017 16:31:14 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1726 Lines: 42 On Sat, 2017-12-09 at 10:28 -0800, Casey Schaufler wrote: > On 12/9/2017 2:20 AM, Micka�l Sala�n wrote: > > What about automatically create > > and assign an ID to a process when it enters a namespace different > > than > > one of its parent process? This delegates the (permission) > > responsibility to the use of namespaces (e.g. /proc/sys/user/max_* > > limit). > > That gets ugly when you have a container that uses user, filesystem, > network and whatever else namespaces. If all containers used the same > set of namespaces I think this would be a fine idea, but they don't. > > > One interesting side effect of this approach would be to be able to > > identify which processes are in the same set of namespaces, even if > > not > > spawn from the container but entered after its creation (i.e. using > > setns), by creating container IDs as a (deterministic) checksum > > from the > > /proc/self/ns/* IDs. > > > > Since the concern is to identify a container, I think the ability > > to > > audit the switch from one container ID to another is enough. I > > don't > > think we need nested IDs. > > Because a container doesn't have to use namespaces to be a container > you still need a mechanism for a process to declare that it is in > fact > in a container, and to identify the container. I like the idea but I'm still tossing it around in my head (and thinking about Casey's statement too). Lets say we have a 'docker-like' container with pid=100 netns=X,userns=Y,mountns=Z. If I'm on the host in all init namespaces and I run nsenter -t 100 -n ip link set eth0 promisc on How should this be logged? Did this command run in it's own 'container' unrelated to the 'docker-like' container? -Eric