Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp409023lqs; Thu, 13 Jun 2024 13:43:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsXDkuYxqLrFz34ovLuLtkDG7mMNzHVIAOHdkDRBRusbTNj2Oh1ARxNK4jJ1rv/6flry2poDktsBkJYP1jESgByG9gfXZVGH0iRhU2eA== X-Google-Smtp-Source: AGHT+IEgSwp9AxLR9Yb07iMeYFbCI+efxdeBJt0pZBH1gGCtcHGhKONPVfK2o/zbVE41ioQUawEw X-Received: by 2002:a17:902:bb87:b0:1f7:345a:e23d with SMTP id d9443c01a7336-1f8626d264fmr7988255ad.31.1718311415435; Thu, 13 Jun 2024 13:43:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718311415; cv=pass; d=google.com; s=arc-20160816; b=Ta+KDhaJuKTAKL3u5WsyhL+tpzirylQdTx5T/9zN7jwHZniM6ntaha6tvBz/Bssp9M 9dXtS2L7PrW1XV/uvs7g3sD/AR2nVY5szP68c4EoQ5lXcen6sl95A9qG08//wQhomEjA CcwotTzRJP8748SFUpAgaAu8KhN9soEHdjkjHPocD+vTldY0M7rIiYtNGBCm4FP65yZM rnPNBw97Cfw4KonJDiMupXpL8X3inCHVimpfrvQFkn+LLfX8WmeO6MaUPa1d3dvwZTMa iCdrJkgsnD2voARVMp71SNNgs8JjTC7qKgAm9DUqKt6aHxfK6OrdT6XKW3LGMPYdhCDl pbRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Mbp06UNvP6AGs/AzZYfCY2RlFHeTWL3VjFq/M7RiWuQ=; fh=aUhaJo9cNM0MnaYactqoOaRufi1yDZLlv/1lKb4Mavg=; b=ZaPF8Fg9u7y3E6qIZND/FTaKpRLt4BPAB19MqvKcV7fLXjEshQliErzCcWmfQMIw4B DN7aA+l1uHTWhHmN7SKgIFR3/LHNB4jOrxam8KcA9Am7MpfVA8ED7F3SqQ84wREzl+tG nrIzu6N2zd0EJsrsrhrHvKHTNdlc/bkernn7IuWWMzfQYChOv6XWBpOTiQlITkFzjgRD JOKfvC2fbKMAhz9qv0MNQCpJoi+RNduVhPGFvJuJqcaNrutw5FXoF4OzHxqdk+Fn9Arg 6uywyzTSUEkgMszNWUI2Lo5NgQNS0Rtm5cl2OKBOGRAMXGiKlLVuvoKz1k9hyxhthV7a AruA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=fuMZHDa4; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-214001-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f855e3adf2si20057015ad.61.2024.06.13.13.43.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 13:43:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214001-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=fuMZHDa4; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-214001-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CB1E9284F01 for ; Thu, 13 Jun 2024 20:43:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A4F913BAD5; Thu, 13 Jun 2024 20:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="fuMZHDa4" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2A6713B595 for ; Thu, 13 Jun 2024 20:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718311397; cv=none; b=QVZJBoe/PuL/JfJLOlwYlywbB+Ti9MzzqF5pKo/MAAe4qHtRihnKNe+nTc6IdGdXWOnQdxkt8fjZrNZYpNrZW2YqmkHJSMpxROMkPYFiz5UyGXEUIpTTjvTFOuYL8MFNvyKMC25KPNAcBFnhAEWZOgXvlzaUNM39i28Is6l/tAc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718311397; c=relaxed/simple; bh=Te1wWeTYuhWG0UJJRZ0nQ9Ccy7EzdVqqwIlRrujyH3k=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Axjb7DJ0yPlzHbpiwh+RWyLBcsAg0BVQXkjspHwHxCRF6fvmYXdRq5Tx11kWzW9DCR+cJDefiueTITcmUixMXlOv1T3C4qWuS700ueQYWAB0UR517zqXWKLGO3HjDMr6XoK6jSoRRFqZKNezQgNefpWpb0SxwPhIfBCOGsr678Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=fuMZHDa4; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-dfef5980a69so1808482276.3 for ; Thu, 13 Jun 2024 13:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1718311394; x=1718916194; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Mbp06UNvP6AGs/AzZYfCY2RlFHeTWL3VjFq/M7RiWuQ=; b=fuMZHDa4bjNFsZajlFm6gAnBMvg/BwfoJNgcncVCRis1Xp1EqIcaCMTgNtrGkb+lev Td1yWR1Rkd2rkCeBDcQJUchRHw/8NkPLAFMjtHsDDx4h3uwj27b8hpy81y9LyFa2yyfM 9ipuVzXbIEcs/BrpeRd3fBf6ccrZSzLeL8ssvU9nrI5TxLLoREyYQ7oBFjKdY47fYmNX brSHYzQODPhrEttIHfMF8nrIT17YW5MH2w3MuvykUxNS6eeSH7aWNVoHMwlDZOaX/+Nv qu3T40pgZ0PL8LiZWv6i/IS/Cc+IYcgv1Cs9LlVkewvKLmdhIAUqNzgMG4diumVCwnjX H+XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718311394; x=1718916194; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mbp06UNvP6AGs/AzZYfCY2RlFHeTWL3VjFq/M7RiWuQ=; b=P42O55tNGf5WXwInlKPAyBbiuSVFrulQsNj4wNtpbQWTy6wnEhCT7OBm3jGY/pyjCl kG1co1y05EVEzOKMh6Q0UVIPV2bOsmmRk/QJhvmxnluIouqSQfNFqkvFuF9WzxnyYLM5 Vxp++wobl19w8GjSNvGI0CMzTlPCb1doHe02XpvYsZYCQ+8WzF1U8IJ1Xulb+wyfCFOI +t+3JRIQGhfj7x+8bZV45RPiupjeiQP9g8uuUrXWQriMdg7rx3FeQcC+fFWO90XsPczy +FhZGCLUf+laosIzLqiyIF5tMGIAb6ciBg5yi9t7fBMtss8K7nJGYCcmwYzOB+BEboGv 4arA== X-Forwarded-Encrypted: i=1; AJvYcCWZLIezp8TzPcL8x96by012oJE8DhLtp3Sl07eG+7X6IpQVE+3bZZ9I7BsSRCnbxHzbYR/OdZt4mBpCTRWJJZNZAFliL0xPJ+Z5UZX3 X-Gm-Message-State: AOJu0YwYrkCdjcubKnS2+zOYMq9fmx9F07bSuIKU2/7Fd1YzJEIIsyqU w9zAgS+iwJ727NsVcRyieh6kkHKHgLhWZwpGxBhM/X8ZDa1Sw2qjMkUhEQZ0K6leyTbJh9KJArp JYDsShsoN7JuhGEelG4Ks8rWPLAWEMBo7ZHlu X-Received: by 2002:a25:b327:0:b0:dfe:653:3de0 with SMTP id 3f1490d57ef6-dff154f9c91mr601718276.63.1718311394391; Thu, 13 Jun 2024 13:43:14 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240609104355.442002-1-jcalmels@3xx0.net> <20240609104355.442002-5-jcalmels@3xx0.net> <887a3658-2d8d-4f9e-98f2-27124bb6f8e6@canonical.com> In-Reply-To: From: Paul Moore Date: Thu, 13 Jun 2024 16:43:03 -0400 Message-ID: Subject: Re: [PATCH v2 4/4] bpf,lsm: Allow editing capabilities in BPF-LSM hooks To: John Johansen Cc: Jonathan Calmels , brauner@kernel.org, ebiederm@xmission.com, Jonathan Corbet , James Morris , "Serge E. Hallyn" , KP Singh , Matt Bobrowski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , Stanislav Fomichev , Hao Luo , Jiri Olsa , Luis Chamberlain , Kees Cook , Joel Granados , David Howells , Jarkko Sakkinen , Stephen Smalley , Ondrej Mosnacek , Mykola Lysenko , Shuah Khan , containers@lists.linux.dev, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, bpf@vger.kernel.org, apparmor@lists.ubuntu.com, keyrings@vger.kernel.org, selinux@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 12, 2024 at 11:54=E2=80=AFPM John Johansen wrote: > On 6/12/24 10:29, Paul Moore wrote: > > On Wed, Jun 12, 2024 at 4:15=E2=80=AFAM Jonathan Calmels wrote: > >> On Tue, Jun 11, 2024 at 06:38:31PM GMT, Paul Moore wrote: > >>> On Tue, Jun 11, 2024 at 6:15=E2=80=AFPM Jonathan Calmels wrote: > > > > ... > > > >>>> Arguably, if we do want fine-grained userns policies, we need LSMs t= o > >>>> influence the userns capset at some point. > >>> > >>> One could always use, or develop, a LSM that offers additional > >>> controls around exercising capabilities. There are currently four > >>> in-tree LSMs, including the capabilities LSM, which supply a > >>> security_capable() hook that is used by the capability-based access > >>> controls in the kernel; all of these hook implementations work > >>> together within the LSM framework and provide an additional level of > >>> control/granularity beyond the existing capabilities. > >> > >> Right, but the idea was to have a simple and easy way to reuse/trigger > >> as much of the commoncap one as possible from BPF. If we're saying we > >> need to reimplement and/or use a whole new framework, then there is > >> little value. > > > > I can appreciate how allowing direct manipulation of capability bits > > from a BPF LSM looks attractive, but my hope is that our discussion > > here revealed that as you look deeper into making it work there are a > > number of pitfalls which prevent this from being a safe option for > > generalized systems. > > > >> TBH, I don't feel strongly about this, which is why it is absent from > >> v1. However, as John pointed out, we should at least be able to modify > >> the blob if we want flexible userns caps policies down the road. > > > > As discussed in this thread, there are existing ways to provide fine > > grained control over exercising capabilities that can be safely used > > within the LSM framework. I don't want to speak to what John is > > envisioning, but he should be aware of these mechanisms, and if I > > recall he did voice a level of concern about the same worries I > > mentioned. > > > > sorry, I should have been more clear. I envision LSMs being able to > update their own state in the userns hook. Ah, okay, yes, that seems reasonable; although like any other change, until we have an in-tree user we should just leave it as-is. --=20 paul-moore.com