Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5022986rwb; Wed, 17 Aug 2022 09:41:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR6XHK8UxnDs44Oe3ehXe3I+VNewn4KByh1DPB0UUJ0ymHWnZGLNHoGJl3YbuFqmmT8ihK8q X-Received: by 2002:a17:907:97d5:b0:730:9eac:d965 with SMTP id js21-20020a17090797d500b007309eacd965mr16724398ejc.353.1660754494894; Wed, 17 Aug 2022 09:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660754494; cv=none; d=google.com; s=arc-20160816; b=h0T7WdoEzkoRws08r17mxgPdhHab2C4dB1me3bwFsIUJExMTsTDzwzxz01F23rrsJV I9nHVQ2ZD9ZRX5FeenanVuYE1lHQKpdqSPbRm1bb80dWJ1oRSippmjXweAjVWjDEcVOh wTOya02gBap68ZFqF67NPbPFT2SU2TmiE42FQoJeARyiibxz1ZcDiino2v6p47+eW790 glu28vd5vnnqNtKuIDwxm9zAB+kx7UuB/Y6s5Hlguv/vYlkusxN2MhOpDoJR51i5+GiL sRNdJ3eAU3r3LgzLetnUvCApVmLXcwfrR0n2rY1vqWQbSbK0IbDC3tEfEhVBvigVUuge DOBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UVFUNCqPRpisdlSVRU+tLvNHfgHjwvastlgvyU/I+ug=; b=OoAxojFGFEfBdht9LoObFHFfKw/d5I2JDN8WBqCObJnXuplOv0ndhfxSJdsTJ84WvA qzIH0zc8GA/j4oWdhx1cxezBK2n2K98Y9n/yy/7Un76HsFp1JIwlYE++RR7+J7qQgkCa 4LYbj2CWNOdd5HJqfnrkY2Kk7jY5Qvd+1mHc+GUYWPTnqpb1Lm6/LZv1OyS1r7FotKZY C9Jun9cfAMwloonBsX6ex640GhhkaZoCcqpOIOendSJuXHdypjajmhLQD0LpspLtcCWP 4YfmQlx1d6C0RcnAMOJxdqD9pky68A/Nm7gUoPEC7toA8dupljz3cd94CJkUACPnPwaG oTlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=nhD+LomY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020aa7d6c3000000b0043c141aaddfsi11741096edr.146.2022.08.17.09.41.08; Wed, 17 Aug 2022 09:41:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=nhD+LomY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240955AbiHQQXI (ORCPT + 99 others); Wed, 17 Aug 2022 12:23:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237770AbiHQQXE (ORCPT ); Wed, 17 Aug 2022 12:23:04 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A7E89D8C9 for ; Wed, 17 Aug 2022 09:23:01 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id c185so15886645oia.7 for ; Wed, 17 Aug 2022 09:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=UVFUNCqPRpisdlSVRU+tLvNHfgHjwvastlgvyU/I+ug=; b=nhD+LomYohgAaMtQcxIoxV4+vU0oMCpwBU85S4CbJpWNUKtrOHMu96fL8IGGB9i7cw FNxyZ6ErfmSrX8Yjx7DJa7BfR/bOMY7rG80bdYrOvc0TBQdWfsCyw5PjJYDICr6XKe+H JK3MHzzpfJoiBFlNfEtLwxaJnHksXBBcOFgkYQyoUf3mhDxovH/WHeOyApy39dRcRbIQ fcxTkUgqfab5tVzG1DNRoypYdqSxaxz4/7zjslkpqhcWYI3keTaRIl+SBo37PltiKNpL NAd4uWTOTjI1QLYBuCHvcDwPay7mfA0nxGkY2Qg9BvzND3mU7WGHhnkXAU1YWGsIIF6T KwRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=UVFUNCqPRpisdlSVRU+tLvNHfgHjwvastlgvyU/I+ug=; b=XQnGJyI5SaESKua7EsgVRT7E39BXpz/caRYlrPTGQN4TGPebnNNpDF/wKgZRjh8jV/ Jkqe7EgsEjTledcfUhbzka3orSclIE6+cdG/enANw5nBlf0vM1dgY5RIBlWbg55J3KuL ca4bpJKLEMPkIJWmxB1LBJTXyU9sL1usUZSrF3sWgBMNydAsGiGO1q8pL7APf7LZyjjT 6zYUBdDR2KIoxbKJAodDvV3UkktTLBHhbG2qrJLW3UE48iDvn9wqZZW0K8ed3WuIdhwV exVZZyZYyj37RsMVNKS9VRcqhhRW5XePVTg0k8l3ElN7qRukvbn5quBKf87F7xZSgnAm JiPQ== X-Gm-Message-State: ACgBeo1V7OIHsCyQNESXzh/X4/BhQNzxLydlbMnpZaCBaGW9aiw/COLQ DMppx5FR+9iMSI855lPw6K5dJ47O40Yvi0UL9oAb X-Received: by 2002:a05:6808:3a9:b0:343:4b14:ccce with SMTP id n9-20020a05680803a900b003434b14cccemr1872909oie.41.1660753380093; Wed, 17 Aug 2022 09:23:00 -0700 (PDT) MIME-Version: 1.0 References: <20220725124123.12975-1-flaniel@linux.microsoft.com> <4420381.LvFx2qVVIh@pwmachine> <20220817161924.GA20337@mail.hallyn.com> In-Reply-To: <20220817161924.GA20337@mail.hallyn.com> From: Paul Moore Date: Wed, 17 Aug 2022 12:22:49 -0400 Message-ID: Subject: Re: [RFC PATCH v4 0/2] Add capabilities file to securityfs To: "Serge E. Hallyn" Cc: Casey Schaufler , Francis Laniel , linux-security-module@vger.kernel.org, Eric Biederman , James Morris , open list , "open list:BPF [MISC]" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 17, 2022 at 12:19 PM Serge E. Hallyn wrote: > On Wed, Aug 17, 2022 at 12:10:25PM -0400, Paul Moore wrote: > > On Wed, Aug 17, 2022 at 11:50 AM Casey Schaufler wrote: > > > On 8/17/2022 7:52 AM, Paul Moore wrote: > > > > On Wed, Aug 17, 2022 at 7:53 AM Francis Laniel > > > > wrote: > > > >> Le mardi 16 ao=C3=BBt 2022, 23:59:41 CEST Paul Moore a =C3=A9crit = : > > > >>> On Mon, Jul 25, 2022 at 8:42 AM Francis Laniel > > > >>> > > > >>> wrote: > > > >>>> Hi. > > > >>>> > > > >>>> First, I hope you are fine and the same for your relatives. > > > >>> Hi Francis :) > > > >>> > > > >>>> A solution to this problem could be to add a way for the userspa= ce to ask > > > >>>> the kernel about the capabilities it offers. > > > >>>> So, in this series, I added a new file to securityfs: > > > >>>> /sys/kernel/security/capabilities. > > > >>>> The goal of this file is to be used by "container world" softwar= e to know > > > >>>> kernel capabilities at run time instead of compile time. > > > >>> ... > > > >>> > > > >>>> The kernel already exposes the last capability number under: > > > >>>> /proc/sys/kernel/cap_last_cap > > > >>> I'm not clear on why this patchset is needed, why can't the > > > >>> application simply read from "cap_last_cap" to determine what > > > >>> capabilities the kernel supports? > > > >> When you capabilities with, for example, docker, you will fill cap= abilities > > > >> like this: > > > >> docker run --rm --cap-add SYS_ADMIN debian:latest echo foo > > > >> As a consequence, the "echo foo" will be run with CAP_SYS_ADMIN se= t. > > > >> > > > >> Sadly, each time a new capability is added to the kernel, it means= "container > > > >> stack" software should add a new string corresponding to the numbe= r of the > > > >> capabilities [1]. > > > > Thanks for clarifying things, I thought you were more concerned abo= ut > > > > detecting what capabilities the running kernel supported, I didn't > > > > realize it was getting a string literal for each supported capabili= ty. > > > > Unless there is a significant show of support for this > > > > > > I believe this could be a significant help in encouraging the use of > > > capabilities. An application that has to know the list of capabilitie= s > > > at compile time but is expected to run unmodified for decades isn't > > > going to be satisfied with cap_last_cap. The best it can do with that > > > is abort, not being able to ask an admin what to do in the presence o= f > > > a capability that wasn't around before because the name isn't known. > > > > An application isn't going to be able to deduce the semantic value of > > a capability based solely on a string value, an integer is just as > > meaningful in that regard. What might be useful is if the application > > Maybe it's important to point out that an integer value capability in > kernel will NEVER change its string value (or semantic meaning). > > The libcap tools like capsh accept integer capabilities, other tools > probably should as well. (see man 3 cap_from_text) Seems like a reasonable thing to me, I would much prefer that than the approach in this patchset. --=20 paul-moore.com