mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
PVF worker: switch on seccomp networking restrictions (#2221)
This commit is contained in:
@@ -77,7 +77,7 @@ pub enum PrepareError {
|
||||
#[codec(index = 9)]
|
||||
ClearWorkerDir(String),
|
||||
/// The preparation job process died, due to OOM, a seccomp violation, or some other factor.
|
||||
JobDied(String),
|
||||
JobDied { err: String, job_pid: i32 },
|
||||
#[codec(index = 10)]
|
||||
/// Some error occurred when interfacing with the kernel.
|
||||
#[codec(index = 11)]
|
||||
@@ -96,7 +96,7 @@ impl PrepareError {
|
||||
match self {
|
||||
Prevalidation(_) | Preparation(_) | JobError(_) | OutOfMemory => true,
|
||||
IoErr(_) |
|
||||
JobDied(_) |
|
||||
JobDied { .. } |
|
||||
CreateTmpFile(_) |
|
||||
RenameTmpFile { .. } |
|
||||
ClearWorkerDir(_) |
|
||||
@@ -119,7 +119,8 @@ impl fmt::Display for PrepareError {
|
||||
JobError(err) => write!(f, "panic: {}", err),
|
||||
TimedOut => write!(f, "prepare: timeout"),
|
||||
IoErr(err) => write!(f, "prepare: io error while receiving response: {}", err),
|
||||
JobDied(err) => write!(f, "prepare: prepare job died: {}", err),
|
||||
JobDied { err, job_pid } =>
|
||||
write!(f, "prepare: prepare job with pid {job_pid} died: {err}"),
|
||||
CreateTmpFile(err) => write!(f, "prepare: error creating tmp file: {}", err),
|
||||
RenameTmpFile { err, src, dest } =>
|
||||
write!(f, "prepare: error renaming tmp file ({:?} -> {:?}): {}", src, dest, err),
|
||||
|
||||
@@ -46,7 +46,7 @@ pub enum WorkerResponse {
|
||||
///
|
||||
/// We cannot treat this as an internal error because malicious code may have killed the job.
|
||||
/// We still retry it, because in the non-malicious case it is likely spurious.
|
||||
JobDied(String),
|
||||
JobDied { err: String, job_pid: i32 },
|
||||
/// An unexpected error occurred in the job process, e.g. failing to spawn a thread, panic,
|
||||
/// etc.
|
||||
///
|
||||
|
||||
@@ -53,7 +53,7 @@ pub struct SecurityStatus {
|
||||
pub can_enable_landlock: bool,
|
||||
/// Whether the seccomp features we use are fully available on this system.
|
||||
pub can_enable_seccomp: bool,
|
||||
// Whether we are able to unshare the user namespace and change the filesystem root.
|
||||
/// Whether we are able to unshare the user namespace and change the filesystem root.
|
||||
pub can_unshare_user_namespace_and_change_root: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ pub fn run_worker<F>(
|
||||
#[cfg_attr(not(target_os = "linux"), allow(unused_mut))] mut worker_dir_path: PathBuf,
|
||||
node_version: Option<&str>,
|
||||
worker_version: Option<&str>,
|
||||
#[cfg_attr(not(target_os = "linux"), allow(unused_variables))] security_status: &SecurityStatus,
|
||||
security_status: &SecurityStatus,
|
||||
mut event_loop: F,
|
||||
) where
|
||||
F: FnMut(UnixStream, PathBuf) -> io::Result<Never>,
|
||||
|
||||
@@ -67,11 +67,9 @@
|
||||
//!
|
||||
//! # Action on syscall violations
|
||||
//!
|
||||
//! On syscall violations we currently only log, to make sure this works correctly before enforcing.
|
||||
//!
|
||||
//! In the future, when a forbidden syscall is attempted we immediately kill the process in order to
|
||||
//! prevent the attacker from doing anything else. In execution, this will result in voting against
|
||||
//! the candidate.
|
||||
//! When a forbidden syscall is attempted we immediately kill the process in order to prevent the
|
||||
//! attacker from doing anything else. In execution, this will result in voting against the
|
||||
//! candidate.
|
||||
|
||||
use crate::{
|
||||
worker::{stringify_panic_payload, WorkerKind},
|
||||
@@ -82,7 +80,7 @@ use std::{collections::BTreeMap, path::Path};
|
||||
|
||||
/// The action to take on caught syscalls.
|
||||
#[cfg(not(test))]
|
||||
const CAUGHT_ACTION: SeccompAction = SeccompAction::Log;
|
||||
const CAUGHT_ACTION: SeccompAction = SeccompAction::KillProcess;
|
||||
/// Don't kill the process when testing.
|
||||
#[cfg(test)]
|
||||
const CAUGHT_ACTION: SeccompAction = SeccompAction::Errno(libc::EACCES as u32);
|
||||
|
||||
Reference in New Issue
Block a user