Article View: linux.kernel.netdev
Article #16294[PATCH RFC v2 18/42] selinux: use fc_init_pseudo() for selinuxfs
From: Christian Brauner
Date: Sat, 14 Nov 2026 13:01
Date: Sat, 14 Nov 2026 13:01
51 lines
10775 bytes
10775 bytes
Initialize selinuxfs as a pseudo filesystem. This raises SB_I_PSEUDO and
SB_I_NOEXEC. selinuxfs never holds executables. SB_I_NOEXEC also
refuses PROT_EXEC mappings but the status and policy files are only
ever mapped for reading.
But selinuxfs needs device nodes. The kernel replaces file descriptors
with /sys/fs/selinux/null on exec via dentry_open() which doesn't care
about SB_I_NODEV. Android init however opens /sys/fs/selinux/null by
path as /dev/null doesn't exist yet at that point. So clear SB_I_NODEV
again in sel_fill_super().
Reviewed-by: Alexander Mikhalitsyn <alex@amutable.com>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
security/selinux/selinuxfs.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 310e19efff1d0..d7ae853b6d685 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -18,6 +18,7 @@
#include <linux/vmalloc.h>
#include <linux/fs.h>
#include <linux/fs_context.h>
+#include <linux/pseudo_fs.h>
#include <linux/hex.h>
#include <linux/mount.h>
#include <linux/mutex.h>
@@ -1852,6 +1853,9 @@ static int sel_fill_super(struct super_block *sb, struct fs_context *fc)
/* last one */ {"", NULL, 0}
};
+ /* Android init opens the null device below by path. */
+ sb->s_iflags &= ~SB_I_NODEV;
+
ret = selinux_fs_info_create(sb);
if (ret)
goto err;
@@ -1955,6 +1959,7 @@ static const struct fs_context_operations sel_context_ops = {
static int sel_init_fs_context(struct fs_context *fc)
{
+ fc_init_pseudo(fc);
fc->ops = &sel_context_ops;
return 0;
}
--
2.53.0
Technical Details
Message-ID:
<20261114-work-loop-pseudo-v2-18-98639a2286fb@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363252-linux-kernel-netdev=dewy.ruReferences:
<20261114-work-loop-pseudo-v2-0-98639a2286fb@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363252-linux-kernel-netdev=dewy.ru From: brauner@kernel.org (Christian Brauner) Newsgroups: linux.kernel.netdev Subject: [PATCH RFC v2 18/42] selinux: use fc_init_pseudo() for selinuxfs Date: Sat, 14 Nov 2026 14:01:59 +0100 Organization: Usenet Network Message-ID: <20261114-work-loop-pseudo-v2-18-98639a2286fb@kernel.org> References: <20261114-work-loop-pseudo-v2-0-98639a2286fb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1575672"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3qmUUDsrIlqlPfexN53Sqv1nkLA= sha256:dO6DLAZQphe5Wm0Nmty4JQRLzbVwCJ8nK9POoKy/t6k= sha1:MuF3vMnvROsmrjD0Y/TnxnLW8rQ= sha256:6ugpGTBDXtkijNW0Mqk64ltNahgFQjI1bAKL1aty7YQ= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D33341147F7; Sat, 14 Nov 2026 16:13:27 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.301 X-Spam-Status: No, score=-2.301 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fSiwCh1Lzx5B; Sat, 14 Nov 2026 16:13:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363252-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id BF45B1147F4; Sat, 14 Nov 2026 16:13:16 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A7158464F2; Sat, 14 Nov 2026 13:10:53 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794661665; b=DrgQ5qeKv6knByZIPDaSvsCm8ea7/Q756PYycmITOPaSpecpCtLGX92l/yj93CWn6VFg MZuIg8MMOdJC6A7BJmw4UOnoZksn0jQ/YQf5k5x5mGEuSMhCvCY7Cg56KdKii6/0nhuWX YazicXc+apzwoLHPvitJ858roc+Os0uOIpqtFX6h9rNq/cm5PZjmRbJ010SdXokGNoNq1 OeNpLbV+c9r5sNMjeyaNVfS4mqnId6Wr47vexpcZIgzylUqDJ86MW/k5Y8khujsY0T9Ps RC3ofaao/PMQeeOEWIg2nd9HW/qGlLye+dzDr4B0cnEv5QJsI9BhEacfL9JSA6ntOAA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794661665; h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=PsEZAEo2EWjwlrQyS8FDrkYLrSxc4EoXaQ3VAa3T0to=; b=ZNO7eXZJfxCBJa+CScXJT708gq2DJu8ZvZ8MkXRm54o87jsyh7F3Q8E3cnZhuZAtrKh+ Lb36LOHLIhkXPm2/Pua+JAg1i7IUzbN2FYZ5rtZPR+Ox/LScw/t8M/jAFRQ44Fpxzx+vh Im0KJa69kyn0EojaCW+xhl21jxmnRxe57ZkJ5pYmfCVlsjHnkCiuepHu+sKyou4zJc531 ROuWviS9kl4MckvXScCeBKaOmHZxpY8YAOvqnc+Av0EupGPIFo4gUVFj/xI6RMOavgtY9 1wBv59RZIhEfF2BefaWuv0b+eG63IV4lvPO3/UQr05ZgflrGvtf4dUcI+p43wi0gWtQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RP6bdqxg; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05077606A33F; Sat, 14 Nov 2026 13:07:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RP6bdqxg X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794661664; b=YWYgIi74u0hykKmeds5qSz1i524gPz1VKpU3P/KlUv4nbWN+lIytC5UowuuRPUHj1Th9 Fb5j6U3zc/uwTMAwpnCBMQMIxmV66kNLPxqQ2WmNiPCY1qQ8YkXmGqDmu9MPDKvNzrT++ /DGAWO0xcxlGX0oSVyhg1XX6MYavjcfVO+mltcRe+o3Q52C7bD75L+jfoAYwxtWS2EJA7 pbkDbgZz4zmhPJYx/rafKxTSEAFmTvmuHCZt8WEdZebLKTiHMX2U0B7lN1Uo3ITZmEaj1 zsRYw2on0e+6zxJc5csANSFw3PxlL5tIbWEPnuoGoITvS34Am4t8qqZm3BcubxC330A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794661664; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=PsEZAEo2EWjwlrQyS8FDrkYLrSxc4EoXaQ3VAa3T0to=; b=45rYBaYtD2uxQgwKEHraqMJM5n3rkpo/AYurQ3ofNYjR2yeBo99zLfHokLCR8AkbvHpJ pt9ptPEvPd2SvTR3wfutSEDIG+llIXl5fUz543XNi1MW7Y4Ey0n6oufhr2AujRw75KshF pzCQ9bi11FOxk4Ec5Q9iXTs1QwlLgcsNUzEcfMbQn4QjUOg9+C5gAT1v9pzYTHbebAUT9 pb+z2B8PeaTcQ4lcT15HIm30ZIfjdJlj5q5+S8fJKVbj+RgPM8IWUbh3bN9FqIurXwSM8 yZeIiBqqCLfDEt10A1b9N7bZyZFuTsEp/byLoqWBg5W1OHrfiCwPLA4XnDY0OsMCirg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RP6bdqxg; arc=none smtp.remote-ip=100.103.45.18 X-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 20CDB606FB2D; Sat, 14 Nov 2026 13:07:43 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 254A51F000C4; Sat, 14 Nov 2026 13:07:36 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794661663; bh=PsEZAEo2EWjwlrQyS8FDrkYLrSxc4EoXaQ3VAa3T0to=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=RP6bdqxgYdTOvKQFb6NUJlAnzP0iuFZn14JV3dopj4eOhvt4mal1MYZtl7BQYCoxt w45XbT2grNM6Qg55/tsCLUdM0CQBOxLR2Kunja7yy54lP9Qfg63cbpj/uCek58LMdr 2g0icThdvpsN4HTsfTKz9VeiMePWjWf1Q1K5NnEjU8lTRxQrEHOb8z5qeiSteKne2v cZsD/rPxnGg04mAtEBHiWHv5l/XXKkWr1ku1sBIHTZe1CFwHTqP1ghScoLp+fr2OPo fJrxBzLLgHTvheGhtWCqgnNRz1198UueTs5pHbgLcHIkedb4JvrikevLf2qm5DDpBH /871dihUSqoKg== X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261114-work-loop-pseudo-v2-0-98639a2286fb@kernel.org> X-Cc: Jann Horn <jannh@google.com>, Chris Mason <mason@kernel.org>, Josef Bacik <josef@toxicpanda.com>, Christoph Hellwig <hch@lst.de>, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, driver-core@lists.linux.dev, linux-mm@kvack.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, apparmor@lists.ubuntu.com, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, fuse-devel@lists.linux.dev, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org, ocfs2-devel@lists.linux.dev, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-usb@vger.kernel.org, Amir Goldstein <amir73il@gmail.com>, linux-erofs@lists.ozlabs.org, linux-kselftest@vger.kernel.org, "Christian Brauner (Amutable)" <brauner@kernel.org>, Alexander Mikhalitsyn <alex@amutable.com> X-Mailer: b4 0.17-dev-ce4c1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1689; i=brauner@kernel.org; h=from:subject:message-id; bh=Eg4JynB39S+cJriPMxPoEFKswaAikvmz7VyAKkVX+DM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWT9iKlyMVy9yP1TKKNxrIjSmW/cGdIrJik/frn0dv3to /8K4+ukO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACYSMIHhv2uEhSiX6eXHduxb hf4+qrT5tnTptBUl2zO0TXL7X/736WFkWNSWEJ/+ZOJcg73v3vA+s01c+03lUdAuJu+uVeeshCM ymAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624