From mboxrd@z Thu Jan 1 00:00:00 1970 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 08EA536C0DE; Mon, 9 Feb 2026 11:11:27 +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=1770635488; cv=none; b=ABu9oPsfL4TblNnMPYWIHiLdizNwWGO8+ZfHyX+H7kp9lpzTiAVhh5PIZNNUurKGsTf312c1dabBGGJAwb1lhPiU8N6v2YGYyctkw3R5Ss5qyvv026A7WBYMkTMuazyTVdnTo9ONcGTCl1fK0ABk18VJDkpt37TVMvIMqunCy6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770635488; c=relaxed/simple; bh=t9KSThTVOz35Ej5vEwbl+zga07u71//fQQzyyB/C/1E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gP9UHY+7cUFkUBsu40Qg0xLXMpAXoAL/nZ9qOUMYmWUFSaeafXhVLpTbB14xOB7K9Uu4L9dDuun1W7VrOzjAeCAemzZopCRQNlAXn3bVYGEaGFklvrwA73WP0hho8L4kjIpukh/n38P5+5kS3R0hLWJb/WKr8BpFKdYUizKG2wc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=US3j3mXe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="US3j3mXe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0DBDC116C6; Mon, 9 Feb 2026 11:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770635487; bh=t9KSThTVOz35Ej5vEwbl+zga07u71//fQQzyyB/C/1E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=US3j3mXewcTiSU8I3Xlw/cde2ucDVcT7xZfdQwl8uJ+rDRL1avQRXq/A9rmRM4DJG 9SwKd9wUkYOeG1boavbpk62LUM81u9QoeAKdiC7p2BX4wnNqJeC5hc7RoKh2uRwh+t vXmXRqAWp4gEdqTetrH/uhy8uYpPW6xB8EzRgqTWcOeanqUS82UqDijHgr62WOyH5A E2mTGW2TP6GnlBgB1SwvN9Rbb4mJQN2/2rTcP41Fm0TUNwONGY8XPHqbdPDeWCI1P+ ta2NA7X0xvBytjX3PsXkAVxAg/isRpoSn0Qm4whT6WZ0xuKsnGRQ/1QxuuCj5TpbZb zMTQ7+FuXtyUg== Date: Mon, 9 Feb 2026 12:11:20 +0100 From: Christian Brauner To: Alexander Mikhalitsyn Cc: ast@kernel.org, Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jeff Layton , bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Mikhalitsyn Subject: Re: [PATCH] bpf: use FS_USERNS_DELEGATABLE for bpffs Message-ID: <20260209-infolge-dachorganisation-acd79c9ad934@brauner> References: <20260205104541.171034-1-alexander@mihalicyn.com> <20260206-gelenk-gierig-82ad15ec8080@brauner> 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 In-Reply-To: On Fri, Feb 06, 2026 at 01:42:17PM +0100, Alexander Mikhalitsyn wrote: > Am Fr., 6. Feb. 2026 um 13:33 Uhr schrieb Christian Brauner > : > > > > On Thu, Feb 05, 2026 at 11:45:41AM +0100, Alexander Mikhalitsyn wrote: > > > From: Alexander Mikhalitsyn > > > > > > Instead of FS_USERNS_MOUNT we should use recently introduced > > > FS_USERNS_DELEGATABLE cause it better expresses what we > > > really want to get there. Filesystem should not be allowed > > > to be mounted by an unprivileged user, but at the same time > > > we want to have sb->s_user_ns to point to the container's > > > user namespace, at the same time superblock can only > > > be created if capable(CAP_SYS_ADMIN) check is successful. > > > > > > Tested and no regressions noticed. > > > > > > No functional change intended. > > > > > > Link: https://lore.kernel.org/linux-fsdevel/6dd181bf9f6371339a6c31f58f582a9aac3bc36a.camel@kernel.org [1] > > > Fixes: 6fe01d3cbb92 ("bpf: Add BPF token delegation mount options to BPF FS") > > > Cc: Alexei Starovoitov > > > Cc: Daniel Borkmann > > > Cc: Andrii Nakryiko > > > Cc: Martin KaFai Lau > > > Cc: Eduard Zingerman > > > Cc: Song Liu > > > Cc: Yonghong Song > > > Cc: John Fastabend > > > Cc: KP Singh > > > Cc: Stanislav Fomichev > > > Cc: Hao Luo > > > Cc: Jiri Olsa > > > Cc: Jeff Layton > > > Cc: Christian Brauner > > > Cc: bpf@vger.kernel.org > > > Cc: linux-fsdevel@vger.kernel.org > > > Cc: linux-kernel@vger.kernel.org > > > Signed-off-by: Alexander Mikhalitsyn > > > - RWB-tag from Jeff [1] > > > Reviewed-by: Jeff Layton > > > --- > > > kernel/bpf/inode.c | 6 +----- > > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > > > diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c > > > index 9f866a010dad..d8dfdc846bd0 100644 > > > --- a/kernel/bpf/inode.c > > > +++ b/kernel/bpf/inode.c > > > @@ -1009,10 +1009,6 @@ static int bpf_fill_super(struct super_block *sb, struct fs_context *fc) > > > struct inode *inode; > > > int ret; > > > > > > - /* Mounting an instance of BPF FS requires privileges */ > > > - if (fc->user_ns != &init_user_ns && !capable(CAP_SYS_ADMIN)) > > > - return -EPERM; > > > > Jeff's patch does: > > > > if (user_ns != &init_user_ns && > > !(fc->fs_type->fs_flags & (FS_USERNS_MOUNT | FS_USERNS_DELEGATABLE))) { > > errorfc(fc, "VFS: Mounting from non-initial user namespace is not allowed"); > > return ERR_PTR(-EPERM); > > } > > Hi Christian, > > > > > IOW, it only restricts the ability to end up in bpf_fill_super() if > > FS_USERNS_DELEGATABLE is set. You still need to perform the permission > > check in bpf_fill_super() though otherwise anyone can mount bpffs in an > > unprivileged container now. > > Yeah, this is what mount_capable(struct fs_context *fc) does. I'm removing > FS_USERNS_MOUNT so know it checks capable(CAP_SYS_ADMIN), instead of > ns_capable(fc->user_ns, CAP_SYS_ADMIN). > > No functional changes here. Ah right, I remember. We require global CAP_SYS_ADMIN if FS_USERNS_MOUNT isn't set. That's great. Thanks! I can route Jeff's patch as fix since the original change technically regressed nfs a while ago.