Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3131799lqo; Tue, 21 May 2024 07:46:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVonLU0Fkj+Kjv9yZPwVXja5PsFpW2S2xLrPDAQAINWRxJZY3Ts03MVP7UtXODUOUcdCPdH0bXOdowbuWT1Zx+njzTh/1uUQxXkNuZHtg== X-Google-Smtp-Source: AGHT+IHgTuS3g2otv/X1iQ9HBe2FGvDySTupaAu0MCMB4zxloYTTQB5IrozTTOoG+OgxIJgWlC78 X-Received: by 2002:a50:8d06:0:b0:572:7d75:a70e with SMTP id 4fb4d7f45d1cf-5734d5d0209mr2394366a12.25.1716302773061; Tue, 21 May 2024 07:46:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716302773; cv=pass; d=google.com; s=arc-20160816; b=vNEmbGFyzvS020BRKsS9GV8eFKJPluX4kZfxRBuryDpro+tlwaWfPzYXpBn2T30WoX L2lZpTa9rqQDMM4KGE0knbn/ARkDtrhjKKCl4eUrTxMsPTGkIitgfa9hEf2vgNGWaqwz qxFiJuxnnGXTa+EQseKuLFyR69ntw7tV6YBR4DTeY392UY2zJgCf5ZlnOMe9HxK4OqFT 3daaZHcj764YiIRdDx2A+jyaohwvJ/LkwHY0R2vo+3E0O0NQ+BUL3RD/mA8rCHgeLhdA 9aXb4RJ0lQz2KEs2GctxkvHGM6pQZAvBd10sUwbFgeTripEjnDNxeuxzFPFbCzFP70o0 tv+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=Ic9FH/eiEd1sRlpkQ4u5UUOkbvWzy5eNpRs8pLzb6Fw=; fh=swkxxPgtdqCGULFW7nfafMWGSUEwohGbdQ9NW1X6yM4=; b=w9JAwVXROuWTyE++eEu2A7kx6Ar6ElABdBcZqmInZ3p9OBcRqAC7KgHIvVRYamznlO Zg8517ldDa+9+afErgoZrN/qFZqUMCZVhGbEwUA31E44hfF8OOEdEM+Y0b/pZRvLPYqc zklT9UoVy8tCTRtaPfhelDVmul0U3qI2Re3IU1SXj5gGYaYgyk+1QTLv9NqCm0FsZWtK oFk/J70rI36oq1ZTwNNp9sVAzNASx2CabLzxFj0GgeRKzSneKqyG8DxFCdJ5P6EYDVcy VKb/hcfIdrYAD/OWGaHzlczHUbjCwTj+gVGbaT0nQV53dln8XcO5w58iG/rNH41V2QVo SojA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bTfMZ3+n; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-185116-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185116-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c378270si14621124a12.631.2024.05.21.07.46.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 07:46:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185116-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bTfMZ3+n; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-185116-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185116-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id A404C1F212A9 for ; Tue, 21 May 2024 14:46:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB38F142E6C; Tue, 21 May 2024 14:45:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bTfMZ3+n" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D745A1CD32; Tue, 21 May 2024 14:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716302758; cv=none; b=QmBUV0aTegrohR1HT1attII7UZ8UB5s6XIElBwpaOd3V9UUhFTeoYZQ321ekjtC7xI+pz4MFLmW/HG+qpUraoPhBVeCpzBZT2ojx4ls0YR2x9SW7o0KAOOeK+nzYlHpPMHgaRviy8RL1a05ij1pIb7B3yq/suuKmQnRwMIMMo/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716302758; c=relaxed/simple; bh=h56f1QL3jb+GHUV4CymHSyb4E4n54peG+Qn4CsaG9Ts=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc: References:In-Reply-To; b=hovhlnMbpxvTx4NgzMVrZQ3SCV4qBpfVBf2tXmDCJwf8JzQ3kvdS7dx+IXDxqvIUGur0mVTjreDKyJ73yfHLnSx49FUom3X85xXj/L593Qw9S7zytKIy9qOCVBpIJsTQYpEXKJiZ/RI7g64wu8DkK7Z1bndUi5wrzVCPuaySw4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bTfMZ3+n; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 186EFC2BD11; Tue, 21 May 2024 14:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716302757; bh=h56f1QL3jb+GHUV4CymHSyb4E4n54peG+Qn4CsaG9Ts=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=bTfMZ3+ncJE7OLdODIqNXZ6D9GrNsCumq/EQpRt77Z9Zv7L06eor07wgeqfv89scD Uu5zX7o+SWFtkq9wHB9lE/UtUdRmwKpQBgwRnvvp2cHsqRR8vyS2nNzlR1KKKnWhLp 8bBJbDfB1DCxyn5/IIE7YnJq/C6naem9KgEpliUFexiziI0pbrWlMRHmeziBo4ys97 8TadNnKqkHCElBZv7jUzucCHAqq2gyM3nonTLdTBj0hKRr34OgEyAkBVe01MumVDa8 Q2k7oOBbEXFe5GZyAZnviDypZ41Kw/7IZhkms94HsIXqgAiMA3oqJQfIWDASrPv1zd qFAIt4azUjK/A== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 21 May 2024 17:45:52 +0300 Message-Id: Subject: Re: [PATCH 3/3] capabilities: add cap userns sysctl mask From: "Jarkko Sakkinen" To: "Tycho Andersen" Cc: "Jonathan Calmels" , , , "Luis Chamberlain" , "Kees Cook" , "Joel Granados" , "Serge Hallyn" , "Paul Moore" , "James Morris" , "David Howells" , , , , , X-Mailer: aerc 0.17.0 References: <20240516092213.6799-1-jcalmels@3xx0.net> <20240516092213.6799-4-jcalmels@3xx0.net> In-Reply-To: On Tue May 21, 2024 at 5:29 PM EEST, Tycho Andersen wrote: > On Tue, May 21, 2024 at 01:12:57AM +0300, Jarkko Sakkinen wrote: > > On Tue May 21, 2024 at 12:13 AM EEST, Tycho Andersen wrote: > > > On Mon, May 20, 2024 at 12:25:27PM -0700, Jonathan Calmels wrote: > > > > On Mon, May 20, 2024 at 07:30:14AM GMT, Tycho Andersen wrote: > > > > > there is an ongoing effort (started at [0]) to constify the first= arg > > > > > here, since you're not supposed to write to it. Your usage looks > > > > > correct to me, so I think all it needs is a literal "const" here. > > > >=20 > > > > Will do, along with the suggestions from Jarkko > > > >=20 > > > > > > + struct ctl_table t; > > > > > > + unsigned long mask_array[2]; > > > > > > + kernel_cap_t new_mask, *mask; > > > > > > + int err; > > > > > > + > > > > > > + if (write && (!capable(CAP_SETPCAP) || > > > > > > + !capable(CAP_SYS_ADMIN))) > > > > > > + return -EPERM; > > > > >=20 > > > > > ...why CAP_SYS_ADMIN? You mention it in the changelog, but don't > > > > > explain why. > > > >=20 > > > > No reason really, I was hoping we could decide what we want here. > > > > UMH uses CAP_SYS_MODULE, Serge mentioned adding a new cap maybe. > > > > > > I don't have a strong preference between SETPCAP and a new capability= , > > > but I do think it should be just one. SYS_ADMIN is already god mode > > > enough, IMO. > >=20 > > Sometimes I think would it make more sense to invent something > > completely new like capabilities but more modern and robust, instead of > > increasing complexity of a broken mechanism (especially thanks to > > CAP_MAC_ADMIN). > >=20 > > I kind of liked the idea of privilege tokens both in Symbian and Maemo > > (have been involved professionally in both). Emphasis on the idea not > > necessarily on implementation. > >=20 > > Not an LSM but like something that you could use in the place of POSIX > > caps. Probably quite tedious effort tho because you would need to pull > > the whole industry with the new thing... > > And then we have LSM hooks, (ns_)capable(), __secure_computing() plus > a new set of hooks for this new thing sprinkled around. I guess > kernel developers wouldn't be excited about it, let alone the rest of > the industry :) > > Thinking out loud: I wonder if fixing the seccomp TOCTOU against > pointers would help here. I guess you'd still have issues where your > policy engine resolves a path arg to open() and that inode changes > between the decision and the actual vfs access, you have just changed > the TOCTOU. > > Or even scarier: what if you could change the return value at any > kprobe? :) I had one crazy idea related to seccomp filters once. What if there was way to compose tokens that would be just a seccomp filter like the one that you pass to PR_SET_SECCOMP but presented with a file descriptor? Then you could send these with SCM_RIGHTS to other processes and they could upgrade their existing filter with them. So it would be a kind of extension mechanism for a seccomp filter. Not something I'm seriously suggesting but though to flush this out now that we are on these topics anyhow ;-) > Tycho PS. Sorry if my language was a bit harsh earlier but I think I had also a point related to at least to the patch set presentation. I.e. you are very precise describing the mechanism but motivation and bringing topic somehow to a context is equally important :-) BR, Jarkko