Skip to content

Commit e51eded

Browse files
committed
epoll_ctl: throw unsupported error on unsupported opcode
1 parent 45a9a7c commit e51eded

File tree

1 file changed

+4
-11
lines changed
  • src/tools/miri/src/shims/unix/linux

1 file changed

+4
-11
lines changed

src/tools/miri/src/shims/unix/linux/epoll.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
256256
let epollhup = this.eval_libc_u32("EPOLLHUP");
257257
let epollerr = this.eval_libc_u32("EPOLLERR");
258258

259-
// Fail on unsupported operations.
260-
if op & epoll_ctl_add != epoll_ctl_add
261-
&& op & epoll_ctl_mod != epoll_ctl_mod
262-
&& op & epoll_ctl_del != epoll_ctl_del
263-
{
264-
throw_unsup_format!("epoll_ctl: encountered unknown unsupported operation {:#x}", op);
265-
}
266-
267259
// Throw EINVAL if epfd and fd have the same value.
268260
if epfd_value == fd {
269261
this.set_last_error(LibcError("EINVAL"))?;
@@ -368,7 +360,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
368360
// Notification will be returned for current epfd if there is event in the file
369361
// descriptor we registered.
370362
check_and_update_one_event_interest(&fd_ref, interest, id, this)?;
371-
return interp_ok(Scalar::from_i32(0));
363+
interp_ok(Scalar::from_i32(0))
372364
} else if op == epoll_ctl_del {
373365
let epoll_key = (id, fd);
374366

@@ -394,9 +386,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
394386
.unwrap()
395387
.retain(|event| event.upgrade().is_some());
396388

397-
return interp_ok(Scalar::from_i32(0));
389+
interp_ok(Scalar::from_i32(0))
390+
} else {
391+
throw_unsup_format!("unsupported epoll_ctl operation: {op}");
398392
}
399-
interp_ok(Scalar::from_i32(-1))
400393
}
401394

402395
/// The `epoll_wait()` system call waits for events on the `Epoll`

0 commit comments

Comments
 (0)