Skip to content

contain: add core scheduling support (PR_SCHED_CORE)#271

Merged
robertswiecki merged 1 commit into
google:masterfrom
Alvov1:use-core-scheduling
Jun 18, 2026
Merged

contain: add core scheduling support (PR_SCHED_CORE)#271
robertswiecki merged 1 commit into
google:masterfrom
Alvov1:use-core-scheduling

Conversation

@Alvov1

@Alvov1 Alvov1 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Closes #198

Adds --use_core_scheduling flag that calls prctl(PR_SCHED_CORE_CREATE) in the child process, giving each jail its
own SMT scheduling group. This prevents a jailed process from sharing a physical CPU core with processes outside the
jail, mitigating L1TF/MDS side-channel attacks in multi-tenant environments.

Changes:

  • config.proto: new use_core_scheduling bool field (field 101)
  • cmdline.cc: --use_core_scheduling CLI flag; included in startup log via logParams()
  • contain.cc: containCoreSched(), called after containDropPrivs()PR_SCHED_CORE_CREATE does not require
    capabilities
  • missing_defs.h: fallback defines for PR_SCHED_CORE / PR_SCHED_CORE_CREATE / PR_SCHED_CORE_SCOPE_THREAD_GROUP
    for builds against older kernel headers
  • README.md: flag documented in the security options section

Requires Linux kernel >= 5.14. Disabled by default; no behavior change for existing configs.

Adds --use_core_scheduling proto flag that calls prctl(PR_SCHED_CORE_CREATE) in the child process, giving each jail its own SMT scheduling group. Prevents sharing a physical core with other tenants and mitigates L1TF/MDS side-channel attacks in multi-tenant environments. Requires Linux >= 5.14; guarded with #ifdef PR_SCHED_CORE for compatibility with older kernel headers.
@robertswiecki

Copy link
Copy Markdown
Collaborator

Thank you, great!

@robertswiecki
robertswiecki merged commit d6454b4 into google:master Jun 18, 2026
5 checks passed
@Alvov1
Alvov1 deleted the use-core-scheduling branch June 18, 2026 18:02
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.

[Feature Request] Support for core scheduling in nsjail

2 participants