Skip to content

Commit ac2fe79

Browse files
Alexandra Iordachealxiord
Alexandra Iordache
authored andcommitted
metrics: remove bad_syscalls
In case of seccomp fault, the offending syscall is logged. This metric is not useful. Fixes #869 Signed-off-by: Alexandra Iordache <[email protected]>
1 parent 1fdde19 commit ac2fe79

File tree

3 files changed

+7
-22
lines changed

3 files changed

+7
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
- When running with `jailer` the location of the API socket has changed to
1010
`<jail-root-path>/api.socket` (API socket was moved _inside_ the jail).
1111

12+
### Removed
13+
14+
- Removed the `seccomp.bad_syscalls` metric.
15+
1216
## [0.15.0]
1317

1418
### Added

logger/src/metrics.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ use std::sync::atomic::{AtomicUsize, Ordering};
2929
use chrono;
3030
use serde::{Serialize, Serializer};
3131

32-
const SYSCALL_MAX: usize = 350;
33-
3432
/// Used for defining new types of metrics that can be either incremented with an unit
3533
/// or an arbitrary amount of units.
3634
// This trait helps with writing less code. It has to be in scope (via an use directive) in order
@@ -308,27 +306,12 @@ pub struct NetDeviceMetrics {
308306
}
309307

310308
/// Metrics for the seccomp filtering.
311-
#[derive(Serialize)]
309+
#[derive(Default, Serialize)]
312310
pub struct SeccompMetrics {
313-
/// Number of black listed syscalls.
314-
pub bad_syscalls: Vec<SharedMetric>,
315311
/// Number of errors inside the seccomp filtering.
316312
pub num_faults: SharedMetric,
317313
}
318314

319-
impl Default for SeccompMetrics {
320-
fn default() -> SeccompMetrics {
321-
let mut def_syscalls = vec![];
322-
for _syscall in 0..SYSCALL_MAX {
323-
def_syscalls.push(SharedMetric::default());
324-
}
325-
SeccompMetrics {
326-
num_faults: SharedMetric::default(),
327-
bad_syscalls: def_syscalls,
328-
}
329-
}
330-
}
331-
332315
/// Metrics specific to the UART device.
333316
#[derive(Default, Serialize)]
334317
pub struct SerialDeviceMetrics {

vmm/src/sigsys_handler.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ extern "C" fn sigsys_handler(
6666
// function are blocked due to the sa_mask used when registering the signal handler.
6767
let syscall = unsafe { *(info as *const i32).offset(SI_OFF_SYSCALL) as usize };
6868
METRICS.seccomp.num_faults.inc();
69-
METRICS.seccomp.bad_syscalls[syscall].inc();
7069
error!(
7170
"Shutting down VM after intercepting a bad syscall ({}).",
7271
syscall
@@ -138,8 +137,7 @@ mod tests {
138137
];
139138

140139
assert!(setup_seccomp(SeccompLevel::Basic(REQUIRED_SYSCALLS)).is_ok());
141-
let sys_idx = libc::SYS_getpid as usize;
142-
assert_eq!(METRICS.seccomp.bad_syscalls[sys_idx].count(), 0);
140+
assert_eq!(METRICS.seccomp.num_faults.count(), 0);
143141

144142
// Calls the blacklisted SYS_getpid.
145143
let _pid = process::id();
@@ -154,7 +152,7 @@ mod tests {
154152
// tests, so we use this as an heuristic to decide if we check the assertion.
155153
if cpu_count() > 1 {
156154
// The signal handler should let the program continue during unit tests.
157-
assert_eq!(METRICS.seccomp.bad_syscalls[sys_idx].count(), 1);
155+
assert_eq!(METRICS.seccomp.num_faults.count(), 1);
158156
}
159157
}
160158
}

0 commit comments

Comments
 (0)