Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1431407lqs; Sat, 15 Jun 2024 08:20:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhmXoMXrLLEdlJUb/1aYFk3Im6V5s6ZJhImYS7twV84/lASWtN5ciPIZsn0ev33WEJOL2EMDb3wM6zyfkd06qr0Xty/liQ9M/abX5NJA== X-Google-Smtp-Source: AGHT+IG0B1krDivzpTL1ZDE+aQLJpQSAuYbS4tbvFw9cIg/tI3+qF4q0yM6hUkDmu36zbHm2o0z4 X-Received: by 2002:a17:902:f687:b0:1f7:1ca3:d0d3 with SMTP id d9443c01a7336-1f8625ce5femr59802175ad.4.1718464839591; Sat, 15 Jun 2024 08:20:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718464839; cv=pass; d=google.com; s=arc-20160816; b=L02H6LeIOCtjIAPgBY2wKWX0tY4p8DG5HL/SHRDriVwNCuzrLq6majtwHq8cQ92520 Ly8bVex9aC2HevpPYtmaLH2i6y4w6N8uWZTccCymgCERkrNTvWKL1xDuOW+t2WJWPyhu dqRHWNlpcDcEJFv9eb4J9n2TM3JUP6AptRE9/dzTfI0sQGQgG8cOYCOEwiaypJr/xIS6 /rkEMdFmaSnGYxxXi/qlH9JspvLxY6St/wSaORZYJZyYlA7aLFwSO+SiRRoNkEhE3ZL5 EJFLU+N3FoOWJAV58jDIEB5I+B4QNY1om4PkywZl1jkMYKaZMHotI78tt8E9nb8wFTp2 FlWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=mKY6GVXOoK4QHGZQvvzQGu+jHNMdZl9SgDiVE0xF8Pg=; fh=NJzCKBWm2BCUcIdUH7dKICwuRUwwoKckPKAFQZy2rtE=; b=KwSVhh+nxaLYF9QGIWXQad+CVpQgxllMN+VPDec1MrwVUdQKtu1fMfOAptjVrET/6B wunOYOuuL/Q3Gk4703kZifvtC7M3QndmF6YMhUM4Il9o94DmGdSe7PIIOTIDosX3mFK2 WMsmFexSnvsR92zRjiCM6vWq8LMJSM1UYt0sQNSvVd4uHivJvlQN3OrsbHY6dahwaB77 WNnpiYow2asuSXBWeVVd7x2bVUeRtuR/h16CAK+4qnrccaFdfLH+XhjTdrprW7KhNT/t j2RhTw/zyWeqIa/9PoOZSht6m3jw7fpGxulCIn6uUWDuxN0FFYbd67GCqMlC8i8Zezpm rNDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=mail.hallyn.com); spf=pass (google.com: domain of linux-kernel+bounces-215921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215921-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f855f2c0d2si55248045ad.624.2024.06.15.08.20.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jun 2024 08:20:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=mail.hallyn.com); spf=pass (google.com: domain of linux-kernel+bounces-215921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215921-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A8E45B20D2D for ; Sat, 15 Jun 2024 15:20:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 089844F207; Sat, 15 Jun 2024 15:20:15 +0000 (UTC) Received: from mail.hallyn.com (mail.hallyn.com [178.63.66.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D3C94F5FB; Sat, 15 Jun 2024 15:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.63.66.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718464814; cv=none; b=t/qDyQvBWykUa4Y55oUZok5TibYHV4ya+DPfbm/tfss2drYKrCmPmzv8XQKA6VYB2L1Floj0Ilw1AE3uwlj9LgJtokPfB/LpoesMnLsNUHdxacBi8bBFjcjd6PJo/EQo5I5A9oi1q20psg931hxXzeYEyQunRIn3cjH9P45KFW0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718464814; c=relaxed/simple; bh=IFh8KhffQ3yr0f1VsXFjXTwbEQq/G+GmRuWLfL7ScZg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R+doN4MywucFqVQdmjAMERqw4cu9tTMxZHkRX8o3/YXzxyLv0e2ioersrlQqdzSnigwT/H9d74yOFtuqN5hBz5zlwSJIpANGeYAaynva9oWH46Qzh+u1a7JzOR/nBBa7pcberwNrQRHxiY6EH8DcyNcgJqpwAoc1PsJlnbY/6Cs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hallyn.com; spf=pass smtp.mailfrom=mail.hallyn.com; arc=none smtp.client-ip=178.63.66.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hallyn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mail.hallyn.com Received: by mail.hallyn.com (Postfix, from userid 1001) id A5A8DC18; Sat, 15 Jun 2024 10:20:10 -0500 (CDT) Date: Sat, 15 Jun 2024 10:20:10 -0500 From: "Serge E. Hallyn" To: Jonathan Calmels Cc: John Johansen , Paul Moore , 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 Subject: Re: [PATCH v2 4/4] bpf,lsm: Allow editing capabilities in BPF-LSM hooks Message-ID: <20240615152010.GB44653@mail.hallyn.com> References: <887a3658-2d8d-4f9e-98f2-27124bb6f8e6@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Jun 13, 2024 at 01:50:29AM -0700, Jonathan Calmels wrote: > On Wed, Jun 12, 2024 at 08:54:28PM GMT, John Johansen wrote: > > On 6/12/24 10:29, Paul Moore wrote: > > > On Wed, Jun 12, 2024 at 4:15 AM Jonathan Calmels wrote: > > > > On Tue, Jun 11, 2024 at 06:38:31PM GMT, Paul Moore wrote: > > > > > On Tue, Jun 11, 2024 at 6:15 PM Jonathan Calmels wrote: > > > > > > ... > > > > > > > > > Arguably, if we do want fine-grained userns policies, we need LSMs to > > > > > > 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. > > > > Basically the portion of the patch that removes const from the > > userns hook. > > Yes, pretty sure we'll need this regardless. > > > An LSM updating the capset is worrysome for all the reasons you > > pointed out, and I think a few more. I haven't had a chance to really > > look at v2 yet, so I didn't want to speak directly on the bpf part of > > the patch without first giving a good once over. > > > > > I'm happy to discuss ways in which we can adjust the LSM hooks/layer > > > to support different approaches to capability controls, but one LSM > > > directly manipulating the state of another is going to be a no vote > > > from me. > > > > > I might not be as hard no as Paul here, I am always willing to listen > > to arguments, but it would have to be a really good argument to > > modify the capset, when there are multiple LSMs in play on a system. > > The way I see it, it's more about enhancing the capability LSM with BPF > hooks and have it modify its own state dynamically, not so much > crosstalk between two distinct LSM frameworks (say one where the BPF > LSM implements a lot of things like capable()). > > In this context and with enough safeguards (say we only allow dropping > caps) this could be a net positive. Sure, ordering could come into play > in very specific scenarios, but at this point I would expect the > admin/LSM author to be conscious about it. > > If we think there is no way we can come up with something that's safe > enough, and that the risks outweigh the benefits, fine by me, we can > drop this patch from the series. I think pursuing patches 1-3 now, and punting on 4 until later, would be great.