Skip to content

Commit a59e4cc

Browse files
committed
fix(isolation): block broad child signaling
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent eb3ad63 commit a59e4cc

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

‎crates/openshell-isolation-interface/src/linux/child_seccomp.rs‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ pub fn prepare(sandbox_tgid: u32) -> io::Result<ChildHardeningProgram> {
166166
] {
167167
append_argument_equal_deny(&mut instructions, syscall, argument, sandbox_tgid)?;
168168
}
169-
append_argument_equal_deny(&mut instructions, libc::SYS_kill, 0, u32::MAX)?;
170-
append_argument_equal_deny(&mut instructions, libc::SYS_rt_sigqueueinfo, 0, u32::MAX)?;
169+
// Negative PID arguments target process groups or every signalable
170+
// process. The workload never needs that authority and must not be able
171+
// to include the trusted sandbox workers in a broad signal operation.
172+
append_argument_masked_deny(&mut instructions, libc::SYS_kill, 0, 1 << 31)?;
173+
append_argument_masked_deny(&mut instructions, libc::SYS_rt_sigqueueinfo, 0, 1 << 31)?;
171174

172175
for syscall in [
173176
libc::SYS_prlimit64,
@@ -375,6 +378,12 @@ mod tests {
375378
{
376379
unsafe { libc::_exit(4) };
377380
}
381+
let sandbox_group = -unsafe { libc::getpgrp() };
382+
if unsafe { libc::kill(sandbox_group, 0) } != -1
383+
|| io::Error::last_os_error().raw_os_error() != Some(libc::EPERM)
384+
{
385+
unsafe { libc::_exit(7) };
386+
}
378387
if unsafe { libc::syscall(libc::SYS_prlimit64, sandbox_tgid, libc::RLIMIT_CORE, 0, 0) }
379388
!= -1
380389
|| io::Error::last_os_error().raw_os_error() != Some(libc::EPERM)
@@ -393,6 +402,23 @@ mod tests {
393402
{
394403
unsafe { libc::_exit(6) };
395404
}
405+
if unsafe { libc::fcntl(libc::STDIN_FILENO, libc::F_SETOWN, sandbox_tgid) } != -1
406+
|| io::Error::last_os_error().raw_os_error() != Some(libc::EPERM)
407+
{
408+
unsafe { libc::_exit(8) };
409+
}
410+
let mut owner = sandbox_tgid;
411+
if unsafe {
412+
libc::ioctl(
413+
libc::STDIN_FILENO,
414+
libc::c_ulong::from(FIOSETOWN_REQUEST),
415+
&raw mut owner,
416+
)
417+
} != -1
418+
|| io::Error::last_os_error().raw_os_error() != Some(libc::EPERM)
419+
{
420+
unsafe { libc::_exit(9) };
421+
}
396422
unsafe { libc::_exit(0) };
397423
}
398424

0 commit comments

Comments
 (0)