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=1796443367; b=n5r7rVOSob2xDVptTmN/hxemF0wJKKZKxeTe9joVdWXmuTVa0MuEVdiH3Xg0aQ3rPatB EbMik0FJ9qw5DskpIx1RKNd9Gt7wOJoO813Ezwsyw/SZmuLOh6yNwHoP07Za0Uc7ngoWa sGDTbyANnxJ0YyJqWllA5esb2g41/KRk6QGXN1r2DBLUl7e5b2rH0KsUMQB/5NYMwn1Ko N2t1bXRPLgqD8ig3KH4mHoE18/s2wWmF0EC1VxIDIy40MZqok/jqRnD79ADQxats6O6Bn T0jcnpoNY17oHZthaJBVwLZNyVQPv2NCMZ2gGUc24ztawY8+Ax9s7iXCimHxnUU5phw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796443367; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=ZRJUbPbXIjQ4mqckU9XnnauO1JFEoBDC2+T45v92OU0=; b=nYiAdlV8M7FvKHcP+eMh6DOgC4sv7kRjtD8nM6aI6CkxsxApnLPCQ5G2fpZmEupm3Uiu tORrkjPVQCzO9wSzIkmUTEzPezhJ6On6qL3xYbsYcuUq/rUHRgtmMuANuGRh/YPCCpSjy ApIA8Zb0P8ZJjbKi/LF6157DNdqig877ViLVTYuW3BauOMZmnIVf1qe4R4Tq5toieIL2Y X/87vKcWMrlm8yId1gAPaJgM1HfSlC3fCsAXgSxkTW1dlvP2CB97UiysBZElp5DWl3EqX DZvq58uUbTbSz5YV/xRyPas8r62oBiNWZmWgfIMTAW50ExRPPzFZ10Yz/JG8offRe7w== 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="Rw/aDh2k"; 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 EB25A606A69F; Sat, 5 Dec 2026 04:02:46 +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=Rw/aDh2k Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8E0B1F00A14; Sat, 5 Dec 2026 04:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796443366; bh=ZRJUbPbXIjQ4mqckU9XnnauO1JFEoBDC2+T45v92OU0=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=Rw/aDh2kAxM6psv7HFs2yURNDHIKJ9sCDWJfLPRKf30sfcxgJzT73cA1jnvcXwyny BNEnFTzubZo5R1Udyn2IKsT/QAYz4AOgTT4gqjl3AjPpBOFY9vX80zjTShJQRNdokr kszIKWoiCmL+MSEuXAdvnq5iRiUgsjIeQq4h/t5zM8k3z4u9Tk7YJM0+4/VKcUXgiH W+RSKdsNJsEh3fMbOhNfyvFU1inyKOfbr2qLEcjUTy9vrx7wC49zro/EWahrYQqGuw Ikp0GOcCA6BlgaCX2tNxYL97Ujmi1ZCZoN5DznAi3i79+qg9ndufN9Ucfr7bAGb8m1 lOnyl4Ua0CeUw== Content-Type: multipart/mixed; boundary="===============2655639886765532700==" 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: <8ab4f86fb3a9ddb45d72ed52c9fe2338e7ec22fb361b7ed18d0268729d7832b3@mail.kernel.org> In-Reply-To: <20261205032633.1702772-3-jarkko@kernel.org> References: <20261205032633.1702772-3-jarkko@kernel.org> Subject: Re: [RFC PATCH v10 02/28] userns: Add NS_SET_IDMAP ioctl 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:02:39 +0000 (UTC) --===============2655639886765532700== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > userns: Add NS_SET_IDMAP ioctl TL;DR: NS_SET_IDMAP in userns_set_idmap() runs both caller and opener capability checks eagerly, so successful calls may log spurious audited LSM/SELinux denials; the review suggests a noaudit check first. > diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c > --- a/kernel/user_namespace.c > +++ b/kernel/user_namespace.c [ ... ] > +long userns_set_idmap(struct file *filp, struct user_namespace *ns, > + const struct userns_idmap __user *map, size_t size) > +{ [ ... ] > + if (!ns->parent) > + return -EPERM; > + if (current_user_ns() != ns && current_user_ns() != ns->parent) > + return -EPERM; > + > + file_ok = (filp->f_cred->user_ns == ns || > + filp->f_cred->user_ns == ns->parent) && > + file_ns_capable(filp, ns, CAP_SYS_ADMIN); > + if (!ns_capable(ns, CAP_SYS_ADMIN) && !file_ok) > + return -EPERM; Is it intended that both capability checks always run here? file_ok is computed eagerly through file_ns_capable(), and ns_capable() is then evaluated as well. Both are audited checks, so every NS_SET_IDMAP call produces two LSM capability decisions. In the main use case from the commit message, an unprivileged owner opens its user namespace and passes the fd to a privileged mapping helper. The helper's ns_capable() check is sufficient, but the opener check still runs and SELinux checks cap_userns { sys_admin } for the opener's domain. If policy denies that, an AVC denial is logged for an ioctl that then succeeds. The reverse case behaves the same way: a caller without the capability, whose fd opener had it, gets an audited ns_capable() failure before file_ok allows the ioctl. Other code that accepts either of two capability checks uses the noaudit variant for the first one, for example checkpoint_restore_ns_capable_noaudit() in include/linux/capability.h and pid_table_root_permissions() in kernel/pid.c. Could the caller be checked first with ns_capable_noaudit(ns, CAP_SYS_ADMIN), consulting the opener through file_ns_capable() only when that fails? This does not appear to be addressed later in the series; the capability check in userns_set_idmap() is unchanged at the end of it. --- 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 --===============2655639886765532700==--