From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752699AbcGMHbj (ORCPT ); Wed, 13 Jul 2016 03:31:39 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:36620 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752267AbcGMHaw (ORCPT ); Wed, 13 Jul 2016 03:30:52 -0400 Subject: Re: [PATCH] capabilities: audit capability use To: "Eric W. Biederman" References: <1468235672-3745-1-git-send-email-toiwoton@gmail.com> <87vb0bbzyo.fsf@x220.int.ebiederm.org> <878tx79et8.fsf@x220.int.ebiederm.org> Cc: linux-kernel@vger.kernel.org, pmladek@suse.com, luto@kernel.org, serge@hallyn.com, keescook@chromium.org, Paul Moore , Eric Paris , Tejun Heo , Li Zefan , Johannes Weiner , "moderated list:AUDIT SUBSYSTEM" , "open list:CONTROL GROUP (CGROUP)" , "open list:CAPABILITIES" From: Topi Miettinen Openpgp: id=A0F2EB0D8452DA908BEC8E911CF9ADDBD610E936 Message-ID: Date: Wed, 13 Jul 2016 07:30:18 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: <878tx79et8.fsf@x220.int.ebiederm.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/12/16 13:16, Eric W. Biederman wrote: > Topi Miettinen writes: > >> On 07/11/16 21:57, Eric W. Biederman wrote: >>> Topi Miettinen writes: >>> >>>> There are many basic ways to control processes, including capabilities, >>>> cgroups and resource limits. However, there are far fewer ways to find >>>> out useful values for the limits, except blind trial and error. >>>> >>>> Currently, there is no way to know which capabilities are actually used. >>>> Even the source code is only implicit, in-depth knowledge of each >>>> capability must be used when analyzing a program to judge which >>>> capabilities the program will exercise. >>>> >>>> Generate an audit message at system call exit, when capabilities are used. >>>> This can then be used to configure capability sets for services by a >>>> software developer, maintainer or system administrator. >>>> >>>> Test case demonstrating basic capability monitoring with the new >>>> message types 1330 and 1331 and how the cgroups are displayed (boot to >>>> rdshell): >>> >>> You totally miss the interactions with the user namespace so this won't >>> give you the information you are aiming for. >> >> Please correct me if this is not right: >> >> There are two cases: >> a) real capability use as seen outside the namespace >> b) use of capabilities granted by the namespace >> Both cases could be active independently. >> >> For auditing purposes, we're mostly interested in a) and log noise from >> b) could be even seen a distraction. >> >> For configuration purposes, both cases can be interesting, a) for the >> configuration of services and b) in case where the containerized >> configuration is planned to be deployed outside. I'd still only log >> a). >> >> >> The same logic should apply with cgroup namespaces. > > Not logging capabilities outside of the initial user namespace is > certainly the conservative place to start, and what selinux does. > > You should also be logging capability use from cap_capable. Not But cap_capable is not called from apparmor aa_capable or selinux selinux_capable, how about security_capable()? > ns_capable. You are missing several kinds of capability use as > a quick review of kernel/capability.c should have shown you. Right, sorry about that. -Topi > > Eric >