mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Introduce Landlock module
This module introduces methods to apply Landlock LSM to cloud-hypervisor threads. Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
This commit is contained in:
committed by
Liu Wei
parent
1d89f98edf
commit
af5a9677c8
@@ -3,6 +3,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use crate::landlock::LandlockAccess;
|
||||
pub use crate::vm_config::*;
|
||||
use clap::ArgMatches;
|
||||
use option_parser::{
|
||||
@@ -211,6 +212,8 @@ pub enum ValidationError {
|
||||
RestoreNetFdCountMismatch(String, usize, usize),
|
||||
/// Path provided in landlock-rules doesn't exist
|
||||
LandlockPathDoesNotExist(PathBuf),
|
||||
/// Access provided in landlock-rules in invalid
|
||||
InvalidLandlockAccess(String),
|
||||
}
|
||||
|
||||
type ValidationResult<T> = std::result::Result<T, ValidationError>;
|
||||
@@ -369,6 +372,9 @@ impl fmt::Display for ValidationError {
|
||||
s.as_path()
|
||||
)
|
||||
}
|
||||
InvalidLandlockAccess(s) => {
|
||||
write!(f, "{s}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2361,6 +2367,8 @@ impl LandlockConfig {
|
||||
if !self.path.exists() {
|
||||
return Err(ValidationError::LandlockPathDoesNotExist(self.path.clone()));
|
||||
}
|
||||
LandlockAccess::try_from(self.access.as_str())
|
||||
.map_err(|e| ValidationError::InvalidLandlockAccess(e.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user