Skip to content

Add a capability LSM module and route capability checks through the security stack#2

Draft
zzj-5341 wants to merge 55 commits intolsm-framework-yamafrom
codex/capability-after-lsm-yama
Draft

Add a capability LSM module and route capability checks through the security stack#2
zzj-5341 wants to merge 55 commits intolsm-framework-yamafrom
codex/capability-after-lsm-yama

Conversation

@zzj-5341
Copy link
Copy Markdown
Owner

Summary

This draft PR builds on top of the initial LSM framework and Yama migration and introduces capability authorization into the LSM stack.

The main goal is to stop open-coding capability checks across subsystems and instead route them through the security facade and the built-in LSM dispatch path.

After this change, the built-in LSM stack becomes:

  • capability as the major authorization module
  • yama as a minor ptrace restriction module

What this PR changes

Add a built-in capability LSM module

This PR introduces a dedicated capability module under kernel/src/security/lsm/modules/capability.rs.

The module provides capability-based authorization through the LSM framework instead of keeping the logic scattered across subsystem-local checks.

Extend the LSM framework for capability authorization

This PR expands the current framework with the hook surface needed by capability migration, including:

  • capable
  • bprm_check_security
  • bprm_committed_creds
  • inode_permission
  • file_open
  • inode_dac_override

It also adds the supporting context types and CapabilityReason so capability checks carry explicit semantic intent through the security layer.

Route capability checks through the security facade

This PR migrates several existing authorization paths to the LSM-backed capability interface, including:

  • credential-changing paths
  • ptrace and alien access integration
  • namespace-related checks
  • signal permission checks
  • resource limit checks
  • reboot authorization
  • socket privilege checks
  • capset
  • trusted xattr access
  • inode DAC override
  • post-execve committed-creds hook plumbing

Update security regression coverage

This PR updates the security regression entry so capability-related tests run through the new LSM-based path.

Why

The initial LSM framework PR establishes the dispatch structure and migrates one narrow policy module, Yama.

This follow-up moves capability authorization into that same structure, which makes the security model more coherent:

  • subsystem code describes security-sensitive operations through a common facade
  • authorization decisions flow through one framework
  • major and minor security modules can evolve within one stack instead of mixing framework and policy logic in unrelated subsystems

Validation

Validated in:

  • /home/zzj/asterinas-cap-lsm-upstream-stacked
  • branch: codex/capability-after-lsm-yama

Commands used:

source ~/.cargo/env
export VDSO_LIBRARY_DIR=$HOME/linux_vdso
git diff --check origin/lsm-framework-yama..HEAD
make run_kernel AUTO_TEST=test CONSOLE=hvc0

Result:

All general tests passed.

Scope of this draft

This draft intentionally focuses on:

  • extending the LSM hook surface for capability authorization
  • adding the capability module
  • migrating capability call sites onto the LSM-backed security path
  • updating the necessary security regression entry points

It intentionally does not include design documents or boot-only helper programs.

Follow-up work

  • clean up newly introduced warnings
  • decide whether boot-only capability regression helpers should land in this PR or separately
  • further refine capability handling as user namespace support evolves
  • decide whether more hooks should consume CapabilityReason more deeply

@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from e7ff475 to 1e4ba7f Compare April 14, 2026 14:08
@zzj-5341 zzj-5341 force-pushed the lsm-framework-yama branch from 5382d4d to 303d372 Compare April 14, 2026 14:50
@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from 1e4ba7f to c07b860 Compare April 14, 2026 14:50
@zzj-5341 zzj-5341 force-pushed the lsm-framework-yama branch from 303d372 to 51dd817 Compare April 14, 2026 15:23
@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from c07b860 to 800f579 Compare April 14, 2026 15:23
@zzj-5341 zzj-5341 force-pushed the lsm-framework-yama branch from 51dd817 to 8b8c1d3 Compare April 14, 2026 16:08
@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from 800f579 to 24c1421 Compare April 14, 2026 16:18
@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from c1db361 to a35c905 Compare April 16, 2026 06:04
@zzj-5341 zzj-5341 force-pushed the lsm-framework-yama branch 2 times, most recently from 6ac5ec4 to a5a4937 Compare April 21, 2026 02:48
@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from 7313d3d to dda1683 Compare April 27, 2026 13:31
@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from dda1683 to fe4d8fd Compare April 27, 2026 13:36
@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from 6dce4f2 to 14d14a1 Compare April 28, 2026 03:24
@zzj-5341 zzj-5341 force-pushed the codex/capability-after-lsm-yama branch from 50ef908 to 6961279 Compare April 28, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants