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 680982848A8; Fri, 6 Feb 2026 12:33:07 +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=1770381187; cv=none; b=XvwlGXgZyw9YaqQ9DsugtEw2RSHHH2Z5FaDwg7zaxACQaq/4ITpX3SYJydNsIXUijWaCfTitp8c8L2Ty14s4T7GIEUz7alOfAC4o9jPtsn1Y3e0CSzzVA81bjJMeLM2hsLAiQwOLVOMQJy9dC2yGA5OVr7yIdEie3r4cP1Flb0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770381187; c=relaxed/simple; bh=gSmF7pi8WQ8aARRlt/FySFKhBoJ2Omx/PirWEVZGtHo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZmXOJyMXAR+d1AZmVa0wVh/utehqMhulNwSE8T+zu6eC7TKFZTcUzj1afua1YONzAjve4pGHYF/vO2Qec6OhGpj5q3qtGFOcQ/3NE+bmpBKBlpddIhGqCUXa2lhIyYRrxmNteg2E8YyN2bx8FrmLoolfeo2BOoN80W61gFwnmps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VcLcHrFU; 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="VcLcHrFU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCC87C116C6; Fri, 6 Feb 2026 12:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770381187; bh=gSmF7pi8WQ8aARRlt/FySFKhBoJ2Omx/PirWEVZGtHo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VcLcHrFUxCL9Ob78SoV+oJ7iEPx99a47Qd6UCVRuiWKujIfSZeyFOVIPemHrnQigb nzpTzvPG33esU/bj45DDA+EpnaZtm4VDIO5JQpPjEL5LwiQqklEc67OaEf7y6ckRUX lKHRY9609OyVakq6PAEgSvLI3AomtywpTMIOGJyKzuPNOhTaziGkUHKppErUqaGwnG muMUWP+v2l2yqNkabmxFpLSxoKvbYfDxyJNc2xoKUbX/PxkHCOBmkonfpMxmGugSGG 620dPxXRimHh/6Ew/ZKxfPbBthWJMhWg0bDy++e2IDaGSxz8yn7guhfo9g+Lub2Xfz Un8H6uSKReWYw== Date: Fri, 6 Feb 2026 13:32:59 +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: <20260206-gelenk-gierig-82ad15ec8080@brauner> References: <20260205104541.171034-1-alexander@mihalicyn.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 In-Reply-To: <20260205104541.171034-1-alexander@mihalicyn.com> 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); } 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. So either Jeff's patch needs to be changed to require capable(CAP_SYS_ADMIN) when FS_USERNS_DELEGATABLE is set (which makes sense to me in general) or the check needs to remain n bpf_fill_super(). @Jeff do you require capable(CAP_SYS_ADMIN) from within nfs? I think you somehow must because otherwise what prevents a container from mounting arbitrary servers? > - > ret = simple_fill_super(sb, BPF_FS_MAGIC, bpf_rfiles); > if (ret) > return ret; > @@ -1085,7 +1081,7 @@ static struct file_system_type bpf_fs_type = { > .init_fs_context = bpf_init_fs_context, > .parameters = bpf_fs_parameters, > .kill_sb = bpf_kill_super, > - .fs_flags = FS_USERNS_MOUNT, > + .fs_flags = FS_USERNS_DELEGATABLE, > }; > > static int __init bpf_init(void) > -- > 2.47.3 >