hyperlight_host/seccomp/mod.rs
1/*
2Copyright 2025 The Hyperlight Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17// For more information on seccomp and its implementation in Hyperlight,
18// refer to: https://github.com/hyperlight-dev/hyperlight/blob/dev/docs/seccomp.md
19
20/// This module defines all seccomp filters (i.e., used for blockage of non-specified syscalls)
21/// needed for execution of guest code within Hyperlight through a syscalls allow-list.
22pub(crate) mod guest;
23
24// The credit on the creation of the macros below goes to the cloud-hypervisor team
25// (https://github.com/cloud-hypervisor/cloud-hypervisor/blob/main/vmm/src/seccomp_filters.rs)
26
27/// Shorthand for chaining `SeccompCondition`s with the `and` operator in a `SeccompRule`.
28/// The rule will take the `Allow` action if _all_ the conditions are true.
29#[macro_export]
30macro_rules! and {
31 ($($x:expr),*) => (SeccompRule::new(vec![$($x),*]).unwrap())
32}
33
34/// Shorthand for chaining `SeccompRule`s with the `or` operator in a `SeccompFilter`.
35#[macro_export]
36macro_rules! or {
37 ($($x:expr,)*) => (vec![$($x),*]);
38 ($($x:expr),*) => (vec![$($x),*])
39}