hermit-run 0.4.0

Hermit: a deterministic Linux execution engine for reproducible runs, record and replay, and concurrency-race search.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 */

use reverie::Errno;
use reverie::RdtscResult;
use reverie::syscalls::AddrMut;
use reverie::syscalls::PollFd;
use reverie::syscalls::StatBuf;
use reverie::syscalls::StatxBuf;
use reverie::syscalls::Syscall;
use reverie::syscalls::Timespec;
use reverie::syscalls::Timeval;
use reverie::syscalls::Timezone;
use reverie::syscalls::ioctl;
use serde::Deserialize;
use serde::Serialize;

const SIOCETHTOOL: usize = 0x8946;

/// Returns the stable error used for legacy ioctls whose nested output cannot
/// be represented by the currently pinned Reverie decoder.
pub(crate) fn deterministic_ioctl_error(request: &ioctl::Request<'_>) -> Option<Errno> {
    match request {
        // SIOCETHTOOL stores its output behind the data pointer nested in an
        // ifreq. Treating it as an opaque request would lose guest-visible
        // memory updates, so reject it identically during record and replay.
        ioctl::Request::SIOCETHTOOL(_) | ioctl::Request::Other(SIOCETHTOOL, _) => {
            Some(Errno::ENODEV)
        }
        _ => None,
    }
}

// TODO-HUMAN-REVIEW(PR-3601)
/// Returns the output buffer and its size for an xattr query (`getxattr`,
/// `lgetxattr`, `fgetxattr` and the `listxattr` family), or `None` for any
/// other syscall. A zero size only asks for the length the value needs: the
/// kernel copies nothing out and returns that length.
pub(crate) fn xattr_query_output(syscall: &Syscall) -> Option<(Option<AddrMut<'_, u8>>, usize)> {
    match syscall {
        Syscall::Getxattr(call) => Some((call.value().map(|a| a.cast()), call.size())),
        Syscall::Lgetxattr(call) => Some((call.value().map(|a| a.cast()), call.size())),
        Syscall::Fgetxattr(call) => Some((call.value().map(|a| a.cast()), call.size())),
        Syscall::Listxattr(call) => Some((call.list().map(|a| a.cast()), call.size())),
        Syscall::Llistxattr(call) => Some((call.list().map(|a| a.cast()), call.size())),
        Syscall::Flistxattr(call) => Some((call.list().map(|a| a.cast()), call.size())),
        _ => None,
    }
}

/// An event. This contains everything needed to verify and reproduce the
/// execution of a syscall.
#[derive(Debug, Serialize, Deserialize)]
pub struct Event {
    /// The event that we use to reconstruct the outputs of the original syscall.
    /// This is `Some` if need to record this syscall. If the syscall is already
    /// deterministic, then this is `None`.
    ///
    /// If a recorded syscall failed, then this is `Some(Err(Errno))`. That is,
    /// the failure should be reproduced during replay.
    pub event: Result<SyscallEvent, Errno>,
}

