Skip to content

Commit eb3ad63

Browse files
committed
fix(isolation): support musl seccomp ioctls
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 25670ec commit eb3ad63

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,14 @@ fn verify_notification_sizes() -> io::Result<()> {
806806
fn ioctl_ptr(fd: RawFd, request: libc::c_ulong, argument: *mut libc::c_void) -> io::Result<i64> {
807807
// SAFETY: every caller supplies the UAPI structure encoded into `request`,
808808
// alive and writable for the ioctl duration.
809+
// `libc::ioctl` models the request as `c_ulong` for glibc and `c_int`
810+
// for musl. Linux UAPI request values fit both representations.
811+
#[cfg(target_env = "musl")]
812+
let request = u32::try_from(request).map_err(|_| {
813+
io::Error::new(io::ErrorKind::InvalidInput, "ioctl request exceeds 32 bits")
814+
})?;
815+
#[cfg(target_env = "musl")]
816+
let request = libc::c_int::from_ne_bytes(request.to_ne_bytes());
809817
let result = unsafe { libc::ioctl(fd, request, argument) };
810818
if result < 0 {
811819
Err(io::Error::last_os_error())

0 commit comments

Comments
 (0)