Skip to main content

sandbox/
syscall_denylist.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Authoritative platform-specific syscall denial policy.
5
6/// Whether denying a syscall is required or workload-dependent.
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub enum Enforcement {
9    /// The syscall must remain denied.
10    Mandatory,
11    /// The syscall may be allowed when profiling demonstrates a workload need.
12    Optional,
13}
14
15/// One configured syscall denial.
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub struct DeniedSyscall {
18    /// Platform syscall name.
19    pub name: &'static str,
20    /// Whether the denial is mandatory or optional.
21    pub enforcement: Enforcement,
22    /// Security rationale for denying the syscall.
23    pub reason: Option<&'static str>,
24}
25
26/// Iterate over the syscall denial policy for the current platform.
27///
28/// Backends compile mandatory entries into their baseline enforcement.
29/// Profiling may omit optional entries when a workload demonstrates a need for
30/// them.
31pub fn platform_syscall_denylist() -> impl Iterator<Item = &'static DeniedSyscall> {
32    #[cfg(target_os = "linux")]
33    {
34        crate::unix::syscall_denylist::SYSCALL_DENYLIST_MANDATORY
35            .iter()
36            .chain(crate::unix::syscall_denylist::SYSCALL_DENYLIST_OPTIONAL)
37    }
38
39    #[cfg(not(target_os = "linux"))]
40    {
41        std::iter::empty()
42    }
43}