/// A `SyscallEvent` contains all the necessary information to replay a system
/// call.
///
/// Note that we only need a small amount of information to replay a syscall. The
/// only side effects observable by the user are:
///  1. Mutable pointers
///  2. Return values.
///
/// No registers are modified by the kernel except for `rax` (the return value).
/// Therefore, registers themselves do not need to be recorded since they are
/// strictly inputs. However, any arguments that are pointers that point to
/// mutable data expected to be modified by the kernel need to be recorded. If
/// this rule is applied uniformly for all syscalls, then we should be able to
/// implement full record and replay.
#[derive(Debug, Serialize, Deserialize)]
pub enum SyscallEvent {
    Bytes(Vec<u8>),
    /// The flattened output bytes of a vectored read (`readv`/`preadv`/
    /// `preadv2`). The bytes are stored contiguously in read order; on replay
    /// they are scattered back across the guest's `iovec` buffers. The length of
    /// the vector is exactly the return value of the syscall.
    Readv(Vec<u8>),
    Write(i64),
    Mmap(MmapEvent),
    Recvmsg(RecvmsgEvent),
    /// A syscall whose only value we care about is the return value. For many
    /// syscalls, this is often the only output of the syscall and thus it is the
    /// only piece of information that needs to be recorded.
    Return(i64),
    Stat(StatEvent),
    Statfs(Vec<u8>),
    Statx(StatxBuf),
    Rdtsc(RdtscResult),
    Ioctl(ioctl::Output),
    Timespec(TimespecEvent),
    Timeofday((Timeval, Timezone)),
    Poll(PollEvent),
    SockOpt(SockOptEvent),
    EpollWait(EpollWaitEvent),
    // AUTONOMOUS-BOT-IMPLEMENTED
    // TODO-HUMAN-REVIEW(#662): Audit the replay filesystem event schema.
    Open(OpenEvent),
    /// Result of `mkdir`/`mkdirat` plus the physical side effect replay must
    /// reconstruct when the recorded call found an existing directory.
    Mkdir(MkdirEvent),
    // TODO-HUMAN-REVIEW(#557): Audit the V2 record/replay event schema.
    WriteV2(WriteEvent),
    ReadV2(ReadEvent),
    ReadvV2(ReadEvent),
    FtruncateV2(FtruncateEvent),
    /// Destination length after a successful clone ioctl.
    FileClone(FileCloneEvent),
    /// A successful exec and the executable images required immediately before
    /// replaying it. Failed execs use the enclosing [`Event::event`] error.
    Exec(ExecEvent),
    /// The result and mutable output fields of a raw `ppoll` call.
    Ppoll(PpollEvent),
    /// The result and mutable output fields of a raw `select` or `pselect6`
    /// call.
    Select(SelectEvent),
    /// The result of a guest-semantic `madvise` and the file-backed contents
    /// replay must restore over its anonymous replacement mappings.
    Madvise(MadviseEvent),
}

/// Recorded output and signal side effects of a read syscall.
// TODO-HUMAN-REVIEW(#557): Audit the recorded signalfd side-effect API.
#[derive(Debug, Serialize, Deserialize)]
pub struct ReadEvent {
    /// Bytes returned to the guest.
    pub bytes: Vec<u8>,
    /// Number of pending SIGPIPE instances consumed by this signalfd read.
    pub consumed_sigpipe_count: u64,
    /// Kernel object whose state must advance during replay.
    pub replay_fd_kind: ReplayFdKind,
}

/// Recorded result and side effects of a write-family syscall.
// TODO-HUMAN-REVIEW(#557): Audit the recorded output and SIGPIPE API.
#[derive(Debug, Serialize, Deserialize)]
pub struct WriteEvent {
    pub result: Result<i64, Errno>,
    /// Original captured output stream aliased by the descriptor, if any.
    pub output_fd: Option<i32>,
    /// Byte offset used when the captured output endpoint is a regular file.
    pub output_offset: Option<i64>,
    /// Whether the write advances the captured open-file description offset.
    pub advances_output_offset: bool,
    /// Whether the kernel generated SIGPIPE together with EPIPE.
    pub generated_sigpipe: bool,
    /// Kernel object whose state must advance during replay.
    pub replay_fd_kind: ReplayFdKind,
    /// Offset at which a regular-file write began.
    pub replay_file_offset: Option<i64>,
    /// Whether the regular-file write advanced its open-file description.
    pub replay_file_advances_offset: bool,
}

/// Recorded result and captured-output side effect of ftruncate.
// TODO-HUMAN-REVIEW(#557): Audit the recorded ftruncate side-effect API.
#[derive(Debug, Serialize, Deserialize)]
pub struct FtruncateEvent {
    /// Recorded syscall result.
    pub result: Result<i64, Errno>,
    /// Original captured output stream aliased by the descriptor, if any.
    pub output_fd: Option<i32>,
    /// Requested file length.
    pub length: libc::off_t,
    /// Whether the target was a regular file during recording.
    pub replay_regular_file: bool,
}

// AUTONOMOUS-BOT-IMPLEMENTED
// TODO-HUMAN-REVIEW(#662): Audit descriptor-kind replay side effects.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum ReplayFdKind {
    None,
    Eventfd,
    RegularFile,
}

