From nobody Sat Oct 4 03:17:47 2025 Received: from mail-ot1-f73.google.com (mail-ot1-f73.google.com [209.85.210.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FEC229DB6E for ; Wed, 20 Aug 2025 21:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755725009; cv=none; b=bILu0rmhyVSmh5doh1kMBe4BXkaVC/YpvtSSnPd03G5AGjcRr61ZATOwoUAZjwXq27iWdLWC1QL5CLZNyeVn2GNIs0zHwQjtF4Q4adXIlStmyU/DiEAS6eKPTn3f5MwoPGHLiVPX4Z8KKga9ZQuuRiBiAJT0LXp6SwfxgbALvPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755725009; c=relaxed/simple; bh=MmgkxmR/RHD0gAuy+J/k1De83SPERK5OISiT4zyEcLI=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=FgeZ0MFc8VbnZLDKk9HX7btO+haZyV0hY4WwryhQhTQrqm7At/dsUqK2UnQTK/+gJLLQ2Ewk0yVzosBSQ9F8efr3P5iM3a3sUetotTec4ghx5Dfu5oxyD5pGYbVM5wIG9UxZTI3unWCC5G0bHrazrID8o3tjz/W68W95EBW1YT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--nkapron.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BVeZ13sr; arc=none smtp.client-ip=209.85.210.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--nkapron.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BVeZ13sr" Received: by mail-ot1-f73.google.com with SMTP id 46e09a7af769-74381ec8883so513891a34.1 for ; Wed, 20 Aug 2025 14:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1755725007; x=1756329807; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=52NO8e8KBKouByykf50TxpA8fzaA+CANU9c8tLjIyos=; b=BVeZ13srzbSFnPuACl6Whd+S4BBI2qsVQQYT83HAyTd/hGTN8k5VuCnWJVmFIT/S5Y 0R3Gq49YHL98OYYr5l8upVQPrwIO+V+Lsnl+nAvUJsWX+Ye1zRmOaMDBC15z+E+oqmA9 8hZIWYXUO5frhxUvNs9/bAIj1iBZstMK1lrAMFAFDZoSfXFoYom1QHFva9epWHwA8HfY BLdl/ICfkmKr2lRW69nNPO7dKr4EyTfFDOFDik25EmlhyrqKLcgwWWxcZCxeDJqMZyO1 UjUJeuBz2UYVmM6RxblljnhWAC3DcRDKu1Jiw+xDU/nvZeYFYecoXjz+YboJYVl2pOSz RMYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755725007; x=1756329807; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=52NO8e8KBKouByykf50TxpA8fzaA+CANU9c8tLjIyos=; b=ukFjgOD+u4xEv88909Pw698pLwFMw+qy7wmH5QEEZpFME45Kb4DeUAG5smX1msW5rY xAj/lFUZFx7pQ7NmX/9mYDCeVt55gBMvjj/r1nGS9dhZxRlg+deFOgMaJumtTz+2gazW Ay+IIKB426DfIf9OKwLS/j8NHDHbVOuBrZaPkFCc2cKBJT4VWqnhufCwv4gkknzzb95r Vj0NNZ70mly1eYBvNPxH9VIJDDsheOVwcTeUGkkfZ3RIbYecWfEu7wKBEtXE3vhCuDeq XhYmSMg5FoZYsGL9NpfxgdK1lHhxNePiWDgC2gXaV0DLdcjfJ9ClP7YK/hjFZGHys4v/ rYHg== X-Forwarded-Encrypted: i=1; AJvYcCVDEQB/hnBboK3jH0VZbiWBmdPpRjknTF7eI6mG0HSznrAZ7XOSOAcOmwjJqP5uw19a8j6x9SHpeup4dC4=@vger.kernel.org X-Gm-Message-State: AOJu0Yzg+LbPxj2cOEWQsTBdhc/Ye1iEBEYk+LCdFTLI7lUHHWaKxphO aqqqSFlQzEJw4Mz2fj4FRs7QZ5r6X4GmVLxHMXu/FJVjfQzxmilMUpC/frCRUcbaa/jP1xpGwk6 Ccyy0uGQbww== X-Google-Smtp-Source: AGHT+IEWgVPot+3z7mWm/U5UY6IePVqWOvsPtMCX+ZTPEXirfgLAzmQbxaj6CSM1E/O77ukOhXQrhy36+LzF X-Received: from otln10.prod.google.com ([2002:a9d:64ca:0:b0:742:f956:71c9]) (user=nkapron job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6830:7002:b0:742:6d79:ed03 with SMTP id 46e09a7af769-744f6b21d05mr222839a34.24.1755725007057; Wed, 20 Aug 2025 14:23:27 -0700 (PDT) Date: Wed, 20 Aug 2025 21:23:01 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.51.0.261.g7ce5a0a67e-goog Message-ID: <20250820212302.2325779-1-nkapron@google.com> Subject: [PATCH] selinux: enable per-file labeling for functionfs From: Neill Kapron To: Paul Moore , Stephen Smalley , Ondrej Mosnacek Cc: Neill Kapron , kernel-team@android.com, selinux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch adds support for genfscon per-file labeling of functionfs files as well as support for userspace to apply labels after new functionfs endpoints are created. This allows for separate labels and therefore access control on a per-endpoint basis. An example use case would be for the default endpoint EP0 used as a restricted control endpoint, and additional usb endpoints to be used by other more permissive domains. It should be noted that if there are multiple functionfs mounts on a system, genfs file labels will apply to all mounts, and therefore will not likely be as useful as the userspace relabeling portion of this patch - the addition to selinux_is_genfs_special_handling(). Signed-off-by: Neill Kapron --- security/selinux/hooks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index e474cd7398ef..54b82c814b4d 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -474,6 +474,7 @@ static int selinux_is_genfs_special_handling(struct sup= er_block *sb) !strcmp(sb->s_type->name, "debugfs") || !strcmp(sb->s_type->name, "tracefs") || !strcmp(sb->s_type->name, "rootfs") || + !strcmp(sb->s_type->name, "functionfs") || (selinux_policycap_cgroupseclabel() && (!strcmp(sb->s_type->name, "cgroup") || !strcmp(sb->s_type->name, "cgroup2"))); @@ -741,6 +742,7 @@ static int selinux_set_mnt_opts(struct super_block *sb, !strcmp(sb->s_type->name, "binder") || !strcmp(sb->s_type->name, "bpf") || !strcmp(sb->s_type->name, "pstore") || + !strcmp(sb->s_type->name, "functionfs") || !strcmp(sb->s_type->name, "securityfs")) sbsec->flags |=3D SE_SBGENFS; =20 --=20 2.51.0.261.g7ce5a0a67e-goog