From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796444280; b=IvymKwqXpg2kN3BWXE3pXjoNgzW5X+E+KMe6YjsqxKYuXdUBxXOAN7uCjI6NGcMX1n0L 5wt4UYsjaqZty6B1PP9zVk6YoJCIxfPwIltn4itG9hoI1e6qfcwKVo7atyB+nL8vH5AoR CieCfk96gP5A9U5nagXAiuzs+wv7IxFjxe31ZNvIlKIs2vkVVyc8iDfWjlK3Xy4baCeUZ 9gWjXA0eOF5p920Y3comxcCfausLDFwAHtcaycrglYfvE2yoAcJDApysv4WnFGfp5faHx Cj51uBPGQrac4KO+NwoJe2F9v5iypa76ADphhBxOPOgZaeP5z6yYn2ve8R2zXCNnu0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796444280; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=CBR7cmpSZe+4C8WanB3ylFhIK70LcJSS9Bp9S6CrBgs=; b=lfzz5mp80BabJD2lXzzQjB0RNC6iMH3NKFclb9L2S4EB1e6VitClQXiGsju/GqykO6Es +uNA7j08z4NxELmKgMZZto2LM84M1Fmz0R6+pS2Plr5b7SzEXv4lSBYDzOJ6ChJNP4Nq+ hFLQNrIwT40t0PtsvXWmsSmAALW6+B6kI0EIgXS1UeeqK+24E7b9aVAAMsnhyAxfrY29O c0dHhBxvdCbMo/Fg4+OShGdOiPwBazD3wuVF8aVrjGIQjsvov/4LOr51p20RfS/pMnoZc gemwT13M0vAmQ8axrfCPZ+tYfHG9J9sYuwPDDQ03dQpKJca3v0DmBCPGTOUjhyNrH1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Tfoq59mh; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B4CA606A684; Sat, 5 Dec 2026 04:18:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Tfoq59mh Received: by smtp.kernel.org (Postfix) with ESMTPSA id C41261F0092B; Sat, 5 Dec 2026 04:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796444280; bh=CBR7cmpSZe+4C8WanB3ylFhIK70LcJSS9Bp9S6CrBgs=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=Tfoq59mhgX1FqPdXb3qAcLJLzHFlfioGSYl/Mn9qwXiMW8JUcnO8LNe1UJK4Ygb5H XU4J1IBm7mEOdgXmp1uwnKKM7kJLVPPY481/tk9t4d2MmlAGgrbgld5ngOBRivbYCP Bzd5ag4vhWoNs1BXiU3zHdX9Rm2Nl9Tgl6lKcq1aJ+F2D8Myr64MmSim2eWSp6Z+wG arlstnEQ+fpxg9tALqFtz+4rrpMeSUXmm4e87Bu89vcXF43K69NRS4akRUwPlOlaKA /rJFlmb2oq/2CX0CfOeDZ+iJa/HQ98EZEBT5MmcZb60fleY4gryhrNna70i66gaujq /z4BaX6kv0rVA== Content-Type: multipart/mixed; boundary="===============4470185223046592373==" X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: <409d00cec4a381e756a288c072ade69099b5dc5163569ff98ba5c597e13a2578@mail.kernel.org> In-Reply-To: <20261205032633.1702772-20-jarkko@kernel.org> References: <20261205032633.1702772-20-jarkko@kernel.org> Subject: Re: [RFC PATCH v10 19/28] fs: Support FSCONFIG_SET_RUN in fsconfig() From: bot+bpf-ci@kernel.org To: jarkko@kernel.org,fsdevel@vger.kernel.org Cc: jarkko@kernel.org,bpf@vger.kernel.org,containers@lists.linux.dev,linux-api@vger.kernel.org,linux-arch@vger.kernel.org,linux-doc@vger.kernel.org,linux-fsdevel@vger.kernel.org,linux-integrity@vger.kernel.org,linux-kernel@vger.kernel.org,linux-kselftest@vger.kernel.org,linux-mm@kvack.org,linux-security-module@vger.kernel.org,aleksa@amutable.com,alex@amutable.com,viro@zeniv.linux.org.uk,ast@kernel.org,akpm@linux-foundation.org,andrii@kernel.org,luto@amacapital.net,arnd@arndb.de,baolin.wang@linux.alibaba.com,bsegall@google.com,brauner@kernel.org,daniel@iogearbox.net,david@kernel.org,dhowells@redhat.com,dwmw2@infradead.org,dave@stgolabs.net,dietmar.eggemann@arm.com,eddyz87@gmail.com,emil@etsalapatis.com,ebiggers@kernel.org,georgia.garcia@canonical.com,giuseppe@scrivano.org,gnoack@google.com,hughd@google.com,ihor.solodrai@linux.dev,mingo@redhat.com,jmorris@namei.org,jack@suse.cz,jgg@nvidia.com,jlayton@kernel.org,jolsa@kernel.org,john.johansen@canonical.com,corbet@lwn.net,josef@toxicpand a.com,juri.lelli@redhat.com,kees@kernel.org,kprateek.nayak@amd.com,kpsingh@kernel.org,memxor@gmail.com,lennart@poettering.net,liam@infradead.org,manfred@colorfullife.com,martin.lau@linux.dev,matt@bobrowski.net,mgorman@suse.de,mhocko@suse.com,mic@digikod.net,rppt@kernel.org,neal@gompa.dev,oleg@redhat.com,paul@paul-moore.com,ptikhomirov@virtuozzo.com,peterz@infradead.org,rdunlap@infradead.org,serge@hallyn.com,sergeh@kernel.org,skhan@linuxfoundation.org,song@kernel.org,stephen.smalley.work@gmail.com,rostedt@goodmis.org,vschneid@redhat.com,vincent.guittot@linaro.org,yonghong.song@linux.dev,zygmunt.krynicki@canonical.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev Date: Sat, 5 Dec 2026 04:17:53 +0000 (UTC) --===============4470185223046592373== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > fs: Support FSCONFIG_SET_RUN in fsconfig() TL;DR: - devpts ptmx may be owned by an unmapped host uid for run-bound mounts, possibly making /dev/pts/ptmx unusable in the run - FS_RUN_MOUNT comment omits that it allows fsopen() by callers failing may_mount() > diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c > index bd1e8eb26edb..814eed794da7 100644 > --- a/fs/devpts/inode.c > +++ b/fs/devpts/inode.c [ ... ] > @@ -457,7 +463,7 @@ static struct file_system_type devpts_fs_type = { > .init_fs_context = devpts_init_fs_context, > .parameters = devpts_param_specs, > .kill_sb = devpts_kill_sb, > - .fs_flags = FS_USERNS_MOUNT, > + .fs_flags = FS_USERNS_MOUNT | FS_RUN_MOUNT, > }; With FS_RUN_MOUNT set here, a manager outside the run's user namespace can now reach devpts_fill_super() and mknod_ptmx() for a run-bound context: fsconfig(FSCONFIG_SET_RUN) fsconfig(FSCONFIG_CMD_CREATE) vfs_get_tree() devpts_get_tree() get_tree_nodev() devpts_fill_super() mknod_ptmx() In mknod_ptmx() the owner of the ptmx inode comes from the current task: kuid_t ptmx_uid = current_fsuid(); kgid_t ptmx_gid = current_fsgid(); ... inode->i_uid = ptmx_uid; inode->i_gid = ptmx_gid; Here current is the manager, not a task inside fc->user_ns. If the manager is host root (kuid 0) and the run maps 0..65535 to 100000..165535, the ptmx node of a superblock with s_user_ns set to the run's user namespace ends up owned by kuid 0 / kgid 0, which is not mapped in s_user_ns. With the default DEVPTS_DEFAULT_PTMX_MODE (0000), can any task in the run still open /dev/pts/ptmx? generic_permission() denies by mode, and capable_wrt_inode_uidgid(CAP_DAC_OVERRIDE) should fail because privileged_wrt_inode_uidgid() requires the inode uid/gid to be mapped in the caller's namespace. chmod looks like it fails the same way, since inode_owner_or_capable() needs the mapping for CAP_FOWNER. Only a remount with ptmxmode= appears to recover it. This also seems inconsistent with the kuid_has_mapping(fc->user_ns, ...) and kgid_has_mapping(fc->user_ns, ...) checks this patch adds to devpts_parse_param(), which keep explicit uid=/gid= options from giving the instance an owner that is unmapped in fc->user_ns. The implicit owner taken from current is neither checked nor remapped. The commit message says fc->cred is refreshed for the run binding, but mknod_ptmx() does not use fc->cred. Should the owner be derived from fc->user_ns when fc->run_bound is set, for example make_kuid(fc->user_ns, 0) and make_kgid(fc->user_ns, 0), or should an unmapped owner be rejected? [ ... ] > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 5b3a100aba77..91479495b49e 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -2306,6 +2306,7 @@ struct file_system_type { > #define FS_USERNS_MOUNT_RESTRICTED 512 /* Restrict mount in userns if not already visible */ > #define FS_USERNS_DELEGATABLE 1024 /* Can be mounted inside userns from outside */ > #define FS_DISALLOW_NOTIFY 2048 /* No fsnotify marks on its objects */ > +#define FS_RUN_MOUNT 4096 /* Supports FSCONFIG_SET_RUN */ > #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ Does this comment describe the whole effect of the flag? In sys_fsopen() it is what lets a caller that fails may_mount() open the filesystem at all: priv = may_mount(); if (!priv && !IS_ENABLED(CONFIG_RUNFD)) return -EPERM; ... if (!priv && !(fs_type->fs_flags & FS_RUN_MOUNT)) { put_filesystem(fs_type); return -EPERM; } The flag is also not required for FSCONFIG_SET_RUN itself, since fsconfig_set_run() accepts either flag: if (!(fc->fs_type->fs_flags & (FS_RUN_MOUNT | FS_USERNS_DELEGATABLE))) return -EOPNOTSUPP; A filesystem with only FS_USERNS_DELEGATABLE (bpf, nfs, nfs4) therefore supports FSCONFIG_SET_RUN without FS_RUN_MOUNT, while a filesystem that sets FS_RUN_MOUNT because it "supports FSCONFIG_SET_RUN" also lets any user fsopen() it when CONFIG_RUNFD=y. Could the comment (and the new mount_api.rst text) say that FS_RUN_MOUNT permits fsopen() by callers that fail may_mount()? --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/47474652355 --===============4470185223046592373==--