// AUTONOMOUS-BOT-IMPLEMENTED
// TODO-HUMAN-REVIEW(#662): Audit physical-open replay policy.
#[derive(Debug, Serialize, Deserialize)]
pub struct OpenEvent {
    /// Recorded syscall result.
    pub result: Result<i64, Errno>,
    /// Which filesystem object must exist physically during replay.
    pub materialize: OpenMaterialization,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum OpenMaterialization {
    None,
    RegularFile,
    Directory,
}

/// Recorded result and replay-side materialization policy for `mkdir` and
/// `mkdirat`.
#[derive(Debug, Serialize, Deserialize)]
pub struct MkdirEvent {
    /// Recorded syscall result returned unchanged to the replayed guest.
    pub result: Result<i64, Errno>,
    /// True only when an `EEXIST` result was caused by a directory at the final
    /// path component (not by a regular file or symlink).
    pub existing_directory: bool,
}

/// A successful `execve`/`execveat` attempt. The event is written only from the
/// post-exec callback, so its presence is proof that Linux replaced the image.
#[derive(Debug, Serialize, Deserialize)]
pub struct ExecEvent {
    pub(crate) request: ExecRequest,
    pub(crate) executable: ExecImage,
    pub(crate) target: ExecTarget,
    pub(crate) dependencies: Vec<ExecDependency>,
}

/// Raw pathname bytes and lookup context supplied to `execveat`. Detcore
/// canonicalizes `execve` into this form before the recorder sees it.
#[derive(Debug, Deserialize, Eq, PartialEq, Serialize)]
pub(crate) struct ExecRequest {
    pub(crate) dirfd: libc::c_int,
    pub(crate) path: Vec<u8>,
    pub(crate) flags: libc::c_int,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ExecImage {
    pub(crate) digest: detcore::Digest,
    pub(crate) mode: u32,
}

/// Guest-visible state of a descriptor used as an executable object. Replay
/// restores this descriptor from the recorded image before asking Linux to
/// resolve an `AT_EMPTY_PATH` or procfs-fd exec request.
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ExecDescriptor {
    /// Descriptor named by the exec request.
    pub(crate) target_fd: libc::c_int,
    pub(crate) status_flags: libc::c_int,
    pub(crate) offset: Option<libc::off_t>,
    /// Every descriptor that shared the target's open-file description before
    /// exec. `FD_CLOEXEC` belongs to each descriptor rather than the shared
    /// open-file description, so it is captured per alias.
    pub(crate) aliases: Vec<ExecDescriptorAlias>,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ExecDescriptorAlias {
    pub(crate) fd: libc::c_int,
    pub(crate) descriptor_flags: libc::c_int,
}

/// How the main target is reconstructed. Ordinary paths are materialized using
/// their recorded symlink topology. Procfs/fd magic links and `AT_EMPTY_PATH`
/// must already resolve to the recorded live object and are verified instead.
#[derive(Debug, Serialize, Deserialize)]
pub(crate) enum ExecTarget {
    Materialize(ExecMaterialization),
    VerifyLive,
    RestoreDescriptor(ExecDescriptor),
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ExecMaterialization {
    pub(crate) base: ExecMaterializationBase,
    pub(crate) path: Vec<u8>,
    pub(crate) symlinks: Vec<crate::record_replay_path::ResolvedSymlink>,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub(crate) enum ExecMaterializationBase {
    Root,
    Cwd,
    DirectoryFd(libc::c_int),
}

/// A shebang or ELF interpreter required by the recorded image.
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ExecDependency {
    pub(crate) base: ExecMaterializationBase,
    pub(crate) path: Vec<u8>,
    pub(crate) image: ExecImage,
    pub(crate) symlinks: Vec<crate::record_replay_path::ResolvedSymlink>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct FileCloneEvent {
    /// Final logical destination length.
    pub length: u64,
    /// Destination offset where the recorded source image begins.
    pub destination_offset: u64,
    /// Logical length of the cloned source range.
    pub replacement_length: u64,
    /// Whether the clone replaces the complete destination image.
    pub truncate_destination: bool,
    /// Recorded representation of the final destination image.
    pub image: FileCloneImage,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum FileCloneImage {
    /// Allocated data extents stored directly in the event stream.
    Extents(Vec<FileExtent>),
    /// Path relative to the recording data directory for a streamed snapshot.
    Sidecar(String),
}

#[derive(Debug, Serialize, Deserialize)]
pub struct FileExtent {
    /// Byte offset of this extent.
    pub offset: u64,
    /// Extent contents.
    pub bytes: Vec<u8>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MmapEvent {
    /// The address where the memory shall be mapped.
    pub addr: usize,
    /// The contents of the memory map. Note that this may be less than the
    /// requested `length`.
    pub buf: Vec<u8>,
}

/// Recorded outcome of a guest-semantic `madvise`.
///
/// Replay maps recorded files as anonymous memory, so advice whose effect
/// depends on the backing store cannot simply run live.
#[derive(Debug, Serialize, Deserialize)]
pub struct MadviseEvent {
    pub result: Result<i64, Errno>,
    /// Length of the prefix of the advised range that replay applies live.
    /// It is shorter than the guest's length when Linux stopped at a
    /// file-backed mapping that replay represents anonymously.
    pub live_len: usize,
    /// File-backed contents observed after the call, which replay writes
    /// over the zero pages its anonymous mappings expose.
    pub refills: Vec<MadviseRefill>,
}

/// Contents of one file-backed range after a recorded `madvise`.
#[derive(Debug, Serialize, Deserialize)]
pub struct MadviseRefill {
    pub addr: usize,
    pub bytes: Vec<u8>,
    /// `PROT_*` bits of the mapping, restored after replay writes the bytes.
    pub prot: i32,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct RecvmsgEvent {
    pub result: i64,
    pub iovs: Vec<Vec<u8>>,
    pub name: Vec<u8>,
    pub name_len: libc::socklen_t,
    pub control: Vec<u8>,
    pub control_len: usize,
    pub flags: libc::c_int,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct StatEvent {
    #[serde(with = "StatBuf")]
    pub statbuf: libc::stat,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct TimespecEvent {
    pub timespec: Timespec,
}

/// Records every guest-visible output of a raw `poll` call.
#[derive(Serialize, Deserialize, Debug)]
pub struct PollEvent {
    /// The exact return value or errno observed while recording.
    pub result: Result<i64, Errno>,

    /// Whether the guest supplied a non-null pollfd pointer.
    pub fds_pointer_present: bool,

    /// The post-kernel pollfd output. Successful calls contain the complete
    /// array. An EFAULT may contain only the readable prefix because Linux can
    /// fault after writing earlier `revents` entries.
    pub fds: Option<Vec<PollFd>>,
}

/// Records every guest-visible output of a raw `ppoll` call.
///
/// Unlike `poll`, Linux treats the timeout as an in-out parameter. The pollfd
/// and timeout copyouts are independent of the return value. Linux writes
/// `revents` before attempting the remaining-time copyout and preserves the
/// syscall result when that later write faults. Keep both output snapshots
/// alongside the nested result so replay can restore the writes in kernel order
/// before returning either success or the error.
#[derive(Serialize, Deserialize, Debug)]
pub struct PpollEvent {
    /// The exact return value or errno observed while recording.
    pub result: Result<i64, Errno>,

    /// Whether the guest supplied a non-null pollfd pointer.
    pub fds_pointer_present: bool,

    /// Complete output on success or the readable output prefix on EFAULT.
    pub fds: Option<Vec<PollFd>>,

    /// Whether the guest supplied a non-null raw timeout pointer.
    pub timeout_pointer_present: bool,

    /// The exact remaining timeout after the kernel call. Raw `ppoll` mutates
    /// this continuously; replay must restore the captured value without
    /// rounding, freezing, or synthesizing it.
    pub timeout: Option<Timespec>,
}

/// Records every guest-visible output of a raw `select` or `pselect6` call.
///
/// Linux copies the three descriptor sets out only when the call succeeds, or
/// partially before an EFAULT. It may then write the remaining time into a
/// non-null timeout (a `struct timeval` for `select`, a `struct timespec` for
/// `pselect6`); the recorder keeps the post-call bytes whether or not it did.
/// Replay restores the writes in that order before returning the recorded
/// result.
#[derive(Serialize, Deserialize, Debug)]
pub struct SelectEvent {
    /// The exact return value or errno observed while recording.
    pub result: Result<i64, Errno>,

    /// Post-kernel bytes of the read, write and exception sets, in argument
    /// order. Each holds the readable prefix of the set's `FDS_BYTES(nfds)`
    /// range, with `nfds` clamped to the guest's descriptor table, or `None`
    /// when the pointer was null or the kernel did not copy the sets out.
    pub fd_sets: [Option<Vec<u8>>; 3],

    /// Post-kernel bytes of the timeout, when its pointer was non-null and
    /// readable. Replay restores them exactly, without rounding or freezing.
    pub timeout: Option<Vec<u8>>,
}

/// Bytes Linux copies in and out for each descriptor set of `nfds` bits:
/// whole `long`s, as `FDS_BYTES` in fs/select.c.
pub fn fd_set_bytes(nfds: i32) -> usize {
    const LONG_BYTES: usize = std::mem::size_of::<libc::c_long>();
    usize::try_from(nfds).map_or(0, |nfds| nfds.div_ceil(8 * LONG_BYTES) * LONG_BYTES)
}

#[derive(Serialize, Deserialize, Debug)]
pub struct EpollWaitEvent {
    /// Raw initialized epoll_event bytes returned by the kernel.
    pub events: Vec<u8>,
    /// The number of initialized events in the buffer.
    pub updated: usize,
    /// Whether replay must wait on the guest-created kernel epoll set.
    pub replay_kernel_side_effect: bool,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SockOptEvent {
    /// The (possibly truncated) value.
    pub value: Vec<u8>,

    /// The length of the value. If this is the same as `value.len()`, then
    /// no truncation of the value occurred.
    pub length: libc::socklen_t,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn siocethtool_has_a_deterministic_error() {
        let request = ioctl::Request::SIOCETHTOOL(None);

        assert_eq!(deterministic_ioctl_error(&request), Some(Errno::ENODEV));

        let legacy_request = ioctl::Request::Other(SIOCETHTOOL, 0x1234);
        assert_eq!(
            deterministic_ioctl_error(&legacy_request),
            Some(Errno::ENODEV)
        );
    }

    #[test]
    fn neighboring_unknown_ioctl_is_not_rejected() {
        let request = ioctl::Request::Other(SIOCETHTOOL - 1, 0x1234);

        assert_eq!(deterministic_ioctl_error(&request), None);
    }

    #[test]
    fn mkdir_event_schema_preserves_directory_classification() {
        let events = vec![
            Event {
                event: Ok(SyscallEvent::Mkdir(MkdirEvent {
                    result: Err(Errno::EEXIST),
                    existing_directory: true,
                })),
            },
            Event {
                event: Ok(SyscallEvent::Mkdir(MkdirEvent {
                    result: Err(Errno::ENOENT),
                    existing_directory: false,
                })),
            },
        ];
        let encoded = bincode::serde::encode_to_vec(&events, bincode::config::legacy()).unwrap();
        let (decoded, consumed): (Vec<Event>, usize) =
            bincode::serde::decode_from_slice(&encoded, bincode::config::legacy()).unwrap();

        assert_eq!(consumed, encoded.len());
        let [first, second] = decoded.as_slice() else {
            panic!("unexpected mkdir event count")
        };
        assert!(matches!(
            &first.event,
            Ok(SyscallEvent::Mkdir(MkdirEvent {
                result: Err(Errno::EEXIST),
                existing_directory: true,
            }))
        ));
        assert!(matches!(
            &second.event,
            Ok(SyscallEvent::Mkdir(MkdirEvent {
                result: Err(Errno::ENOENT),
                existing_directory: false,
            }))
        ));
    }

    #[test]
    fn exec_event_schema_preserves_non_utf8_paths_and_topology() {
        let event = Event {
            event: Ok(SyscallEvent::Exec(ExecEvent {
                request: ExecRequest {
                    dirfd: libc::AT_FDCWD,
                    path: b"relative/\xff-program".to_vec(),
                    flags: 0,
                },
                executable: ExecImage {
                    digest: detcore::Digest::new(b"program"),
                    mode: 0o751,
                },
                target: ExecTarget::Materialize(ExecMaterialization {
                    base: ExecMaterializationBase::Cwd,
                    path: b"relative/\xff-program".to_vec(),
                    symlinks: vec![crate::record_replay_path::ResolvedSymlink {
                        lookup_index: 1,
                        target: b"target-\xfe".to_vec(),
                    }],
                }),
                dependencies: Vec::new(),
            })),
        };
        let encoded = bincode::serde::encode_to_vec(&event, bincode::config::legacy()).unwrap();
        let (decoded, consumed): (Event, usize) =
            bincode::serde::decode_from_slice(&encoded, bincode::config::legacy()).unwrap();

        assert_eq!(consumed, encoded.len());
        let Ok(SyscallEvent::Exec(decoded)) = decoded.event else {
            panic!("unexpected exec event")
        };
        assert_eq!(decoded.request.path, b"relative/\xff-program");
        let ExecTarget::Materialize(materialization) = decoded.target else {
            panic!("unexpected exec target policy")
        };
        assert_eq!(materialization.path, b"relative/\xff-program");
        assert_eq!(materialization.symlinks[0].target, b"target-\xfe");
    }
}