[PATCH v2 2/3] security: Expand task_setscheduler LSM hook to include CPU affinity mask
Paul Moore
paul at paul-moore.com
Mon May 11 20:28:09 UTC 2026
On Sat, May 9, 2026 at 5:38 PM Aaron Tomlin <atomlin at atomlin.com> wrote:
>
> At present, the task_setscheduler LSM hook provides security modules
> with the opportunity to mediate changes to a task's scheduling policy.
> However, when invoked via sched_setaffinity(), the hook lacks
> visibility into the actual CPU affinity mask being requested.
> Consequently, BPF-based security modules are entirely blind to the
> target CPUs and cannot make granular access control decisions based on
> spatial isolation.
>
> In modern multi-tenant and real-time environments, CPU isolation is a
> critical boundary. The inability to audit or restrict specific CPU
> pinning requests limits the effectiveness of eBPF-driven security
> policies, particularly when attempting to shield isolated or
> cryptographic cores from unprivileged or compromised tasks.
>
> This patch expands the security_task_setscheduler() hook signature to
> include a pointer to the requested cpumask. Because this is a shared
> hook used for multiple scheduling attribute changes, call sites that do
> not modify CPU affinity are updated to safely pass NULL.
> To protect against unverified dereferences, the parameter is annotated
> with __nullable in the LSM hook definition, ensuring the BPF verifier
> mandates explicit NULL checks for attached eBPF programs.
>
> This change updates all in-tree security modules (SELinux and Smack) to
> accommodate the new parameter mechanically, whilst providing BPF LSMs
> with the necessary context to enforce strict affinity policies.
>
> Signed-off-by: Aaron Tomlin <atomlin at atomlin.com>
> ---
> arch/mips/kernel/mips-mt-fpaff.c | 30 +++++++++++++++++-------------
> fs/proc/base.c | 2 +-
> include/linux/lsm_hook_defs.h | 3 ++-
> include/linux/security.h | 11 +++++++----
> kernel/cgroup/cpuset.c | 4 ++--
> kernel/sched/syscalls.c | 4 ++--
> security/commoncap.c | 7 +++++--
> security/security.c | 11 ++++++-----
> security/selinux/hooks.c | 3 ++-
> security/smack/smack_lsm.c | 11 +++++++++--
> 10 files changed, 53 insertions(+), 33 deletions(-)
I haven't looked too closely at this patch yet, but based on a quick
glance, can you help me understand why it is included with the other
two patches in one patchset? The other two patches look like stable
level kernel bug fixes, while this patch introduces functionality to
an existing LSM hook; one of these is not like the others :)
Unless there is something critical that I'm missing here, I would
suggest splitting this patch out from the other two bugfixes for
separate handling. If there is a patch dependency issue you can
always mention that in the cover letter.
--
paul-moore.com
More information about the Linux-security-module-archive
mailing list