Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp357037lqp; Mon, 10 Jun 2024 06:25:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHcGdhV4scAPD2Vgj6KwYft6d8CQDQX67s/AmO43MoJ0jG5iRSvX29n4B0QQ87pfxrJH3BUuky7n7L/ul74BEv2vgen3GEZ1OfiMIJVg== X-Google-Smtp-Source: AGHT+IFG8YmvWvzDeRDuFx/fCogNqPHN+CqLPvgUtDt5b2iO0whJ21IDsN12pbJ9wOHOoyvwLmKM X-Received: by 2002:a05:6a21:999f:b0:1b6:dffa:d6e4 with SMTP id adf61e73a8af0-1b6dffad769mr2998581637.4.1718025932047; Mon, 10 Jun 2024 06:25:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718025932; cv=pass; d=google.com; s=arc-20160816; b=y/f9Z07zU8DzmpiEE00RIr5ej4Mc2nlHLilP5bcuUC6qMKfN3Xg5dAUtA/O0WkTNwE RT0qhtEjaO65n7j5pxi8x0EtTumBU734E8T022s2L1zo8xp/Kn4d3ZT1eNnp+Au+x8j/ EtBf66+XK/REbnOEd5FXN0GuZcyxHd1ind2OunG0QPbk21ERNnebKdCSyiehnOv7nnHd PzPgVamQUmdrvOhQDzVhv5T5beUwYDsuTYTisx9X1QhZSPUiG2dcnmFW071AA2lxulFv Dr8NCmgX+XW1Nxx0XaXF6EDDhXEIBxxI99fIACMtXX3RTEWKNMiuwMIkXbzMA2a7IY+P 6+zQ== 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=lfjqR6J6O3orONiIQKvcNogjP0NH24Ps05XFZAD5qTQ=; fh=I0fS9IvwCgxDsi2bPkGl68bXCYH4uVtTHA0RBhnWipU=; b=nUKI83gops20dEnXAXhjFDDJCxrp9pHWdtgswdBDtytI3BMTyCbe/cDeNFqHHj0jpb 93OsqSP2zKLaf18p7XWxO3z7vkkbZc3t/TU8PleIriCGI5LSaX627nYzHqrZZ/s53eSI g23QZJSEcjRTyGBHQjaWw4fBvC3cG0CxmdyH0In5vglqZalxOhR6iIUNZslFhjaruxLX zOoqBwtN2AWzGcK5t+sXtFpVGjnRPbz/tR8VUNJ8h3x1g4wo6amihUTaozHgpPWX8RVp KPMSMRJfbMoEPc3rMojTbcEewTwXZ3XlfFIYJOmcs13ipv8YmCEhQzV7u3T7Tv5+BTXM MxPQ==; 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-208210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208210-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 d2e1a72fcca58-703fd566ee4si4082599b3a.326.2024.06.10.06.25.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 06:25:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208210-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-208210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208210-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 033ACB22744 for ; Mon, 10 Jun 2024 13:06:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E593B82483; Mon, 10 Jun 2024 13:05:43 +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 E4FD57F490; Mon, 10 Jun 2024 13:05:41 +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=1718024743; cv=none; b=mms4yZnzUBSpJ8CZAqPmBrzFLlqPfkdY71YuM5QYKySHbNfUwWUixQm4MXt32bbSTgnS/bUmwNjJyROVcGKQlWUUcosHTNOKCsaE5xZWVB1PYBMoHkxMQk5+zocKlLHFnUir0FqpkE37b1JsbIE2xPYMGwNY6S5QrdnKhOMIuCY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718024743; c=relaxed/simple; bh=zJgbNNJw/GCorqly4uRVoGjpIM8ilgL2XnXXEjZD+mw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FG5uoGCetUBRtRAscEyI1apKbrL9wxS1gPmPJkcysCZRa1Kn1nIfYb7EImOqnBLtDa9eGnPF+uSu+2Rz9x6BUCzDkvHPf5vzwe2OmOrlsC0T1tgPQflXNc9YBYfRL6xdf6QD60gv7/DgPoVcnGimxOd++nnkyqitww6h7yi3F2k= 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 4456B579; Mon, 10 Jun 2024 08:05:40 -0500 (CDT) Date: Mon, 10 Jun 2024 08:05:40 -0500 From: "Serge E. Hallyn" To: Jonathan Calmels Cc: "Serge E. Hallyn" , brauner@kernel.org, ebiederm@xmission.com, Jonathan Corbet , Paul Moore , James Morris , 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 , John Johansen , 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 2/4] capabilities: Add securebit to restrict userns caps Message-ID: <20240610130540.GC2193924@mail.hallyn.com> References: <20240609104355.442002-1-jcalmels@3xx0.net> <20240609104355.442002-3-jcalmels@3xx0.net> <20240610023301.GA2183903@mail.hallyn.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 Mon, Jun 10, 2024 at 02:46:06AM -0700, Jonathan Calmels wrote: > On Sun, Jun 09, 2024 at 09:33:01PM GMT, Serge E. Hallyn wrote: > > On Sun, Jun 09, 2024 at 03:43:35AM -0700, Jonathan Calmels wrote: > > > This patch adds a new capability security bit designed to constrain a > > > task’s userns capability set to its bounding set. The reason for this is > > > twofold: > > > > > > - This serves as a quick and easy way to lock down a set of capabilities > > > for a task, thus ensuring that any namespace it creates will never be > > > more privileged than itself is. > > > - This helps userspace transition to more secure defaults by not requiring > > > specific logic for the userns capability set, or libcap support. > > > > > > Example: > > > > > > # capsh --secbits=$((1 << 8)) --drop=cap_sys_rawio -- \ > > > -c 'unshare -r grep Cap /proc/self/status' > > > CapInh: 0000000000000000 > > > CapPrm: 000001fffffdffff > > > CapEff: 000001fffffdffff > > > CapBnd: 000001fffffdffff > > > CapAmb: 0000000000000000 > > > CapUNs: 000001fffffdffff > > > > But you are not (that I can see, in this or the previous patch) > > keeping SECURE_USERNS_STRICT_CAPS in securebits on the next > > level unshare. Though I think it's ok, because by then both > > cap_userns and cap_bset are reduced and cap_userns can't be > > expanded. (Sorry, just thinking aloud here) > > Right this is safe to reset, but maybe we do keep it if the secbit is > locked? This is kind of a special case compared to the other bits. I don't think it would be worth the extra complication in the secbits code, and it's semantically very different from the cap_userns. > > > + /* Limit userns capabilities to our parent's bounding set. */ > > > > In the case of userns_install(), it will be the target user namespace > > creator's bounding set, right? Not "our parent's"? > > Good point, I should reword this comment.